Skip to content

Commit

Permalink
v 3.6.8, fixed major bug with highrate RINEX 3 files producing bad er…
Browse files Browse the repository at this point in the history
…ror message, though it did create a SNR file bizarrely.
  • Loading branch information
kristinemlarson committed Sep 11, 2024
1 parent 189f3f7 commit 76c8f61
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 71 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ you can set that and not have to type it in the command line.
Added a few info messages in quickLook explaining why station coordinates are not needed
(though they are helpful). Also check that azim1 is < azim2.

Fixed a very stupid bug in conv2snr that was looking for RINEX files even though
they already existed (as nolook option was set and the file was found). Optional
filename now sent to conv2snr to make sure this choice is not made.

## 3.6.7

added savearcs_format option - allows pickle format which has more information
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# gnssrefl v3.6.7
# gnssrefl v3.6.8

gnssrefl is an open source software package for GNSS Interferometric Reflectometry (GNSS-IR).
When citing gnssrefl, please use:
Expand Down
5 changes: 5 additions & 0 deletions developer_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# should get rid of flipit detritus in subdaily

compile the fortran first
f2py -c -m gnssrefl.gpssnr gnssrefl/gpssnr.f



https://stackoverflow.com/questions/7053996/how-do-i-install-imagemagick-with-homebrew

https://realpython.com/pypi-publish-python-package/#version-your-package
Expand Down
11 changes: 6 additions & 5 deletions gnssrefl/gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2615,10 +2615,11 @@ def rinex_unavco_highrate(station, year, month, day):
station : str
4 ch station name
year : int
month : intr
full year
month : int
month number
day : int
calendar day number
"""
#print('in rinex_unavco_highrate')
Expand Down Expand Up @@ -3701,7 +3702,7 @@ def new_rinex3_rinex2(r3_filename,r2_filename,dec=1,gpsonly=False):
"""
This code translates a RINEX 3 file into a RINEX 2.11 file.
It is assumed that the gfzrnx exists and that the RINEX 3 file is
Hatanaka uncompressed or compressed.
Hatanaka uncompressed or compressed. (ending in rnx or crx)
Parameters
----------
Expand Down Expand Up @@ -3794,7 +3795,7 @@ def new_rinex3_rinex2(r3_filename,r2_filename,dec=1,gpsonly=False):
#print('remove RINEX3 rnx version of the file ',r3_filename_new)
subprocess.call(['rm', '-f', r3_filename_new ])

return fexists
return fexists


def ign_orbits(filename, directory,year):
Expand Down
22 changes: 12 additions & 10 deletions gnssrefl/nmea2snr.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ def fix_angle_azimuth(time, angle, azimuth):
return angle_fixed, azim_fixed

def azimuth_diff2(azim1, azim2):
"""
Someone that is not me should document this
"""
diff = azim1 - azim2
idx = (diff > +180)
diff[idx] = diff[idx] - 360
Expand All @@ -677,6 +681,8 @@ def azimuth_diff2(azim1, azim2):

def azimuth_diff1 (azim):
"""
Someone that is not me should document this
Parameters
----------
azim: ??
Expand All @@ -690,7 +696,7 @@ def azimuth_diff1 (azim):

def azimuth_diff(azim1, azim2):
"""
someone should document this
Someone that is not me should document this
Parameters
----------
Expand All @@ -712,7 +718,7 @@ def azimuth_diff(azim1, azim2):

def angle_range_positive(ang):
"""
someone should document this
This code lacks documentation
Parameters
----------
Expand All @@ -727,7 +733,7 @@ def angle_range_positive(ang):

def azimuth_mean(azim1, azim2):
"""
someone that is not me should document this
Someone that is not me should document this
Parameters
----------
Expand Down Expand Up @@ -758,22 +764,19 @@ def azimuth_mean(azim1, azim2):
def quickname(station,year,cyy, cdoy, csnr):
"""
Creates a full name of the snr file name (i.e. including the path)
>>>> Checks that directories exist.
Checks that directories exist.
Parameters
----------
station : str
4 ch station name
year : int
full year
cyy : str
two character year
cdoy : str
three character day of year
csnr : str
snr type, e.g. '66'
Expand Down Expand Up @@ -801,7 +804,6 @@ def quickname(station,year,cyy, cdoy, csnr):

def elev_limits(snroption):
"""
Given a snr option, return the elevation angle limits
Parameters
Expand Down Expand Up @@ -833,7 +835,7 @@ def elev_limits(snroption):

