예제 #1
0
    def test_get_orbit_cart(self):
        p = PropagatorOrekit()

        self._gen_cart(p)

        ecefs = p.get_orbit_cart(self.t, **self.init_data_cart)
        self.assertEqual(ecefs.shape, (6, len(self.t)))
예제 #2
0
    def test_kep_cart(self):
        p = PropagatorOrekit(
            in_frame='EME',
            out_frame='EME',
        )
        ecefs = p.get_orbit(self.t0, **self.init_data)

        ecefs2 = p.get_orbit_cart(
            self.t0,
            ecefs[0],
            ecefs[1],
            ecefs[2],
            ecefs[3],
            ecefs[4],
            ecefs[5],
            mjd0=self.init_data['mjd0'],
            m=self.init_data['m'],
            A=self.init_data['A'],
            C_R=self.init_data['C_R'],
            C_D=self.init_data['C_D'],
        )

        nt.assert_array_almost_equal(ecefs / ecefs2,
                                     n.ones(ecefs.shape, dtype=ecefs.dtype),
                                     decimal=7)
예제 #3
0
def tryMPI():

    comm = MPI.COMM_WORLD
    rank = comm.rank

    p = PropagatorOrekit()
    init_data = {
        'a': 9000e3,
        'e': 0.1,
        'inc': 90.0,
        'raan': 10,
        'aop': 10,
        'mu0': 40.0,
        'mjd0': 57125.7729,
        'C_D': 2.3,
        'C_R': 1.0,
        'm': 8000,
        'A': 1.0,
    }
    t = np.linspace(0, 24 * 3600.0, num=1000, dtype=np.float)
    t0 = time.time()
    print('start rank {}'.format(rank))
    ecefs = p.get_orbit(t, **init_data)
    print('get orbit time (rank {}): {} sec'.format(rank, time.time() - t0))

    comm.barrier()
    print('pass barrier {}'.format(rank))

    t0 = time.time()
    ecefs = p.get_orbit(t, **init_data)
    print('get orbit time, no init work, (rank {}): {} sec'.format(
        rank,
        time.time() - t0))
예제 #4
0
def trySentinel1_compare(ax, sv, label, **kw):

    prop_args = dict(
        frame_tidal_effects=False,
        radiation_pressure=False,
    )
    for key, item in kw.items():
        if key in prop_args:
            prop_args[key] = item
            del kw[key]

    p = PropagatorOrekit(in_frame='ITRF', out_frame='ITRF', **prop_args)

    x, y, z = sv[0].pos
    vx, vy, vz = sv[0].vel
    mjd0 = (sv[0]['utc'] - np.datetime64('1858-11-17')) / np.timedelta64(
        1, 'D')

    N = len(sv)
    t = 10 * np.arange(N)

    kwargs = dict(m=2300., C_R=0., C_D=.0, A=4 * 2.3)
    kwargs.update(**kw)

    pv = p.get_orbit_cart(t, x, y, z, vx, vy, vz, mjd0, **kwargs)

    perr = np.linalg.norm(pv[:3].T - sv.pos, axis=1)
    verr = np.linalg.norm(pv[3:].T - sv.vel, axis=1)

    ax[0].plot(t / 3600., perr, label=label)
    ax[1].plot(t / 3600., verr, label=label)

    return pv
