当前位置: 首页>>代码示例>>Python>>正文


Python units.mas方法代码示例

本文整理汇总了Python中astropy.units.mas方法的典型用法代码示例。如果您正苦于以下问题:Python units.mas方法的具体用法?Python units.mas怎么用?Python units.mas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在astropy.units的用法示例。


在下文中一共展示了units.mas方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def __init__(self, **specs):
        
        #define mapping between attributes we need and the IPAC data
        #table loaded in the Planet Population module
        self.atts_mapping = {'Name':'pl_hostname',
                             'Spec':'st_spstr',
                             'parx':'st_plx',
                             'Umag':'st_uj',
                             'Bmag':'st_bj',
                             'Vmag':'st_vj',
                             'Rmag':'st_rc',
                             'Imag':'st_ic',
                             'Jmag':'st_j',
                             'Hmag':'st_h',
                             'Kmag':'st_k',
                             'dist':'st_dist',
                             'BV':'st_bmvj',
                             'L':'st_lum', #ln(solLum)
                             'pmra':'st_pmra', #mas/year
                             'pmdec':'st_pmdec', #mas/year
                             'rv': 'st_radv'}
        
        TargetList.__init__(self, **specs) 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:25,代码来源:KnownRVPlanetsTargetList.py

示例2: test_nan_distance

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def test_nan_distance(self):
        """ This is a regression test: calling represent_as() and passing in the
            same class as the object shouldn't round-trip through cartesian.
        """

        sph = SphericalRepresentation(1*u.deg, 2*u.deg, np.nan*u.kpc)
        new_sph = sph.represent_as(SphericalRepresentation)
        assert_allclose_quantity(new_sph.lon, sph.lon)
        assert_allclose_quantity(new_sph.lat, sph.lat)

        dif = SphericalCosLatDifferential(1*u.mas/u.yr, 2*u.mas/u.yr,
                                          3*u.km/u.s)
        sph = sph.with_differentials(dif)
        new_sph = sph.represent_as(SphericalRepresentation)
        assert_allclose_quantity(new_sph.lon, sph.lon)
        assert_allclose_quantity(new_sph.lat, sph.lat) 
开发者ID:holzschu,项目名称:Carnets,代码行数:18,代码来源:test_representation.py

示例3: test_init_differential_compatible

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def test_init_differential_compatible(self):
        # TODO: more extensive checking of this

        # should fail - representation and differential not compatible
        diff = SphericalDifferential(d_lon=1 * u.mas/u.yr,
                                     d_lat=2 * u.mas/u.yr,
                                     d_distance=3 * u.km/u.s)
        with pytest.raises(TypeError):
            CartesianRepresentation(x=1 * u.kpc, y=2 * u.kpc, z=3 * u.kpc,
                                    differentials=diff)

        # should succeed - representation and differential are compatible
        diff = SphericalCosLatDifferential(d_lon_coslat=1 * u.mas/u.yr,
                                           d_lat=2 * u.mas/u.yr,
                                           d_distance=3 * u.km/u.s)

        r1 = SphericalRepresentation(lon=15*u.deg, lat=21*u.deg,
                                     distance=1*u.pc,
                                     differentials=diff) 
开发者ID:holzschu,项目名称:Carnets,代码行数:21,代码来源:test_representation.py

示例4: test_hcrs_icrs_differentials

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def test_hcrs_icrs_differentials():
    # Regression to ensure that we can transform velocities from HCRS to LSR.
    # Numbers taken from the original issue, gh-6835.
    hcrs = HCRS(ra=8.67*u.deg, dec=53.09*u.deg, distance=117*u.pc,
                pm_ra_cosdec=4.8*u.mas/u.yr, pm_dec=-15.16*u.mas/u.yr,
                radial_velocity=23.42*u.km/u.s)
    icrs = hcrs.transform_to(ICRS)

    # The position and velocity should not change much
    assert allclose(hcrs.cartesian.xyz, icrs.cartesian.xyz, rtol=1e-8)
    assert allclose(hcrs.velocity.d_xyz, icrs.velocity.d_xyz, rtol=1e-2)

    hcrs2 = icrs.transform_to(HCRS)

    # The values should round trip
    assert allclose(hcrs.cartesian.xyz, hcrs2.cartesian.xyz, rtol=1e-12)
    assert allclose(hcrs.velocity.d_xyz, hcrs2.velocity.d_xyz, rtol=1e-12) 
