本文整理汇总了Python中astropy.units.arcsec方法的典型用法代码示例。如果您正苦于以下问题:Python units.arcsec方法的具体用法?Python units.arcsec怎么用?Python units.arcsec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.units
的用法示例。
在下文中一共展示了units.arcsec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ppFact_fits
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_ppFact_fits(self):
# get fits file path for ppFact test
classpath = os.path.split(inspect.getfile(self.__class__))[0]
ppFactPath = os.path.join(classpath,'test_PostProcessing_ppFact.fits')
# fits file has values for WA in [0.1,0.2]
testWA = np.linspace(0.1,0.2,100)*u.arcsec
for mod in self.allmods:
with RedirectStreams(stdout=self.dev_null):
obj = mod(ppFact=ppFactPath,**self.specs)
vals = obj.ppFact(testWA)
self.assertTrue(np.all(vals > 0),'negative value of ppFact for %s'%mod.__name__)
self.assertTrue(np.all(vals <= 1),'ppFact > 1 for %s'%mod.__name__)
示例2: test_FAdMag0_fits
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_FAdMag0_fits(self):
# get fits file path for FAdMag0 test
classpath = os.path.split(inspect.getfile(self.__class__))[0]
FAdMag0Path = os.path.join(classpath,'test_PostProcessing_FAdMag0.fits')
# fits file has values for WA in [0.1, 0.2] and FAdMag0 in [10, 20]
testWA = np.linspace(0.1, 0.2, 100)*u.arcsec
for mod in self.allmods:
with RedirectStreams(stdout=self.dev_null):
obj = mod(FAdMag0=FAdMag0Path,**self.specs)
vals = obj.FAdMag0(testWA)
self.assertTrue(np.all(vals >= 10),'value below range of FAdMag0 for %s'%mod.__name__)
self.assertTrue(np.all(vals <= 20),'value above range of FAdMag0 for %s'%mod.__name__)
示例3: test_fEZ
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_fEZ(self):
"""
Test that fEZ returns correct shape and units.
"""
exclude_mods=[]
for mod in self.allmods:
if mod.__name__ in exclude_mods:
continue
if 'fEZ' in mod.__dict__:
obj = mod()
# use 3 planets
d = 10.*np.random.rand(3)*u.AU
I = np.random.uniform(0.0, 180.0, 3)*u.deg
fEZs = obj.fEZ(self.TL.MV[0], I, d)
self.assertEqual(len(fEZs), 3, 'fEZ does not return same number of values as planets tested for {}'.format(mod.__name__))
self.assertEqual(fEZs.unit, self.unit, 'fEZ does not return 1/arcsec**2 for {}'.format(mod.__name__))
示例4: test_calcfZmin
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_calcfZmin(self):
"""
Test calcfZmin method
"""
for mod in self.allmods:
if 'calcfZmin' in mod.__dict__:
with RedirectStreams(stdout=self.dev_null):
obj = mod()
sInds = np.asarray([0])
currentTimeAbs = self.TK.currentTimeAbs
OS = self.sim.OpticalSystem
allModes = OS.observingModes
mode = list(filter(lambda mode: mode['detectionMode'] == True, allModes))[0]
hashname = self.sim.SurveySimulation.cachefname
self.sim.ZodiacalLight.fZ_startSaved = obj.generate_fZ(self.Obs, self.TL, self.TK, mode, hashname)
fZQuads = obj.calcfZmin(sInds, self.Obs, self.TL, self.TK, mode, hashname)
[valfZmin, timefZmin] = obj.extractfZmin_fZQuads(fZQuads)
self.assertTrue(len(valfZmin) == len(sInds))
self.assertTrue(len(timefZmin) == len(sInds))
self.assertTrue(valfZmin[0].unit == 1/u.arcsec**2)
self.assertTrue(timefZmin[0].format == currentTimeAbs.format)
示例5: test_calc_intTime
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_calc_intTime(self):
"""
Check calc_intTime i/o only
"""
for mod in self.allmods:
if 'calc_intTime' not in mod.__dict__:
continue
obj = mod(**copy.deepcopy(self.spec))
#first check, infinite dMag should give zero C_p
intTime = obj.calc_intTime(self.TL, np.arange(self.TL.nStars), np.array([0]*self.TL.nStars)/(u.arcsec**2.),
np.array([0]*self.TL.nStars)/(u.arcsec**2.),np.ones(self.TL.nStars)*obj.dMag0,
np.array([obj.WA0.value]*self.TL.nStars)*obj.WA0.unit,obj.observingModes[0])
self.assertEqual(len(intTime),self.TL.nStars)
示例6: test_calc_dMag_per_intTime
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_calc_dMag_per_intTime(self):
"""
Check calc_dMag_per_intTime i/o
"""
for mod in self.allmods:
if 'calc_dMag_per_intTime' not in mod.__dict__:
continue
obj = mod(**copy.deepcopy(self.spec))
dMag = obj.calc_dMag_per_intTime(np.ones(self.TL.nStars)*u.day,
self.TL, np.arange(self.TL.nStars),
np.array([0]*self.TL.nStars)/(u.arcsec**2.),np.array([0]*self.TL.nStars)/(u.arcsec**2.),
np.array([obj.WA0.value]*self.TL.nStars)*obj.WA0.unit,obj.observingModes[0])
self.assertEqual(dMag.shape,np.arange(self.TL.nStars).shape)
示例7: test_ddMag_dt
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_ddMag_dt(self):
"""
Check ddMag_dt i/o
"""
for mod in self.allmods:
if 'ddMag_dt' not in mod.__dict__:
continue
obj = mod(**copy.deepcopy(self.spec))
ddMag = obj.ddMag_dt(np.ones(self.TL.nStars)*u.day,
self.TL, np.arange(self.TL.nStars),
np.array([0]*self.TL.nStars)/(u.arcsec**2.),np.array([0]*self.TL.nStars)/(u.arcsec**2.),
np.array([obj.WA0.value]*self.TL.nStars)*obj.WA0.unit,obj.observingModes[0])
self.assertEqual(ddMag.shape,np.arange(self.TL.nStars).shape)
示例8: test_init_psf
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_init_psf(self):
r"""Test of initialization and __init__ -- PSF
Method: We instantiate OpticalSystem objects and verify
that IWA and OWA vary as expected with the domain of WA of the throughput
lookup table (from 0 to 1).
"""
filename = os.path.join(resource_path(), 'OpticalSystem', 'psf_5x5.fits')
sampling = 1.234e-5 * u.arcsec # sampling rate keyword in above file
for specs in [specs_default]:
# the input dict is modified in-place -- so copy it
our_specs = deepcopy(specs_default)
for syst in our_specs['starlightSuppressionSystems']:
syst['PSF'] = filename
optsys = self.fixture(**deepcopy(our_specs))
# Check that the sampling rate is correct
self.assertEqual(optsys.starlightSuppressionSystems[0]['samp'], sampling)
# Check that the PSF is present and has right size
# Values are checked elsewhere
psf = optsys.starlightSuppressionSystems[0]['PSF'](1.0,1.0)
self.assertIsInstance(psf, np.ndarray)
self.assertEqual(psf.shape, (5,5))
示例9: test_dcomp_dt
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_dcomp_dt(self):
dt = self.fixture.dcomp_dt(np.ones(self.nStars)*u.d,self,np.arange(self.nStars),0/(u.arcsec**2),0/(u.arcsec**2),0*u.arcsec,{})
self.assertTrue(len(dt),self.nStars)
with self.assertRaises(AssertionError):
dt = self.fixture.dcomp_dt(np.ones(self.nStars-1)*u.d,self,np.arange(self.nStars),0/(u.arcsec**2),0/(u.arcsec**2),0*u.arcsec,{})
with self.assertRaises(AssertionError):
dt = self.fixture.dcomp_dt(np.ones(self.nStars)*u.d,self,np.arange(self.nStars),np.zeros(2)/(u.arcsec**2),0/(u.arcsec**2),0*u.arcsec,{})
with self.assertRaises(AssertionError):
dt = self.fixture.dcomp_dt(np.ones(self.nStars)*u.d,self,np.arange(self.nStars),0/(u.arcsec**2),np.zeros(2)/(u.arcsec**2),0*u.arcsec,{})
with self.assertRaises(AssertionError):
dt = self.fixture.dcomp_dt(np.ones(self.nStars-1)*u.d,self,np.arange(self.nStars),0/(u.arcsec**2),0/(u.arcsec**2),np.zeros(2)*u.arcsec,{})
示例10: test_outside_IWA_filter
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_outside_IWA_filter(self):
n0 = self.targetlist.nStars
#Test default IWA = 0
self.targetlist.outside_IWA_filter()
n1 = self.targetlist.nStars
self.assertEqual( n0, n1 )
#Test particular case
self.opticalsystem.IWA = 10 * u.arcsec
self.targetlist.outside_IWA_filter()
#assert self.targetlist.nStars == 417 #not a useful test
n1 = self.targetlist.nStars #reference
#introduce two stars with planet below 10 arcsec. should be removed
self.targetlist.dist[10] = 21 * u.pc #rrange is 1e-3 to 200au, so this planet is below the IWA of 10 arcsec
self.targetlist.dist[12] = 22 * u.pc
self.targetlist.outside_IWA_filter()
self.assertEqual( self.targetlist.nStars , n1 - 2 )
#Test limiting case of IWA = PI/2
self.opticalsystem.IWA = 3.14/2 * u.rad
with self.assertRaises(IndexError):
self.targetlist.outside_IWA_filter()
#self.assertEqual(targetlist.nStars, 0) #Note that nStars is now zero so I can no longer filter out stars. This is why the limiting case of dMagLim = 0 should be done last
示例11: __init__
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def __init__(self, **specs):
# call prototype constructor
SurveySimulation.__init__(self, **specs)
TL = self.TargetList
SU = self.SimulatedUniverse
# reinitialize working angles and delta magnitudes used for integration
self.WAint = np.zeros(TL.nStars)*u.arcsec
self.dMagint = np.zeros(TL.nStars)
# calculate estimates of shortest WAint and largest dMagint for each target
for sInd in range(TL.nStars):
pInds = np.where(SU.plan2star == sInd)[0]
self.WAint[sInd] = np.arctan(np.min(SU.a[pInds])/TL.dist[sInd]).to('arcsec')
phis = np.array([np.pi/2]*pInds.size)
dMags = deltaMag(SU.p[pInds], SU.Rp[pInds], SU.a[pInds], phis)
self.dMagint[sInd] = np.min(dMags)
# populate outspec with arrays
self._outspec['WAint'] = self.WAint.value
self._outspec['dMagint'] = self.dMagint
示例12: show_from_ds9
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def show_from_ds9(ds9, self, zout, use_sky=True, **kwargs):
import numpy as np
if use_sky:
xy = np.cast[float](ds9.get('pan fk5').split())
cosd = np.cos(xy[1]/180*np.pi)
r = np.sqrt((self.cat['ra']-xy[0])**2*cosd**2 + (self.cat['dec']-xy[1])**2)*3600
runit = 'arcsec'
if (not use_sky) | (xy.sum() == 0):
xy = np.cast[float](ds9.get('pan image').split())
r = np.sqrt((self.cat['x_image']-xy[0])**2 + (self.cat['y_image']-xy[1])**2)
runit = 'pix'
ix = np.argmin(r)
print('ID: {0}, r={1:.1f} {2}'.format(self.cat['id'][ix], r[ix], runit))
print(' z={0:.2f} logM={1:.2f}'.format(zout['z_phot'][ix], np.log10(zout['mass'][ix])))
fig = self.show_fit(self.cat['id'][ix], **kwargs)
return fig, self.cat['id'][ix], zout['z_phot'][ix]
示例13: test_against_jpl_horizons
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_against_jpl_horizons():
"""Check that Astropy gives consistent results with the JPL Horizons example.
The input parameters and reference results are taken from this page:
(from the first row of the Results table at the bottom of that page)
http://ssd.jpl.nasa.gov/?horizons_tutorial
"""
obstime = Time('1998-07-28 03:00')
location = EarthLocation(lon=Angle('248.405300d'),
lat=Angle('31.9585d'),
height=2.06 * u.km)
# No atmosphere
altaz_frame = AltAz(obstime=obstime, location=location)
altaz = SkyCoord('143.2970d 2.6223d', frame=altaz_frame)
radec_actual = altaz.transform_to('icrs')
radec_expected = SkyCoord('19h24m55.01s -40d56m28.9s', frame='icrs')
distance = radec_actual.separation(radec_expected).to('arcsec')
# Current value: 0.238111 arcsec
assert distance < 1 * u.arcsec
示例14: test_m31_coord_transforms
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_m31_coord_transforms(fromsys, tosys, fromcoo, tocoo):
"""
This tests a variety of coordinate conversions for the Chandra point-source
catalog location of M31 from NED.
"""
coo1 = fromsys(ra=fromcoo[0]*u.deg, dec=fromcoo[1]*u.deg, distance=m31_dist)
coo2 = coo1.transform_to(tosys)
if tosys is FK4:
coo2_prec = coo2.transform_to(FK4(equinox=Time('B1950')))
assert (coo2_prec.spherical.lon - tocoo[0]*u.deg) < convert_precision # <1 arcsec
assert (coo2_prec.spherical.lat - tocoo[1]*u.deg) < convert_precision
else:
assert (coo2.spherical.lon - tocoo[0]*u.deg) < convert_precision # <1 arcsec
assert (coo2.spherical.lat - tocoo[1]*u.deg) < convert_precision
assert coo1.distance.unit == u.kpc
assert coo2.distance.unit == u.kpc
assert m31_dist.unit == u.kpc
assert (coo2.distance - m31_dist) < dist_precision
# check round-tripping
coo1_2 = coo2.transform_to(fromsys)
assert (coo1_2.spherical.lon - fromcoo[0]*u.deg) < roundtrip_precision
assert (coo1_2.spherical.lat - fromcoo[1]*u.deg) < roundtrip_precision
assert (coo1_2.distance - m31_dist) < dist_precision
示例15: test_component_names_repr
# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcsec [as 别名]
def test_component_names_repr():
from astropy.coordinates.baseframe import BaseCoordinateFrame, RepresentationMapping
# Frame class with new component names that includes a name swap
class NameChangeFrame(BaseCoordinateFrame):
default_representation = r.PhysicsSphericalRepresentation
frame_specific_representation_info = {
r.PhysicsSphericalRepresentation: [
RepresentationMapping('phi', 'theta', u.deg),
RepresentationMapping('theta', 'phi', u.arcsec),
RepresentationMapping('r', 'JUSTONCE', u.AU)]
}
frame = NameChangeFrame(0*u.deg, 0*u.arcsec, 0*u.AU)
# Check for the new names in the Frame repr
assert "(theta, phi, JUSTONCE)" in repr(frame)
# Check that the letter "r" has not been replaced more than once in the Frame repr
assert repr(frame).count("JUSTONCE") == 1