diff --git a/MANIFEST.in b/MANIFEST.in index 065cc87..ac99775 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,3 @@ include LICENSE recursive-include tests *.py +recursive-include tests/data * diff --git a/georinex/nav2.py b/georinex/nav2.py index d1eaf14..960357f 100644 --- a/georinex/nav2.py +++ b/georinex/nav2.py @@ -108,7 +108,12 @@ def rinexnav2(fn: Path, for i in svi: it = np.nonzero(timesu == times[i])[0][0] # int by defn - data[:, it, j] = [float(raws[i][k*Lf:(k+1)*Lf]) for k in range(len(fields))] + """ + some files sometimes drop the last measurement, this fixes that. + It assumes the blank is always in the last measurement for now. + """ + dvec = [float(raws[i][k*Lf:(k+1)*Lf]) for k in range(min(len(fields), len(raws[i])//Lf))] + data[:len(dvec), it, j] = dvec # %% assemble output # NOTE: time must be datetime64[ns] or .to_netcdf will fail diff --git a/georinex/plots.py b/georinex/plots.py index 51004ba..e115948 100644 --- a/georinex/plots.py +++ b/georinex/plots.py @@ -1,6 +1,7 @@ import xarray import pandas import logging +import numpy as np from matplotlib.pyplot import figure try: @@ -55,7 +56,10 @@ def receiver_locations(locs: pandas.DataFrame): else: # large or undefined interval c = 'b' - ax.scatter(loc.lon, loc.lat, s=1000*1/loc.interval, c=c, label=name) + if np.isfinite(loc.interval): + ax.scatter(loc.lon, loc.lat, s=1000*1/loc.interval, c=c, label=name) + else: + ax.scatter(loc.lon, loc.lat, c=c, label=name) def navtimeseries(nav: xarray.Dataset): diff --git a/georinex/utils.py b/georinex/utils.py index e484aec..4c23b53 100644 --- a/georinex/utils.py +++ b/georinex/utils.py @@ -13,6 +13,10 @@ def globber(path: Path, glob: Sequence[str]) -> List[Path]: + path = Path(path).expanduser() + if path.is_file(): + return [path] + if isinstance(glob, str): glob = [glob] @@ -69,10 +73,14 @@ def getlocations(flist: Sequence[Path]) -> pandas.DataFrame: columns=['lat', 'lon', 'interval']) for f in flist: - try: - hdr = rinexheader(f) - except ValueError: - continue + if f.suffix == '.nc': + dat = xarray.open_dataset(f, group='OBS') + hdr = dat.attrs + else: + try: + hdr = rinexheader(f) + except ValueError: + continue if 'position_geodetic' not in hdr: continue diff --git a/setup.cfg b/setup.cfg index b02ad64..4518054 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = georinex -version = 1.6.7 +version = 1.6.7.1 author = Michael Hirsch, Ph.D. author_email = scivision@users.noreply.github.com description = Python RINEX 2/3 NAV/OBS reader with speed and simplicity. diff --git a/tests/14601736.18n b/tests/data/14601736.18n similarity index 100% rename from tests/14601736.18n rename to tests/data/14601736.18n diff --git a/tests/14601736.18o b/tests/data/14601736.18o similarity index 100% rename from tests/14601736.18o rename to tests/data/14601736.18o diff --git a/tests/ABMF00GLP_R_20181330000_01D_30S_MO.zip b/tests/data/ABMF00GLP_R_20181330000_01D_30S_MO.zip similarity index 100% rename from tests/ABMF00GLP_R_20181330000_01D_30S_MO.zip rename to tests/data/ABMF00GLP_R_20181330000_01D_30S_MO.zip diff --git a/tests/CEBR00ESP_R_20182000000_01D_30S_MO.crx.gz b/tests/data/CEBR00ESP_R_20182000000_01D_30S_MO.crx.gz similarity index 100% rename from tests/CEBR00ESP_R_20182000000_01D_30S_MO.crx.gz rename to tests/data/CEBR00ESP_R_20182000000_01D_30S_MO.crx.gz diff --git a/tests/CEDA00USA_R_20182100000_01D_MN.rnx.gz b/tests/data/CEDA00USA_R_20182100000_01D_MN.rnx.gz similarity index 100% rename from tests/CEDA00USA_R_20182100000_01D_MN.rnx.gz rename to tests/data/CEDA00USA_R_20182100000_01D_MN.rnx.gz diff --git a/tests/CEDA00USA_R_20182100000_23H_15S_MO.rnx.gz b/tests/data/CEDA00USA_R_20182100000_23H_15S_MO.rnx.gz similarity index 100% rename from tests/CEDA00USA_R_20182100000_23H_15S_MO.rnx.gz rename to tests/data/CEDA00USA_R_20182100000_23H_15S_MO.rnx.gz diff --git a/tests/ELKO00USA_R_20182100000_01D_MN.rnx.gz b/tests/data/ELKO00USA_R_20182100000_01D_MN.rnx.gz similarity index 100% rename from tests/ELKO00USA_R_20182100000_01D_MN.rnx.gz rename to tests/data/ELKO00USA_R_20182100000_01D_MN.rnx.gz diff --git a/tests/VILL00ESP_R_20181700000_01D_MN.rnx.gz b/tests/data/VILL00ESP_R_20181700000_01D_MN.rnx.gz similarity index 100% rename from tests/VILL00ESP_R_20181700000_01D_MN.rnx.gz rename to tests/data/VILL00ESP_R_20181700000_01D_MN.rnx.gz diff --git a/tests/ab422100.18n.Z b/tests/data/ab422100.18n.Z similarity index 100% rename from tests/ab422100.18n.Z rename to tests/data/ab422100.18n.Z diff --git a/tests/ab430140.18o.zip b/tests/data/ab430140.18o.zip similarity index 100% rename from tests/ab430140.18o.zip rename to tests/data/ab430140.18o.zip diff --git a/tests/ac660270.18o.Z b/tests/data/ac660270.18o.Z similarity index 100% rename from tests/ac660270.18o.Z rename to tests/data/ac660270.18o.Z diff --git a/tests/blank.10n b/tests/data/blank.10n similarity index 100% rename from tests/blank.10n rename to tests/data/blank.10n diff --git a/tests/blank.10o b/tests/data/blank.10o similarity index 100% rename from tests/blank.10o rename to tests/data/blank.10o diff --git a/tests/blank3.10n b/tests/data/blank3.10n similarity index 100% rename from tests/blank3.10n rename to tests/data/blank3.10n diff --git a/tests/blank3.10o b/tests/data/blank3.10o similarity index 100% rename from tests/blank3.10o rename to tests/data/blank3.10o diff --git a/tests/data/brdc2420.18n.gz b/tests/data/brdc2420.18n.gz new file mode 100644 index 0000000..993f082 Binary files /dev/null and b/tests/data/brdc2420.18n.gz differ diff --git a/tests/brdc2800.15n.Z b/tests/data/brdc2800.15n.Z similarity index 100% rename from tests/brdc2800.15n.Z rename to tests/data/brdc2800.15n.Z diff --git a/tests/ceda2100.18e.Z b/tests/data/ceda2100.18e.Z similarity index 100% rename from tests/ceda2100.18e.Z rename to tests/data/ceda2100.18e.Z diff --git a/tests/demo.10n b/tests/data/demo.10n similarity index 100% rename from tests/demo.10n rename to tests/data/demo.10n diff --git a/tests/demo.10o b/tests/data/demo.10o similarity index 100% rename from tests/demo.10o rename to tests/data/demo.10o diff --git a/tests/demo.17n b/tests/data/demo.17n similarity index 100% rename from tests/demo.17n rename to tests/data/demo.17n diff --git a/tests/demo3.10n b/tests/data/demo3.10n similarity index 100% rename from tests/demo3.10n rename to tests/data/demo3.10n diff --git a/tests/demo3.10o b/tests/data/demo3.10o similarity index 100% rename from tests/demo3.10o rename to tests/data/demo3.10o diff --git a/tests/galileo3.15n b/tests/data/galileo3.15n similarity index 100% rename from tests/galileo3.15n rename to tests/data/galileo3.15n diff --git a/tests/minimal.10n b/tests/data/minimal.10n similarity index 100% rename from tests/minimal.10n rename to tests/data/minimal.10n diff --git a/tests/minimal.10o b/tests/data/minimal.10o similarity index 100% rename from tests/minimal.10o rename to tests/data/minimal.10o diff --git a/tests/minimal3.10n b/tests/data/minimal3.10n similarity index 100% rename from tests/minimal3.10n rename to tests/data/minimal3.10n diff --git a/tests/minimal3.10o b/tests/data/minimal3.10o similarity index 100% rename from tests/minimal3.10o rename to tests/data/minimal3.10o diff --git a/tests/p1462100.18g.Z b/tests/data/p1462100.18g.Z similarity index 100% rename from tests/p1462100.18g.Z rename to tests/data/p1462100.18g.Z diff --git a/tests/qzss3.14n b/tests/data/qzss3.14n similarity index 100% rename from tests/qzss3.14n rename to tests/data/qzss3.14n diff --git a/tests/r2G.nc b/tests/data/r2G.nc similarity index 100% rename from tests/r2G.nc rename to tests/data/r2G.nc diff --git a/tests/r2GR.nc b/tests/data/r2GR.nc similarity index 100% rename from tests/r2GR.nc rename to tests/data/r2GR.nc diff --git a/tests/r2_C1_indicators.nc b/tests/data/r2_C1_indicators.nc similarity index 100% rename from tests/r2_C1_indicators.nc rename to tests/data/r2_C1_indicators.nc diff --git a/tests/r2all.nc b/tests/data/r2all.nc similarity index 100% rename from tests/r2all.nc rename to tests/data/r2all.nc diff --git a/tests/r2all_indicators.nc b/tests/data/r2all_indicators.nc similarity index 100% rename from tests/r2all_indicators.nc rename to tests/data/r2all_indicators.nc diff --git a/tests/r3G.nc b/tests/data/r3G.nc similarity index 100% rename from tests/r3G.nc rename to tests/data/r3G.nc diff --git a/tests/r3GR.nc b/tests/data/r3GR.nc similarity index 100% rename from tests/r3GR.nc rename to tests/data/r3GR.nc diff --git a/tests/r3all.nc b/tests/data/r3all.nc similarity index 100% rename from tests/r3all.nc rename to tests/data/r3all.nc diff --git a/tests/r3all_indicators.nc b/tests/data/r3all_indicators.nc similarity index 100% rename from tests/r3all_indicators.nc rename to tests/data/r3all_indicators.nc diff --git a/tests/r3galileo.nc b/tests/data/r3galileo.nc similarity index 100% rename from tests/r3galileo.nc rename to tests/data/r3galileo.nc diff --git a/tests/r3gps.nc b/tests/data/r3gps.nc similarity index 100% rename from tests/r3gps.nc rename to tests/data/r3gps.nc diff --git a/tests/r3qzss.nc b/tests/data/r3qzss.nc similarity index 100% rename from tests/r3qzss.nc rename to tests/data/r3qzss.nc diff --git a/tests/r3sbas.nc b/tests/data/r3sbas.nc similarity index 100% rename from tests/r3sbas.nc rename to tests/data/r3sbas.nc diff --git a/tests/rinex2onesat.10o b/tests/data/rinex2onesat.10o similarity index 100% rename from tests/rinex2onesat.10o rename to tests/data/rinex2onesat.10o diff --git a/tests/test_batch_convert.py b/tests/test_batch_convert.py index 531fb86..d0b1060 100755 --- a/tests/test_batch_convert.py +++ b/tests/test_batch_convert.py @@ -4,7 +4,7 @@ from pathlib import Path import georinex as gr -R = Path(__file__).parent +R = Path(__file__).parent / 'data' def test_obs(): diff --git a/tests/test_conv.py b/tests/test_conv.py index 2f23bb7..d2b6e36 100755 --- a/tests/test_conv.py +++ b/tests/test_conv.py @@ -12,7 +12,7 @@ import os WIN32 = os.name == 'nt' # -R = Path(__file__).parent +R = Path(__file__).parent / 'data' @pytest.mark.xfail(WIN32, reason='Windows PermissionError for missing files') diff --git a/tests/test_hatanaka.py b/tests/test_hatanaka.py index 8617a9d..0e6b84f 100755 --- a/tests/test_hatanaka.py +++ b/tests/test_hatanaka.py @@ -6,7 +6,7 @@ from datetime import datetime import os -R = Path(__file__).parent +R = Path(__file__).parent / 'data' Rexe = Path(__file__).resolve().parents[1] / 'rnxcmp' exe = './crx2rnx' shell = False diff --git a/tests/test_nav2.py b/tests/test_nav2.py index ef03730..6ef8b4c 100755 --- a/tests/test_nav2.py +++ b/tests/test_nav2.py @@ -5,9 +5,10 @@ from pathlib import Path from datetime import datetime import georinex as gr +import numpy as np import tempfile # -R = Path(__file__).parent +R = Path(__file__).parent / 'data' def test_blank(): @@ -74,6 +75,24 @@ def test_mangled(): assert times == datetime(2018, 6, 22, 8) +def test_mangled2(): + fn = R/'brdc2420.18n.gz' + + nav = gr.load(fn) + + G10 = nav.sel(sv='G10').dropna(dim='time', how='all') + assert G10['Crc'].values == approx([221.59375, 225.7421875]) + assert np.isnan(G10['FitIntvl'][0]) + assert G10['FitIntvl'][1] == approx(4) + + times = nav.time.values.astype('datetime64[us]').astype(datetime) + assert (times == [datetime(2018, 8, 29, 22, 0), + datetime(2018, 8, 29, 23, 0), + datetime(2018, 8, 29, 23, 30), + datetime(2018, 8, 29, 23, 59, 12), + datetime(2018, 8, 29, 23, 59, 44)]).all() + + def test_tlim(): pytest.importorskip('unlzw') diff --git a/tests/test_nav3.py b/tests/test_nav3.py index 1ca75c8..e2e6e30 100755 --- a/tests/test_nav3.py +++ b/tests/test_nav3.py @@ -6,7 +6,7 @@ import tempfile from datetime import datetime # -R = Path(__file__).parent +R = Path(__file__).parent / 'data' def test_blank(): diff --git a/tests/test_obs2.py b/tests/test_obs2.py index 7cfbd43..8361fc4 100755 --- a/tests/test_obs2.py +++ b/tests/test_obs2.py @@ -8,7 +8,7 @@ import numpy as np from datetime import datetime # -R = Path(__file__).parent +R = Path(__file__).parent / 'data' def test_blank(): diff --git a/tests/test_obs3.py b/tests/test_obs3.py index 2f60258..be36f57 100755 --- a/tests/test_obs3.py +++ b/tests/test_obs3.py @@ -8,7 +8,7 @@ import georinex as gr import tempfile # -R = Path(__file__).parent +R = Path(__file__).parent / 'data' def test_blank(): diff --git a/tests/test_scripts.py b/tests/test_scripts.py index b7ba022..ff41dcd 100755 --- a/tests/test_scripts.py +++ b/tests/test_scripts.py @@ -7,7 +7,7 @@ from pathlib import Path import tempfile -R = Path(__file__).parent +R = Path(__file__).parent / 'data' def test_convenience():