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


Python coordinates.Longitude方法代码示例

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


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

示例1: test_healpix_to_lonlat

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def test_healpix_to_lonlat(self):
        lon, lat = self.pix.healpix_to_lonlat([1, 2, 3])

        assert isinstance(lon, Longitude)
        assert isinstance(lat, Latitude)

        index = self.pix.lonlat_to_healpix(lon, lat)

        assert_equal(index, [1, 2, 3])

        lon, lat = self.pix.healpix_to_lonlat([1, 2, 3],
                                              dx=[0.1, 0.2, 0.3],
                                              dy=[0.5, 0.4, 0.7])

        assert isinstance(lon, Longitude)
        assert isinstance(lat, Latitude)

        index, dx, dy = self.pix.lonlat_to_healpix(lon, lat, return_offsets=True)

        assert_equal(index, [1, 2, 3])
        assert_allclose(dx, [0.1, 0.2, 0.3])
        assert_allclose(dy, [0.5, 0.4, 0.7]) 
开发者ID:astropy,项目名称:astropy-healpix,代码行数:24,代码来源:test_high_level.py

示例2: test_healpix_to_lonlat

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def test_healpix_to_lonlat(order):
    lon, lat = healpix_to_lonlat([1, 2, 3], 4, order=order)

    assert isinstance(lon, Longitude)
    assert isinstance(lat, Latitude)

    index = lonlat_to_healpix(lon, lat, 4, order=order)

    assert_equal(index, [1, 2, 3])

    lon, lat = healpix_to_lonlat([1, 2, 3], 4,
                                 dx=[0.1, 0.2, 0.3],
                                 dy=[0.5, 0.4, 0.7], order=order)

    assert isinstance(lon, Longitude)
    assert isinstance(lat, Latitude)

    index, dx, dy = lonlat_to_healpix(lon, lat, 4, order=order, return_offsets=True)

    assert_equal(index, [1, 2, 3])
    assert_allclose(dx, [0.1, 0.2, 0.3])
    assert_allclose(dy, [0.5, 0.4, 0.7]) 
开发者ID:astropy,项目名称:astropy-healpix,代码行数:24,代码来源:test_core.py

