Esempio n. 1
0
def test_orbit_from_spk_id_raises_when_error(mock_get):
    resp = requests.Response()

    resp.status_code = 404
    mock_get.return_value = resp
    with pytest.raises(requests.HTTPError):
        neows.orbit_from_spk_id("")
Esempio n. 2
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)
Esempio n. 3
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.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
Esempio n. 4
0
                print("Orbital elements:")
                print(final.classical())
                print("")
                print("Final co-ordinates:")
                print(final.rv())
                print("")
                f_orbit = final
                #print(f_orbit.ecc)
                plotOrbit((f_orbit.a.value), (f_orbit.ecc.value),
                          (f_orbit.inc.value), (f_orbit.raan.value),
                          (f_orbit.argp.value), (f_orbit.nu.value))

            elif (opt_2 == '2'):
                print("Enter SPK id:")
                str_2 = input()
                orbit = neows.orbit_from_spk_id(str_2)
                print(orbit)
                print(orbit.rv())
                frame = OrbitPlotter2D()
                frame.plot(orbit, label=str_2)

                print(
                    "\nPropagate to(Enter time in format='iso', scale='utc':")
                p_t_s = input()
                p_t_o = Time(p_t_s, format='iso', scale='utc')
                print("")
                final = orbit.propagate(p_t_o)
                #final.plot()
                print("Orbital elements:")
                print(final.classical())
                print("")