Skip to content

Commit

Permalink
Merge 6ed7d61 into de44b8b
Browse files Browse the repository at this point in the history
  • Loading branch information
nmayorov committed Nov 1, 2018
2 parents de44b8b + 6ed7d61 commit 5bd3f0e
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 95 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ rnx2crx

.mypy_cache/
.pytest_cache/
data/
*.nc
*.h5
*.15*
Expand Down
28 changes: 28 additions & 0 deletions georinex/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
def rinex_string_to_float(x: str) -> float:
return float(x.replace('D', 'E'))


def determine_time_system(header: dict) -> str:
"""Determine which time system is used in an observation file."""
# Current implementation is quite inconsistent in terms what is put into
# header.
try:
file_type = header['RINEX VERSION / TYPE'][40]
except KeyError:
file_type = header['systems']
if file_type == 'G':
return 'GPS'
elif file_type == 'R':
return 'GLO'
elif file_type == 'E':
return 'GAL'
elif file_type == 'J':
return 'QZS'
elif file_type == 'C':
return 'BDT'
elif file_type == 'I':
return 'IRN'

# Else the type is mixed and the time system must be specified in
# TIME OF FIRST OBS row.
return header['TIME OF FIRST OBS'][48:51]
4 changes: 0 additions & 4 deletions georinex/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,3 @@ def rinexinfo(f: Union[Path, TextIO]) -> Dict[str, Any]:
raise ValueError(f'not a known/valid RINEX file. {e}')

return info


