Skip to content

Commit

Permalink
Merge 92dce97 into 2d6d2cc
Browse files Browse the repository at this point in the history
  • Loading branch information
nmayorov committed Nov 7, 2018
2 parents 2d6d2cc + 92dce97 commit 5a3c5fa
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
26 changes: 17 additions & 9 deletions georinex/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,24 @@ def rinexinfo(f: Union[Path, TextIO]) -> Dict[str, Any]:
if not isinstance(line, str) or line[60:80] not in ('RINEX VERSION / TYPE', 'CRINEX VERS / TYPE'):
raise ValueError

info = {'version': float(line[:9]), # yes :9
'filetype': line[20],
'systems': line[40],
'hatanaka': line[20:40] == 'COMPACT RINEX FORMAT'}

if info['systems'] == ' ':
if info['filetype'] == 'N' and int(info['version']) == 2: # type: ignore
info['systems'] = 'G'
version = float(line[:9])
file_type = line[20]
if int(version) == 2:
if file_type == 'N':
system = 'G'
elif file_type == 'G':
system = 'R'
elif file_type == 'E':
system = 'E'
else:
info['systems'] = info['filetype']
system = line[40]
else:
system = line[40]

info = {'version': version,
'filetype': file_type,
'systems': system,
'hatanaka': line[20:40] == 'COMPACT RINEX FORMAT'}

except (ValueError, UnicodeDecodeError) as e:
# keep ValueError for consistent user error handling
Expand Down
7 changes: 7 additions & 0 deletions georinex/nav2.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ def rinexnav2(fn: Path,
if k is None:
continue
nav[k] = (('time', 'sv'), data[i, :, :])

# GLONASS uses kilometers to report its ephemeris.
# Convert to meters here to be consistent with NAV3 implementation.
if svtype == 'R':
for name in ['X', 'Y', 'Z', 'dX', 'dY', 'dZ', 'dX2', 'dY2', 'dZ2']:
nav[name] *= 1e3

# %% other attributes
nav.attrs['version'] = header['version']
nav.attrs['filename'] = fn.name
Expand Down
4 changes: 2 additions & 2 deletions georinex/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def rinextype(fn: Path) -> str:
else:
fnl = fn.name.lower()

if fnl.endswith(('o', 'o.rnx', 'o.crx')):
if fnl.endswith(('obs', 'o', 'o.rnx', 'o.crx')):
return 'obs'
elif fnl.endswith(('e', 'g', 'n', 'n.rnx')):
elif fnl.endswith(('nav', 'e', 'g', 'n', 'n.rnx')):
return 'nav'
elif fn.suffix.endswith('.nc'):
return 'nc'
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ io =
psutil

[tool:pytest]
minversion = 3.9
filterwarnings =
ignore::DeprecationWarning

Expand Down

0 comments on commit 5a3c5fa

Please sign in to comment.