Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_to_datetime(time, exp_time):
assert gr.to_datetime(time) == exp_time
def test_tlim_past_eof():
fn = R/'CEDA00USA_R_20182100000_01D_MN.rnx.gz'
nav = gr.load(fn, tlim=('2018-07-29T23', '2018-07-29T23:30'))
times = gr.to_datetime(nav.time)
assert times == datetime(2018, 7, 29, 23)
def test_mangled():
fn = R/'14601736.18n'
nav = gr.load(fn)
times = gr.to_datetime(nav.time)
assert times == datetime(2018, 6, 22, 8)
def test_galileo():
nav = gr.load(R/'ceda2100.18e')
E18 = nav.sel(sv='E18').dropna(dim='time', how='all')
assert gr.to_datetime(E18.time) == datetime(2018, 7, 29, 12, 40)
assert E18.to_array().values.squeeze() == approx([6.023218797054e-3, -2.854960712284e-11, 0.,
76, 79.53125, 3.006910964197e-09, -1.308337580849, 6.468966603279e-06,
1.659004657995e-01, 3.594905138016e-07, 5.289377120972e3,
45600, 5.243346095085e-06, 1.437602366755, 4.358589649200e-06,
8.809314114035e-01, 3.329375000000e2, 1.349316878658, -4.092313318419e-09,
-6.553844422498e-10, 517, 2.012000000000e3, 3.12, 455, 1.396983861923e-08,
1.536682248116e-08, 47064])
pytest.skip(f'crx2rnx not found')
fn = R / 'P43300USA_R_20190012056_17M_15S_MO.crx'
info = gr.rinexinfo(fn)
assert int(info['version']) == 3
# %% full file
obs = gr.load(fn, tlim=('2019-01-01', '2019-01-01T20:57'))
assert (obs.sv.values == ['C08', 'C19', 'C20', 'C22', 'C32', 'C36', 'C37', 'E02', 'E03',
'E05', 'E08', 'E24', 'E25', 'G01', 'G03', 'G06', 'G09', 'G14',
'G16', 'G22', 'G23', 'G26', 'G31', 'R01', 'R02', 'R08', 'R10',
'R11', 'R12', 'R17', 'S31', 'S33', 'S35', 'S38']).all()
times = gr.to_datetime(obs.time)
assert times[0] == datetime(2019, 1, 1, 20, 56, 45)
assert times[-1] == datetime(2019, 1, 1, 20, 57)
def test_obs2_lzw():
pytest.importorskip('unlzw3')
fn = R / 'ac660270.18o.Z'
obs = gr.load(fn)
hdr = gr.rinexheader(fn)
assert hdr['t0'] <= gr.to_datetime(obs.time[0])
assert not obs.fast_processing
def test_mangled_times():
fn = R/'badtime.10o'
obs = gr.load(fn)
times = gr.to_datetime(obs.time)
assert times
def test_tlim():
nav = gr.load(R/'ceda2100.18e', tlim=('2018-07-29T11', '2018-07-29T12'))
times = gr.to_datetime(nav.time)
assert (times == [datetime(2018, 7, 29, 11, 50), datetime(2018, 7, 29, 12)]).all()