def test_perifocal_points_to_perigee(): _d = 1.0 * u.AU # Unused distance _ = 0.5 * u.one # Unused dimensionless value _a = 1.0 * u.deg # Unused angle ss = ClassicalState(Sun, _d, _, _a, _a, _a, _a) p, _, _ = ss.pqw() assert_allclose(p, ss.e_vec / ss.ecc)
def test_perifocal_points_to_perigee(): _d = 1.0 * u.AU # Unused distance _ = 0.5 * u.one # Unused dimensionless value _a = 1.0 * u.deg # Unused angle ss = ClassicalState(Sun, _d, _, _a, _a, _a, _a) p, _, _ = ss.pqw() assert_almost_equal(p, ss.e_vec / ss.ecc)
def test_state_has_elements_given_in_constructor(): # Mars data from HORIZONS at J2000 a = 1.523679 * u.AU ecc = 0.093315 * u.one inc = 1.85 * u.deg raan = 49.562 * u.deg argp = 286.537 * u.deg nu = 23.33 * u.deg ss = ClassicalState(Sun, a * (1 - ecc**2), ecc, inc, raan, argp, nu) assert ss.coe() == (a, ecc, inc, raan, argp, nu)
def test_state_has_elements_given_in_constructor(): # Mars data from HORIZONS at J2000 a = 1.523679 * u.AU ecc = 0.093315 * u.one inc = 1.85 * u.deg raan = 49.562 * u.deg argp = 286.537 * u.deg nu = 23.33 * u.deg ss = ClassicalState(Sun, a, ecc, inc, raan, argp, nu) assert ss.coe() == (a, ecc, inc, raan, argp, nu)
def test_perigee_and_apogee(): expected_r_a = 500 * u.km expected_r_p = 300 * u.km a = (expected_r_a + expected_r_p) / 2 ecc = expected_r_a / a - 1 _a = 1.0 * u.deg # Unused angle ss = ClassicalState(Earth, a * (1 - ecc**2), ecc, _a, _a, _a, _a) assert_allclose(ss.r_a.to(u.km).value, expected_r_a.to(u.km).value) assert_allclose(ss.r_p.to(u.km).value, expected_r_p.to(u.km).value)
def test_state_has_individual_elements(): a = 1.523679 * u.AU ecc = 0.093315 * u.one inc = 1.85 * u.deg raan = 49.562 * u.deg argp = 286.537 * u.deg nu = 23.33 * u.deg ss = ClassicalState(Sun, a * (1 - ecc**2), ecc, inc, raan, argp, nu) assert ss.a == a assert ss.ecc == ecc assert ss.inc == inc assert ss.raan == raan assert ss.argp == argp assert ss.nu == nu
def test_convert_from_rv_to_coe(): # Data from Vallado, example 2.6 attractor = Earth p = 11067.790 * u.km ecc = 0.83285 * u.one inc = 87.87 * u.deg raan = 227.89 * u.deg argp = 53.38 * u.deg nu = 92.335 * u.deg expected_r = [6525.344, 6861.535, 6449.125] * u.km expected_v = [4.902276, 5.533124, -1.975709] * u.km / u.s r, v = ClassicalState(attractor, p, ecc, inc, raan, argp, nu).rv() assert_quantity_allclose(r, expected_r, rtol=1e-5) assert_quantity_allclose(v, expected_v, rtol=1e-5)
def test_state_has_attractor_given_in_constructor(): _d = 1.0 * u.AU # Unused distance _ = 0.5 * u.one # Unused dimensionless value _a = 1.0 * u.deg # Unused angle ss = ClassicalState(Sun, _d, _, _a, _a, _a, _a) assert ss.attractor == Sun