예제 #1
0
def test_class_creation(indirect_fixture):
    base_class, rot_frame = indirect_fixture

    rot_class = type(rot_frame)

    # Check that that the RotatedSunFrame metaclass is derived from the frame's metaclass
    assert issubclass(type(rot_class), type(base_class))

    # Check that the RotatedSunFrame class name has both 'RotatedSun' and the name of the base
    assert 'RotatedSun' in rot_class.__name__
    assert base_class.__name__ in rot_class.__name__

    # Check that the base class is in fact the specified class
    assert type(rot_frame.base) == base_class

    # Check that one-leg transformations have been created
    assert len(
        frame_transform_graph.get_transform(rot_class,
                                            rot_class).transforms) == 1
    assert len(
        frame_transform_graph.get_transform(base_class,
                                            rot_class).transforms) == 1
    assert len(
        frame_transform_graph.get_transform(rot_class,
                                            base_class).transforms) == 1

    # Check that the base frame is in the cache
    assert base_class in _rotatedsun_cache

    # Check that the component data has been migrated
    assert rot_frame.has_data
    assert not rot_frame.base.has_data
예제 #2
0
def test_class_creation(indirect_fixture):
    base_class, rot_frame = indirect_fixture

    rot_class = type(rot_frame)

    # Check that the RotatedSunFrame class name has both 'RotatedSun' and the name of the base
    assert 'RotatedSun' in rot_class.__name__
    assert base_class.__name__ in rot_class.__name__

    # Check that the base class is in fact the specified class
    assert type(rot_frame.base) == base_class

    # Check that the new class does *not* have the `obstime` frame attribute
    assert 'obstime' not in rot_frame.frame_attributes

    # Check that one-leg transformations have been created
    assert len(
        frame_transform_graph.get_transform(rot_class,
                                            rot_class).transforms) == 1
    assert len(
        frame_transform_graph.get_transform(f.HeliographicStonyhurst,
                                            rot_class).transforms) == 1
    assert len(
        frame_transform_graph.get_transform(
            rot_class, f.HeliographicStonyhurst).transforms) == 1

    # Check that the base frame is in the cache
    assert base_class in _rotatedsun_cache

    # Check that the component data has been migrated
    assert rot_frame.has_data
    assert not rot_frame.base.has_data
def test_icrs_hadec_consistency():
    """
    Check ICRS<->HADec for consistency with ICRS<->CIRS<->HADec
    """
    usph = golden_spiral_grid(200)
    dist = np.linspace(0.5, 1, len(usph)) * u.km * 1e5
    icoo = SkyCoord(ra=usph.lon, dec=usph.lat, distance=dist)

    observer = EarthLocation(28*u.deg, 23*u.deg, height=2000.*u.km)
    obstime = Time('J2010')
    hd_frame = HADec(obstime=obstime, location=observer)

    # check we are going direct!
    trans = frame_transform_graph.get_transform(ICRS, HADec).transforms
    assert(len(trans) == 1)

    # check that ICRS-HADec and ICRS->CIRS->HADec are consistent
    aa1 = icoo.transform_to(hd_frame)
    aa2 = icoo.transform_to(CIRS()).transform_to(hd_frame)
    assert_allclose(aa1.separation_3d(aa2), 0*u.mm, atol=1*u.mm)

    # check roundtrip
    roundtrip = icoo.transform_to(hd_frame).transform_to(icoo)
    assert_allclose(roundtrip.separation_3d(icoo), 0*u.mm, atol=1*u.mm)

    # check there and back via CIRS mish-mash
    roundtrip = icoo.transform_to(hd_frame).transform_to(
        CIRS()).transform_to(icoo)
    assert_allclose(roundtrip.separation_3d(icoo), 0*u.mm, atol=1*u.mm)
예제 #4
0
def test_icrs_consistency():
    """
    Check ICRS<->AltAz for consistency with ICRS<->CIRS<->AltAz

    The latter is extensively tested in test_intermediate_transformations.py
    """
    ra, dec, dist = randomly_sample_sphere(200)
    icoo = SkyCoord(ra=ra, dec=dec, distance=dist * u.km * 1e5)

    observer = EarthLocation(28 * u.deg, 23 * u.deg, height=2000. * u.km)
    obstime = Time('J2010')
    aa_frame = AltAz(obstime=obstime, location=observer)

    # check we are going direct!
    trans = frame_transform_graph.get_transform(ICRS, AltAz).transforms
    assert (len(trans) == 1)

    # check that ICRS-AltAz and ICRS->CIRS->AltAz are consistent
    aa1 = icoo.transform_to(aa_frame)
    aa2 = icoo.transform_to(CIRS()).transform_to(aa_frame)
    assert_allclose(aa1.separation_3d(aa2), 0 * u.mm, atol=1 * u.mm)

    # check roundtrip
    roundtrip = icoo.transform_to(aa_frame).transform_to(icoo)
    assert_allclose(roundtrip.separation_3d(icoo), 0 * u.mm, atol=1 * u.mm)

    # check there and back via CIRS mish-mash
    roundtrip = icoo.transform_to(aa_frame).transform_to(
        CIRS()).transform_to(icoo)
    assert_allclose(roundtrip.separation_3d(icoo), 0 * u.mm, atol=1 * u.mm)