开发者ID:holzschu,项目名称:Carnets,代码行数:19,代码来源:test_celestial_transformations.py

示例5: test_missing_component_error_names

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def test_missing_component_error_names():
    """
    This test checks that the component names are frame component names, not
    representation or differential names, when referenced in an exception raised
    when not passing in enough data. For example:

    ICRS(ra=10*u.deg)

    should state:

    TypeError: __init__() missing 1 required positional argument: 'dec'
    """
    from astropy.coordinates.builtin_frames import ICRS

    with pytest.raises(TypeError) as e:
        ICRS(ra=150 * u.deg)
    assert "missing 1 required positional argument: 'dec'" in str(e.value)

    with pytest.raises(TypeError) as e:
        ICRS(ra=150*u.deg, dec=-11*u.deg,
             pm_ra=100*u.mas/u.yr, pm_dec=10*u.mas/u.yr)
    assert "pm_ra_cosdec" in str(e.value) 
开发者ID:holzschu,项目名称:Carnets,代码行数:24,代码来源:test_frames.py

示例6: test_api

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def test_api():
    # transform observed Barycentric velocities to full-space Galactocentric
    with galactocentric_frame_defaults.set('latest'):
        gc_frame = Galactocentric()
        icrs = ICRS(ra=151.*u.deg, dec=-16*u.deg, distance=101*u.pc,
                    pm_ra_cosdec=21*u.mas/u.yr, pm_dec=-71*u.mas/u.yr,
                    radial_velocity=71*u.km/u.s)
        icrs.transform_to(gc_frame)

        # transform a set of ICRS proper motions to Galactic
        icrs = ICRS(ra=151.*u.deg, dec=-16*u.deg,
                    pm_ra_cosdec=21*u.mas/u.yr, pm_dec=-71*u.mas/u.yr)
        icrs.transform_to(Galactic)

        # transform a Barycentric RV to a GSR RV
        icrs = ICRS(ra=151.*u.deg, dec=-16*u.deg, distance=1.*u.pc,
                    pm_ra_cosdec=0*u.mas/u.yr, pm_dec=0*u.mas/u.yr,
                    radial_velocity=71*u.km/u.s)
        icrs.transform_to(Galactocentric) 
开发者ID:holzschu,项目名称:Carnets,代码行数:21,代码来源:test_frames_with_velocity.py

示例7: test_negative_distance

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def test_negative_distance():
    """ Regression test: #7408
    Make sure that negative parallaxes turned into distances are handled right
    """

    RA = 150 * u.deg
    DEC = -11*u.deg
    c = ICRS(ra=RA, dec=DEC,
             distance=(-10*u.mas).to(u.pc, u.parallax()),
             pm_ra_cosdec=10*u.mas/u.yr,
             pm_dec=10*u.mas/u.yr)
    assert quantity_allclose(c.ra, RA)
    assert quantity_allclose(c.dec, DEC)

    c = ICRS(ra=RA, dec=DEC,
             distance=(-10*u.mas).to(u.pc, u.parallax()))
    assert quantity_allclose(c.ra, RA)
    assert quantity_allclose(c.dec, DEC) 
开发者ID:holzschu,项目名称:Carnets,代码行数:20,代码来源:test_frames_with_velocity.py

