Exemple #1
0
def test_orbit_from_spk_id_has_proper_values(mock_get, mock_response):
    mock_orbital_data = {
        "orbital_data": {
            "eccentricity": ".2225889698301071",
            "semi_major_axis": "1.457940027185708",
            "inclination": "10.82759100494802",
            "ascending_node_longitude": "304.3221633898424",
            "perihelion_argument": "178.8165910886752",
            "mean_anomaly": "71.28027812836476",
            "epoch_osculation": "2458000.5",
        }
    }

    mock_response.json.return_value = mock_orbital_data
    mock_get.return_value = mock_response
    ss = neows.orbit_from_spk_id("")

    assert ss.frame.is_equivalent_frame(
        HeliocentricEclipticJ2000(obstime=ss.epoch))
    assert ss.ecc == mock_orbital_data["orbital_data"]["eccentricity"] * u.one
    assert ss.a == mock_orbital_data["orbital_data"]["semi_major_axis"] * u.AU
    assert ss.inc == mock_orbital_data["orbital_data"]["inclination"] * u.deg
    assert (ss.raan ==
            mock_orbital_data["orbital_data"]["ascending_node_longitude"] *
            u.deg)
    assert ss.argp == mock_orbital_data["orbital_data"][
        "perihelion_argument"] * u.deg
    assert (nu_to_M(
        ss.nu,
        ss.ecc) == mock_orbital_data["orbital_data"]["mean_anomaly"] * u.deg)
Exemple #2
0
def orbit_from_record(record):
    """Return :py:class:`~poliastro.twobody.orbit.Orbit` given a record.

        Retrieve info from JPL DASTCOM5 database.

        Parameters
        ----------
        record : int
            Object record.

        Returns
        -------
        orbit : ~poliastro.twobody.orbit.Orbit
            NEO orbit.

        """
    body_data = read_record(record)
    a = body_data["A"].item() * u.au
    ecc = body_data["EC"].item() * u.one
    inc = body_data["IN"].item() * u.deg
    raan = body_data["OM"].item() * u.deg
    argp = body_data["W"].item() * u.deg
    m = body_data["MA"].item() * u.deg
    nu = M_to_nu(m, ecc)
    epoch = Time(body_data["EPOCH"].item(), format="jd", scale="tdb")

    orbit = Orbit.from_classical(Sun, a, ecc, inc, raan, argp, nu, epoch)
    orbit._frame = HeliocentricEclipticJ2000(obstime=epoch)
    return orbit
Exemple #3
0
def test_orbit_accepts_ecliptic_plane():
    r = [1e09, -4e09, -1e09] * u.km
    v = [5e00, -1e01, -4e00] * u.km / u.s

    ss = Orbit.from_vectors(Sun, r, v, plane=Planes.EARTH_ECLIPTIC)

    assert ss.frame.is_equivalent_frame(HeliocentricEclipticJ2000(obstime=J2000))
def test_orbit_from_spk_id_has_proper_values(mock_get, mock_response):
    mock_orbital_data = {
        'orbital_data': {
            'eccentricity': '.2225889698301071',
            'semi_major_axis': '1.457940027185708',
            'inclination': '10.82759100494802',
            'ascending_node_longitude': '304.3221633898424',
            'perihelion_argument': '178.8165910886752',
            'mean_anomaly': '71.28027812836476',
            'epoch_osculation': '2458000.5',
        }
    }

    mock_response.json.return_value = mock_orbital_data
    mock_get.return_value = mock_response
    ss = neows.orbit_from_spk_id('')

    assert ss.frame.is_equivalent_frame(
        HeliocentricEclipticJ2000(obstime=ss.epoch))
    assert ss.ecc == mock_orbital_data['orbital_data']['eccentricity'] * u.one
    assert ss.a == mock_orbital_data['orbital_data']['semi_major_axis'] * u.AU
    assert ss.inc == mock_orbital_data['orbital_data']['inclination'] * u.deg
    assert ss.raan == mock_orbital_data['orbital_data'][
        'ascending_node_longitude'] * u.deg
    assert ss.argp == mock_orbital_data['orbital_data'][
        'perihelion_argument'] * u.deg
    assert nu_to_M(
        ss.nu,
        ss.ecc) == mock_orbital_data['orbital_data']['mean_anomaly'] * u.deg