예제 #5
0
    def test_orbit_kep_cart_correspondance(self):
        mjd0 = dpt.jd_to_mjd(2457126.2729)

        orb_init_list = self._gen_orbits(100)

        prop = PropagatorOrekit(
            in_frame='EME',
            out_frame='EME',
        )

        t = n.linspace(0, 12 * 3600, num=100, dtype=n.float)

        for kep in orb_init_list:
            state_ref = dpt.kep2cart(kep,
                                     m=self.init_data['m'],
                                     M_cent=prop.M_earth,
                                     radians=False)

            state_kep = prop.get_orbit(
                t=t,
                mjd0=mjd0,
                a=kep[0],
                e=kep[1],
                inc=kep[2],
                raan=kep[4],
                aop=kep[3],
                mu0=dpt.true2mean(kep[5], kep[1], radians=False),
                C_D=self.init_data['C_D'],
                m=self.init_data['m'],
                A=self.init_data['A'],
                C_R=self.init_data['C_R'],
                radians=False,
            )
            state_cart = prop.get_orbit_cart(
                t=t,
                mjd0=mjd0,
                x=state_ref[0],
                y=state_ref[1],
                z=state_ref[2],
                vx=state_ref[3],
                vy=state_ref[4],
                vz=state_ref[5],
                C_D=self.init_data['C_D'],
                m=self.init_data['m'],
                A=self.init_data['A'],
                C_R=self.init_data['C_R'],
            )

            state_diff1 = n.abs(state_kep - state_cart)

            nt.assert_array_less(
                state_diff1[:3, :],
                n.full((3, t.size), 1e-5, dtype=state_diff1.dtype))
            nt.assert_array_less(
                state_diff1[3:, :],
                n.full((3, t.size), 1e-7, dtype=state_diff1.dtype))
예제 #6
0
    def test_circ_orbit(self):
        p = PropagatorOrekit(solarsystem_perturbers=[],
                             radiation_pressure=False)
        self.init_data['a'] = 36000e3

        ecefs = p.get_orbit(self.t, **self.init_data)
        rn = n.sum(ecefs[:3, :]**2, axis=0) / 36000.0e3**2

        nt.assert_array_almost_equal(rn,
                                     n.ones(rn.shape, dtype=ecefs.dtype),
                                     decimal=4)
예제 #7
0
 def test_raise_models(self):
     with self.assertRaises(Exception):
         p = PropagatorOrekit(earth_gravity='THIS DOES NOT EXIST', )
     with self.assertRaises(Exception):
         p = PropagatorOrekit(atmosphere='THIS DOES NOT EXIST', )
         ecefs = p.get_orbit(self.t0, **self.init_data)
     with self.assertRaises(Exception):
         p = PropagatorOrekit(solar_activity='THIS DOES NOT EXIST', )
         ecefs = p.get_orbit(self.t0, **self.init_data)
예제 #8
0
def try2():

    p = PropagatorOrekit()
    d_v = [0.1, 0.2]
    init_data = {
        'a': (R_e + 400.0) * 1e3,
        'e': 0.01,
        'inc': 90.0,
        'raan': 10,
        'aop': 10,
        'mu0': 40.0,
        'mjd0': 57125.7729,
        'C_D': 2.3,
        'C_R': 1.0,
        'm': 3.0,
        'A': np.pi * (d_v[0] * 0.5)**2,
    }
    t = np.linspace(0, 3 * 3600.0, num=500, dtype=np.float)

    ecefs1 = p.get_orbit(t, **init_data)

    init_data['A'] = np.pi * (d_v[1] * 0.5)**2
    ecefs2 = p.get_orbit(t, **init_data)

    dr = np.sqrt(np.sum((ecefs1[:3, :] - ecefs2[:3, :])**2, axis=0))
    dv = np.sqrt(np.sum((ecefs1[3:, :] - ecefs2[3:, :])**2, axis=0))

    fig = plt.figure(figsize=(15, 15))
    ax = fig.add_subplot(211)
    ax.plot(t / 3600.0, dr)
    ax.set_xlabel('Time [h]')
    ax.set_ylabel('Position difference [m]')
    ax.set_title('Propagation difference diameter {} vs {} m'.format(
        d_v[0], d_v[1]))
    ax = fig.add_subplot(212)
    ax.plot(t / 3600.0, dv)
    ax.set_xlabel('Time [h]')
    ax.set_ylabel('Velocity difference [m/s]')

    fig = plt.figure(figsize=(15, 15))
    ax = fig.add_subplot(111, projection='3d')
    plothelp.draw_earth_grid(ax)
    ax.plot(ecefs1[0, :], ecefs1[1, :], ecefs1[2, :], ".", color="green")
    ax.plot(ecefs2[0, :], ecefs2[1, :], ecefs2[2, :], ".", color="red")
    plt.show()