示例8: setup

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def setup(self):
        lon = Longitude(np.arange(0, 24, 4), u.hourangle)
        lat = Latitude(np.arange(-90, 91, 30), u.deg)

        # With same-sized arrays
        self.s0 = SphericalRepresentation(
            lon[:, np.newaxis] * np.ones(lat.shape),
            lat * np.ones(lon.shape)[:, np.newaxis],
            np.ones(lon.shape + lat.shape) * u.kpc)

        self.diff = SphericalDifferential(
            d_lon=np.ones(self.s0.shape)*u.mas/u.yr,
            d_lat=np.ones(self.s0.shape)*u.mas/u.yr,
            d_distance=np.ones(self.s0.shape)*u.km/u.s)
        self.s0 = self.s0.with_differentials(self.diff)

        # With unequal arrays -> these will be broadcasted.
        self.s1 = SphericalRepresentation(lon[:, np.newaxis], lat, 1. * u.kpc,
                                          differentials=self.diff)

        # For completeness on some tests, also a cartesian one
        self.c0 = self.s0.to_cartesian() 
开发者ID:holzschu,项目名称:Carnets,代码行数:24,代码来源:test_representation_methods.py

示例9: test_user_friendly_pm_error

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def test_user_friendly_pm_error():
    """
    This checks that a more user-friendly error message is raised for the user
    if they pass, e.g., pm_ra instead of pm_ra_cosdec
    """

    with pytest.raises(ValueError) as e:
        SkyCoord(ra=150*u.deg, dec=-11*u.deg,
                 pm_ra=100*u.mas/u.yr, pm_dec=10*u.mas/u.yr)
    assert 'pm_ra_cosdec' in str(e.value)

    with pytest.raises(ValueError) as e:
        SkyCoord(l=150*u.deg, b=-11*u.deg,
                 pm_l=100*u.mas/u.yr, pm_b=10*u.mas/u.yr,
                 frame='galactic')
    assert 'pm_l_cosb' in str(e.value)

    # The special error should not turn on here:
    with pytest.raises(ValueError) as e:
        SkyCoord(x=1*u.pc, y=2*u.pc, z=3*u.pc,
                 pm_ra=100*u.mas/u.yr, pm_dec=10*u.mas/u.yr,
                 representation_type='cartesian')
    assert 'pm_ra_cosdec' not in str(e.value) 
开发者ID:holzschu,项目名称:Carnets,代码行数:25,代码来源:test_sky_coord.py

示例10: test_parallax

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def test_parallax():
    a = u.arcsecond.to(u.pc, 10, u.parallax())
    assert_allclose(a, 0.10)
    b = u.pc.to(u.arcsecond, a, u.parallax())
    assert_allclose(b, 10)

    a = u.arcminute.to(u.au, 1, u.parallax())
    assert_allclose(a, 3437.7467916)
    b = u.au.to(u.arcminute, a, u.parallax())
    assert_allclose(b, 1)

    val = (-1 * u.mas).to(u.pc, u.parallax())
    assert np.isnan(val.value)

    val = (-1 * u.mas).to_value(u.pc, u.parallax())
    assert np.isnan(val) 
开发者ID:holzschu,项目名称:Carnets,代码行数:18,代码来源:test_equivalencies.py

