Skip to content

Commit

Permalink
fixed small bugs in various tools
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinemlarson committed Jan 23, 2025
1 parent aa574e8 commit 3c8ecbf
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 50 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## 3.10.7

Fixed bug in check_rinex_file

Added nz archive to Rinex3 30 second list in download_rinex

Made better error messages for nmea2snr, added debug option so you aren't behind
a try. And parallel processing is segregated.

Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# gnssrefl v3.10.6
# gnssrefl v3.10.7

gnssrefl is an open source software package for GNSS Interferometric Reflectometry (GNSS-IR).
When showing results created using gnssrefl, please use:
Expand Down Expand Up @@ -59,11 +59,14 @@ If you want to access to any Earthscope data, [an account is required](https://d
GNSS-IR was developed with funding from NSF (ATM 0740515, EAR 0948957, AGS 0935725, EAR 1144221, AGS 1449554) and
NASA (NNX12AK21G and NNX13AF43G). <code>gnssrefl</code> was initially developed
as a fun post-retirement project, followed by support from NASA (80NSSC20K1731).

The [CRC 1502 DETECT project](https://sfb1502.de/) and the University of Bonn supported this project from 2022-2024.

I am not funded to give courses on using <code>gnssrefl</code>. If you are interested in
hosting a GNSS-IR workshop, as was done by the Earth Observatory of Singapore in
2022, please feel free to contact me.

Kristine M. Larson

March 19, 2024
January 19, 2025


141 changes: 100 additions & 41 deletions gnssrefl/check_rinex_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys


def check_l2(i,savebase,nsat_line1, lines,nlin,l2index,year,doy):
def check_l2(i,savebase,nsat_line1, lines,nlin,l2index,year,doy,screenstats):
"""
Parameters
----------
Expand All @@ -18,11 +18,13 @@ def check_l2(i,savebase,nsat_line1, lines,nlin,l2index,year,doy):
nlin : int
number of lines per satellite allocated in RINEX file
l2index : int
index of L1 observable
index of L2 observable
year : int
full year
doy : int
day of year
screenstats : bool
print extra info to the screen
"""
l2c_sat, l5_sat = g.l2c_l5_list(year,doy)
Expand All @@ -35,38 +37,79 @@ def check_l2(i,savebase,nsat_line1, lines,nlin,l2index,year,doy):
base3 = lines[i+3][31:80].strip()
savebase = savebase + base3
ii = i + 4
if (nsat_line1 > 36):
print('Too many satellites - submit a PR to update the code.')
sys.exit()

print('Satellites at first epoch:', savebase, '\n')
lines2read = nsat_line1 * nlin
#print('linesto read ', lines2read)
isat = 0 ; l2psats = 0; foundGPS = 0 ; l2cfound = 0
total_gps = 0

# startI is to start the incrementing in the right line
# l2i is the index on a single line (rather than how RINEX stored it)
if l2index < 5:
startI = 0
l2i = l2index*16
elif l2index >= 5 | l2index < 10:
startI = 1
l2i = (l2index - 5)*16
elif l2index >= 10:
startI = 2
l2i = (l2index - 10)*16
else:
print('Too many observables - I am tired of reading RINEX 2.11 files.')
print('Feel free to fix this code and submit a pull request')
sys.exit()

if screenstats:
print('loop' , ii, ii+lines2read, nlin)
for ij in range(ii, ii+lines2read,nlin):
if savebase[isat:isat+1] == 'G':
if savebase[isat:isat+1] != 'G':
#print('Skipping ', savebase[isat:isat+3])
okok = 1
else:
foundGPS = foundGPS + 1
GPSnum = int ( savebase[isat+1:isat+3] )
total_gps = total_gps + 1
if GPSnum in l2c_sat:
print('found GPS satellite in L2C list ', GPSnum)
if screenstats:
print('found GPS satellite that could be L2C quality ', GPSnum)
l2cfound = l2cfound + 1

for k in range(0,nlin):
if (l2index < 5+k*5) and (l2index > k*5):
eek = l2index*16
l2obs = lines[ij+k][eek:eek+16]
if l2obs[12:15] == ' ':
else:
if screenstats:
print('found non-L2C transmitting GPS satellite ', GPSnum)


for k in range(startI,startI+1):
eek = lines[ij+k][l2i:l2i+16]
if screenstats:
print('Checking LLI status on ', eek)
# 4 is what RINEX 2.11 uses for non-code tracking
if (eek[14:15] == ' '):
if screenstats:
print(' possibly good L2C data')
elif (eek[14:15] =='0') :
if screenstats:
print(' possibly good L2C data')
else:
if (int(eek[14:15]) >= 4):
l2psats = l2psats + 1
foundGPS = foundGPS - 1 # since there really was no obs
else:
if l2obs[14:15] == ' ':
#print('blank')
okok = 1
else:
if int(l2obs[14:15]) > 0:
l2psats = l2psats + 1
if screenstats:
print(' Unfortunately this appears to be low-quality L2P data')
if float(eek[0:14]) == 0:
if screenstats:
print(' Observation appears to be zero. So that is not good')
l2psats = l2psats + 1


isat = isat + 3

print('\nFound ', l2cfound, ' GPS satellites that could possibly be L2C in first epoch')
print('Of those, your file has ', foundGPS-l2psats, ' valid L2C SNR observations')
print('Your file seems to have ', total_gps-l2psats, ' valid L2C SNR observations')

def check_rinex_file(rinexfile):
def check_rinex_file(rinexfile,screenstats):
"""
commandline tool to look at header information in a RINEX file
tries to look for existence of L2C data
Expand All @@ -80,6 +123,8 @@ def check_rinex_file(rinexfile):
----------
rinexfile : str
name of the RINEX 2.11 file
screenstats : bool
extra info sent to the screen
"""
last = rinexfile[-12:]
Expand All @@ -97,33 +142,40 @@ def check_rinex_file(rinexfile):
#print('reading ', line)
eoh+=1
base = line[0:60].strip()
if ("END OF HEADER" in line) or (eoh > 150):
if ("END OF HEADER" in line) or (eoh > 250):

print('Observables: ',obs)
observables = obs.split()
#print(Nobservables)
if numobs > 20:
print('Too many observables for this simple code.')
print('Current max is 20 ... feel free to submit PR')
sys.exit()
# first line of satellites
base = lines[i+1][0:60].strip()
savebase = lines[i+1][32:80].strip()

nsat_line1 = int(base[28:31])
print('Number of satellites ' , nsat_line1)
print('Number of satellites at first epoch: ' , nsat_line1)
base2 = ''
ii = i+2 # this is an index in the RINEX file
if 'L2' in observables:
l2index = observables.index('L2')
print('l2index',l2index)
check_l2(i,savebase,nsat_line1, lines,nlin,l2index,year,doy)
if screenstats:
print('l2index in python speak ',l2index)
check_l2(i,savebase,nsat_line1, lines,nlin,l2index,year,doy,screenstats)

else:
print('\nWe cannot check for L2C unless the L2 observable is present')

print('\n')
if ('G' in savebase):
print('Found GPS Data')
if ('E' in savebase):
print('Found Galileo Data')
if ('R' in savebase):
print('Found Glonass Data')
print('\n')
#print('\n')
#if ('G' in savebase):
# print('Found GPS Data')
#if ('E' in savebase):
# print('Found Galileo Data')
#if ('R' in savebase):
# print('Found Glonass Data')
#print('\n')
break
else:
desc = line[60:80].strip()
Expand Down Expand Up @@ -158,17 +210,20 @@ def check_rinex_file(rinexfile):


if ('S' not in obs):
print('WARNING: no SNR observables in this file')
else:
if 'S1' in obs:
print('L1 SNR data column found')
if 'S2' in obs:
print('L2 SNR data column found')
if 'S5' in obs:
print('L5 SNR data column found')
print('WARNING: no SNR observables in this file. Exiting')
sys.exit()
#else:
# if 'S1' in obs:
# print('L1 SNR data column found')
# if 'S2' in obs:
# print('L2 SNR data column found')
# if 'S5' in obs:
# print('L5 SNR data column found')

if (recx == 0) or (recy == 0):
print('WARNING: useful receiver coordinates are not provided.')
print('You need coordinates for gnssrefl to work properly. Exiting.')
sys.exit()
else:
print('File was not found ', rinexfile)
return
Expand All @@ -177,10 +232,14 @@ def main():

parser = argparse.ArgumentParser()
parser.add_argument("rinexfile", help="rinexfile 2.11 name", type=str)
parser.add_argument("-screenstats", help="extra info will print to screen, default F. ", type=str)
args = parser.parse_args()
screenstats = False
if args.screenstats == 'T':
screenstats = True
rinexfile = args.rinexfile
if os.path.exists(rinexfile):
check_rinex_file(rinexfile)
check_rinex_file(rinexfile,screenstats)
else:
print('Your input file: ', rinexfile, ' does not exist ')

Expand Down
2 changes: 1 addition & 1 deletion gnssrefl/download_rinex.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def download_rinex(station: str, year: int, month: int, day: int, rate: str = 'l
archive_list_high = ['gnet','bkg','unavco', 'nrcan', 'ga'] # though it is confusing because some are rinex 2.11 and others 3

# archive list for rinex3 lowrate files
archive_list_rinex3 = ['unavco', 'bkg','cddis', 'ga', 'bev', 'ign', 'epn', 'bfg','sonel','all','nrcan','gfz','gnet']
archive_list_rinex3 = ['unavco', 'bkg','cddis', 'ga', 'bev', 'ign', 'epn', 'bfg','sonel','all','nrcan','gfz','gnet','nz']

if doy_end is None:
doy_end = doy
Expand Down
2 changes: 2 additions & 0 deletions gnssrefl/karnak_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def universal(station9ch, year, doy, archive,srate,stream,debug=False):
subprocess.call(['gunzip', file_name])
file_name = file_name[0:-3]
print('Now', file_name)
else:
print('Did not find the file ')
return file_name, foundit


Expand Down
11 changes: 7 additions & 4 deletions gnssrefl/ymd.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
# -*- coding: utf-8 -*-
import argparse
import sys
import gnssrefl.gps as g

# this requires python 3.8
#from importlib.metadata import version

def main():
"""
converts year month day to day of year and prints it to the screen
converts year,month, day to day of year and prints it to the screen
MJD is an optional output
Parameters
----------
year : int
4 ch year
month : int
calendar month
day : int
calendar day
mjd : str
use T or True to get MJD printed to the screen
Expand All @@ -43,6 +41,11 @@ def main():
month = args.month
day = args.day

if (month > 13) or (month < 1):
print('Illegal month', month); sys.exit()
if (day > 31) or (day< 1):
print('Illegal day ', day); sys.exit()

doy,cdoy,cyyyy,cyy = g.ymd2doy(year, month, day )
print(cdoy)
if args.mjd is not None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "mesonpy"

[project]
name = "gnssrefl"
version = "3.10.6"
version = "3.10.7"
description = "A GNSS reflectometry software package "
readme = "README.md"
maintainers = [
Expand Down

0 comments on commit 3c8ecbf

Please sign in to comment.