示例#1
0
def test_rotatedsun_transforms(frame, lon, lat, obstime, rotated_time1,
                               rotated_time2):
    # Tests the transformations (to, from, and loopback) for consistency with `diff_rot` output

    if hasattr(frame, 'observer'):
        base = frame(lon=lon, lat=lat, observer='earth', obstime=obstime)
    else:
        base = frame(lon=lon, lat=lat, obstime=obstime)

    # Map any 2D coordinate to the surface of the Sun
    if base.spherical.distance.unit is u.one and u.allclose(
            base.spherical.distance, 1 * u.one):
        newrepr = base.spherical * constants.radius
        base = base.realize_frame(newrepr)

    # Test the RotatedSunFrame->base transformation
    rsf1 = RotatedSunFrame(base=base, rotated_time=rotated_time1)
    result1 = rsf1.transform_to(base)

    desired_delta_lon1 = diff_rot((rotated_time1 - obstime).to(u.day), lat)

    assert_longitude_allclose(result1.lon,
                              rsf1.lon + desired_delta_lon1,
                              atol=1e-5 * u.deg)
    assert_quantity_allclose(base.lat, result1.lat, atol=1e-10 * u.deg)
    # Use the `spherical` property since the name of the component varies with frame
    assert_quantity_allclose(base.spherical.distance,
                             result1.spherical.distance)

    # Test the base->RotatedSunFrame transformation
    rsf2 = RotatedSunFrame(base=base, rotated_time=rotated_time2)
    result2 = base.transform_to(rsf2)

    desired_delta_lon2 = -diff_rot((rotated_time2 - obstime).to(u.day), lat)

    assert_longitude_allclose(result2.lon,
                              rsf2.lon + desired_delta_lon2,
                              atol=1e-5 * u.deg)
    assert_quantity_allclose(base.lat, result2.lat, atol=1e-10 * u.deg)
    # Use the `spherical` property since the name of the component varies with frame
    assert_quantity_allclose(base.spherical.distance,
                             result2.spherical.distance)

    # Test the RotatedSunFrame->RotatedSunFrame transformation
    result3 = rsf1.transform_to(rsf2)

    desired_delta_lon3 = desired_delta_lon1 + desired_delta_lon2

    assert_longitude_allclose(result3.lon,
                              rsf1.lon + desired_delta_lon3,
                              atol=1e-5 * u.deg)
    assert_quantity_allclose(result3.lat, result1.lat, atol=1e-10 * u.deg)
    # Use the `spherical` property since the name of the component varies with frame
    assert_quantity_allclose(result3.spherical.distance,
                             result1.spherical.distance)
def test_consistency_with_rotatedsunframe():
    old_observer = frames.HeliographicStonyhurst(10 * u.deg,
                                                 20 * u.deg,
                                                 1 * u.AU,
                                                 obstime='2001-01-01')
    new_observer = frames.HeliographicStonyhurst(30 * u.deg,
                                                 40 * u.deg,
                                                 2 * u.AU,
                                                 obstime='2001-01-08')

    hpc_coord = SkyCoord(100 * u.arcsec,
                         200 * u.arcsec,
                         frame='helioprojective',
                         observer=old_observer,
                         obstime=old_observer.obstime)

    # Perform the differential rotation using solar_rotate_coordinate()
    result1 = solar_rotate_coordinate(hpc_coord, observer=new_observer)

    # Perform the differential rotation using RotatedSunFrame, with translational motion of the Sun
    # ignored using transform_with_sun_center()
    rsf_coord = RotatedSunFrame(base=hpc_coord,
                                rotated_time=new_observer.obstime)
    with transform_with_sun_center():
        result2 = rsf_coord.transform_to(result1.replicate_without_data())

    assert_quantity_allclose(result1.Tx, result2.Tx)
    assert_quantity_allclose(result1.Ty, result2.Ty)
    assert_quantity_allclose(result1.distance, result2.distance)
示例#3
0
def test_rotatedsun_transforms(frame, lon, lat, obstime, rotated_time1,
                               rotated_time2):
    # Tests the transformations (to, from, and loopback) for consistency with `diff_rot` output

    base = frame(lon=lon, lat=lat, obstime=obstime)

    # Test the RotatedSunFrame->base transformation
    rsf1 = RotatedSunFrame(base=base, rotated_time=rotated_time1)
    result1 = rsf1.transform_to(base)

    desired_delta_lon1 = diff_rot((rotated_time1 - obstime).to(u.day), lat)

    assert_longitude_allclose(result1.lon,
                              rsf1.lon + desired_delta_lon1,
                              atol=1e-5 * u.deg)
    assert_quantity_allclose(base.lat, result1.lat)
    # Use the `spherical` property since the name of the component varies with frame
    assert_quantity_allclose(base.spherical.distance,
                             result1.spherical.distance)

    # Test the base->RotatedSunFrame transformation
    rsf2 = RotatedSunFrame(base=base, rotated_time=rotated_time2)
    result2 = base.transform_to(rsf2)

    desired_delta_lon2 = -diff_rot((rotated_time2 - obstime).to(u.day), lat)

    assert_longitude_allclose(result2.lon,
                              rsf2.lon + desired_delta_lon2,
                              atol=1e-5 * u.deg)
    assert_quantity_allclose(base.lat, result2.lat)
    # Use the `spherical` property since the name of the component varies with frame
    assert_quantity_allclose(base.spherical.distance,
                             result2.spherical.distance)

    # Test the RotatedSunFrame->RotatedSunFrame transformation
    result3 = rsf1.transform_to(rsf2)

    desired_delta_lon3 = desired_delta_lon1 + desired_delta_lon2

    assert_longitude_allclose(result3.lon,
                              rsf1.lon + desired_delta_lon3,
                              atol=1e-5 * u.deg)
    assert_quantity_allclose(result3.lat, result1.lat)
    # Use the `spherical` property since the name of the component varies with frame
    assert_quantity_allclose(result3.spherical.distance,
                             result1.spherical.distance)