コード例 #1
0
def test_representation_representation():
    """
    Test that Representations are represented correctly.
    """
    # With no unit we get "None" in the unit row
    c = coordinates.CartesianRepresentation([0], [1], [0], unit=u.one)
    t = Table([c])
    assert t.pformat() == ['    col0    ',
                           '------------',
                           '(0., 1., 0.)']

    c = coordinates.CartesianRepresentation([0], [1], [0], unit='m')
    t = Table([c])
    assert t.pformat() == ['    col0    ',
                           '     m      ',
                           '------------',
                           '(0., 1., 0.)']

    c = coordinates.SphericalRepresentation([10]*u.deg, [20]*u.deg, [1]*u.pc)
    t = Table([c])
    assert t.pformat() == ['     col0     ',
                           ' deg, deg, pc ',
                           '--------------',
                           '(10., 20., 1.)']

    c = coordinates.UnitSphericalRepresentation([10]*u.deg, [20]*u.deg)
    t = Table([c])
    assert t.pformat() == ['   col0   ',
                           '   deg    ',
                           '----------',
                           '(10., 20.)']

    c = coordinates.SphericalCosLatDifferential(
        [10]*u.mas/u.yr, [2]*u.mas/u.yr, [10]*u.km/u.s)
    t = Table([c])
    assert t.pformat() == ['           col0           ',
                           'mas / yr, mas / yr, km / s',
                           '--------------------------',
                           '            (10., 2., 10.)']
コード例 #2
0
    'latitude':
    coordinates.Latitude([5., 6., 10., 11.] * u.deg),
    'time':
    time.Time([2000, 2001, 2002, 2003], format='jyear'),
    'skycoord':
    coordinates.SkyCoord(ra=[0, 1, 2, 3] * u.deg, dec=[0, 1, 2, 3] * u.deg),
    'sphericalrep':
    coordinates.SphericalRepresentation([0, 1, 2, 3] * u.deg,
                                        [0, 1, 2, 3] * u.deg, 1 * u.kpc),
    'cartesianrep':
    coordinates.CartesianRepresentation([0, 1, 2, 3] * u.pc,
                                        [4, 5, 6, 7] * u.pc,
                                        [9, 8, 8, 6] * u.pc),
    'sphericaldiff':
    coordinates.SphericalCosLatDifferential([0, 1, 2, 3] * u.mas / u.yr,
                                            [0, 1, 2, 3] * u.mas / u.yr,
                                            10 * u.km / u.s),
    'arraywrap':
    table_helpers.ArrayWrapper([0, 1, 2, 3]),
    'ndarray':
    np.array([(7, 'a'), (8, 'b'), (9, 'c'), (9, 'c')],
             dtype='<i4,|S1').view(table.NdarrayMixin),
}
MIXIN_COLS['earthlocation'] = coordinates.EarthLocation(
    lon=MIXIN_COLS['longitude'],
    lat=MIXIN_COLS['latitude'],
    height=MIXIN_COLS['quantity'])
MIXIN_COLS['sphericalrepdiff'] = coordinates.SphericalRepresentation(
    MIXIN_COLS['sphericalrep'], differentials=MIXIN_COLS['sphericaldiff'])

コード例 #3
0
def vhel_to_gal(coordinate,
                pm,
                rv,
                vcirc=None,
                vlsr=None,
                galactocentric_frame=None):
    r"""THIS FUNCTION IS DEPRECATED!

    Use the `velocity transformations
    <http://docs.astropy.org/en/stable/coordinates/velocities.html>`_ from
    Astropy instead.

    The frame of the input coordinate determines how to interpret the given
    proper motions. For example, if the input coordinate is in the ICRS frame,
    the input velocity is assumed to be as well.

    Parameters
    ----------
    coordinate : :class:`~astropy.coordinates.SkyCoord`, :class:`~astropy.coordinates.BaseCoordinateFrame`
        This is most commonly a :class:`~astropy.coordinates.SkyCoord` object,
        but alternatively, it can be any coordinate frame object that is
        transformable to the Galactocentric frame.
    pm : :class:`~astropy.units.Quantity` or iterable of :class:`~astropy.units.Quantity` objects
        Proper motion in the same frame as the coordinate. For example, if your
        input coordinate is in :class:`~astropy.coordinates.ICRS`, then the
        proper motion is assumed to be in this frame as well. The order of
        elements should always be proper motion in (longitude, latitude), and
        should have shape (2,N). The longitude component is assumed to have the
        cosine of the latitude already multiplied in, so that in ICRS, for
        example, this would be :math:`\mu_\alpha\cos\delta`.
    rv : :class:`~astropy.units.Quantity`
        Barycentric radial velocity. Should have shape (1,N) or (N,).
    vcirc : :class:`~astropy.units.Quantity` (optional)
        Circular velocity of the Sun.
    vlsr : :class:`~astropy.units.Quantity` (optional)
        Velocity of the Sun relative to the local standard
        of rest (LSR).
    galactocentric_frame : :class:`~astropy.coordinates.Galactocentric` (optional)
        An instantiated :class:`~astropy.coordinates.Galactocentric` frame
        object with custom parameters for the Galactocentric coordinates. For
        example, if you want to set your own position of the Galactic center,
        you can pass in a frame with custom attributes.

    Returns
    -------
    vxyz : :class:`~astropy.units.Quantity` (optional)
        Cartesian velocity components (U,V,W). A :class:`~astropy.units.Quantity`
        object with shape (3,N).

    """

    url = "http://docs.astropy.org/en/stable/coordinates/velocities.html"
    warnings.warn(
        "This function is now deprecated. Use the velocity "
        "transformation functionality in Astropy instead. For more "
        "information, see: {0}".format(url), DeprecationWarning)

    if hasattr(coordinate, 'frame'):
        frame = coordinate.frame
    else:
        frame = coordinate

    frame_cls = frame.__class__
    c = frame_cls(
        coordinate.data.with_differentials(
            coord.SphericalCosLatDifferential(pm[0], pm[1], rv)))

    if vcirc is None:
        vcirc = 220 * u.km / u.s  # default in Astropy

    if vlsr is None:
        vlsr = [11.1, 12.24, 7.25] * u.km / u.s  # default in Astropy

    v_sun = vlsr + [0, 1, 0] * vcirc

    if galactocentric_frame is None:
        galactocentric_frame = coord.Galactocentric

    kwargs = dict([(k, getattr(galactocentric_frame, k))
                   for k in galactocentric_frame.frame_attributes])
    kwargs['galcen_v_sun'] = coord.CartesianDifferential(*v_sun)
    gc_no_data = coord.Galactocentric(**kwargs)

    new_c = c.transform_to(gc_no_data)
    return new_c.data.differentials['s'].d_xyz