def run_nmea2snr(station, year, doy, isnr, overwrite, dec, llh, recv, sp3, gzip,orb,hour):
"""
runs the nmea2snr conversion code - ONE DAY AT A TIME (2024 March 16)
runs the nmea2snr conversion code
Looks for NMEA files in $REFL_CODE/nmea/ssss/2023 for station ssss and year 2023.
I prefer lowercase station names, but I believe the code allows both upper and lower
Expand Down
69 changes: 44 additions & 25 deletions gnssrefl/rinex2snr.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,12 @@ def run_rinex2snr(station, year, doy, isnr, orbtype, rate,dec_rate,archive, nol
print(localpath2)
if nol:
current_local = os.getcwd()
print('Will first assume RINEX file ', station, ' year:', year, ' doy:', doy, 'is located here :', current_local)
print('Looking for the RINEX file on your machine')
print('Will first assume station ', station, ' year:', year, ' doy:', doy, 'is located here :', current_local)
# this assumes RINEX file is in local directory or "nearby"
if version == 2:

if screenstats:
print('Version 2.11')
if mk:
the_makan_option(station,cyyyy,cyy,cdoy) # looks everywhere in your local directories
if not os.path.exists(r):
Expand All @@ -206,11 +208,12 @@ def run_rinex2snr(station, year, doy, isnr, orbtype, rate,dec_rate,archive, nol
if screenstats:
print('Testing out stripping the RINEX 2 file here')
k.strip_rinexfile(r)
conv2snr(year, doy, station, isnr, orbtype,rate,dec_rate,archive,translator)

conv2snr(year, doy, station, isnr, orbtype,rate,dec_rate,archive,translator,rinex2_filename=r)
else:
print('You Chose the No Look Option, but did not provide the needed RINEX file.')
if version == 3:
if screenstats:
print('RINEX Version 3')
if rate == 'high':
csrate = '01' # high rate assumes 1-sec
else:
Expand Down Expand Up @@ -254,8 +257,10 @@ def run_rinex2snr(station, year, doy, isnr, orbtype, rate,dec_rate,archive, nol
print('The RINEX 3 file exists locally', r3)
# convert to RINEX 2.11
fexists = g.new_rinex3_rinex2(r3,r2,dec_rate)
# this is so flawed. If file exists, it should not look for it via conv2snr
# It looks like i was just trying to use old code here. Have added rinex2_filename parameter
if fexists:
conv2snr(year, doy, station, isnr, orbtype,rate,dec_rate,archive,translator)
conv2snr(year, doy, station, isnr, orbtype,rate,dec_rate,archive,translator,rinex2_filename=r2)
else:
print('Something about the RINEX 3-2 conversion did not work')
else:
Expand All @@ -273,7 +278,7 @@ def run_rinex2snr(station, year, doy, isnr, orbtype, rate,dec_rate,archive, nol
r2 = station + cdoy + '0.' + cyy + 'o'
rinex2exists = False; rinex3name = '';
if (rate == 'high'):
print('This code only accesses 1-Hz Rinex 3 data at BKG, CDDIS, GA, the Spanish IGN, and GNET')
print('Looks for 1-Hz Rinex 3 data at BKG, CDDIS, GA, the Spanish IGN, and GNET')
if archive == 'ga':
deleteOld = True
# this downloads RINEX 3 and converts to Rinex 2
Expand Down Expand Up @@ -331,6 +336,8 @@ def run_rinex2snr(station, year, doy, isnr, orbtype, rate,dec_rate,archive, nol
fexists = g.new_rinex3_rinex2(rnx_filename,r2,dec_rate)

else:
if screenstats:
print('looks for lowrate RINEX 3 files')
if (archive == 'all'):
file_name,foundit = k.universal_all(station9ch, year, doy,srate,stream,screenstats)
if (not foundit): # try again
Expand All @@ -353,21 +360,26 @@ def run_rinex2snr(station, year, doy, isnr, orbtype, rate,dec_rate,archive, nol
if screenstats:
print('RINEX 2 created from v3', year, doy, ' Now remove RINEX 3 files and convert')
subprocess.call(['rm', '-f',rnx_filename]) # rnx
conv2snr(year, doy, station, isnr, orbtype,rate,dec_rate,archive,translator)
# should send it the version 2 name
conv2snr(year, doy, station, isnr, orbtype,rate,dec_rate,archive,translator,rinex2_filename=r2)
else:
print('Unsuccessful RINEX 3 retrieval/translation', year, doy)
else:
print(station, ' year:', year, ' doy:', doy, ' from: ', archive, ' rate:', rate, ' orb:', orbtype)
# this is rinex version 2 - finds rinex and converts it
# for version 2, since i was using old code, the RINEX 2.11 searching goes on in conv2snr
conv2snr(year, doy, station, isnr, orbtype,rate,dec_rate,archive,translator)


def conv2snr(year, doy, station, option, orbtype,receiverrate,dec_rate,archive,translator):
def conv2snr(year, doy, station, option, orbtype,receiverrate,dec_rate,archive,translator,**kwargs):
"""
convert RINEX files to SNR files
This code originally picked up and translated files. You can now optionally send
a parameter called rinex2_filename if the file exists. This needs to be done especially for RINEX 3
which have been converted to RINEX 2.11
2024 March 29: change location of logs directory to below REFL_CODE
Parameters
----------
year : int
Expand All @@ -388,6 +400,9 @@ def conv2snr(year, doy, station, option, orbtype,receiverrate,dec_rate,archive,t
hybrid, python, or fortran
"""

r2_filename = kwargs.get('rinex2_filename','')

xdir = os.environ['REFL_CODE']

# universal location for the log directory
Expand Down Expand Up @@ -427,7 +442,6 @@ def conv2snr(year, doy, station, option, orbtype,receiverrate,dec_rate,archive,t
if translator == 'fortran':
fortran == True


if (snre == True):
log.write("The snrfile already exists: {0:50s} \n".format(snrname_full))
print("The snrfile already exists: ", snrname_full)
Expand All @@ -444,22 +458,27 @@ def conv2snr(year, doy, station, option, orbtype,receiverrate,dec_rate,archive,t
rinexfile,rinexfiled = g.rinex_name(station, year, month, day)
# This goes to find the rinex file. I am changing it to allow
# an archive preference
if receiverrate == 'high':
strip_snr = False # for now -
#print('trying to find highrate file')
file_name, foundit = k.rinex2_highrate(station, year, doy,archive,strip_snr)
if len(r2_filename) > 0:
print('In principle this RINEX 2.11 file exists: ', r2_filename)
# further down code wnats it called rinexfile ... so let's play along
rinexfile = r2_filename
else:
# added karnak librariies
if (archive == 'all'):
foundrinex = False
for archivechoice in ['unavco','sopac','sonel']:
if (not foundrinex):
file_name,foundrinex = k.universal_rinex2(station, year, doy, archivechoice,screenstats)
print('In principle the RINEX 2.11 file does not yet exist : ', r2_filename)
if receiverrate == 'high':
strip_snr = False # for now -
file_name, foundit = k.rinex2_highrate(station, year, doy,archive,strip_snr)
else:
file_name,foundrinex = k.universal_rinex2(station, year, doy, archive,screenstats)
# added karnak librariies
if (archive == 'all'):
foundrinex = False
for archivechoice in ['unavco','sopac','sonel']:
if (not foundrinex):
file_name,foundrinex = k.universal_rinex2(station, year, doy, archivechoice,screenstats)
else:
file_name,foundrinex = k.universal_rinex2(station, year, doy, archive,screenstats)

if foundrinex: #uncompress etc to make o files ...
rinexfile, foundit2 = k.make_rinex2_ofiles(file_name) # translate
if foundrinex: #uncompress etc to make o files ...
rinexfile, foundit2 = k.make_rinex2_ofiles(file_name) # translate

# define booleans for various files
oexist = os.path.isfile(orbdir + '/' + f) == True
Expand Down Expand Up @@ -488,7 +507,7 @@ def conv2snr(year, doy, station, option, orbtype,receiverrate,dec_rate,archive,t
in2 = g.binary(snrname) # this file is made locally and moved later
in3 = g.binary(orbfile)
if (len(snrname) > 132) or (len(orbfile) > 132):
print('The orbit or SNR file name is too long.')
print('The orbit or SNR file name you are using is too long.')
print('Make your environment variable names shorter.')
return
in4 = g.binary(str(option))
Expand Down
Loading

0 comments on commit 76c8f61

Please sign in to comment.