def test_pqw_returns_dimensionless(): r_0 = ([1, 0, 0] * u.au).to(u.km) v_0 = ([0, 6, 0] * u.au / u.year).to(u.km / u.day) ss = RVState(Sun, r_0, v_0) p, q, w = ss.pqw() assert p.unit == u.one assert q.unit == u.one assert w.unit == u.one
def test_convert_from_coe_to_rv(): # Data from Vallado, example 2.5 attractor = Earth r = [6524.384, 6862.875, 6448.296] * u.km v = [4.901327, 5.533756, -1.976341] * u.km / u.s ss = RVState(Earth, r, v) _, ecc, inc, raan, argp, nu = ss.coe() p = ss.p assert_almost_equal(p.to(u.km).value, 11067.79, decimal=0) assert_almost_equal(ecc.value, 0.832853, decimal=4) assert_almost_equal(inc.to(u.deg).value, 87.870, decimal=2) assert_almost_equal(raan.to(u.deg).value, 227.89, decimal=1) assert_almost_equal(argp.to(u.deg).value, 53.38, decimal=2) assert_almost_equal(nu.to(u.deg).value, 92.335, decimal=2)
def _extract_arrays(t_domain, r_vectors, v_vectors): ecc_values = np.zeros_like(t_domain) for ii in range(len(t_domain)): r = r_vectors[ii] v = v_vectors[ii] if r.any(): ss = RVState(Earth, r * u.km, v * u.km / u.s) ecc_values[ii] = ss.ecc.value return ecc_values
def _extract_arrays(t_domain, r_vectors, v_vectors): a_values = np.zeros_like(t_domain) inc_values = np.zeros_like(t_domain) v_values = norm(v_vectors, axis=1) for ii in range(len(t_domain)): r = r_vectors[ii] v = v_vectors[ii] if r.any(): ss = RVState(Earth, r * u.km, v * u.km / u.s) a_values[ii] = ss.a.to(u.km).value inc_values[ii] = ss.inc.to(u.rad).value return a_values, inc_values, v_values
def test_convert_from_coe_to_rv(): # Data from Vallado, example 2.5 attractor = Earth r = [6524.384, 6862.875, 6448.296] * u.km v = [4.901327, 5.533756, -1.976341] * u.km / u.s expected_p = 11067.79 * u.km expected_ecc = 0.832853 * u.one expected_inc = 87.870 * u.deg expected_raan = 227.89 * u.deg expected_argp = 53.38 * u.deg expected_nu = 92.335 * u.deg ss = RVState(attractor, r, v) _, ecc, inc, raan, argp, nu = ss.coe() p = ss.p assert_quantity_allclose(p, expected_p, rtol=1e-4) assert_quantity_allclose(ecc, expected_ecc, rtol=1e-4) assert_quantity_allclose(inc, expected_inc, rtol=1e-4) assert_quantity_allclose(raan, expected_raan, rtol=1e-4) assert_quantity_allclose(argp, expected_argp, rtol=1e-4) assert_quantity_allclose(nu, expected_nu, rtol=1e-4)
def test_state_has_rv_given_in_constructor(): r = [1.0, 0.0, 0.0] * u.AU v = [0.0, 1.0e-6, 0.0] * u.AU / u.s ss = RVState(Sun, r, v) assert ss.rv() == (r, v)
def test_arglat_within_range(): r = [3539.08827417, 5310.19903462, 3066.31301457] * u.km v = [-6.49780849, 3.24910291, 1.87521413] * u.km / u.s ss = RVState(Earth, r, v) assert 0 * u.deg <= ss.arglat <= 360 * u.deg
def wrapper(t, u_, k, *args, **kwargs): r, v = u_[:3], u_[3:] ss = RVState(Body(None, k * u.km3s2, "_Dummy"), r * u.km, v * u.kms) return func(t, ss, *args, **kwargs)