Skip to content

Commit

Permalink
basic sanity check for mandatory headers of rinex 2/3
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed May 8, 2018
1 parent db215d2 commit c2f4fc6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pyrinex/rinex2.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ def _scan2(fn:Path, use:Union[str,list,tuple], verbose:bool=False) -> xarray.Dat
else:
header[h.strip()] += " " + c
#concatenate to the existing string


# %% sanity check that MANDATORY RINEX 2 headers exist
for h in ('RINEX VERSION / TYPE', 'APPROX POSITION XYZ', 'INTERVAL'):
if not h in header:
raise IOError('Mandatory RINEX 2 headers are missing from {fn}, is it a valid RINEX 2 file?')
# %% file seems OK, keep processing
verRinex = float(header['RINEX VERSION / TYPE'][:9]) # %9.2f
# list with x,y,z cartesian
header['APPROX POSITION XYZ'] = [float(j) for j in header['APPROX POSITION XYZ'].split()]
Expand Down
4 changes: 4 additions & 0 deletions pyrinex/rinex3.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ def _getObsTypes(f:TextIO, use:Union[str,list,tuple]) -> tuple:
# string with info
else: # concatenate to the existing string
header[h.strip()] += " " + c
# %% sanity check for Mandatory RINEX 3 headers
for h in ('APPROX POSITION XYZ',):
if not h in header:
raise IOError('Mandatory RINEX 3 headers are missing from file, is it a valid RINEX 3 file?')

# list with x,y,z cartesian
header['APPROX POSITION XYZ'] = [float(j) for j in header['APPROX POSITION XYZ'].split()]
Expand Down

0 comments on commit c2f4fc6

Please sign in to comment.