예제 #9
0
    def test_orbit_inverse_error_cart(self):
        mjd0 = dpt.jd_to_mjd(2457126.2729)

        orb_init_list = self._gen_orbits(1000)

        prop = PropagatorOrekit(
            in_frame='EME',
            out_frame='EME',
        )

        t = n.array([0.0])
        orbs_done = 0
        for kep in orb_init_list:
            state_ref = dpt.kep2cart(kep,
                                     m=self.init_data['m'],
                                     M_cent=prop.M_earth,
                                     radians=False)

            state = prop.get_orbit_cart(
                t=t,
                mjd0=mjd0,
                x=state_ref[0],
                y=state_ref[1],
                z=state_ref[2],
                vx=state_ref[3],
                vy=state_ref[4],
                vz=state_ref[5],
                C_D=self.init_data['C_D'],
                m=self.init_data['m'],
                A=self.init_data['A'],
                C_R=self.init_data['C_R'],
            )

            state_diff1 = n.abs(state_ref - state[:, 0])
            if n.linalg.norm(state_diff1[:3]) > 1e-5:
                print(kep)
                print(orbs_done)
            nt.assert_array_less(state_diff1[:3],
                                 n.full((3, ), 1e-5, dtype=state_diff1.dtype))
            nt.assert_array_less(state_diff1[3:],
                                 n.full((3, ), 1e-7, dtype=state_diff1.dtype))
            orbs_done += 1
예제 #10
0
    def test_orbit_inverse_error_kep(self):
        mjd0 = dpt.jd_to_mjd(2457126.2729)

        orb_init_list = self._gen_orbits(1000)

        prop = PropagatorOrekit(
            in_frame='EME',
            out_frame='EME',
        )

        t = n.array([0.0])

        for kep in orb_init_list:
            state_ref = dpt.kep2cart(kep,
                                     m=self.init_data['m'],
                                     M_cent=prop.M_earth,
                                     radians=False)

            state = prop.get_orbit(
                t=t,
                mjd0=mjd0,
                a=kep[0],
                e=kep[1],
                inc=kep[2],
                raan=kep[4],
                aop=kep[3],
                mu0=dpt.true2mean(kep[5], kep[1], radians=False),
                C_D=self.init_data['C_D'],
                m=self.init_data['m'],
                A=self.init_data['A'],
                C_R=self.init_data['C_R'],
                radians=False,
            )

            state_diff1 = n.abs(state_ref - state[:, 0])

            nt.assert_array_less(state_diff1[:3],
                                 n.full((3, ), 1e-5, dtype=state_diff1.dtype))
            nt.assert_array_less(state_diff1[3:],
                                 n.full((3, ), 1e-7, dtype=state_diff1.dtype))
예제 #11
0
def trySentinel1(**kw):

    p = PropagatorOrekit(
        in_frame='ITRF',
        out_frame='ITRF',
        frame_tidal_effects=True,
        #earth_gravity='Newtonian',
        #radiation_pressure=False,
        #solarsystem_perturbers=[],
        #drag_force=False,
    )

    sv, _, _ = over.read_poe(
        'data/S1A_OPER_AUX_POEORB_OPOD_20150527T122640_V20150505T225944_20150507T005944.EOF'
    )

    x, y, z = sv[0].pos
    vx, vy, vz = sv[0].vel
    mjd0 = (sv[0]['utc'] - np.datetime64('1858-11-17')) / np.timedelta64(
        1, 'D')

    N = len(sv)
    t = 10 * np.arange(N)

    kwargs = dict(m=2300., C_R=0., C_D=.0, A=4 * 2.3)
    kwargs.update(**kw)

    pv = p.get_orbit_cart(t, x, y, z, vx, vy, vz, mjd0, **kwargs)

    perr = np.linalg.norm(pv[:3].T - sv.pos, axis=1)
    verr = np.linalg.norm(pv[3:].T - sv.vel, axis=1)

    f, ax = plt.subplots(2, 1)
    ax[0].plot(t / 3600., perr)
    ax[0].set_title('Errors from propagation')
    ax[0].set_ylabel('Position error [m]')
    ax[1].plot(t / 3600., verr)
    ax[1].set_ylabel('Velocity error [m/s]')
    ax[1].set_xlabel('Time [h]')
