def eachfile(fn: Path, verbose: bool = False): try: times = gr.gettime(fn) except ValueError as e: if verbose: print(f"{fn.name}: {e}") return # %% output Ntimes = times.size if Ntimes == 0: return ostr = f"{fn.name}:" f" {times[0].isoformat()}" f" {times[-1].isoformat()}" f" {Ntimes}" hdr = gr.rinexheader(fn) interval = hdr.get("interval", np.nan) if ~np.isnan(interval): ostr += f" {interval}" Nexpect = (times[-1] - times[0]) // timedelta(seconds=interval) + 1 if Nexpect != Ntimes: logging.warning( f"{fn.name}: expected {Nexpect} but got {Ntimes} times") print(ostr) if verbose: print(times)
def eachfile(fn: Path, verbose: bool = False): try: times = gr.gettime(fn) except Exception as e: if verbose: print(f'{fn.name}: {e}') return # %% output try: ostr = (f"{fn.name}:" f" {times[0].isoformat()}" f" {times[-1].isoformat()}") except IndexError: return try: if ~np.isnan(times.interval): ostr += f" {times.interval}" except AttributeError: pass print(ostr) if verbose: print(times)
def test_time(): times = gr.gettime(R / 'VILL00ESP_R_20181700000_01D_MN.rnx.gz').values.astype( 'datetime64[us]').astype(datetime) assert times[0] == datetime(2018, 4, 24, 8) assert times[-1] == datetime(2018, 6, 20, 22)
def test_time(): pytest.importorskip('unlzw') times = gr.gettime( R / 'ab422100.18n.Z').values.astype('datetime64[us]').astype(datetime) assert times[0] == datetime(2018, 7, 29, 1, 59, 44) assert times[-1] == datetime(2018, 7, 30)
def test_junk_time(fname): """ some RINEX 3 are observed to have unexpected non-time data fixes https://github.com/geospace-code/georinex/issues/77 """ times = gr.gettime(R / fname) assert times.tolist() == [datetime(2010, 3, 5, 0, 0, 30), datetime(2010, 3, 5, 0, 1, 30)]
def test_blank(): fn = R / 'blank.10n' nav = gr.load(fn) assert nav is None with tempfile.TemporaryDirectory() as outdir: gr.load(fn, outdir) times = gr.gettime(fn) assert times is None
def test_blank(tmp_path): fn = R / 'blank3.10n' nav = gr.load(fn) assert nav is None outdir = tmp_path gr.load(fn, outdir) times = gr.gettime(fn) assert times is None
def test_one_sv(): obs = gr.load(R / 'rinex2onesat.10o') assert len(obs.sv) == 1 assert obs.sv.item() == 'G13' times = gr.to_datetime(gr.gettime(R/'rinex2onesat.10o')) assert (times == [datetime(2010, 3, 5, 0, 0), datetime(2010, 3, 5, 0, 0, 30)]).all() assert obs.fast_processing
def test_blank(tmp_path): fn = R / 'blank.10o' obs = gr.load(fn) assert obs is None outdir = tmp_path gr.load(fn, outdir) assert not (outdir / (fn.name + '.nc')).is_file() times = gr.gettime(fn) assert times is None
def test_blank(): fn = R / 'blank.10o' obs = gr.load(fn) assert obs is None with tempfile.TemporaryDirectory() as outdir: outdir = Path(outdir) gr.load(fn, outdir) assert not (outdir / (fn.name + '.nc')).is_file() times = gr.gettime(fn) assert times is None
def test_zip(): fn = R/'ABMF00GLP_R_20181330000_01D_30S_MO.zip' obs = gr.load(fn) assert (obs.sv.values == ['E04', 'E09', 'E12', 'E24', 'G02', 'G05', 'G06', 'G07', 'G09', 'G12', 'G13', 'G17', 'G19', 'G25', 'G30', 'R01', 'R02', 'R08', 'R22', 'R23', 'R24', 'S20', 'S31', 'S35', 'S38']).all() times = gr.gettime(fn) assert (times == [datetime(2018, 5, 13, 1, 30), datetime(2018, 5, 13, 1, 30, 30), datetime(2018, 5, 13, 1, 31)]).all() hdr = gr.rinexheader(fn) assert hdr['t0'] <= times[0]
def test_minimal(tmp_path): fn = R/'minimal3.10o' obs = gr.load(fn) assert isinstance(obs, xarray.Dataset), f'{type(obs)} should be xarray.Dataset' outdir = tmp_path gr.load(fn, outdir) outfn = (outdir / (fn.name + '.nc')) assert outfn.is_file() assert obs.equals(gr.load(outfn)), f'{outfn} {fn}' times = gr.gettime(fn) assert np.isnan(times.interval)
def test_obs(rinex_version): fn = R / f"minimal{rinex_version}.10o" txt = fn.read_text() with io.StringIO(txt) as f: info = gr.rinexinfo(f) assert info["rinextype"] == "obs" times = gr.gettime(f) obs = gr.load(f) assert times == datetime(2010, 3, 5, 0, 0, 30) assert obs.equals(gr.load(fn)), "StringIO not matching direct file read"
def test_nav3(rinex_version, t): fn = R / f"minimal{rinex_version}.10n" txt = fn.read_text() with io.StringIO(txt) as f: info = gr.rinexinfo(f) assert info["rinextype"] == "nav" times = gr.gettime(f) nav = gr.load(f) assert times == t assert nav.equals(gr.load(fn)), "StringIO not matching direct file read"
def test_zip(): fn = R/'ABMF00GLP_R_20181330000_01D_30S_MO.zip' obs = gr.load(fn) assert (obs.sv.values == ['E04', 'E09', 'E12', 'E24', 'G02', 'G05', 'G06', 'G07', 'G09', 'G12', 'G13', 'G17', 'G19', 'G25', 'G30', 'R01', 'R02', 'R08', 'R22', 'R23', 'R24', 'S20', 'S31', 'S35', 'S38']).all() times = gr.gettime(fn).values.astype('datetime64[us]').astype(datetime) assert (times == [datetime(2018, 5, 13, 1, 30), datetime(2018, 5, 13, 1, 30, 30), datetime(2018, 5, 13, 1, 31)]).all() hdr = gr.rinexheader(fn) assert hdr['t0'] <= times[0]
def test_obs(rinex_version): fn = R / f'minimal{rinex_version}.10o' txt = fn.read_text() with io.StringIO(txt) as f: info = gr.rinexinfo(f) assert info['rinextype'] == 'obs' times = gr.gettime(f) obs = gr.load(f) assert times == datetime(2010, 3, 5, 0, 0, 30) assert obs.equals(gr.load(fn)), 'StringIO not matching direct file read'
def test_nav3(rinex_version, t): fn = R / f'minimal{rinex_version}.10n' txt = fn.read_text() with io.StringIO(txt) as f: info = gr.rinexinfo(f) assert info['rinextype'] == 'nav' times = gr.gettime(f) nav = gr.load(f) assert times == t assert nav.equals(gr.load(fn)), 'StringIO not matching direct file read'
def test_minimal(): fn = R/'minimal3.10o' obs = gr.load(fn) assert isinstance(obs, xarray.Dataset), f'{type(obs)} should be xarray.Dataset' with tempfile.TemporaryDirectory() as outdir: outdir = Path(outdir) gr.load(fn, outdir) outfn = (outdir / (fn.name + '.nc')) assert outfn.is_file() assert obs.equals(gr.load(outfn)), f'{outfn} {fn}' times = gr.gettime(fn) assert np.isnan(times.interval)
def test_one_sv(): obs = gr.load(R / 'rinex2onesat.10o') assert len(obs.sv) == 1 assert obs.sv.item() == 'G13' times = gr.gettime( R / 'rinex2onesat.10o').values.astype('datetime64[us]').astype(datetime) assert (times == [ datetime(2010, 3, 5, 0, 0), datetime(2010, 3, 5, 0, 0, 30) ]).all() assert obs.fast_processing
def test_tlim(fn, tlim, tref, tlen): """ Important test, be sure it's runnable on all systems """ dat = gr.load(fn, tlim=tlim) times = gr.to_datetime(dat.time) assert (times == tref).all() if dat.rinextype == 'obs' and 2 <= dat.version < 3: assert dat.fast_processing alltimes = gr.gettime(fn) assert isinstance(alltimes, np.ndarray) assert alltimes.size == tlen assert np.isin(times, alltimes).size == times.size
def test_zip(fname): fn = R / fname obs = gr.load(fn) assert ( obs.sv.values == [ "E04", "E09", "E12", "E24", "G02", "G05", "G06", "G07", "G09", "G12", "G13", "G17", "G19", "G25", "G30", "R01", "R02", "R08", "R22", "R23", "R24", "S20", "S31", "S35", "S38", ] ).all() times = gr.gettime(fn) assert times.tolist() == [ datetime(2018, 5, 13, 1, 30), datetime(2018, 5, 13, 1, 30, 30), datetime(2018, 5, 13, 1, 31), ] hdr = gr.rinexheader(fn) assert hdr["t0"] <= times[0]
def test_zip(): fn = R / "ABMF00GLP_R_20181330000_01D_30S_MO.zip" obs = gr.load(fn) assert (obs.sv.values == [ "E04", "E09", "E12", "E24", "G02", "G05", "G06", "G07", "G09", "G12", "G13", "G17", "G19", "G25", "G30", "R01", "R02", "R08", "R22", "R23", "R24", "S20", "S31", "S35", "S38", ]).all() times = gr.gettime(fn) assert (times == [ datetime(2018, 5, 13, 1, 30), datetime(2018, 5, 13, 1, 30, 30), datetime(2018, 5, 13, 1, 31), ]).all() hdr = gr.rinexheader(fn) assert hdr["t0"] <= times[0]
def test_minimal(tmp_path, filename): pytest.importorskip("netCDF4") fn = R / filename dat = gr.load(fn) assert isinstance(dat, xarray.Dataset), f"{type(dat)} should be xarray.Dataset" gr.load(fn, tmp_path) outfn = tmp_path / (fn.name + ".nc") assert dat.equals(gr.load(outfn)), f"{outfn} {fn}" times = gr.gettime(fn) assert times.size == 1 if dat.rinextype == "obs": if int(dat.version) == 2: assert dat.fast_processing elif int(dat.version) == 3: assert not dat.fast_processing # FIXME: update when OBS3 fast processing is added.
def test_minimal(tmp_path, filename): pytest.importorskip('netCDF4') fn = R/filename dat = gr.load(fn) assert isinstance(dat, xarray.Dataset), f'{type(dat)} should be xarray.Dataset' gr.load(fn, tmp_path) outfn = (tmp_path / (fn.name + '.nc')) assert dat.equals(gr.load(outfn)), f'{outfn} {fn}' times = gr.gettime(fn) assert times.size == 1 if dat.rinextype == 'obs': if int(dat.version) == 2: assert dat.fast_processing elif int(dat.version) == 3: assert not dat.fast_processing # FIXME: update when OBS3 fast processing is added.
def test_blank_times(filename): times = gr.gettime(R / filename) assert times.size == 0
def test_time(): times = gr.gettime(R / 'VILL00ESP_R_20181700000_01D_MN.rnx.gz') assert times[0] == datetime(2018, 4, 24, 8) assert times[-1] == datetime(2018, 6, 20, 22)
def test_blank_times(filename): times = gr.gettime(R/filename) assert times.size == 0
def test_time(): times = gr.gettime(R / "ab422100.18n") assert times[0] == datetime(2018, 7, 29, 1, 59, 44) assert times[-1] == datetime(2018, 7, 30)
def __init__(self, rinex_file): self._hdr = gr.rinexheader(rinex_file) self.times = gr.gettime(rinex_file) self.file = rinex_file self.T01_file = rinex_file.replace('rnx', 'T01') self.rinex_filename = ''
def test_time(fname): times = gr.gettime(R / fname) assert times[0] == datetime(2018, 4, 24, 8) assert times[-1] == datetime(2018, 6, 20, 22)
def test_time(): times = gr.gettime(R/'ab422100.18n') assert times[0] == datetime(2018, 7, 29, 1, 59, 44) assert times[-1] == datetime(2018, 7, 30)
def read_rinex(file): brdc = gr.load(file) times = gr.gettime(file) return brdc