示例11: __init__

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def __init__(self, ntargs=1000, star_dist=5, **specs):
        
        StarCatalog.__init__(self,**specs)
        
        # ntargs must be an integer >= 1
        self.ntargs = max(int(ntargs), 1)
        
        # list of astropy attributes
        self.coords = self.inverse_method(self.ntargs,star_dist)     # ICRS coordinates
        self.ntargs = int(len(self.coords.ra))
        self.dist = star_dist*np.ones(self.ntargs)*u.pc               # distance
        self.parx = self.dist.to('mas', equivalencies=u.parallax())   # parallax
        self.pmra = np.zeros(self.ntargs)*u.mas/u.yr                 # proper motion in RA
        self.pmdec = np.zeros(self.ntargs)*u.mas/u.yr                # proper motion in DEC
        self.rv = np.zeros(self.ntargs)*u.km/u.s                     # radial velocity
        
        # list of non-astropy attributes to pass target list filters
        self.Name = np.array([str(x) for x in range(self.ntargs)])   # star names
        self.Spec = np.array(['G']*self.ntargs)                      # spectral types
        self.Umag = np.zeros(self.ntargs)                            # U magnitude
        self.Bmag = np.zeros(self.ntargs)                            # B magnitude
        self.Vmag = 5*np.ones(self.ntargs)                           # V magnitude
        self.Rmag = np.zeros(self.ntargs)                            # R magnitude
        self.Imag = np.zeros(self.ntargs)                            # I magnitude
        self.Jmag = np.zeros(self.ntargs)                            # J magnitude
        self.Hmag = np.zeros(self.ntargs)                            # H magnitude
        self.Kmag = np.zeros(self.ntargs)                            # K magnitude
        self.BV = np.zeros(self.ntargs)                              # B-V Johnson magnitude
        self.MV   = self.Vmag - 5*( np.log10(star_dist) - 1 )   # absolute V magnitude 
        self.BC   = -0.10*np.ones(self.ntargs)                       # bolometric correction
        
        BM        = self.MV + self.BC
        L0        = 3.0128e28
        BMsun     = 4.74
        self.L    = L0*10**(0.4*(BMsun-BM))                     # stellar luminosity in ln(SolLum)
        self.Binary_Cut = np.zeros(self.ntargs, dtype=bool)          # binary closer than 10 arcsec
        
        # populate outspecs
        self._outspec['ntargs'] = self.ntargs 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:41,代码来源:FakeCatalog.py

示例12: fakemag_to_parallax

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def fakemag_to_parallax(fakemag, mag, fakemag_err=None):
    """
    To convert fakemag to parallax, Magic Number will be preserved

    :param fakemag: astroNN fakemag
    :type fakemag: Union[float, ndarray]
    :param mag: apparent magnitude
    :type mag: Union[float, ndarray]
    :param fakemag_err: Optional, fakemag_err
    :type fakemag_err: Union[NoneType, float, ndarray]
    :return: array of parallax in mas with astropy Quantity (with additional return of propagated error if fakemag_err is provided)
    :rtype: astropy Quantity
    :History: 2018-Aug-11 - Written - Henry Leung (University of Toronto)
    """
    fakemag = np.array(fakemag)
    mag = np.array(mag)
    # treat non-positive fakemag as MAGIC_NUMBER, check for magic number and negative fakemag
    magic_idx = ((fakemag == MAGIC_NUMBER) | (mag == MAGIC_NUMBER) | (fakemag <= 0.))

    with warnings.catch_warnings():  # suppress numpy Runtime warning caused by MAGIC_NUMBER
        warnings.simplefilter("ignore")
        parallax = fakemag / (10. ** (0.2 * mag))
    if fakemag.shape != ():  # check if its only 1 element
        parallax[magic_idx] = MAGIC_NUMBER
    else:  # for float
        parallax = MAGIC_NUMBER if magic_idx == [1] else parallax

    if fakemag_err is None:
        return parallax * u.mas
    else:
        with warnings.catch_warnings():  # suppress numpy Runtime warning caused by MAGIC_NUMBER
            warnings.simplefilter("ignore")
            parallax_err = (fakemag_err / fakemag) * parallax
        if fakemag.shape != ():  # check if its only 1 element
            parallax_err[magic_idx] = MAGIC_NUMBER
        else:  # for float
            parallax_err = MAGIC_NUMBER if magic_idx == [1] else parallax_err
        return parallax * u.mas, parallax_err * u.mas 
开发者ID:henrysky,项目名称:astroNN,代码行数:40,代码来源:gaia_shared.py

