def test_R_A_A_N(): r""" Test for RAAN Function """ n_vector = [.25, .5, .75] actual_out = RV2COE.R_A_A_N(n_vector) expected_out = 1.1071487177940904 np.testing.assert_allclose(actual_out, expected_out)
def test_line_of_nodes(): r""" Test for Line of Nodes Function """ h_hat = [1, 2, 3] actual_out = RV2COE.line_of_nodes(h_hat) expected_out = [-2, 1, 0] np.testing.assert_allclose(actual_out, expected_out)
def test_unit_vector(): r""" Test for the Unit Vector Function """ vector = [1, 1, 1] actual_out = RV2COE.unit_vector(vector) expected_out = [1 / np.sqrt(3), 1 / np.sqrt(3), 1 / np.sqrt(3)] np.testing.assert_allclose(actual_out, expected_out)
def test_inclination(): r""" Test for Inclination Function """ h_hat = [.25, .75, .5] actual_out = RV2COE.inclination(h_hat) expected_out = 1.0471975511965976 np.testing.assert_allclose(actual_out, expected_out)
def test_semi_latus_rectum(): r""" Test for Semi Latus Rectum Function """ mu = 10 h_vector = [-3, 6, -3] actual_out = RV2COE.semi_latus_rectum(mu, h_vector) expected_out = 5.4 np.testing.assert_allclose(actual_out, expected_out)
def test_ang_momentum(): r""" Test for Angular Momentum Function """ r_vector = [1, 2, 3] v_vector = [4, 5, 6] actual_out = RV2COE.ang_momentum(r_vector, v_vector) expected_out = [-3, 6, -3] np.testing.assert_allclose(actual_out, expected_out)
def test_Orbit_Period(): r""" Test for Orbital Period Function """ mu = 2 a = 2 actual_out = RV2COE.Orbit_Period(mu, a) expected_out = 12.5663706144 np.testing.assert_allclose(actual_out, expected_out)
def test_rad_apo(): r""" Test for Radius of Apoapsis Function """ p = 1 e = .5 actual_out = RV2COE.rad_apo(p, e) expected_out = 2 np.testing.assert_allclose(actual_out, expected_out)
def test_rad_peri(): r""" Test for Radius of Periapsis Function """ p = 1 e = .5 actual_out = RV2COE.rad_peri(p, e) expected_out = .6666666666666 np.testing.assert_allclose(actual_out, expected_out)
def test_semi_major_axis(): r""" Test for Semi Major Axis Function """ p = .75 e = .5 actual_out = RV2COE.semi_major_axis(p, e) expected_out = 1 np.testing.assert_allclose(actual_out, expected_out)
def test_flight_ang(): r""" Test for Radius of Apoapsis Function """ e = .5 theta = 1.2 actual_out = RV2COE.flight_ang(e, theta) expected_out = 0.37578860669992659 np.testing.assert_allclose(actual_out, expected_out)
def test_spec_mech_energy(): r""" Test for Angular Momentum Function """ mu = 10 r_vector = [1, 2, 3] v_vector = [4, 5, 6] actual_out = RV2COE.spec_mech_energy(mu, r_vector, v_vector) expected_out = (77 / 2) - (10 / np.sqrt(14)) np.testing.assert_allclose(actual_out, expected_out)
def test_arg_of_periapsis(): r""" Test for Argument of Periapsis Function """ r_vector = [1, 2, 3] h_vector = [-3, 6, -3] e_vector = [2, 3, 4] actual_out = RV2COE.arg_of_periapsis(r_vector, e_vector, h_vector) expected_out = 0.12186756768575521 np.testing.assert_allclose(actual_out, expected_out)
def test_true_anom(): r""" Test for True Anomaly Function """ r_vector = [1, 2, 3] h_vector = [-3, 6, -3] e_vector = [2, 3, 4] actual_out = RV2COE.true_anom(r_vector, h_vector, e_vector) expected_out = -0.12186756768575521 np.testing.assert_allclose(actual_out, expected_out)
def test_eccentricity(): r""" Test for Eccentricity Function """ mu = 10 r_vector = [1, 2, 3] v_vector = [4, 5, 6] h_vector = [-3, 6, -3] actual_out = RV2COE.eccentricity(mu, r_vector, v_vector, h_vector) expected_out = [(-51 / 10) - (1 / np.sqrt(14)), (-3 / 5) - np.sqrt(2 / 7), (39 / 10) - (3 / np.sqrt(14))] np.testing.assert_allclose(actual_out, expected_out)
pv_eci = np.dot(ecef2eci, pv_ecef) """Rotate rad_r""" rad_r_eci = np.dot(ecef2eci, rad_r_ecef) """Find R and V""" w_E = [0, 0, 0.000072921151467] r_eci_array = pr_eci + rad_r_eci r_eci = [r_eci_array[0][0], r_eci_array[1][0], r_eci_array[2][0]] v_eci_array = pv_eci.transpose() + np.cross(w_E, r_eci) v_eci = np.array( [v_eci_array[0][0], v_eci_array[0][1], v_eci_array[0][2]]) a, e, e_vector, i, raan, w, theta, p, r_p, r_a, n_vector, period = RV2COE.RV2COE( r_eci, v_eci, mu) r"""Print The Results in Full""" Line_3 = ["Semi Major Axis in Kilometers:\n\t", str(a), "\n"] Line_4 = ["Eccentricity:\n\t", str(e), "\n"] Line_5 = ["Eccentricity Vector:\n\t", str(e_vector), "\n"] Line_6 = ["Inclination in Degrees:\n\t", str(np.rad2deg(i)), "\n"] Line_7 = ["RAAN in Degrees:\n\t", str(np.rad2deg(raan)), "\n"] Line_8 = [ "Argument of Periapsis in Degrees:\n\t", str(np.rad2deg(w)), "\n" ] Line_9 = [ "True Anomaly in Degrees:\n\t", str(np.rad2deg(theta)), "\n" ] Line_10 = ["Semi Latus Rectum in Kilometers:\n\t", str(p), "\n"]
Line_0 = ['Line {}\n\t{}\n'.format(count+1,line)] r_i = float(line[0]) r_j = float(line[1]) r_k = float(line[2]) v_i = float(line[3]) v_j = float(line[4]) v_k = float(line[5]) r_input = [r_i, r_j, r_k] v_input = [v_i, v_j, v_k] Line_1 = ("The mu Constant: \n\t", str(mu), "\n", 'Radius {} (km)\n\t{}\n'.format(count+1,r_input)) Line_2 = ('Velocity {} (km/s)\n\t{}\n'.format(count+1,v_input)) r"""Inner Workings, Pulling outside functions""" h_input = RV2COE.ang_momentum(r_input, v_input) e_vector = RV2COE.eccentricity(mu, r_input, v_input, h_input) n_vector = RV2COE.line_of_nodes(RV2COE.unit_vector(h_input)) p = RV2COE.semi_latus_rectum(mu, h_input) theta = RV2COE.true_anom(r_input, h_input, e_vector) i = RV2COE.inclination(RV2COE.unit_vector(h_input)) a = RV2COE.semi_major_axis(p, np.linalg.norm(e_vector)) raan = RV2COE.R_A_A_N(n_vector)
r_k = float(line[2]) v_i = float(line[3]) v_j = float(line[4]) v_k = float(line[5]) change_t = float(line[6]) * 60 r_input = np.array([r_i, r_j, r_k]) v_input = np.array([v_i, v_j, v_k]) Line_1 = ("The mu Constant: \n\t", str(mu), "\n", 'Original Radius {} (km)\n\t{}\n'.format(count + 1, r_input)) Line_2 = ('Original Velocity {} (km/s)\n\t{}\n'.format( count + 1, v_input)) a_i, e_i, e_vector, i_i, raan_i, w_i, theta_i, p, r_p, r_a, n_vector, period = RV2COE.RV2COE( r_input, v_input, mu) a_f, e_f, i_f, raan_f, w_f, theta_f = PROPAGATE.update( a_i, e_i, i_i, raan_i, w_i, theta_i, change_t, mu) r_eci, v_eci = PROPAGATE.COE2RV(a_f, e_f, i_f, raan_f, w_f, theta_f, mu) r"""Print The Results in Full""" Line_3 = ["Semi Major Axis in Kilometers:\n\t", str(a_f), "\n"] Line_4 = ["Eccentricity:\n\t", str(e_f), "\n"] Line_5 = ["Eccentricity Vector:\n\t", str(e_vector), "\n"] Line_6 = [ "Initial Inclination in Degrees:\n\t", str(np.rad2deg(i_i)), "\n" ] Line_7 = [