예제 #12
0
 def test_raise_sc_params_missing(self):
     with self.assertRaises(Exception):
         p = PropagatorOrekit()
         del self.init_data['C_R']
         ecefs = p.get_orbit(self.t0, **self.init_data)
     with self.assertRaises(Exception):
         p = PropagatorOrekit()
         del self.init_data['C_D']
         ecefs = p.get_orbit(self.t0, **self.init_data)
예제 #13
0
def trySteps():
    p = PropagatorOrekit()

    line1 = '1 43947U 19006A   19069.62495353  .00222140  22344-4  39735-3 0  9995'
    line2 = '2 43947  96.6263 343.1609 0026772 226.5664 224.4731 16.01032328  7176'

    mjd0 = dpt.jd_to_mjd(tle.tle_jd(line1))

    state, epoch = tle.TLE_to_TEME(line1, line2)

    x, y, z, vx, vy, vz = state

    kwargs = dict(m=800., C_R=1., C_D=2.3, A=2.0)
    t_end = 24 * 3600.0
    t_vecs = [
        np.linspace(0, t_end, num=ind) for ind in [100, 200, 500, 1000, 10000]
    ]

    fig = plt.figure(figsize=(15, 15))
    ax = fig.add_subplot(111)

    for t in t_vecs:
        pv = p.get_orbit_cart(t, x, y, z, vx, vy, vz, mjd0, **kwargs)

        ax.plot(t / 3600.,
                np.linalg.norm(pv[:3, :] * 1e-3, axis=0),
                label='{} steps @ {} s step size'.format(
                    len(t), t_end / float(len(t))))

    ax.set(
        xlabel='Time [h]',
        ylabel='Range [km]',
        title='Step number difference',
    )
    plt.legend()
    plt.show()
예제 #14
0
def try1():
    t0 = time.time()
    p = PropagatorOrekit()
    print('init time: {} sec'.format(time.time() - t0))

    init_data = {
        'a': 9000e3,
        'e': 0.1,
        'inc': 90.0,
        'raan': 10,
        'aop': 10,
        'mu0': 40.0,
        'mjd0': 57125.7729,
        'C_D': 2.3,
        'C_R': 1.0,
        'm': 8000,
        'A': 1.0,
    }
    t = np.linspace(0, 24 * 3600.0, num=1000, dtype=np.float)

    t0 = time.time()
    ecefs = p.get_orbit(t, **init_data)
    print('get orbit time (first): {} sec'.format(time.time() - t0))

    t0 = time.time()
    ecefs = p.get_orbit(t, **init_data)
    print('get orbit time (second): {} sec'.format(time.time() - t0))

    t0 = time.time()
    init_data['C_D'] = 1.0
    ecefs = p.get_orbit(t, **init_data)
    print('get orbit time (new param): {} sec'.format(time.time() - t0))

    times = []
    nums = []
    for num in range(100, 1000, 100):
        t = np.arange(0,
                      24 * 3600.0 / 1000.0 * num,
                      24 * 3600.0 / 1000.0,
                      dtype=np.float)
        t0 = time.time()
        ecefs = p.get_orbit(t, **init_data)
        times.append(time.time() - t0)
        nums.append(num)

    fig = plt.figure(figsize=(15, 15))
    ax = fig.add_subplot(211)
    ax.plot(nums, times)
    ax = fig.add_subplot(212)
    ax.plot(nums, np.array(times) / np.array(nums, dtype=np.float))

    fig = plt.figure(figsize=(15, 15))
    ax = fig.add_subplot(111, projection='3d')
    ax.plot(ecefs[0, :], ecefs[1, :], ecefs[2, :], ".", color="green")
    plt.show()
