예제 #1
0
def test_hci_hci():
    # Test HCI loopback transformation
    obstime = Time('2001-01-01')
    old = SkyCoord(90*u.deg, 10*u.deg, 0.7*u.AU, frame=HeliocentricInertial(obstime=obstime))
    new = old.transform_to(HeliocentricInertial)

    assert_quantity_allclose(new.lon, old.lon)
    assert_quantity_allclose(new.lat, old.lat)
    assert_quantity_allclose(new.distance, old.distance)

    new = old.transform_to(HeliocentricInertial(obstime=obstime + 1*u.day))

    assert_quantity_allclose(new.lon, old.lon, atol=0.1*u.deg)  # due to Earth motion
    assert_quantity_allclose(new.lat, old.lat, atol=1e-3*u.deg)
    assert_quantity_allclose(new.distance, old.distance, atol=1e-5*u.AU)
예제 #2
0
def test_transform_with_sun_center_reset():
    # This test sequence ensures that the context manager does not change anything permanently

    sun_center = SkyCoord(0 * u.deg,
                          0 * u.deg,
                          0 * u.AU,
                          frame=HeliographicStonyhurst(obstime="2001-01-01"))
    end_frame = HeliocentricInertial(obstime="2001-02-01")

    # Without the context manager, the coordinate should not point at Sun center
    result1 = sun_center.transform_to(end_frame)
    assert result1.lon != sun_center.lon
    assert result1.lat != sun_center.lat
    assert result1.distance != sun_center.radius

    # Using the context manager, the coordinate should point at Sun center
    with transform_with_sun_center():
        result2 = sun_center.transform_to(end_frame)
    assert_quantity_allclose(result2.lon, sun_center.lon)
    assert_quantity_allclose(result2.lat, sun_center.lat)
    assert_quantity_allclose(result2.distance, sun_center.radius)

    # After the context manager, the coordinate should have the same result as the first transform
    result3 = sun_center.transform_to(end_frame)
    assert_quantity_allclose(result3.lon, result1.lon)
    assert_quantity_allclose(result3.lat, result1.lat)
    assert_quantity_allclose(result3.distance, result1.distance)
예제 #3
0
def test_propagate_with_solar_surface():
    # Test propagating the meridian by 6 days of solar rotation
    meridian = SkyCoord(0*u.deg, np.arange(0, 90, 10)*u.deg, 1*u.AU,
                        frame=HeliocentricInertial, obstime='2001-01-01')
    dt = 6*u.day
    end_frame = HeliocentricInertial(obstime=meridian.obstime + dt)

    # Without the context manager
    result1 = meridian.transform_to(end_frame)
    assert u.allclose(result1.lon, 0*u.deg, atol=1e-1*u.deg)  # no rotation with the solar surface
    assert not u.allclose(result1.lon, 0*u.deg, atol=1e-3*u.deg)  # some change due to translation
    assert u.allclose(result1.lat, meridian.lat, atol=1e-2*u.deg)

    # Using the context manager (also test default rotation model is 'howard')
    with propagate_with_solar_surface():
        result2 = meridian.transform_to(end_frame)
    assert u.allclose(result2.lon, diff_rot(dt, meridian.lat, rot_type='howard'))

    # Check that nesting the context manager doesn't confuse anything (also test other models)
    with propagate_with_solar_surface('snodgrass'):
        with propagate_with_solar_surface('allen'):
            pass
        result3 = meridian.transform_to(end_frame)  # should use 'snodgrass', not 'allen'
    assert u.allclose(result3.lon, diff_rot(dt, meridian.lat, rot_type='snodgrass'))

    # After the context manager, the coordinate should have the same result as the first transform
    result4 = meridian.transform_to(end_frame)
    assert_quantity_allclose(result4.lon, result1.lon)
    assert_quantity_allclose(result4.lat, result1.lat)
    assert_quantity_allclose(result4.distance, result1.distance)
예제 #4
0
def test_velocity_hgs_hci():
    # HGS and HCI share the same origin and Z axis, so the induced velocity is entirely angular
    obstime = Time(['2021-01-01', '2021-04-01', '2021-07-01', '2021-10-01'])
    venus_hgs = get_body_heliographic_stonyhurst('venus', obstime, include_velocity=True)
    venus_hci = venus_hgs.transform_to(HeliocentricInertial(obstime=obstime))

    # The induced velocity is the longitude component of Earth's velocity, ~360 deg/yr
    induced_dlon = get_earth(obstime, include_velocity=True).heliocentricinertial.d_lon
    assert_quantity_allclose(induced_dlon, 360*u.deg/u.yr, rtol=0.05)

    # The HCI velocity should be the same as the HGS velocity except for the induced velocity
    assert_quantity_allclose(venus_hci.d_distance, venus_hgs.d_radius, rtol=1e-5)
    assert_quantity_allclose(venus_hci.d_lon, venus_hgs.d_lon + induced_dlon, rtol=1e-6)
    assert_quantity_allclose(venus_hci.d_lat, venus_hgs.d_lat)
예제 #5
0
 def __init__(self, coordinate_frame=None):
     if coordinate_frame is None:
         coordinate_frame = HeliocentricInertial()
     self._coordinate_frame = coordinate_frame