def test_parameters(): toe = t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, }) time = t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, }) valid = 1 fit_interval = 4 * 60 * 60 assert e.Ephemeris.is_params_valid(valid, fit_interval, toe, time) toe = t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, }) time = t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, }) valid = 0 fit_interval = 4 * 60 * 60 assert not e.Ephemeris.is_params_valid(valid, fit_interval, toe, time) toe = t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, }) time = t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, }) valid = 1 fit_interval = 0 * 60 * 60 assert not e.Ephemeris.is_params_valid(valid, fit_interval, toe, time) toe = t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, }) time = t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0 + 3600.0 * 2, }) valid = 1 fit_interval = 4 * 60 * 60 assert e.Ephemeris.is_params_valid(valid, fit_interval, toe, time) toe = t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, }) time = t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0 + 3600.0 * 3, }) valid = 1 fit_interval = 4 * 60 * 60 assert not e.Ephemeris.is_params_valid(valid, fit_interval, toe, time)
def test_gpsdifftime(): cases = [ { 'a': (567890.0, 1234), 'b': (567890.0, 1234), 'dt': 0, 'time': 1062855873 }, { 'a': (567890.0, 1234), 'b': (0.0, 1234), 'dt': 567890, 'time': 1062855873 }, { 'a': (604578.0, 1000), 'b': (222.222, 1001), 'dt': -444.222, 'time': 921369361 }, { 'a': (604578.0, 1001), 'b': (222.222, 1000), 'dt': 1209155.778, 'time': 921974161 }, ] for c in cases: tow_tol = 1e-10 a, b, dt, time = c['a'], c['b'], c['dt'], c['time'] assert t.GpsTime(tow=a[0], wn=a[1]).gps2time() == time print t.GpsTime(tow=a[0], wn=a[1]).normalize_gps_time() assert t.GpsTime(tow=a[0], wn=a[1]).gpsdifftime( t.GpsTime(tow=b[0], wn=b[1])) - dt < tow_tol
def test_prop_single_diff(): rover_nm = [t.NavigationMeasurement(sat_pos=[-19277207.52067729, -8215764.2479763795, 16367744.770246204], pseudorange=21123480.27105955, doppler=0, raw_doppler=0, carrier_phase=-110993309.26669005, sat_vel=[-1025.0370403901404, -1821.9217799467374, -2091.6303199092254], lock_time=0, tot=ti.GpsTime(wn=1876, tow=167131.92954684512), raw_pseudorange=21121324.476403236, raw_carrier_phase=-110993309.26669005, snr=30.0, sid=s.GNSSSignal(code=0, sat=0), lock_counter=0), t.NavigationMeasurement(sat_pos=[-16580310.849158794, 918714.1939749047, 20731444.258332774], pseudorange=22432049.84763688, doppler=0, raw_doppler=0, carrier_phase=-117882743.21601027, sat_vel=[1060.9864205977192, -2411.43509917502, 953.6270954519971], lock_time=0, tot=ti.GpsTime(wn=1876, tow=167131.9251737675), raw_pseudorange=22432340.166121125, raw_carrier_phase=-117882743.21601027, snr=30.0, sid=s.GNSSSignal(code=0, sat=2), lock_counter=0)] base_nm = [t.NavigationMeasurement(sat_pos=[-19277279.74504115, -8215892.62052003, 16367597.39238895], pseudorange=21123480.27105955, doppler=0, raw_doppler=0, carrier_phase=-110993309.26669005, sat_vel=[-1025.03418813, -1821.90205153, -2091.65477547], lock_time=0, tot=ti.GpsTime(wn=1876, tow=167131.92954684512), raw_pseudorange=21121324.476403236, raw_carrier_phase=-110993309.26669005, snr=30.0, sid=s.GNSSSignal(code=0, sat=0), lock_counter=0), t.NavigationMeasurement(sat_pos=[-16580231.46081397, 918533.75723257, 20731515.61249766], pseudorange=22432049.84763688, doppler=0, raw_doppler=0, carrier_phase=-117882743.21601027, sat_vel=[1060.97989026, -2411.44777346, 953.59410165], lock_time=0, tot=ti.GpsTime(wn=1876, tow=167131.9251737675), raw_pseudorange=22432340.166121125, raw_carrier_phase=-117882743.21601027, snr=30.0, sid=s.GNSSSignal(code=0, sat=2), lock_counter=0)] remote_dists = np.array([ 21121393.87562408, 22432814.46819838]) base_pos = np.array( [-2704375, -4263211, 3884637]) sdiffs = o.make_propagated_sdiffs_(rover_nm, base_nm, remote_dists, base_pos) assert len(sdiffs) == 2 assert sdiffs[0].pseudorange > 0 assert sdiffs[1].pseudorange > 0 assert sdiffs[0].carrier_phase < 0 assert sdiffs[0].doppler > 0 assert sdiffs[0].sid['sat'] == 0 assert sdiffs[1].sid['sat'] == 2
def test_almanac_functions(): alm = { 'sid': {'sat': 1, 'code': 0}, 'toa': {'tow': 233472.0, 'wn': 814,}, 'ura': 900.0, 'fit_interval': 144 * 60 * 60, 'valid': 1, 'healthy': 1, 'kepler': { 'sqrta': np.sqrt(26559810.38052176), 'ecc': 0.004033565521, 'w': 0.380143734, 'omega0': -0.9244574916, 'omegadot': -7.874613724e-09, 'm0': 2.030394348, 'inc': 0.9619461694, 'af0': -7.629394531e-06, 'af1': 0.0, } } time = t.GpsTime(**{ 'wn': 814, 'tow': 168214.0,}) pos = np.array([-2704369.61784456, -4263211.09418205, 3884641.21270987]) satAlmanac = a.Almanac(**alm) position, velocity, clock_err, clock_rate_err = satAlmanac.calc_state(time) assert np.allclose(position, np.array([7937862.2780455 , -19534384.87638699, -16087474.32428426])) assert np.allclose(velocity, np.array([1771.85083411, -1031.81872491, 2151.28549392])) assert np.isclose(clock_err, -7.629394531e-06) assert np.isclose(clock_rate_err, 0.0) doppler = satAlmanac.calc_doppler(time, pos) assert np.isclose(doppler, -1607.665252834069) azimuth, elevation = satAlmanac.calc_az_el(time, pos) assert np.isclose(azimuth, 2.437585312667075) assert np.isclose(elevation, -0.23953409326103278)
def test_sat_state(): eph = e.Ephemeris( **{ 'sid': { 'sat': 17, 'band': 0, 'constellation': 0 }, 'toe': { 'wn': 1867, 'tow': 518400.0, }, 'ura': 2.0, 'fit_interval': 4, 'valid': 1, 'healthy': 1, 'kepler': { 'crs': 25.125, 'inc_dot': 3.78944355982045e-10, 'tgd': -1.1175870895385742e-08, 'crc': 106.65625, 'ecc': 0.016364791779778898, 'omegadot': -8.013190924423338e-09, 'inc': 0.9253317285121154, 'cuc': 1.255422830581665e-06, 'omega0': 2.7384009602031045, 'cus': 1.280754804611206e-05, 'm0': -2.057975194561658, 'toc': { 'tow': 518400.0, 'wn': 21845, }, 'dn': 5.035924052164783e-09, 'cic': 2.7194619178771973e-07, 'sqrta': 5153.647108078003, 'cis': 9.313225746154785e-09, 'iode': 50, 'iodc': 21845, 'crc': 49614, 'w': -1.9329047030450934, 'af0': 0.0004458986222743988, 'af1': 3.637978807091713e-12, 'af2': 0.0 } }) assert eph.good(t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, })) time = t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, }) pos, vel, clock_err, clock_rate_err = eph.calc_sat_state(time) assert np.allclose( pos, [8939514.51292471, -19122117.65874583, 16447534.13118957]) assert np.allclose(vel, [1892.86704302, -765.38725981, -1985.61338019]) assert clock_err - 0.00336435649383 < tol assert clock_rate_err - 3.63797880709e-12 < tol assert not eph.good(t.GpsTime(**{ 'wn': 1866, 'tow': 518400.0, })) assert not eph.good(t.GpsTime(**{'wn': 1867, 'tow': 518400.0 + 3600. * 4})) assert eph.good(t.GpsTime(**{'wn': 1867, 'tow': 518400.0 + 3600. * 2})) assert not eph.good(t.GpsTime(**{ 'wn': 1868, 'tow': 518400.0, })) assert len(eph.to_dict()) == 8 assert repr(eph) eph = e.Ephemeris( **{ 'sid': { 'sat': 17, 'band': 0, 'constellation': 0 }, 'toe': { 'wn': 1867, 'tow': 518400.0, }, 'ura': 2.0, 'fit_interval': 4, 'valid': 1, 'healthy': 0, 'kepler': { 'crs': 25.125, 'inc_dot': 3.78944355982045e-10, 'tgd': -1.1175870895385742e-08, 'crc': 106.65625, 'ecc': 0.016364791779778898, 'omegadot': -8.013190924423338e-09, 'inc': 0.9253317285121154, 'cuc': 1.255422830581665e-06, 'omega0': 2.7384009602031045, 'cus': 1.280754804611206e-05, 'm0': -2.057975194561658, 'toc': { 'tow': 518400.0, 'wn': 21845, }, 'dn': 5.035924052164783e-09, 'cic': 2.7194619178771973e-07, 'sqrta': 5153.647108078003, 'cis': 9.313225746154785e-09, 'iode': 50, 'iodc': 21845, 'crc': 49614, 'w': -1.9329047030450934, 'af0': 0.0004458986222743988, 'af1': 3.637978807091713e-12, 'af2': 0.0 } }) assert eph.good(t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, })) eph = e.Ephemeris( **{ 'sid': { 'sat': 17, 'band': 0, 'constellation': 0 }, 'toe': { 'wn': 1867, 'tow': 518400.0, }, 'ura': 2.0, 'fit_interval': 4, 'valid': 0, 'healthy': 0, 'kepler': { 'crs': 25.125, 'inc_dot': 3.78944355982045e-10, 'tgd': -1.1175870895385742e-08, 'crc': 106.65625, 'ecc': 0.016364791779778898, 'omegadot': -8.013190924423338e-09, 'inc': 0.9253317285121154, 'cuc': 1.255422830581665e-06, 'omega0': 2.7384009602031045, 'cus': 1.280754804611206e-05, 'm0': -2.057975194561658, 'toc': { 'tow': 518400.0, 'wn': 21845, }, 'dn': 5.035924052164783e-09, 'cic': 2.7194619178771973e-07, 'sqrta': 5153.647108078003, 'cis': 9.313225746154785e-09, 'iode': 50, 'iodc': 21845, 'crc': 49614, 'w': -1.9329047030450934, 'af0': 0.0004458986222743988, 'af1': 3.637978807091713e-12, 'af2': 0.0 } }) assert not eph.good(t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, })) eph = e.Ephemeris( **{ 'sid': { 'sat': 17, 'band': 0, 'constellation': 0 }, 'toe': { 'wn': 1867, 'tow': 518400.0, }, 'ura': 2.0, 'fit_interval': 6, 'valid': 1, 'healthy': 1, 'kepler': { 'crs': 25.125, 'inc_dot': 3.78944355982045e-10, 'tgd': -1.1175870895385742e-08, 'crc': 106.65625, 'ecc': 0.016364791779778898, 'omegadot': -8.013190924423338e-09, 'inc': 0.9253317285121154, 'cuc': 1.255422830581665e-06, 'omega0': 2.7384009602031045, 'cus': 1.280754804611206e-05, 'm0': -2.057975194561658, 'toc': { 'tow': 518400.0, 'wn': 21845, }, 'dn': 5.035924052164783e-09, 'cic': 2.7194619178771973e-07, 'sqrta': 5153.647108078003, 'cis': 9.313225746154785e-09, 'iode': 50, 'iodc': 21845, 'crc': 49614, 'w': -1.9329047030450934, 'af0': 0.0004458986222743988, 'af1': 3.637978807091713e-12, 'af2': 0.0 } }) assert eph.good(t.GpsTime(**{'wn': 1867, 'tow': 518400.0 + 3600. * 4})) assert not eph.good(t.GpsTime(**{'wn': 1867, 'tow': 518400.0 + 3600. * 6}))
def test_glo_sat_state(): eph1 = e.Ephemeris(**{'sid': {'sat': 3, 'code': 3,}, 'toe': {'wn': 1892, 'tow': 303900.0,}, #from GPS 'ura': 2.0, 'fit_interval': 4 * 60 * 60, 'valid': 1, 'healthy': 1, 'glo': { #data at 2016-04-13T12:25:00 'gamma' : 9.09494701772928238e-13, 'tau' : -6.72144815325737000e-05, 'pos' : [-1.4379786621093750e+07,-7.6587543945312500e+06,1.9676794921875000e+07], 'vel' : [2.6736078262329102e+03,-2.4776077270507813e+02,1.8579368591308594e+03], 'acc' : [0.0,0.0,-2.79396772384643555e-06], }}) eph2 = e.Ephemeris(**{'sid': {'sat': 3, 'code': 3,}, 'toe': {'wn': 1892, 'tow': 305700.0,}, #from GPS 'ura': 2.0, 'fit_interval': 4 * 60 * 60, 'valid': 1, 'healthy': 1, 'glo': { #data at 2016-04-13T12:55:00 'gamma' : 9.09494701772928238e-13, 'tau' : -6.72172755002975464e-05, 'pos' : [-9.2793393554687500e+06,-8.5263706054687500e+06,2.2220868652343750e+07], 'vel' : [2.9441843032836914e+03,-7.2328472137451172e+02,9.5054054260253906e+02], 'acc' : [0.0,0.0,-2.79396772384643555e-06], }}) #check that both ephemeris are valid at 2016-04-13T12:40:00 assert eph1.is_valid(t.GpsTime(**{ 'wn': 1892, 'tow': 304800.0, })) assert eph2.is_valid(t.GpsTime(**{ 'wn': 1892, 'tow': 304800.0, })) assert eph1.is_healthy() assert eph2.is_healthy() #set time in between 2 ephemeris time = t.GpsTime(**{ 'wn': 1892, 'tow': 304800.0, }) #calculate SV orbits at the time pos1, vel1, clock_err1, clock_rate_err1 = eph1.calc_sat_state(time) pos2, vel2, clock_err2, clock_rate_err2 = eph2.calc_sat_state(time) #check if position difference of the SV in 2.5 m range assert np.allclose(pos1, pos2, 0, 2.5) #check if velocity difference of the SV in 0.005 m/s range assert np.allclose(vel1, vel2, 0, 0.005) assert abs(clock_err1 - clock_err2) < 1.0e-8 assert abs(clock_rate_err1 - clock_rate_err2) < 1.0e-8 # Now check GLO orbit computation (pos and vel) at particular time # set reference ephemeris at 2007-15-11T06.15.00 eph = e.Ephemeris(**{'sid': {'sat': 3, 'code': 3,}, 'toe': {'wn': 1453, 'tow': 368100.0,}, #from GPS 'ura': 2.0, 'fit_interval': 4 * 60 * 60, 'valid': 1, 'healthy': 1, 'glo': { #input data from GLO ICD, pg. 55 'gamma' : 0, #not necessary for the test 'tau' : 0, #not necessary for the test 'pos' : [-14081752.701,18358958.252,10861302.124], 'vel' : [-1025.76358,1086.72147,-3157.32343], 'acc' : [1.7156e-6-9.2581e-7,1.0278e-6-1.0343e-6,-1.0368e-6-1.1260e-6], }}) #set time to 6:30 time = t.GpsTime(**{ 'wn': 1453, 'tow': 369000.0, }) #calculate SV orbits at the time pos, vel, clock_err, clock_rate_err = eph.calc_sat_state(time) #check calculated vel and pos data at 2007-15-11T06:30:00 #reference values from GLO ICD, pg 55. Note: it seems there is an typo in # result Vz in ICD example assert np.allclose(pos, [-14836563.872, 19249935.476, 7924017.196], 0, 2.5) assert np.allclose(vel, [-653.97782, 882.62958, -3359.44444], 0, 0.005)
def test_sat_state(): eph = e.Ephemeris( **{ 'sid': { 'sat': 17, 'code': 0, }, 'toe': { 'wn': 1867, 'tow': 518400.0, }, 'ura': 2.0, 'fit_interval': 4 * 60 * 60, 'valid': 1, 'healthy': 1, 'kepler': { 'toc': { 'tow': 518400.0, 'wn': 1867, }, 'crs': 25.125, 'inc_dot': 3.78944355982045e-10, 'tgd': -1.1175870895385742e-08, 'crc': 106.65625, 'ecc': 0.016364791779778898, 'omegadot': -8.013190924423338e-09, 'inc': 0.9253317285121154, 'cuc': 1.255422830581665e-06, 'omega0': 2.7384009602031045, 'cus': 1.280754804611206e-05, 'm0': -2.057975194561658, 'dn': 5.035924052164783e-09, 'cic': 2.7194619178771973e-07, 'sqrta': 5153.647108078003, 'cis': 9.313225746154785e-09, 'iode': 50, 'iodc': 21845, 'crc': 49614, 'w': -1.9329047030450934, 'af0': 0.0004458986222743988, 'af1': 3.637978807091713e-12, 'af2': 0.0 } }) assert eph.is_valid(t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, })) assert eph.is_healthy() time = t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, }) pos, vel, clock_err, clock_rate_err = eph.calc_sat_state(time) assert np.allclose( pos, [8939514.51292471, -19122117.65874583, 16447534.13118957]) assert np.allclose(vel, [1892.86704302, -765.38725981, -1985.61338019]) assert clock_err - 0.00336435649383 < tol assert clock_rate_err - 3.63797880709e-12 < tol gnd_pos = np.array([1115054, -4843905, 3983584]) doppler = eph.calc_doppler(time, gnd_pos) assert np.isclose(doppler, 253.83513370122773) azimuth, elevation = eph.calc_az_el(time, gnd_pos) assert np.isclose(azimuth, 1.5874048317078373) assert np.isclose(elevation, 1.3533993525984187) assert not eph.is_valid(t.GpsTime(**{ 'wn': 1866, 'tow': 518400.0, })) assert not eph.is_valid( t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0 + 3600. * 2 + 1 })) assert not eph.is_valid( t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0 - 3600. * 2 - 1 })) assert eph.is_valid(t.GpsTime(**{'wn': 1867, 'tow': 518400.0 + 3600. * 1})) assert eph.is_valid(t.GpsTime(**{'wn': 1867, 'tow': 518400.0 - 3600. * 1})) assert not eph.is_valid(t.GpsTime(**{ 'wn': 1868, 'tow': 518400.0, })) assert len(eph.to_dict()) == 9 assert repr(eph) eph = e.Ephemeris( **{ 'sid': { 'sat': 17, 'code': 0 }, 'toe': { 'wn': 1867, 'tow': 518400.0, }, 'ura': 2.0, 'fit_interval': 4 * 60 * 60, 'valid': 1, 'healthy': 0, 'kepler': { 'crs': 25.125, 'inc_dot': 3.78944355982045e-10, 'tgd': -1.1175870895385742e-08, 'crc': 106.65625, 'ecc': 0.016364791779778898, 'omegadot': -8.013190924423338e-09, 'inc': 0.9253317285121154, 'cuc': 1.255422830581665e-06, 'omega0': 2.7384009602031045, 'cus': 1.280754804611206e-05, 'm0': -2.057975194561658, 'toc': { 'tow': 518400.0, 'wn': 1867, }, 'dn': 5.035924052164783e-09, 'cic': 2.7194619178771973e-07, 'sqrta': 5153.647108078003, 'cis': 9.313225746154785e-09, 'iode': 50, 'iodc': 21845, 'crc': 49614, 'w': -1.9329047030450934, 'af0': 0.0004458986222743988, 'af1': 3.637978807091713e-12, 'af2': 0.0 } }) assert eph.is_valid(t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, })) assert not eph.is_healthy() eph = e.Ephemeris( **{ 'sid': { 'sat': 17, 'code': 0 }, 'toe': { 'wn': 1867, 'tow': 518400.0, }, 'ura': 2.0, 'fit_interval': 4 * 60 * 60, 'valid': 0, 'healthy': 0, 'kepler': { 'crs': 25.125, 'inc_dot': 3.78944355982045e-10, 'tgd': -1.1175870895385742e-08, 'crc': 106.65625, 'ecc': 0.016364791779778898, 'omegadot': -8.013190924423338e-09, 'inc': 0.9253317285121154, 'cuc': 1.255422830581665e-06, 'omega0': 2.7384009602031045, 'cus': 1.280754804611206e-05, 'm0': -2.057975194561658, 'toc': { 'tow': 518400.0, 'wn': 1867, }, 'dn': 5.035924052164783e-09, 'cic': 2.7194619178771973e-07, 'sqrta': 5153.647108078003, 'cis': 9.313225746154785e-09, 'iode': 50, 'iodc': 21845, 'crc': 49614, 'w': -1.9329047030450934, 'af0': 0.0004458986222743988, 'af1': 3.637978807091713e-12, 'af2': 0.0 } }) assert not eph.is_valid(t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0, })) assert eph.is_healthy() eph = e.Ephemeris( **{ 'sid': { 'sat': 17, 'code': 0 }, 'toe': { 'wn': 1867, 'tow': 518400.0, }, 'ura': 2.0, 'fit_interval': 6 * 60 * 60, 'valid': 1, 'healthy': 1, 'kepler': { 'crs': 25.125, 'inc_dot': 3.78944355982045e-10, 'tgd': -1.1175870895385742e-08, 'crc': 106.65625, 'ecc': 0.016364791779778898, 'omegadot': -8.013190924423338e-09, 'inc': 0.9253317285121154, 'cuc': 1.255422830581665e-06, 'omega0': 2.7384009602031045, 'cus': 1.280754804611206e-05, 'm0': -2.057975194561658, 'toc': { 'tow': 518400.0, 'wn': 1867, }, 'dn': 5.035924052164783e-09, 'cic': 2.7194619178771973e-07, 'sqrta': 5153.647108078003, 'cis': 9.313225746154785e-09, 'iode': 50, 'iodc': 21845, 'crc': 49614, 'w': -1.9329047030450934, 'af0': 0.0004458986222743988, 'af1': 3.637978807091713e-12, 'af2': 0.0 } }) assert eph.is_valid(t.GpsTime(**{'wn': 1867, 'tow': 518400.0 + 3600. * 2})) assert not eph.is_valid( t.GpsTime(**{ 'wn': 1867, 'tow': 518400.0 + 3600. * 3 + 1 })) assert eph.is_healthy()
import numpy as np import pytest import swiftnav.time as ti import swiftnav.track as t import swiftnav.observation as o import swiftnav.signal as s nms = \ [t.NavigationMeasurement(sid=s.GNSSSignal(sat=9, code=0), pseudorange=23946993.888943646, raw_pseudorange=23946993.888943646, sat_pos=(-19477278.087422125, -7649508.9457812719, 16674633.163554827), sat_vel=(0, 0, 0), raw_carrier_phase=0, carrier_phase=0, raw_doppler=0, doppler=0, lock_counter=0, snr=0, lock_time=0, tot=ti.GpsTime(tow=0, wn=0)), t.NavigationMeasurement(sid=s.GNSSSignal(sat=1, code=0), pseudorange=22932174.156858064, raw_pseudorange=22932174.156858064, sat_pos=(-9680013.5408340245, -15286326.354385279, 19429449.383770257), sat_vel=(0, 0, 0), raw_carrier_phase=0, carrier_phase=0, raw_doppler=0, doppler=0, lock_counter=0, snr=0, lock_time=0, tot=ti.GpsTime(tow=0, wn=0)), t.NavigationMeasurement(sid=s.GNSSSignal(sat=2, code=0), pseudorange=24373231.648055989, raw_pseudorange=24373231.648055989, sat_pos=(-19858593.085281931, -3109845.8288993631, 17180320.439503901), sat_vel=(0, 0, 0), raw_carrier_phase=0, carrier_phase=0, raw_doppler=0, doppler=0, lock_counter=0, snr=0, lock_time=0,
def test_prop_single_diff(): rover_nm = [ t.NavigationMeasurement(sat_pos=[ -19277207.52067729, -8215764.2479763795, 16367744.770246204 ], pseudorange=21123480.27105955, doppler=0, raw_doppler=0, carrier_phase=-110993309.26669005, sat_vel=[ -1025.0370403901404, -1821.9217799467374, -2091.6303199092254 ], lock_time=0, tot=ti.GpsTime(wn=1876, tow=167131.92954684512), raw_pseudorange=21121324.476403236, snr=30.0, sid=s.GNSSSignal(band=0, constellation=0, sat=0), lock_counter=0), t.NavigationMeasurement( sat_pos=[ -16580310.849158794, 918714.1939749047, 20731444.258332774 ], pseudorange=22432049.84763688, doppler=0, raw_doppler=0, carrier_phase=-117882743.21601027, sat_vel=[1060.9864205977192, -2411.43509917502, 953.6270954519971], lock_time=0, tot=ti.GpsTime(wn=1876, tow=167131.9251737675), raw_pseudorange=22432340.166121125, snr=30.0, sid=s.GNSSSignal(band=0, constellation=0, sat=2), lock_counter=0) ] remote_dists = np.array([21121393.87562408, 22432814.46819838]) base_pos = np.array([-2704375, -4263211, 3884637]) es = [ Ephemeris( **{ 'ura': 0.0, 'healthy': 1, 'xyz': { 'acc': [ -6.51925802230835e-08, 4.718410826464475e-09, 2.6226835183928943 ], 'iod': 0, 'a_gf0': 5153.648313522339, 'a_gf1': 0.5977821557062277, 'pos': [5.122274160385132e-09, 19.0625, 259.9375], 'rate': [ 1.0151416063308716e-06, 6.260350346565247e-06, -6.332993507385254e-08 ], 'toa': 4096 }, 'valid': 1, 'sid': { 'band': 0, 'constellation': 0, 'sat': 0 }, 'toe': { 'wn': 1876, 'tow': 172800.0 }, 'kepler': { 'inc_dot': 4.4966158735287064e-10, 'tgd': 5.122274160385132e-09, 'omegadot': -8.099980253833005e-09, 'sqrta': 5153.648313522339, 'inc': 0.9634151551139846, 'cus': 6.260350346565247e-06, 'omega0': 0.5977821557062277, 'cuc': 1.0151416063308716e-06, 'm0': 2.6226835183928943, 'toc': { 'wn': 1876, 'tow': 172800.0 }, 'dn': 4.718410826464475e-09, 'ecc': 0.0049016030970960855, 'cic': -6.332993507385254e-08, 'crs': 19.0625, 'iode': 74, 'iodc': 21845, 'cis': -6.51925802230835e-08, 'crc': 259.9375, 'w': 0.4885959643259506, 'af0': 7.212162017822266e-06, 'af1': 9.094947017729282e-13, 'af2': 0.0 }, 'fit_interval': 4 }), Ephemeris( **{ 'ura': 0.0, 'healthy': 1, 'xyz': { 'acc': [ -6.146728992462158e-08, 4.742340394655613e-09, -0.8114190126645531 ], 'iod': 0, 'a_gf0': 5153.798839569092, 'a_gf1': 1.6390180338742641, 'pos': [1.862645149230957e-09, -40.5625, 221.625], 'rate': [ -2.2239983081817627e-06, 8.001923561096191e-06, 3.725290298461914e-09 ], 'toa': 0 }, 'valid': 1, 'sid': { 'band': 0, 'constellation': 0, 'sat': 2 }, 'toe': { 'wn': 1876, 'tow': 172800.0 }, 'kepler': { 'inc_dot': -4.475186409476941e-10, 'tgd': 1.862645149230957e-09, 'omegadot': -8.103551831174965e-09, 'sqrta': 5153.798839569092, 'inc': 0.9587534715647247, 'cus': 8.001923561096191e-06, 'omega0': 1.6390180338742641, 'cuc': -2.2239983081817627e-06, 'm0': -0.8114190126645531, 'toc': { 'wn': 1876, 'tow': 172800.0 }, 'dn': 4.742340394655613e-09, 'ecc': 0.00035172002390027046, 'cic': 3.725290298461914e-09, 'crs': -40.5625, 'iode': 59, 'iodc': 21845, 'cis': -6.146728992462158e-08, 'crc': 221.625, 'w': 2.9037284161724037, 'af0': -9.969808161258698e-07, 'af1': -5.229594535194337e-12, 'af2': 0.0 }, 'fit_interval': 4 }) ] gpst = ti.GpsTime(wn=1876, tow=167132) sdiffs = o.make_propagated_sdiffs_(rover_nm, rover_nm, remote_dists, base_pos, es, gpst) assert len(sdiffs) == 2 assert sdiffs[0].pseudorange > 0 assert sdiffs[1].pseudorange > 0 assert sdiffs[0].carrier_phase < 0 assert sdiffs[0].doppler > 0 assert sdiffs[0].sid['sat'] == 0 assert sdiffs[1].sid['sat'] == 2
def test_datetime2gpst(): test_dt = dt.datetime.strptime('1995-05-07 08:20:00', '%Y-%m-%d %H:%M:%S') gpst = t.datetime2gpst(test_dt) assert str(gpst) == str(t.GpsTime(wn=800, tow=30000))
def test_gpst2datetime(): gpst = t.GpsTime(wn=800, tow=30000) test_dt = t.gpst2datetime(gpst) assert test_dt == dt.datetime.strptime('1995-05-07 08:20:00', '%Y-%m-%d %H:%M:%S')