예제 #15
0
def tryFrame():

    p = PropagatorOrekit(in_frame='ITRF', out_frame='ITRF')

    print(p)

    init_data = {
        'a': (R_e + 400.0) * 1e3,
        'e': 0.01,
        'inc': 90.0,
        'raan': 10,
        'aop': 10,
        'mu0': 40.0,
        'mjd0': 57125.7729,
        'C_D': 2.3,
        'C_R': 1.0,
        'm': 3.0,
        'A': np.pi * 1.0**2,
    }
    t = np.linspace(0, 3 * 3600.0, num=500, dtype=np.float)

    ecefs1 = p.get_orbit(t, **init_data)

    print(p)

    p = PropagatorOrekit(in_frame='EME', out_frame='ITRF')

    ecefs2 = p.get_orbit(t, **init_data)

    fig = plt.figure(figsize=(15, 15))
    ax = fig.add_subplot(111, projection='3d')
    plothelp.draw_earth_grid(ax)
    ax.plot(ecefs1[0, :],
            ecefs1[1, :],
            ecefs1[2, :],
            ".",
            color="green",
            label='Initial frame: ITRF')
    ax.plot(ecefs2[0, :],
            ecefs2[1, :],
            ecefs2[2, :],
            ".",
            color="red",
            label='Initial frame: EME')
    plt.legend()
    plt.show()
예제 #16
0
def tryActivity():

    line1 = '1 43947U 19006A   19069.62495353  .00222140  22344-4  39735-3 0  9995'
    line2 = '2 43947  96.6263 343.1609 0026772 226.5664 224.4731 16.01032328  7176'

    mjd0 = dpt.jd_to_mjd(tle.tle_jd(line1))

    state, epoch = tle.TLE_to_TEME(line1, line2)

    x, y, z, vx, vy, vz = state

    p1 = PropagatorOrekit(solar_activity_strength='STRONG', )

    p2 = PropagatorOrekit(solar_activity_strength='WEAK', )

    kwargs = dict(m=800., C_R=1., C_D=2.3, A=4.0)

    t = np.linspace(0, 3 * 24 * 3600.0, num=5000, dtype=np.float64)

    pv1 = p1.get_orbit_cart(t, x, y, z, vx, vy, vz, mjd0, **kwargs)
    pv2 = p2.get_orbit_cart(t, x, y, z, vx, vy, vz, mjd0, **kwargs)

    fig = plt.figure(figsize=(15, 15))
    ax = fig.add_subplot(211)
    ax.plot(t / 3600., np.linalg.norm(pv1[:3, :] - pv2[:3, :], axis=0) * 1e-3)

    ax.set(
        xlabel='Time [h]',
        ylabel='Position difference [km]',
        title='Strong vs weak solar activity',
    )
    ax = fig.add_subplot(212)
    ax.plot(t / 3600., np.linalg.norm(pv1[:3, :] * 1e-3, axis=0), label='Weak')
    ax.plot(t / 3600.,
            np.linalg.norm(pv2[:3, :] * 1e-3, axis=0),
            label='Strong')

    ax.set(
        xlabel='Time [h]',
        ylabel='Range [km]',
    )
    plt.legend()
    plt.show()
예제 #17
0
def tryLogging(t):
    def print_(s):
        print(s)

    p = PropagatorOrekit(logger_func=print_)

    init_data = {
        'a': (R_e + 400.0) * 1e3,
        'e': 0.01,
        'inc': 90.0,
        'raan': 10,
        'aop': 10,
        'mu0': 40.0,
        'mjd0': 54832.0,
        'C_D': 2.3,
        'C_R': 1.0,
        'm': 3.0,
        'A': np.pi * (0.1)**2,
    }

    ecefs = p.get_orbit(t, **init_data)

    p.print_logger()
    return p.get_logger()
예제 #18
0
 def test_options_tolerance(self):
     p = PropagatorOrekit(position_tolerance=1.0, )
     ecefs = p.get_orbit(self.t0, **self.init_data)
     p = PropagatorOrekit(position_tolerance=100.0, )
     ecefs = p.get_orbit(self.t0, **self.init_data)
예제 #19
0
 def test_options_integrator(self):
     p = PropagatorOrekit(integrator='GraggBulirschStoer', )
     ecefs = p.get_orbit(self.t0, **self.init_data)
예제 #20
0
 def test_options_frames(self):
     p = PropagatorOrekit(
         in_frame='ITRF',
         out_frame='EME',
     )
     ecefs = p.get_orbit(self.t0, **self.init_data)
예제 #21
0
 def test_options_tidal(self):
     p = PropagatorOrekit(frame_tidal_effects=True, )
     ecefs = p.get_orbit(self.t0, **self.init_data)