def rinex_string_to_float(x: str) -> float:
return float(x.replace('D', 'E'))
5 changes: 3 additions & 2 deletions georinex/nav2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import xarray
import numpy as np
import logging
from .io import opener, rinexinfo, rinex_string_to_float
from .io import opener, rinexinfo
from .common import rinex_string_to_float
#
STARTCOL2 = 3 # column where numerical data starts for RINEX 2
Nl = {'G': 7, 'R': 3, 'E': 7} # number of additional SV lines
Expand Down Expand Up @@ -126,7 +127,7 @@ def rinexnav2(fn: Path,
# %% other attributes
nav.attrs['version'] = header['version']
nav.attrs['filename'] = fn.name
nav.attrs['svtype'] = svtype
nav.attrs['svtype'] = [svtype] # Use list for consistency with NAV3.
nav.attrs['rinextype'] = 'nav'

if 'ION ALPHA' in header and 'ION BETA' in header:
Expand Down
3 changes: 2 additions & 1 deletion georinex/nav3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import math
from io import BytesIO
from datetime import datetime
from .io import opener, rinexinfo, rinex_string_to_float
from .io import opener, rinexinfo
from .common import rinex_string_to_float
from typing import Dict, List, Any, Sequence, Optional
from typing.io import TextIO
# constants
Expand Down
2 changes: 2 additions & 0 deletions georinex/obs2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pymap3d import ecef2geodetic
except ImportError:
ecef2geodetic = None
from .common import determine_time_system


def rinexobs2(fn: Path,
Expand Down Expand Up @@ -257,6 +258,7 @@ def rinexsystem2(fn: Path,
obs.attrs['rinextype'] = 'obs'
obs.attrs['toffset'] = toffset
obs.attrs['fast_processing'] = int(fast) # bool is not allowed in NetCDF4
obs.attrs['time_system'] = determine_time_system(hdr)

try:
obs.attrs['position'] = hdr['position']
Expand Down
2 changes: 2 additions & 0 deletions georinex/obs3.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
except ImportError:
ecef2geodetic = None
#
from .common import determine_time_system
"""https://github.com/mvglasow/satstat/wiki/NMEA-IDs"""
SBAS = 100 # offset for ID
GLONASS = 37
Expand Down Expand Up @@ -89,6 +90,7 @@ def rinexobs3(fn: Path,
data.attrs['filename'] = fn.name
data.attrs['version'] = hdr['version']
data.attrs['rinextype'] = 'obs'
data.attrs['time_system'] = determine_time_system(hdr)

try:
data.attrs['position'] = hdr['position']
Expand Down
21 changes: 21 additions & 0 deletions tests/data/default_time_system2.10o
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
2.11 OBSERVATION DATA R (GLONASS) RINEX VERSION / TYPE
7 L1 L2 P1 P2 C1 S1 S2 # / TYPES OF OBSERV
2010 3 5 0 0 0.0000000 TIME OF FIRST OBS
END OF HEADER
10 3 5 0 0 30.0000000 0 8G13R19G32G 7R23G31G20R11
130321269.80108 101549030.34908 24799319.672 9 24799319.752 9 24799318.768 7
62.000 80.000
129262004.57708 24597748.629 7
47.000
133135049.38708 103741584.18208 25334766.349 9 25334768.879 9 25334766.309 7
75.000 83.000
133174968.81808 103772690.97708 25342359.815 9 25342359.952 9 25342359.370 7
65.000 45.000
119323293.47908 22706470.024 7
79.000
114311363.56508 92979182.85108 21752728.352 9 21752728.204 9 21752729.338 7
72.000 63.000
135891004.29908 105889081.83208 25859215.981 9 25859207.736 9 25859205.875 7
44.000 46.000
131986783.86108 25116253.066 7
38.000
15 changes: 15 additions & 0 deletions tests/data/default_time_system3.10o
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
3.01 OBSERVATION DATA E (Galileo) RINEX VERSION / TYPE
G 7 L1C L2P C1P C2P C1C S1P S2P SYS / # / OBS TYPES
R 3 L1C C1C S1C SYS / # / OBS TYPES
S 3 L1C C1C S1C SYS / # / OBS TYPES
2010 3 5 0 0 0.0000000 TIME OF FIRST OBS
END OF HEADER
> 2010 03 05 00 00 30.0000000 0 8
G13 130321269.80108 101549030.34908 24799319.672 9 24799319.752 9 24799318.768 7 62.000 80.000
R19 129262004.57708 24597748.629 7 47.000
G32 133135049.38708 103741584.18208 25334766.349 9 25334768.879 9 25334766.309 7 75.000 83.000
G 7 133174968.81808 103772690.97708 25342359.815 9 25342359.952 9 25342359.370 7 65.000 45.000
R23 119323293.47908 22706470.024 7 79.000
G31 114311363.56508 92979182.85108 21752728.352 9 21752728.204 9 21752729.338 7 72.000 63.000
G20 135891004.29908 105889081.83208 25859215.981 9 25859207.736 9 25859205.875 7 44.000 46.000
R11 131986783.86108 25116253.066 7 38.000
170 changes: 85 additions & 85 deletions tests/data/demo.10o
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
2.11 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE
BLANK OR G = GPS, R = GLONASS, E = GALILEO, M = MIXED COMMENT
gLAB gAGE 17-MAR-10 12:14 PGM / RUN BY / DATE
EXAMPLE OF A MIXED RINEX FILE COMMENT
MRKR MARKER NAME
9080.1.34 MARKER NUMBER
gAGE UPC: Technical University of Catalonia OBSERVER / AGENCY
THIS FILE IS PART OF THE gLAB TOOL SUITE COMMENT
FILE PREPARED BY: ADRIA ROVIRA GARCIA COMMENT
PLEASE EMAIL ANY COMMENT OR REQUEST TO: glab @ gage.es COMMENT
IR2200716006 ASHTECH UZ-12 CQ00 REC # / TYPE / VERS
482 AOAD/M_T NONE ANT # / TYPE
4789028.4701 176610.0133 4195017.0310 APPROX POSITION XYZ
0.9030 0.0000 0.0000 ANTENNA: DELTA H/E/N
1 1 WAVELENGTH FACT L1/2
1 2 3 G14 G18 G19 WAVELENGTH FACT L1/2
7 L1 L2 P1 P2 C1 S1 S2 # / TYPES OF OBSERV
30.000 INTERVAL
2010 3 5 0 0 0.0000000 GPS TIME OF FIRST OBS
2010 3 5 23 59 30.0000000 GPS TIME OF LAST OBS
1 RCV CLOCK OFFS APPL
15 LEAP SECONDS
14 # OF SATELLITES
G07 815 815 815 815 815 815 815 PRN / # OF OBS
G09 246 246 246 246 246 246 246 PRN / # OF OBS
G12 687 687 687 687 687 687 687 PRN / # OF OBS
G13 762 762 762 762 762 762 762 PRN / # OF OBS
G15 454 454 454 454 454 454 454 PRN / # OF OBS
G20 599 599 599 599 599 599 599 PRN / # OF OBS
G21 636 636 636 636 636 636 636 PRN / # OF OBS
G26 210 210 210 210 210 210 210 PRN / # OF OBS
G31 874 874 874 874 874 874 874 PRN / # OF OBS
G32 457 457 457 457 457 457 457 PRN / # OF OBS
R11 907 907 907 PRN / # OF OBS
R19 348 348 348 PRN / # OF OBS
R23 936 936 936 PRN / # OF OBS
S24 198 198 198 PRN / # OF OBS
END OF HEADER
10 3 5 0 0 0.0000000 0 14G13R19G32G 7R23G31G20R11G12G26G 9G21 -0.12345
G15S24
121367582.20508 94572134.49208 23095489.677 9 23095481.949 9 23095483.463 7
42.000 40.000
134357446.85408 23095483.463 7
51.000
34357446.85408 104694102.10708 25567381.585 9 25567371.841 9 25567379.659 7
76.000 84.000
118767195.32608 91018570.22508 22600658.277 9 22600648.232 9 22227666.760 7
57.000 32.000
132798887.20808 22600648.288 7
39.000
130586522.29708 101755719.98608 24849779.954 9 24849799.921 9 24849797.341 7
56.000 24.000
135891004.29908 105889081.83208 25859215.981 9 25859207.736 9 25859205.875 7
44.000 46.000
132678281.64008 25247845.883 7
38.000
106712807.73208 83152833.16108 20306772.310 9 20306771.779 9 20306772.510 7
44.000 46.000
116571368.18108 90834826.58108 22182792.370 9 22182793.119 9 22182794.240 7
35.000 27.000
132197034.89008 103010636.32308 25156289.677 9 25156300.244 9 25156289.059 7
51.000 40.000
119360658.19908 93008298.09808 22713580.654 9 22713581.674 9 22713580.663 7
78.000 35.000
117320174.24208 91418311.51708 22325286.941 9 22325287.194 9 22325287.806 7
63.000 65.000
195486861.41208 37199916.954 7
45.000
10 3 5 0 0 30.0000000 0 8G13R19G32G 7R23G31G20R11 -0.12345
130321269.80108 101549030.34908 24799319.672 9 24799319.752 9 24799318.768 7
62.000 80.000
129262004.57708 24597748.629 7
47.000
133135049.38708 103741584.18208 25334766.349 9 25334768.879 9 25334766.309 7
75.000 83.000
133174968.81808 103772690.97708 25342359.815 9 25342359.952 9 25342359.370 7
65.000 45.000
119323293.47908 22706470.024 7
79.000
114311363.56508 92979182.85108 21752728.352 9 21752728.204 9 21752729.338 7
72.000 63.000
135891004.29908 105889081.83208 25859215.981 9 25859207.736 9 25859205.875 7
44.000 46.000
131986783.86108 25116253.066 7
38.000
2.11 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE
BLANK OR G = GPS, R = GLONASS, E = GALILEO, M = MIXED COMMENT
gLAB gAGE 17-MAR-10 12:14 PGM / RUN BY / DATE
EXAMPLE OF A MIXED RINEX FILE COMMENT
MRKR MARKER NAME
9080.1.34 MARKER NUMBER
gAGE UPC: Technical University of Catalonia OBSERVER / AGENCY
THIS FILE IS PART OF THE gLAB TOOL SUITE COMMENT
FILE PREPARED BY: ADRIA ROVIRA GARCIA COMMENT
PLEASE EMAIL ANY COMMENT OR REQUEST TO: glab @ gage.es COMMENT
IR2200716006 ASHTECH UZ-12 CQ00 REC # / TYPE / VERS
482 AOAD/M_T NONE ANT # / TYPE
4789028.4701 176610.0133 4195017.0310 APPROX POSITION XYZ
0.9030 0.0000 0.0000 ANTENNA: DELTA H/E/N
1 1 WAVELENGTH FACT L1/2
1 2 3 G14 G18 G19 WAVELENGTH FACT L1/2
7 L1 L2 P1 P2 C1 S1 S2 # / TYPES OF OBSERV
30.000 INTERVAL
2010 3 5 0 0 0.0000000 GPS TIME OF FIRST OBS
2010 3 5 23 59 30.0000000 GPS TIME OF LAST OBS
1 RCV CLOCK OFFS APPL
15 LEAP SECONDS
14 # OF SATELLITES
G07 815 815 815 815 815 815 815 PRN / # OF OBS
G09 246 246 246 246 246 246 246 PRN / # OF OBS
G12 687 687 687 687 687 687 687 PRN / # OF OBS
G13 762 762 762 762 762 762 762 PRN / # OF OBS
G15 454 454 454 454 454 454 454 PRN / # OF OBS
G20 599 599 599 599 599 599 599 PRN / # OF OBS
G21 636 636 636 636 636 636 636 PRN / # OF OBS
G26 210 210 210 210 210 210 210 PRN / # OF OBS
G31 874 874 874 874 874 874 874 PRN / # OF OBS
G32 457 457 457 457 457 457 457 PRN / # OF OBS
R11 907 907 907 PRN / # OF OBS
R19 348 348 348 PRN / # OF OBS
R23 936 936 936 PRN / # OF OBS
S24 198 198 198 PRN / # OF OBS
END OF HEADER
10 3 5 0 0 0.0000000 0 14G13R19G32G 7R23G31G20R11G12G26G 9G21 -0.12345
G15S24
121367582.20508 94572134.49208 23095489.677 9 23095481.949 9 23095483.463 7
42.000 40.000
134357446.85408 23095483.463 7
51.000
34357446.85408 104694102.10708 25567381.585 9 25567371.841 9 25567379.659 7
76.000 84.000
118767195.32608 91018570.22508 22600658.277 9 22600648.232 9 22227666.760 7
57.000 32.000
132798887.20808 22600648.288 7
39.000
130586522.29708 101755719.98608 24849779.954 9 24849799.921 9 24849797.341 7
56.000 24.000
135891004.29908 105889081.83208 25859215.981 9 25859207.736 9 25859205.875 7
44.000 46.000
132678281.64008 25247845.883 7
38.000
106712807.73208 83152833.16108 20306772.310 9 20306771.779 9 20306772.510 7
44.000 46.000
116571368.18108 90834826.58108 22182792.370 9 22182793.119 9 22182794.240 7
35.000 27.000
132197034.89008 103010636.32308 25156289.677 9 25156300.244 9 25156289.059 7
51.000 40.000
119360658.19908 93008298.09808 22713580.654 9 22713581.674 9 22713580.663 7
78.000 35.000
117320174.24208 91418311.51708 22325286.941 9 22325287.194 9 22325287.806 7
63.000 65.000
195486861.41208 37199916.954 7
45.000
10 3 5 0 0 30.0000000 0 8G13R19G32G 7R23G31G20R11 -0.12345
130321269.80108 101549030.34908 24799319.672 9 24799319.752 9 24799318.768 7
62.000 80.000
129262004.57708 24597748.629 7
47.000
133135049.38708 103741584.18208 25334766.349 9 25334768.879 9 25334766.309 7
75.000 83.000
133174968.81808 103772690.97708 25342359.815 9 25342359.952 9 25342359.370 7
65.000 45.000
119323293.47908 22706470.024 7
79.000
114311363.56508 92979182.85108 21752728.352 9 21752728.204 9 21752729.338 7
72.000 63.000
135891004.29908 105889081.83208 25859215.981 9 25859207.736 9 25859205.875 7
44.000 46.000
131986783.86108 25116253.066 7
38.000

0 comments on commit 5bd3f0e

Please sign in to comment.