示例3: get_observer_pos_wrt_earth

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [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 
开发者ID:aerospaceresearch,项目名称:orbitdeterminator,代码行数:25,代码来源:gauss_method.py

示例4: test_distance_change

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def test_distance_change():

    ra = Longitude("4:08:15.162342", unit=u.hour)
    dec = Latitude("-41:08:15.162342", unit=u.degree)
    c1 = ICRS(ra, dec, Distance(1, unit=u.kpc))

    oldx = c1.cartesian.x.value
    assert (oldx - 0.35284083171901953) < 1e-10

    # first make sure distances are immutible
    with pytest.raises(AttributeError):
        c1.distance = Distance(2, unit=u.kpc)

    # now x should increase with a bigger distance increases
    c2 = ICRS(ra, dec, Distance(2, unit=u.kpc))
    assert c2.cartesian.x.value == oldx * 2 
开发者ID:holzschu,项目名称:Carnets,代码行数:18,代码来源:test_distance.py

示例5: test_builtin_sites

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def test_builtin_sites():
    reg = get_builtin_sites()

    greenwich = reg['greenwich']
    lon, lat, el = greenwich.to_geodetic()
    assert_quantity_allclose(lon, Longitude('0:0:0', unit=u.deg),
                             atol=10*u.arcsec)
    assert_quantity_allclose(lat, Latitude('51:28:40', unit=u.deg),
                             atol=1*u.arcsec)
    assert_quantity_allclose(el, 46*u.m, atol=1*u.m)

    names = reg.names
    assert 'greenwich' in names
    assert 'example_site' in names

    with pytest.raises(KeyError) as exc:
        reg['nonexistent site']
    assert exc.value.args[0] == "Site 'nonexistent site' not in database. Use the 'names' attribute to see available sites." 
开发者ID:holzschu,项目名称:Carnets,代码行数:20,代码来源:test_sites.py

示例6: test_online_sites

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def test_online_sites():
    reg = get_downloaded_sites()

    keck = reg['keck']
    lon, lat, el = keck.to_geodetic()
    assert_quantity_allclose(lon, -Longitude('155:28.7', unit=u.deg),
                             atol=0.001*u.deg)
    assert_quantity_allclose(lat, Latitude('19:49.7', unit=u.deg),
                             atol=0.001*u.deg)
    assert_quantity_allclose(el, 4160*u.m, atol=1*u.m)

    names = reg.names
    assert 'keck' in names
    assert 'ctio' in names

    with pytest.raises(KeyError) as exc:
        reg['nonexistent site']
    assert exc.value.args[0] == "Site 'nonexistent site' not in database. Use the 'names' attribute to see available sites."

    with pytest.raises(KeyError) as exc:
        reg['kec']
    assert exc.value.args[0] == "Site 'kec' not in database. Use the 'names' attribute to see available sites. Did you mean one of: 'keck'?'" 
开发者ID:holzschu,项目名称:Carnets,代码行数:24,代码来源:test_sites.py

示例7: test_EarthLocation_basic

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def test_EarthLocation_basic():
    greenwichel = EarthLocation.of_site('greenwich')
    lon, lat, el = greenwichel.to_geodetic()
    assert_quantity_allclose(lon, Longitude('0:0:0', unit=u.deg),
                             atol=10*u.arcsec)
    assert_quantity_allclose(lat, Latitude('51:28:40', unit=u.deg),
                             atol=1*u.arcsec)
    assert_quantity_allclose(el, 46*u.m, atol=1*u.m)

    names = EarthLocation.get_site_names()
    assert 'greenwich' in names
    assert 'example_site' in names

    with pytest.raises(KeyError) as exc:
        EarthLocation.of_site('nonexistent site')
    assert exc.value.args[0] == "Site 'nonexistent site' not in database. Use EarthLocation.get_site_names to see available sites." 
开发者ID:holzschu,项目名称:Carnets,代码行数:18,代码来源:test_sites.py

示例8: _erfa_sidereal_time

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def _erfa_sidereal_time(self, model):
        """Calculate a sidereal time using a IAU precession/nutation model."""

        from astropy.coordinates import Longitude

        erfa_function = model['function']
        erfa_parameters = [getattr(getattr(self, scale)._time, jd_part)
                           for scale in model['scales']
                           for jd_part in ('jd1', 'jd2_filled')]

        sidereal_time = erfa_function(*erfa_parameters)

        if self.masked:
            sidereal_time[self.mask] = np.nan

        return Longitude(sidereal_time, u.radian).to(u.hourangle) 
开发者ID:holzschu,项目名称:Carnets,代码行数:18,代码来源:core.py

示例9: _gal2idx

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def _gal2idx(self, gal):
        """
        Converts from Galactic coordinates to pixel indices.

        Args:
            gal (:obj:`astropy.coordinates.SkyCoord`): Galactic coordinates. Must
                store an array of coordinates (i.e., not be scalar).

        Returns:
            ``j, k, mask`` - Pixel indices of the coordinates, as well as a mask
            of in-bounds coordinates. Outputs have the same shape as the input
            coordinates.
        """

        # Make sure that l is in domain [-180 deg, 180 deg)
        l = coordinates.Longitude(gal.l, wrap_angle=180.*units.deg)

        j = (self._inv_pix_scale * (l.deg - self._l_bounds[0])).astype('i4')
        k = (self._inv_pix_scale * (gal.b.deg - self._b_bounds[0])).astype('i4')

        idx = (j < 0) | (j >= self._shape[0]) | (k < 0) | (k >= self._shape[1])

        if np.any(idx):
            j[idx] = -1
            k[idx] = -1

        return j, k, ~idx 
开发者ID:gregreen,项目名称:dustmaps,代码行数:29,代码来源:marshall.py

示例10: _coords2vec

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def _coords2vec(self, coords):
        """
        Converts from sky coordinates to unit vectors. Before conversion to unit
        vectors, the coordiantes are transformed to the coordinate system used
        internally by the :obj:`UnstructuredDustMap`, which can be set during
        initialization of the class.

        Args:
            coords (:obj:`astropy.coordinates.SkyCoord`): Input coordinates to
                convert to unit vectors.

        Returns:
            Cartesian unit vectors corresponding to the input coordinates, after
            transforming to the coordinate system used internally by the
            :obj:`UnstructuredDustMap`.
        """

        # c = coords.transform_to(self._frame)
        # vec = np.empty((c.shape[0], 2), dtype='f8')
        # vec[:,0] = coordinates.Longitude(coords.l, wrap_angle=360.*units.deg).deg[:]
        # vec[:,1] = coords.b.deg[:]
        # return np.radians(vec)

        c = coords.transform_to(self._frame).represent_as('cartesian')
        vec_norm = np.sqrt(c.x**2 + c.y**2 + c.z**2)

        vec = np.empty((c.shape[0], 3), dtype=c.x.dtype)
        vec[:,0] = (c.x / vec_norm).value[:]
        vec[:,1] = (c.y / vec_norm).value[:]
        vec[:,2] = (c.z / vec_norm).value[:]

        return vec 
开发者ID:gregreen,项目名称:dustmaps,代码行数:34,代码来源:unstructured_map.py

示例11: observerpos_mpc

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def observerpos_mpc(long, parallax_s, parallax_c, t_utc):
    """Compute geocentric observer position at UTC instant t_utc, for Sun-centered orbits,
    at a given observation site defined by its longitude, and parallax constants S and C.
    Formula taken from top of page 266, chapter 5, Orbital Mechanics book (Curtis).
    The parallax constants S and C are defined by:
    S=rho cos phi' C=rho sin phi', where
    rho: slant range
    phi': geocentric latitude

       Args:
           long (float): longitude of observing site
           parallax_s (float): parallax constant S of observing site
           parallax_c (float): parallax constant C of observing site
           t_utc (astropy.time.Time): UTC time of observation

       Returns:
           1x3 numpy array: cartesian components of observer's geocentric position
    """
    # Earth's equatorial radius in kilometers
    # Re = cts.R_earth.to(uts.Unit('km')).value

    # define Longitude object for the observation site longitude
    long_site = Longitude(long, uts.degree, wrap_angle=360.0*uts.degree)
    # compute sidereal time of observation at site
    t_site_lmst = t_utc.sidereal_time('mean', longitude=long_site)
    lmst_rad = t_site_lmst.rad # np.deg2rad(lmst_hrs*15.0) # radians

    # compute cartesian components of geocentric (non rotating) observer position
    x_gc = Re*parallax_c*np.cos(lmst_rad)
    y_gc = Re*parallax_c*np.sin(lmst_rad)
    z_gc = Re*parallax_s

    return np.array((x_gc,y_gc,z_gc)) 
开发者ID:aerospaceresearch,项目名称:orbitdeterminator,代码行数:35,代码来源:gauss_method.py

示例12: datetime2sidereal

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def datetime2sidereal(time: datetime, lon_radians: float, *, use_astropy: bool = True) -> float:
    """
    Convert ``datetime`` to local sidereal time

    from D. Vallado "Fundamentals of Astrodynamics and Applications"


    time : datetime.datetime
        time to convert
    lon_radians : float
        longitude (radians)
    use_astropy : bool, optional
        use AstroPy for conversion (False is Vallado)

    Results
    -------

    tsr : float
        Local sidereal time
    """
    if isinstance(time, (tuple, list)):
        return [datetime2sidereal(t, lon_radians) for t in time]

    if use_astropy and Time is not None:
        tsr = Time(time).sidereal_time(kind="apparent", longitude=Longitude(lon_radians, unit=u.radian)).radian
    else:
        jd = juliandate(str2dt(time))
        # %% Greenwich Sidereal time RADIANS
        gst = greenwichsrt(jd)
        # %% Algorithm 15 p. 188 rotate GST to LOCAL SIDEREAL TIME
        tsr = gst + lon_radians

    return tsr 
开发者ID:geospace-code,项目名称:pymap3d,代码行数:35,代码来源:sidereal.py

示例13: setup

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [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, no attributes
        self.s0 = ICRS(lon[:, np.newaxis] * np.ones(lat.shape),
                       lat * np.ones(lon.shape)[:, np.newaxis])
        # Make an AltAz frame since that has many types of attributes.
        # Match one axis with times.
        self.obstime = (Time('2012-01-01') +
                        np.arange(len(lon))[:, np.newaxis] * u.s)
        # And another with location.
        self.location = EarthLocation(20.*u.deg, lat, 100*u.m)
        # Ensure we have a quantity scalar.
        self.pressure = 1000 * u.hPa
        # As well as an array.
        self.temperature = np.random.uniform(
            0., 20., size=(lon.size, lat.size)) * u.deg_C
        self.s1 = AltAz(az=lon[:, np.newaxis], alt=lat,
                        obstime=self.obstime,
                        location=self.location,
                        pressure=self.pressure,
                        temperature=self.temperature)
        # For some tests, also try a GCRS, since that has representation
        # attributes.  We match the second dimension (via the location)
        self.obsgeoloc, self.obsgeovel = self.location.get_gcrs_posvel(
            self.obstime[0, 0])
        self.s2 = GCRS(ra=lon[:, np.newaxis], dec=lat,
                       obstime=self.obstime,
                       obsgeoloc=self.obsgeoloc,
                       obsgeovel=self.obsgeovel)
        # For completeness, also some tests on an empty frame.
        self.s3 = GCRS(obstime=self.obstime,
                       obsgeoloc=self.obsgeoloc,
                       obsgeovel=self.obsgeovel)
        # And make a SkyCoord
        self.sc = SkyCoord(ra=lon[:, np.newaxis], dec=lat, frame=self.s3) 
开发者ID:holzschu,项目名称:Carnets,代码行数:38,代码来源:test_shape_manipulation.py

示例14: test_distance_in_coordinates

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def test_distance_in_coordinates():
    """
    test that distances can be created from quantities and that cartesian
    representations come out right
    """

    ra = Longitude("4:08:15.162342", unit=u.hour)
    dec = Latitude("-41:08:15.162342", unit=u.degree)
    coo = ICRS(ra, dec, distance=2*u.kpc)

    cart = coo.cartesian

    assert isinstance(cart.xyz, u.Quantity) 
开发者ID:holzschu,项目名称:Carnets,代码行数:15,代码来源:test_distance.py

示例15: test_basic

# 需要导入模块: from astropy import coordinates [as 别名]
# 或者: from astropy.coordinates import Longitude [as 别名]
def test_basic():
    lon1 = Longitude(1.23, "radian", wrap_angle='180d')
    s = pickle.dumps(lon1)
    lon2 = pickle.loads(s) 
开发者ID:holzschu,项目名称:Carnets,代码行数:6,代码来源:test_pickle.py


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