예제 #5
0
파일: sgr.py 프로젝트: zilishen/gala
    """
    return R


# Sgr to Galactic coordinates
@frame_transform_graph.transform(coord.StaticMatrixTransform, SagittariusLaw10,
                                 coord.Galactic)
def sgr_to_galactic():
    """ Compute the transformation from heliocentric Sagittarius coordinates to
        spherical Galactic.
    """
    return matrix_transpose(galactic_to_sgr())


# TODO: remove this in next version
class Sagittarius(SagittariusLaw10):
    def __init__(self, *args, **kwargs):
        import warnings
        warnings.warn(
            "This frame is deprecated. Use SagittariusLaw10 "
            "instead.", DeprecationWarning)
        super().__init__(*args, **kwargs)


trans = frame_transform_graph.get_transform(SagittariusLaw10,
                                            coord.Galactic).transforms[0]
frame_transform_graph.add_transform(Sagittarius, coord.Galactic, trans)
trans = frame_transform_graph.get_transform(coord.Galactic,
                                            SagittariusLaw10).transforms[0]
frame_transform_graph.add_transform(coord.Galactic, Sagittarius, trans)
예제 #6
0
        heliocentric Ophiuchus coordinates.
    """
    return R


@frame_transform_graph.transform(coord.StaticMatrixTransform,
                                 OphiuchusPriceWhelan16, coord.Galactic)
def oph_to_gal():
    """ Compute the transformation from heliocentric Ophiuchus coordinates to
        spherical Galactic.
    """
    return matrix_transpose(gal_to_oph())


# TODO: remove this in next version
class Ophiuchus(OphiuchusPriceWhelan16):
    def __init__(self, *args, **kwargs):
        import warnings
        warnings.warn(
            "This frame is deprecated. Use OphiuchusPriceWhelan16"
            " instead.", DeprecationWarning)
        super().__init__(*args, **kwargs)


trans = frame_transform_graph.get_transform(OphiuchusPriceWhelan16,
                                            coord.ICRS).transforms[0]
frame_transform_graph.add_transform(Ophiuchus, coord.ICRS, trans)
trans = frame_transform_graph.get_transform(
    coord.ICRS, OphiuchusPriceWhelan16).transforms[0]
frame_transform_graph.add_transform(coord.ICRS, Ophiuchus, trans)
예제 #7
0
파일: orphan.py 프로젝트: nstarman/gala
                  [-0.84246097, 0.37511331, 0.38671632],
                  [0.29983786, 0.92280606, -0.2419219]])
    return R


# Oph to Galactic coordinates
@frame_transform_graph.transform(coord.StaticMatrixTransform,
                                 OrphanKoposov19, coord.ICRS)
def oph19_to_icrs():
    """ Compute the transformation from heliocentric Orphan coordinates to
        spherical ICRS.
    """
    return matrix_transpose(galactic_to_orp())


# TODO: remove this in next version
class Orphan(OrphanNewberg10):
    def __init__(self, *args, **kwargs):
        import warnings
        warnings.warn("This frame is deprecated. Use OrphanNewberg10 or "
                      "OrphanKoposov19 instead.", DeprecationWarning)
        super().__init__(*args, **kwargs)


trans = frame_transform_graph.get_transform(OrphanNewberg10,
                                            coord.Galactic).transforms[0]
frame_transform_graph.add_transform(Orphan, coord.Galactic, trans)
trans = frame_transform_graph.get_transform(coord.Galactic,
                                            OrphanNewberg10).transforms[0]
frame_transform_graph.add_transform(coord.Galactic, Orphan, trans)
예제 #8
0
def icrs_to_pal5():
    """ Compute the transformation from Galactic spherical to
        heliocentric Pal 5 coordinates.
    """
    return R

@frame_transform_graph.transform(coord.StaticMatrixTransform, Pal5PriceWhelan18,
                                 coord.ICRS)
def pal5_to_icrs():
    """ Compute the transformation from heliocentric Pal 5 coordinates to
        spherical Galactic.
    """
    return matrix_transpose(icrs_to_pal5())


# TODO: remove this in next version
class Pal5(Pal5PriceWhelan18):
    def __init__(self, *args, **kwargs):
        import warnings
        warnings.warn("This frame is deprecated. Use Pal5PriceWhelan18 "
                      "instead.", DeprecationWarning)
        super().__init__(*args, **kwargs)


trans = frame_transform_graph.get_transform(Pal5PriceWhelan18,
                                            coord.ICRS).transforms[0]
frame_transform_graph.add_transform(Pal5, coord.ICRS, trans)
trans = frame_transform_graph.get_transform(coord.ICRS,
                                            Pal5PriceWhelan18).transforms[0]
