示例#1
0
def test_GeocentricSolarEcliptic_against_data():
    gcrs = GCRS(ra="02h31m49.09s", dec="+89d15m50.8s", distance=200 * u.km)
    gse = gcrs.transform_to(GeocentricSolarEcliptic(obstime=J2000))
    lon = 233.11691362602866
    lat = 48.64606410986667
    assert_quantity_allclose(gse.lat.value, lat, atol=1e-7)
    assert_quantity_allclose(gse.lon.value, lon, atol=1e-7)
示例#2
0
def test_GeocentricSolarEcliptic_raises_error_nonscalar_obstime():
    with pytest.raises(ValueError) as excinfo:
        gcrs = GCRS(ra="02h31m49.09s", dec="+89d15m50.8s", distance=200 * u.km)
        gcrs.transform_to(
            GeocentricSolarEcliptic(obstime=Time(["J3200", "J2000"])))
    assert ("To perform this transformation the "
            "obstime Attribute must be a scalar." in str(excinfo.value))
示例#3
0
def validate_GCRF_to_ITRF(r_vec, v_vec):

    # Compute for the norm of position and velocity vectors
    r_norm, v_norm = [norm(vec) for vec in [r_vec, v_vec]]
    R = Earth_poliastro.R.to(u.m).value

    # Correction factor to normalize position and velocity vectors
    k_r = R / r_norm if r_norm != 0 else 1.00
    k_v = 1 / v_norm if v_norm != 0 else 1.00

    # Make a position vector who's norm is equal to the body's radius. Make a
    # unitary velocity vector. Units are in [m] and [m / s].
    rx, ry, rz = [float(k_r * r_i) for r_i in r_vec]
    vx, vy, vz = [float(k_v * v_i) for v_i in v_vec]

    # orekit: build r_vec and v_vec wrt inertial body frame
    xyz_orekit = Vector3D(rx, ry, rz)
    uvw_orekit = Vector3D(vx, vy, vz)
    coords_GCRF_orekit = TimeStampedPVCoordinates(J2000_OREKIT, xyz_orekit,
                                                  uvw_orekit)

    # orekit: build conversion between GCRF and ITRF
    GCRF_TO_ITRF_OREKIT = GCRF_FRAME_OREKIT.getTransformTo(
        ITRF_FRAME_OREKIT,
        J2000_OREKIT,
    )

    # orekit: convert from GCRF to ITRF using previous built conversion
    coords_ITRF_orekit = (GCRF_TO_ITRF_OREKIT.transformPVCoordinates(
        coords_GCRF_orekit).getPosition().toArray())
    coords_ITRF_orekit = np.asarray(coords_ITRF_orekit) * u.m

    # poliastro: build r_vec and v_vec wrt GCRF
    xyz_poliastro = CartesianRepresentation(rx * u.m, ry * u.m, rz * u.m)
    coords_GCRS_poliastro = GCRS_poliastro(xyz_poliastro)

    # poliastro: convert from inertial to fixed frame at given epoch
    coords_ITRS_poliastro = (coords_GCRS_poliastro.transform_to(
        ITRS_poliastro(
            obstime=J2000_POLIASTRO)).represent_as(CartesianRepresentation).xyz
                             )

    # Check position conversion
    assert_quantity_allclose(
        coords_ITRS_poliastro,
        coords_ITRF_orekit,
        atol=1e-3 * u.m,
        rtol=1e-2,
    )
示例#4
0
def test_from_coord_if_coord_is_not_of_shape_zero():
    pos = [0, 1, 0]
    vel = [1, 0, 0]
    cartdiff = CartesianDifferential([vel] * u.km / u.s, xyz_axis=1)
    cartrep = CartesianRepresentation([pos] * u.km, differentials=cartdiff, xyz_axis=1)
    coords = GCRS(cartrep, representation_type=CartesianRepresentation, obstime=J2000)

    ss = Orbit.from_coords(Earth, coords)

    assert_quantity_allclose(ss.r, pos * u.km, rtol=1e-5)
    assert_quantity_allclose(ss.v, vel * u.km / u.s, rtol=1e-5)
示例#5
0
def test_from_coord_fails_for_multiple_positions(obstime):
    cartdiff = CartesianDifferential(
        [[0, 1, 0], [-0.1, 0.9, 0]] * u.km / u.s, xyz_axis=1
    )
    cartrep = CartesianRepresentation(
        [[1, 0, 0], [0.9, 0.1, 0]] * u.km, differentials=cartdiff, xyz_axis=1
    )
    coords = GCRS(cartrep, representation_type=CartesianRepresentation, obstime=obstime)

    with pytest.raises(ValueError) as excinfo:
        Orbit.from_coords(Earth, coords)
    assert (
        "ValueError: Coordinate instance must represents exactly 1 position, found: 2"
        in excinfo.exconly()
    )
示例#6
0
def test_round_trip_from_GeocentricSolarEcliptic_gives_same_results():
    gcrs = GCRS(ra="02h31m49.09s", dec="+89d15m50.8s", distance=200 * u.km)
    gse = gcrs.transform_to(GeocentricSolarEcliptic(obstime=Time("J2000")))
    gcrs_back = gse.transform_to(GCRS(obstime=Time("J2000")))
    assert_quantity_allclose(gcrs_back.dec.value, gcrs.dec.value, atol=1e-7)
    assert_quantity_allclose(gcrs_back.ra.value, gcrs.ra.value, atol=1e-7)