예제 #22
0
    def test_get_orbit_kep(self):
        p = PropagatorOrekit()

        ecefs = p.get_orbit(self.t, **self.init_data)
        self.assertEqual(ecefs.shape, (6, len(self.t)))
예제 #23
0
 def __init__(self, *args, **kwargs):
     self.p = PropagatorOrekit(in_frame='ITRF',
                               out_frame='ITRF',
                               frame_tidal_effects=True)
     super(TestSentinel, self).__init__(*args, **kwargs)
예제 #24
0
class TestSentinel(unittest.TestCase):
    def __init__(self, *args, **kwargs):
        self.p = PropagatorOrekit(in_frame='ITRF',
                                  out_frame='ITRF',
                                  frame_tidal_effects=True)
        super(TestSentinel, self).__init__(*args, **kwargs)

    def setUp(self):
        self.sv, _, _ = over.read_poe(
            'data/S1A_OPER_AUX_POEORB_OPOD_20150527T122640_V20150505T225944_20150507T005944.EOF'
        )

    def test_tg_cart0(self):
        '''
        See if cartesian orbit interface recovers starting state
        '''

        # Statevector from Sentinel-1 precise orbit (in ECEF frame)
        #sv = n.array([('2015-04-30T05:45:44.000000000',
        #    [2721793.785377, 1103261.736653, 6427506.515945],
        #    [ 6996.001258,  -171.659563, -2926.43233 ])],
        #      dtype=[('utc', '<M8[ns]'), ('pos', '<f8', (3,)), ('vel', '<f8', (3,))])
        sv = self.sv

        x, y, z = sv[0].pos
        vx, vy, vz = sv[0].vel
        mjd0 = (sv[0]['utc'] - n.datetime64('1858-11-17')) / n.timedelta64(
            1, 'D')

        t = [0]
        pv = self.p.get_orbit_cart(t,
                                   x,
                                   y,
                                   z,
                                   vx,
                                   vy,
                                   vz,
                                   mjd0,
                                   m=2300.,
                                   C_R=1.,
                                   C_D=2.3,
                                   A=4 * 2.3)

        print('pos error:')
        dp = sv['pos'] - pv[:3].T
        print('{:.5e}, {:.5e}, {:.5e}'.format(*dp[0].tolist()))

        print('vel error:')
        dv = sv['vel'] - pv[3:].T
        print('{:.5e}, {:.5e}, {:.5e}'.format(*dv[0].tolist()))

        nt.assert_array_almost_equal(sv['pos'] / pv[:3].T,
                                     n.ones((1, 3)),
                                     decimal=7)
        nt.assert_array_almost_equal(sv['vel'] / pv[3:].T,
                                     n.ones((1, 3)),
                                     decimal=7)

    def test_tg_cartN(self):
        '''
        See if cartesian orbit propagation interface matches actual orbit
        '''

        # Statevector from Sentinel-1 precise orbit (in ECEF frame)
        #sv = n.array([
        #    ('2015-04-30T05:45:44.000000000',
        #        [2721793.785377, 1103261.736653, 6427506.515945],
        #        [ 6996.001258,  -171.659563, -2926.43233 ]),
        #    ('2015-04-30T05:45:54.000000000',
        #        [2791598.832403, 1101432.471307, 6397880.289842],
        #        [ 6964.872299,  -194.182612, -2998.757484]),
        #    ('2015-04-30T05:46:04.000000000',
        #        [2861088.520266, 1099378.309568, 6367532.487662],
        #        [ 6932.930021,  -216.638226, -3070.746198]),
        #    ('2015-04-30T05:46:14.000000000',
        #        [2930254.733863, 1097099.944255, 6336466.514344],
        #        [ 6900.178053,  -239.022713, -3142.39037 ]),
        #    ('2015-04-30T05:46:24.000000000',
        #        [2999089.394834, 1094598.105058, 6304685.855646],
        #        [ 6866.620117,  -261.332391, -3213.681933]),
        #    ('2015-04-30T05:46:34.000000000',
        #        [3067584.462515, 1091873.55841 , 6272194.077798],
        #        [ 6832.260032,  -283.563593, -3284.612861])],
        #    dtype=[('utc', '<M8[ns]'), ('pos', '<f8', (3,)), ('vel', '<f8', (3,))])
        sv = self.sv

        x, y, z = sv[0].pos
        vx, vy, vz = sv[0].vel
        mjd0 = (sv[0]['utc'] - n.datetime64('1858-11-17')) / n.timedelta64(
            1, 'D')

        N = 7

        t = 10 * n.arange(N)
        pv = self.p.get_orbit_cart(t,
                                   x,
                                   y,
                                   z,
                                   vx,
                                   vy,
                                   vz,
                                   mjd0,
                                   m=2300.,
                                   C_R=1.,
                                   C_D=2.3,
                                   A=4 * 2.3)

        nt.assert_array_less(n.abs(sv[:N]['pos'] - pv[:3].T),
                             n.full((N, 3), 1.0, dtype=pv.dtype))  #m
        nt.assert_array_less(n.abs(sv[:N]['vel'] - pv[3:].T),
                             n.full((N, 3), 1.0e-3, dtype=pv.dtype))  #mm/s

    def test_longer(self):
        sv = self.sv

        x, y, z = sv[0].pos
        vx, vy, vz = sv[0].vel
        mjd0 = (sv[0]['utc'] - np.datetime64('1858-11-17')) / np.timedelta64(
            1, 'D')

        N = len(sv)
        t = 10 * n.arange(N)

        pv = self.p.get_orbit_cart(t,
                                   x,
                                   y,
                                   z,
                                   vx,
                                   vy,
                                   vz,
                                   mjd0,
                                   m=2300.,
                                   C_R=0.,
                                   C_D=.0,
                                   A=4 * 2.3)

        perr = np.linalg.norm(pv[:3].T - sv.pos, axis=1)
        verr = np.linalg.norm(pv[3:].T - sv.vel, axis=1)

        # f, ax = plt.subplots(2,1)
        # ax[0].plot(t/3600., perr)
        # ax[0].set_title('Errors from propagation')
        # ax[0].set_ylabel('Position error [m]')
        # ax[1].plot(t/3600., verr)
        # ax[1].set_ylabel('Velocity error [m/s]')
        # ax[1].set_xlabel('Time [h]')

    def test_s3_pair(self):
        '''
        Statevectors from S3 product
        S3A_OL_1_EFR____20180926T093816_20180926T094049_20180927T140153_0153_036_136_1620_LN1_O_NT_002
        (https://code-de.org/Sentinel3/OLCI/2018/09/26/)
        '''
        def _decomp(v):
            return n.array([float(v['x']), float(v['y']), float(v['z'])])

        sv = [{
            'epoch': {
                'TAI': '2018-09-26T09:11:26.318893',
                'UTC': '2018-09-26T09:10:49.318893',
                'UT1': '2018-09-26T09:10:49.371198'
            },
            'position': {
                'x': -7018544.618,
                'y': -1531717.645,
                'z': 0.001
            },
            'velocity': {
                'x': -341.688439,
                'y': 1605.354223,
                'z': 7366.313136
            }
        }, {
            'epoch': {
                'TAI': '2018-09-26T10:52:25.494280',
                'UTC': '2018-09-26T10:51:48.494280',
                'UT1': '2018-09-26T10:51:48.546508'
            },
            'position': {
                'x': -7001440.416,
                'y': 1608173.405,
                'z': 0.004
            },
            'velocity': {
                'x': 375.658124,
                'y': 1597.811148,
                'z': 7366.302506
            }
        }]

        t0 = n.datetime64(sv[0]['epoch']['TAI'])
        t1 = n.datetime64(sv[1]['epoch']['TAI'])

        t0pos = _decomp(sv[0]['position'])
        t0vel = _decomp(sv[0]['velocity'])
        t1pos = _decomp(sv[1]['position'])
        t1vel = _decomp(sv[1]['velocity'])

        x0, y0, z0 = t0pos
        vx0, vy0, vz0 = t0vel
        x1, y1, z1 = t1pos
        vx1, vy1, vz1 = t1vel

        t = (t1 - t0) / dpt.sec

        mjd0 = dpt.npdt2mjd(dpt.tai2utc(t0))
        mjd1 = dpt.npdt2mjd(dpt.tai2utc(t1))
        # mjd0 = (sv[0]['utc'] - n.datetime64('1858-11-17')) / n.timedelta64(1, 'D')

        # Propagate forwards from t0 to t1
        # If I disable drag and radiation pressure here, errors increase
        # by a factor of almost 300
        pv1 = self.p.get_orbit_cart(t,
                                    x0,
                                    y0,
                                    z0,
                                    vx0,
                                    vy0,
                                    vz0,
                                    mjd0,
                                    m=1250.,
                                    C_R=1.,
                                    C_D=2.3,
                                    A=2.2 * 2.2)

        nt.assert_(
            np.linalg.norm(t1pos - pv1[:3].T) < 150,
            'S3 propagate position')  # m
        nt.assert_(
            np.linalg.norm(t1vel - pv1[3:].T) < .15,
            'S3 propagate velocity')  # m/s

        # Propagate backwards from t1 to t0
        # Need to disable drag and solar radiation pressure,
        # and increase tolerances by factor of 2.33
        # So does that mean Orekit bungles drag when propagating backwards in time?
        pv0 = self.p.get_orbit_cart(-t,
                                    x1,
                                    y1,
                                    z1,
                                    vx1,
                                    vy1,
                                    vz1,
                                    mjd1,
                                    m=1250.,
                                    C_R=0.,
                                    C_D=0.,
                                    A=2.2 * 2.2)

        nt.assert_(
            np.linalg.norm(t0pos - pv0[:3].T) < 350,
            'S3 propagate position')  # m
        nt.assert_(
            np.linalg.norm(t0vel - pv0[3:].T) < .35,
            'S3 propagate velocity')  # m/s
