def test_update_elements_kep(self): t = np.array([0.0], dtype=np.float) obj = SpaceObject(**self.orb_init) xv0 = obj.get_state(t) ox0 = obj.orbit.a[0] #move 100 km in x direction obj.orbit.update(a=obj.orbit.a[0] + 100.0) #print(o) xv1 = obj.get_state(t) ox1 = obj.orbit.a[0] #move 100 km back obj.orbit.update(a=obj.orbit.a[0] - 100.0) #print(o) xv2 = obj.get_state(t) ox2 = obj.orbit.a[0] self.assertAlmostEqual(ox0 + 100.0, ox1) self.assertAlmostEqual(ox1 - 100.0, ox2) self.assertAlmostEqual(ox0, ox2) pos_diff01 = np.linalg.norm(xv0[:3, 0] - xv1[:3, 0]) pos_diff12 = np.linalg.norm(xv1[:3, 0] - xv2[:3, 0]) pos_diff02 = np.linalg.norm(xv0[:3, 0] - xv2[:3, 0]) self.assertLess(np.abs(pos_diff01 - 100.0), 1.0) self.assertLess(np.abs(pos_diff12 - 100.0), 1.0) self.assertLess(pos_diff02, 1.0) nt.assert_almost_equal(xv0, xv2, decimal=2)
def test_change_frame(self): obj = SpaceObject(**self.orb_init) obj.out_frame = 'TEME' xv1 = obj.get_state(0) obj.out_frame = 'ITRS' xv0 = obj.get_state(0) self.assertEqual(xv1.shape, xv0.shape) for ind in range(6): self.assertNotEqual(xv1[ind, 0], xv0[ind, 0])
def test_propagate_epoch(self): self.orb_init['propagator'] = sorts.propagator.Kepler obj = SpaceObject(**self.orb_init) obj.out_frame = obj.in_frame state0 = obj.get_state(10.0) obj.propagate(10.0) state1 = obj.get_state(0.0) state2 = obj.orbit.cartesian nt.assert_almost_equal(state0, state1, decimal=5) nt.assert_almost_equal(state0, state2, decimal=5) nt.assert_almost_equal(state2, state1, decimal=5)
def test_time_input_types(self): obj = SpaceObject(**self.orb_init) states = [] states += [obj.get_state(np.array([1.0], dtype=np.float))] states += [obj.get_state(1.0)] states += [obj.get_state(1)] states += [obj.get_state(TimeDelta(1.0, format='sec'))] states += [obj.get_state(obj.epoch + TimeDelta(1.0, format='sec'))] for state in states: self.assertEqual(state.shape, (6, 1)) for state in states: nt.assert_array_equal(state, states[0])
def test_return_sizes(self): obj = SpaceObject(**self.orb_init) t = np.array([0.0], dtype=np.float) x = obj.get_position(t) v = obj.get_velocity(t) xv = obj.get_state(t) self.assertEqual(x.shape, (3, 1)) self.assertEqual(v.shape, (3, 1)) self.assertEqual(xv.shape, (6, 1)) nt.assert_array_equal(x[:, 0], xv[:3, 0]) nt.assert_array_equal(v[:, 0], xv[3:, 0]) t = np.array([0.0, 1.0], dtype=np.float) x = obj.get_position(t) v = obj.get_velocity(t) xv = obj.get_state(t) self.assertEqual(x.shape, (3, 2)) self.assertEqual(v.shape, (3, 2)) self.assertEqual(xv.shape, (6, 2)) nt.assert_array_equal(x[:, :], xv[:3, :]) nt.assert_array_equal(v[:, :], xv[3:, :]) t = 1.0 x = obj.get_position(t) v = obj.get_velocity(t) xv = obj.get_state(t) self.assertEqual(x.shape, (3, 1)) self.assertEqual(v.shape, (3, 1)) self.assertEqual(xv.shape, (6, 1)) nt.assert_array_equal(x[:], xv[:3]) nt.assert_array_equal(v[:], xv[3:])
), ) t = np.linspace(0, 3600 * 24.0 * 2, num=5000) obj = SpaceObject(Orekit, propagator_options=orekit_options, a=7000e3, e=0.0, i=69, raan=0, aop=0, mu0=0, epoch=Time(57125.7729, format='mjd'), parameters=dict(d=0.2, )) print(obj) states = obj.get_state(t) fig = plt.figure(figsize=(15, 15)) ax = fig.add_subplot(111, projection='3d') ax.plot(states[0, :], states[1, :], states[2, :], "-b") max_range = np.linalg.norm(states[0:3, 0]) * 2 ax.set_xlim(-max_range, max_range) ax.set_ylim(-max_range, max_range) ax.set_zlim(-max_range, max_range) plt.show()