Skip to content

Commit

Permalink
enhance location plot robustness, load .nc location
Browse files Browse the repository at this point in the history
handle NAV2 with intermittent missing values

data move test

pep8

vers
  • Loading branch information
scivision committed Sep 2, 2018
1 parent f3c27bf commit 7fb9cc0
Show file tree
Hide file tree
Showing 57 changed files with 52 additions and 15 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include LICENSE
recursive-include tests *.py
recursive-include tests/data *
7 changes: 6 additions & 1 deletion georinex/nav2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion georinex/plots.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import xarray
import pandas
import logging
import numpy as np
from matplotlib.pyplot import figure

try:
Expand Down Expand Up @@ -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):
Expand Down
16 changes: 12 additions & 4 deletions georinex/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = georinex
version = 1.6.7
version = 1.6.7.1
author = Michael Hirsch, Ph.D.
author_email = [email protected]
description = Python RINEX 2/3 NAV/OBS reader with speed and simplicity.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added tests/data/brdc2420.18n.gz
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_batch_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path
import georinex as gr

R = Path(__file__).parent
R = Path(__file__).parent / 'data'


def test_obs():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hatanaka.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion tests/test_nav2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion tests/test_nav3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import tempfile
from datetime import datetime
#
R = Path(__file__).parent
R = Path(__file__).parent / 'data'


def test_blank():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_obs2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
from datetime import datetime
#
R = Path(__file__).parent
R = Path(__file__).parent / 'data'


def test_blank():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_obs3.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import georinex as gr
import tempfile
#
R = Path(__file__).parent
R = Path(__file__).parent / 'data'


def test_blank():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path
import tempfile

R = Path(__file__).parent
R = Path(__file__).parent / 'data'


def test_convenience():
Expand Down

0 comments on commit 7fb9cc0

Please sign in to comment.