예제 #25
0
 def test_options_rad_off(self):
     p = PropagatorOrekit(radiation_pressure=False, )
     ecefs = p.get_orbit(self.t0, **self.init_data)
예제 #26
0
 def test_options_jpliau(self):
     p = PropagatorOrekit(constants_source='JPL-IAU', )
     ecefs = p.get_orbit(self.t0, **self.init_data)
예제 #27
0
 def test_raise_frame(self):
     with self.assertRaises(Exception):
         p = PropagatorOrekit(in_frame='THIS DOES NOT EXIST', )
     with self.assertRaises(Exception):
         p = PropagatorOrekit(out_frame='THIS DOES NOT EXIST', )
예제 #28
0
import ccsds_write

from propagator_neptune import PropagatorNeptune
from propagator_sgp4 import PropagatorSGP4
from propagator_orekit import PropagatorOrekit

radar = rlib.eiscat_3d()

p_sgp4 = PropagatorSGP4(
    polar_motion=False,
    out_frame='ITRF',
)

p_nept = PropagatorNeptune()
p_orekit = PropagatorOrekit(
    in_frame='TEME',
    out_frame='ITRF',
)

props = [
    p_sgp4,
    p_nept,
    p_orekit,
]

prop_dat = [
    ('-b', 'SGP4'),
    ('-g', 'NEPTUNE'),
    ('-k', 'Orekit'),
]

ut0 = 1241136000.0
    orb = orb_offset + orb * orb_range
    if orb[0] * (1.0 - orb[1]) > R_E + 200e3:
        orb_init_list.append(orb)

np.random.seed(None)

orbs_pass = []
orbs = []
cols = []
orbs_fail = []
fail_inds = []
fail_err = []
fail_errv = []

prop = PropagatorOrekit(
    in_frame='EME',
    out_frame='EME',
)

for ind, kep in enumerate(orb_init_list):

    t = np.array([0.0])

    state_ref = dpt.kep2cart(kep, m=1.0, M_cent=prop.M_earth, radians=False)
    '''
    state = prop.get_orbit(
            t=t, mjd0=mjd0,
            a=kep[0], e=kep[1], inc=kep[2],
            raan=kep[4], aop=kep[3], mu0=dpt.true2mean(kep[5], kep[1], radians=False),
            C_D=2.3, m=1.0, A=1.0, C_R=1.0,
            radians=False,
        )
예제 #30
0
 def test_raise_bodies(self):
     with self.assertRaises(Exception):
         p = PropagatorOrekit(
             solarsystem_perturbers=['THIS DOES NOT EXIST'], )