本文整理汇总了Python中astropy.coordinates.SkyCoord方法的典型用法代码示例。如果您正苦于以下问题:Python coordinates.SkyCoord方法的具体用法?Python coordinates.SkyCoord怎么用?Python coordinates.SkyCoord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.coordinates
的用法示例。
在下文中一共展示了coordinates.SkyCoord方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: query
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def query(self, coords, **kwargs):
"""
Returns E(B-V) (or a different Planck dust inference, depending on how
the class was intialized) at the specified location(s) on the sky.
Args:
coords (:obj:`astropy.coordinates.SkyCoord`): The coordinates to query.
Returns:
A float array of the selected Planck component, at the given
coordinates. The shape of the output is the same as the shape of the
coordinates stored by ``coords``. If extragalactic E(B-V), tau_353
or radiance was chosen, then the output has units of magnitudes of
E(B-V). If the selected Planck component is temperature (or
temperature error), then an :obj:`astropy.Quantity` is returned, with
units of Kelvin. If beta (or beta error) was chosen, then the output
is unitless.
"""
return self._scale * super(PlanckQuery, self).query(coords, **kwargs)
示例2: test_shape
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def test_shape(self):
"""
Test that the output shapes are as expected with input coordinate arrays
of different shapes.
"""
for reps in range(10):
# Draw random coordinates, with different shapes
n_dim = np.random.randint(1,4)
shape = np.random.randint(1,7, size=(n_dim,))
ra = -180. + 360.*np.random.random(shape)
dec = -90. + 180. * np.random.random(shape)
c = coords.SkyCoord(ra, dec, frame='icrs', unit='deg')
ebv_calc = self._sfd(c)
np.testing.assert_equal(ebv_calc.shape, shape)
示例3: test_equ_med_far_vector
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def test_equ_med_far_vector(self):
"""
Test that median reddening is correct in the far limit, using a vector
of coordinates as input.
"""
l = [d['l']*units.deg for d in self._test_data]
b = [d['b']*units.deg for d in self._test_data]
dist = [1.e3*units.kpc for bb in b]
c = coords.SkyCoord(l, b, distance=dist, frame='galactic')
ebv_data = np.array([np.nanmedian(d['samples'][:,-1]) for d in self._test_data])
ebv_calc = self._bayestar(c, mode='median')
# print 'vector:'
# print r'% residual:'
# for ed,ec in zip(ebv_data, ebv_calc):
# print ' {: >8.3f}'.format((ec - ed) / (0.02 + 0.02 * ed))
np.testing.assert_allclose(ebv_data, ebv_calc, atol=0.001, rtol=0.0001)
示例4: test_equ_med_scalar
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def test_equ_med_scalar(self):
"""
Test that median reddening is correct in at arbitary distances, using
individual coordinates as input.
"""
for d in self._test_data:
l = d['l']*units.deg
b = d['b']*units.deg
for reps in range(10):
dm = 3. + (25.-3.)*np.random.random()
dist = 10.**(dm/5.-2.)
c = coords.SkyCoord(l, b, distance=dist*units.kpc, frame='galactic')
ebv_samples = self._interp_ebv(d, dist)
ebv_data = np.nanmedian(ebv_samples)
ebv_calc = self._bayestar(c, mode='median')
np.testing.assert_allclose(ebv_data, ebv_calc, atol=0.001, rtol=0.0001)
示例5: test_equ_random_sample_scalar
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def test_equ_random_sample_scalar(self):
"""
Test that random sample of reddening at arbitary distance is actually
from the set of possible reddening samples at that distance. Uses vector
of coordinates/distances as input. Uses single set of
coordinates/distance as input.
"""
for d in self._test_data:
# Prepare coordinates (with random distances)
l = d['l']*units.deg
b = d['b']*units.deg
dm = 3. + (25.-3.)*np.random.random()
dist = 10.**(dm/5.-2.)
c = coords.SkyCoord(l, b, distance=dist*units.kpc, frame='galactic')
ebv_data = self._interp_ebv(d, dist)
ebv_calc = self._bayestar(c, mode='random_sample')
d_ebv = np.min(np.abs(ebv_data[:] - ebv_calc))
np.testing.assert_allclose(d_ebv, 0., atol=0.001, rtol=0.0001)
示例6: test_equ_samples_nodist_vector
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def test_equ_samples_nodist_vector(self):
"""
Test that full set of samples of reddening vs. distance curves is
correct. Uses vector of coordinates as input.
"""
# Prepare coordinates
l = [d['l']*units.deg for d in self._test_data]
b = [d['b']*units.deg for d in self._test_data]
c = coords.SkyCoord(l, b, frame='galactic')
ebv_data = np.array([d['samples'] for d in self._test_data])
ebv_calc = self._bayestar(c, mode='samples')
# print 'vector random sample:'
# print 'ebv_data.shape = {}'.format(ebv_data.shape)
# print 'ebv_calc.shape = {}'.format(ebv_calc.shape)
# print ebv_data[0]
# print ebv_calc[0]
np.testing.assert_allclose(ebv_data, ebv_calc, atol=0.001, rtol=0.0001)
示例7: test_equ_random_sample_nodist_vector
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def test_equ_random_sample_nodist_vector(self):
"""
Test that a random sample of the reddening vs. distance curve is drawn
from the full set of samples. Uses vector of coordinates as input.
"""
# Prepare coordinates
l = [d['l']*units.deg for d in self._test_data]
b = [d['b']*units.deg for d in self._test_data]
c = coords.SkyCoord(l, b, frame='galactic')
ebv_data = np.array([d['samples'] for d in self._test_data])
ebv_calc = self._bayestar(c, mode='random_sample')
# print 'vector random sample:'
# print 'ebv_data.shape = {}'.format(ebv_data.shape)
# print 'ebv_calc.shape = {}'.format(ebv_calc.shape)
# print ebv_data[0]
# print ebv_calc[0]
d_ebv = np.min(np.abs(ebv_data[:,:,:] - ebv_calc[:,None,:]), axis=1)
np.testing.assert_allclose(d_ebv, 0., atol=0.001, rtol=0.0001)
示例8: test_bounds
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def test_bounds(self):
"""
Test that out-of-bounds coordinates return NaN reddening, and that
in-bounds coordinates do not return NaN reddening.
"""
for mode in (['random_sample', 'random_sample_per_pix',
'median', 'samples', 'mean']):
# Draw random coordinates, both above and below dec = -30 degree line
n_pix = 1000
ra = -180. + 360.*np.random.random(n_pix)
dec = -75. + 90.*np.random.random(n_pix) # 45 degrees above/below
c = coords.SkyCoord(ra, dec, frame='icrs', unit='deg')
ebv_calc = self._bayestar(c, mode=mode)
nan_below = np.isnan(ebv_calc[dec < -35.])
nan_above = np.isnan(ebv_calc[dec > -25.])
pct_nan_above = np.sum(nan_above) / float(nan_above.size)
# print r'{:s}: {:.5f}% nan above dec=-25 deg.'.format(mode, 100.*pct_nan_above)
self.assertTrue(np.all(nan_below))
self.assertTrue(pct_nan_above < 0.05)
示例9: test_shape
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def test_shape(self):
"""
Test that the output shapes are as expected with input coordinate arrays
of different shapes.
"""
for mode in ['random_sample', 'median', 'mean', 'samples']:
for reps in range(5):
# Draw random coordinates, with different shapes
n_dim = np.random.randint(1,4)
shape = np.random.randint(1,7, size=(n_dim,))
ra = -180. + 360.*np.random.random(shape)
dec = -90. + 180. * np.random.random(shape)
c = coords.SkyCoord(ra, dec, frame='icrs', unit='deg')
ebv_calc = self._bayestar(c, mode=mode)
np.testing.assert_equal(ebv_calc.shape[:n_dim], shape)
if mode == 'samples':
self.assertEqual(len(ebv_calc.shape), n_dim+2) # sample, distance
else:
self.assertEqual(len(ebv_calc.shape), n_dim+1) # distance
示例10: test_shape
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def test_shape(self):
"""
Test that the output shapes are as expected with input coordinate arrays
of different shapes.
"""
for reps in range(5):
# Draw random coordinates, with different shapes
n_dim = np.random.randint(1,4)
shape = np.random.randint(1,7, size=(n_dim,))
ra = (-180. + 360.*np.random.random(shape)) * units.deg
dec = (-90. + 180. * np.random.random(shape)) * units.deg
c = coords.SkyCoord(ra, dec, frame='icrs')
E = self._planck(c)
np.testing.assert_equal(E.shape, shape)
示例11: deserialize_skycoord
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def deserialize_skycoord(d):
"""
Deserializes a JSONified :obj:`astropy.coordinates.SkyCoord`.
Args:
d (:obj:`dict`): A dictionary representation of a :obj:`SkyCoord` object.
Returns:
A :obj:`SkyCoord` object.
"""
if 'distance' in d:
args = (d['lon'], d['lat'], d['distance'])
else:
args = (d['lon'], d['lat'])
return coords.SkyCoord(
*args,
frame=d['frame'],
representation='spherical')
示例12: inverse_method
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def inverse_method(self,N,d):
t = np.linspace(1e-3,0.999,N)
f = np.log( t / (1 - t) )
f = f/f[0]
psi= np.pi*f
cosPsi = np.cos(psi)
sinTheta = ( np.abs(cosPsi) + (1-np.abs(cosPsi))*np.random.rand(len(cosPsi)))
theta = np.arcsin(sinTheta)
theta = np.pi-theta + (2*theta - np.pi)*np.round(np.random.rand(len(t)))
cosPhi = cosPsi/sinTheta
phi = np.arccos(cosPhi)*(-1)**np.round(np.random.rand(len(t)))
coords = SkyCoord(phi*u.rad,(np.pi/2-theta)*u.rad,d*np.ones(len(phi))*u.pc)
return coords
示例13: radec_residual_mpc
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def radec_residual_mpc(x, t_ra_dec_datapoint, long, parallax_s, parallax_c):
"""Compute observed minus computed (O-C) residual for a given ra/dec
datapoint, represented as a SkyCoord object, for MPC observation data.
Args:
x (1x6 array): set of Keplerian elements
t_ra_dec_datapoint (SkyCoord): ra/dec datapoint
long (float): longitude of observing site
parallax_s (float): parallax constant S of observing site
parallax_c (float): parallax constant C of observing site
Returns:
(1x2 array): right ascension difference, declination difference
"""
ra_comp, dec_comp = rhovec2radec(long, parallax_s, parallax_c, t_ra_dec_datapoint.obstime,
x[0], x[1], x[2], x[3], x[4], x[5])
ra_obs, dec_obs = t_ra_dec_datapoint.ra.rad, t_ra_dec_datapoint.dec.rad
#"unsigned" distance between points in torus
diff_ra = angle_diff_rad(ra_obs, ra_comp)
diff_dec = angle_diff_rad(dec_obs, dec_comp)
return np.array((diff_ra,diff_dec))
示例14: get_observer_pos_wrt_earth
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def get_observer_pos_wrt_earth(sat_observatories_data, obs_radec, site_codes):
"""Compute position of observer at Earth's surface, with respect
to the Earth, in equatorial frame, during 3 distinct instants.
Args:
sat_observatories_data (string): path to file containing COSPAR satellite tracking stations data.
obs_radec (1x3 SkyCoord array): three rad/dec observations
site_codes (1x3 int array): COSPAR codes of observation sites
Returns:
R (1x3 array): cartesian position vectors (observer wrt Earth)
"""
R = np.array((np.zeros((3,)),np.zeros((3,)),np.zeros((3,))))
# load MPC observatory data
obsite1 = get_station_data(site_codes[0], sat_observatories_data)
obsite2 = get_station_data(site_codes[1], sat_observatories_data)
obsite3 = get_station_data(site_codes[2], sat_observatories_data)
R[0] = observerpos_sat(obsite1['Latitude'], obsite1['Longitude'], obsite1['Elev'], obs_radec[0].obstime)
R[1] = observerpos_sat(obsite2['Latitude'], obsite2['Longitude'], obsite2['Elev'], obs_radec[1].obstime)
R[2] = observerpos_sat(obsite3['Latitude'], obsite3['Longitude'], obsite3['Elev'], obs_radec[2].obstime)
return R
示例15: radec_obs_vec_mpc
# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import SkyCoord [as 别名]
def radec_obs_vec_mpc(inds, mpc_object_data):
"""Compute vector of observed ra,dec values for MPC tracking data.
Args:
inds (int array): line numbers of data in file
mpc_object_data (ndarray): MPC observation data for object
Returns:
rov (1xlen(inds) array): vector of ra/dec observed values
"""
rov = np.zeros((2*len(inds)))
for i in range(0,len(inds)):
indm1 = inds[i]-1
# extract observations data
timeobs = Time( datetime(mpc_object_data['yr'][indm1],
mpc_object_data['month'][indm1],
mpc_object_data['day'][indm1]) + timedelta(days=mpc_object_data['utc'][indm1]) )
obs_t_ra_dec = SkyCoord(mpc_object_data['radec'][indm1], unit=(uts.hourangle, uts.deg), obstime=timeobs)
rov[2*i-2], rov[2*i-1] = obs_t_ra_dec.ra.rad, obs_t_ra_dec.dec.rad
return rov
# compute residuals vector for ra/dec observations with pre-computed observed radec values vector