示例13: test_anderson

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def test_anderson(self):
        from astroNN.gaia import anderson_2017_parallax
        # To load the improved parallax
        # Both parallax and para_var is in mas
        # cuts=True to cut bad data (negative parallax and percentage error more than 20%)
        ra, dec, parallax, para_err = anderson_2017_parallax(cuts=True)
        self.assertEqual(np.any([parallax == -9999.]), False)  # assert no -9999 
开发者ID:henrysky,项目名称:astroNN,代码行数:9,代码来源:test_gaia_tools.py

示例14: correct_pm

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def correct_pm(ra, dec, pmra, pmdec, dist, vlsr=vlsr0):
    """Corrects the proper motion for the speed of the Sun
    Arguments:
        ra - RA in deg
        dec -- Declination in deg
        pmra -- pm in RA in mas/yr
        pmdec -- pm in declination in mas/yr
        dist -- distance in kpc
    Returns:
        (pmra,pmdec) the tuple with the proper motions corrected for the Sun's motion
    """
    
    one = ra * 0 + 1
    zero = ra * 0
    usun,vsun,wsun = get_uvw_sun(vlsr)
    dist_pc = dist * 1000. 
    ur, vr, wr = gal_uvw.gal_uvw(distance=dist_pc, ra=ra, dec=dec,
        pmra=one, pmdec=zero, vrad=zero)
    ud, vd, wd = gal_uvw.gal_uvw(distance=dist_pc, ra=ra, dec=dec,
        pmra=zero, pmdec=one, vrad=zero)



    d_pmra =  -(ur * usun + vr * vsun + wr * wsun) / (ur**2 + vr**2 + wr**2)
    d_pmdec = -(ud * usun + vd * vsun + wd * wsun) / (ud**2 + vd**2 + wd**2)
    # d_pmra d_pmdec -- these should be the pm's of the non-moving object as seen from the moving Sun
    return (pmra-d_pmra,pmdec-d_pmdec) 
开发者ID:segasai,项目名称:astrolibpy,代码行数:29,代码来源:correct_pm.py

示例15: correct_vel

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mas [as 别名]
def correct_vel(ra, dec, vel, vlsr=vlsr0):
    """Corrects the proper motion for the speed of the Sun
    Arguments:
        ra - RA in deg
        dec -- Declination in deg
        pmra -- pm in RA in mas/yr
        pmdec -- pm in declination in mas/yr
        dist -- distance in kpc
    Returns:
        (pmra,pmdec) the tuple with the proper motions corrected for the Sun's motion
    """
    
    C=acoo.ICRS(ra=ra*auni.deg,dec=dec*auni.deg,
                    radial_velocity=vel*auni.km/auni.s,
                    distance=np.ones_like(vel)*auni.kpc,
                    pm_ra_cosdec=np.zeros_like(vel)*auni.mas/auni.year,
                    pm_dec=np.zeros_like(vel)*auni.mas/auni.year)
    #frame = acoo.Galactocentric (galcen_vsun = np.array([ 11.1, vlsr+12.24, 7.25])*auni.km/auni.s)
    kw = dict(galcen_v_sun = acoo.CartesianDifferential(np.array([ 11.1, vlsr+12.24, 7.25])*auni.km/auni.s))                                 
    frame = acoo.Galactocentric (**kw)
    Cg = C.transform_to(frame)
    Cg1 = acoo.Galactocentric(x=Cg.x, y=Cg.y, z=Cg.z,
                              v_x=Cg.v_x*0,
                              v_y=Cg.v_y*0,
                              v_z=Cg.v_z*0, **kw)
    C1=Cg1.transform_to(acoo.ICRS)
    return np.asarray(((C.radial_velocity-C1.radial_velocity)/(auni.km/auni.s)).decompose()) 
开发者ID:segasai,项目名称:astrolibpy,代码行数:29,代码来源:correct_pm.py


注:本文中的astropy.units.mas方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。