frame_transform_graph.add_transform(coord.ICRS, Pal5, trans)
예제 #9
0
def icrs_to_gd1():
    """ Compute the transformation from Galactic spherical to
        heliocentric GD1 coordinates.
    """
    return R

@frame_transform_graph.transform(coord.StaticMatrixTransform, GD1Koposov10,
                                 coord.ICRS)
def gd1_to_icrs():
    """ Compute the transformation from heliocentric GD1 coordinates to
        spherical Galactic.
    """
    return matrix_transpose(icrs_to_gd1())


# TODO: remove this in next version
class GD1(GD1Koposov10):
    def __init__(self, *args, **kwargs):
        import warnings
        warnings.warn("This frame is deprecated. Use GD1Koposov10 instead.",
                      DeprecationWarning)
        super().__init__(*args, **kwargs)


trans = frame_transform_graph.get_transform(GD1Koposov10,
                                            coord.ICRS).transforms[0]
frame_transform_graph.add_transform(GD1, coord.ICRS, trans)
trans = frame_transform_graph.get_transform(coord.ICRS,
                                            GD1Koposov10).transforms[0]
frame_transform_graph.add_transform(coord.ICRS, GD1, trans)
예제 #10
0
파일: orphan.py 프로젝트: adrn/gala
    pm_phi1_cosphi2 : `~astropy.units.Quantity`
        Proper motion in longitude.
    pm_phi2 : `~astropy.units.Quantity`
        Proper motion in latitude.
    radial_velocity : `~astropy.units.Quantity`
        Line-of-sight or radial velocity.
    """

    pole = coord.ICRS(ra=72.2643 * u.deg,
                      dec=-20.6575 * u.deg)
    ra0 = 160 * u.deg
    rotation = 0 * u.deg


# TODO: remove this in next version
class Orphan(OrphanNewberg10):
    def __init__(self, *args, **kwargs):
        import warnings
        warnings.warn("This frame is deprecated. Use OrphanNewberg10 or "
                      "OrphanKoposov19 instead.", DeprecationWarning)
        super().__init__(*args, **kwargs)


trans = frame_transform_graph.get_transform(OrphanNewberg10,
                                            coord.Galactic).transforms[0]
frame_transform_graph.add_transform(Orphan, coord.Galactic, trans)
trans = frame_transform_graph.get_transform(coord.Galactic,
                                            OrphanNewberg10).transforms[0]
frame_transform_graph.add_transform(coord.Galactic, Orphan, trans)
예제 #11
0
파일: oph.py 프로젝트: adrn/gala
def gal_to_oph():
    """ Compute the transformation from Galactic spherical to
        heliocentric Ophiuchus coordinates.
    """
    return R

@frame_transform_graph.transform(coord.StaticMatrixTransform,
                                 OphiuchusPriceWhelan16, coord.Galactic)
def oph_to_gal():
    """ Compute the transformation from heliocentric Ophiuchus coordinates to
        spherical Galactic.
    """
    return matrix_transpose(gal_to_oph())


# TODO: remove this in next version
class Ophiuchus(OphiuchusPriceWhelan16):
    def __init__(self, *args, **kwargs):
        import warnings
        warnings.warn("This frame is deprecated. Use OphiuchusPriceWhelan16"
                      " instead.", DeprecationWarning)
        super().__init__(*args, **kwargs)


trans = frame_transform_graph.get_transform(OphiuchusPriceWhelan16,
                                            coord.ICRS).transforms[0]
frame_transform_graph.add_transform(Ophiuchus, coord.ICRS, trans)
trans = frame_transform_graph.get_transform(coord.ICRS,
                                            OphiuchusPriceWhelan16).transforms[0]
frame_transform_graph.add_transform(coord.ICRS, Ophiuchus, trans)
예제 #12
0
파일: sgr.py 프로젝트: adrn/gala
    """ Compute the transformation from Galactic spherical to
        heliocentric Sagittarius coordinates.
    """
    return R

# Sgr to Galactic coordinates
@frame_transform_graph.transform(coord.StaticMatrixTransform, SagittariusLaw10,
                                 coord.Galactic)
def sgr_to_galactic():
    """ Compute the transformation from heliocentric Sagittarius coordinates to
        spherical Galactic.
    """
    return matrix_transpose(galactic_to_sgr())


# TODO: remove this in next version
class Sagittarius(SagittariusLaw10):
    def __init__(self, *args, **kwargs):
        import warnings
        warnings.warn("This frame is deprecated. Use SagittariusLaw10 "
                      "instead.", DeprecationWarning)
        super().__init__(*args, **kwargs)


trans = frame_transform_graph.get_transform(SagittariusLaw10,
                                            coord.Galactic).transforms[0]
frame_transform_graph.add_transform(Sagittarius, coord.Galactic, trans)
trans = frame_transform_graph.get_transform(coord.Galactic,
                                            SagittariusLaw10).transforms[0]
frame_transform_graph.add_transform(coord.Galactic, Sagittarius, trans)