コード例 #1
0
def test_rotating_vector_into_frame():
    et_seconds = 259056665.1855896
    ts = load.timescale()
    t = ts.tdb_jd(T0 + et_seconds / 3600. / 24.0)

    pc = PlanetaryConstants()
    pc.read_text(load('moon_080317.tf'))
    pc.read_binary(load('moon_pa_de421_1900-2050.bpc'))

    # Example from "moon_080317.tf" (the raw vector is taken from a
    # tweaked version of the script in the file that uses "J2000"):

    vector = ICRF(
        np.array([
            2.4798273371071659e+05, -2.6189996683651494e+05,
            -1.2455830876097400e+05
        ]) / AU_KM)
    vector.t = t
    meter = 1e-3

    frame = pc.build_frame_named('MOON_PA_DE421')
    result = vector.frame_xyz(frame)
    assert max(abs(result.km - [379908.634, 33385.003, -12516.8859])) < meter

    relative_frame = pc.build_frame_named('MOON_ME_DE421')
    result = vector.frame_xyz(relative_frame)
    assert max(abs(result.km - [379892.825, 33510.118, -12661.5278])) < meter
コード例 #2
0
def test_frame_rotations_for_mean_of_date():
    ts = api.load.timescale()
    t = ts.utc(2020, 11, 21)
    p = ICRF((1.1, 1.2, 1.3), t=t)
    lat, lon, distance1 = p.frame_latlon(true_equator_and_equinox_of_date)

    # Verify that the frame_latlon() coordinates match those from the
    # more conventional radec() call.
    ra, dec, distance2 = p.radec(epoch='date')
    assert abs(lat.arcseconds() - dec.arcseconds()) < 1e-6
    assert abs(lon.arcseconds() - ra.arcseconds()) < 1e-6
    assert abs(distance1.au - distance2.au) < 1e-15

    # Now that we know the coordinates are good, we can use them to
    # rebuild a trusted x,y,z vector with which to test frame_xyz().
    x1, y1, z1 = from_spherical(distance1.au, lat.radians, lon.radians)
    x2, y2, z2 = p.frame_xyz(true_equator_and_equinox_of_date).au
    assert abs(x1 - x2) < 1e-15
    assert abs(y1 - y2) < 1e-15
    assert abs(z1 - z2) < 1e-15