def run_rinex2snr(station, year_list, doy_list, isnr, orbtype, rate, dec_rate, archive, fortran, nol, overwrite, translator): """ runs the rinex 2 snr conversion inputs: station name year_list list of years to be analyzed doy_list list of doy to be analyzed isnr = integer file type choice orbtype = 3character orbit type rate = high or low dec_rate = integer for decimation archive = allows you to pick a specific archive fortran = boolean, whether you use fortran rinex translators nol = boolean for nolook, if set to True, then it will assume RINEX files are in local directory overwrite = boolean, make a new SNR file even if one already exists 2021feb11, kristine Larson ultimately we will get rid of the fortran option, but we are keeping it for backwards compatibility translator has three possibilies: fortran, python, or hybrid. the hybrid option requires you to have compiled the fortran code using numpy.f2py """ NS = len(station) if (NS == 4): #print('Assume RINEX 2.11'); version = 2 station = station.lower() elif (NS == 9): #print('Assume RINEX 3'); version = 3 station9ch = station.upper() station = station[0:4].lower() else: print( 'Illegal station input - Station must have 4 or 9 characters. Exiting' ) sys.exit() # loop thru years and days for year in year_list: ann = g.make_nav_dirs(year) for doy in doy_list: csnr = str(isnr) cdoy = '{:03d}'.format(doy) cyy = '{:02d}'.format(year - 2000) # first, check to see if the SNR file exists fname = quickname(station, year, cyy, cdoy, csnr) #print(fname) snre = g.snr_exist(station, year, doy, csnr) if snre: print('SNR file exists', fname) if overwrite: #print('you requested it be overwritten, so removing file') subprocess.call(['rm', fname]) snre = False if (not snre): r = station + cdoy + '0.' + cyy + 'o' rgz = station + cdoy + '0.' + cyy + 'o.gz' print('Will seek RINEX file ', station, ' year:', year, ' doy:', doy, ' translate with ', translator) if nol: # this assumes RINEX file is in local directory if version == 2: if os.path.exists(r) or os.path.exists(rgz): #print('RINEX 2 file exists locally') if not os.path.exists(r): subprocess.call(['gunzip', rgz]) conv2snr(year, doy, station, isnr, orbtype, rate, dec_rate, archive, fortran, translator) else: print( 'You Chose the No Look Option, but did not provide the needed RINEX file.' ) if version == 3: r3 = station9ch + '_R_' + str( year) + cdoy + '0000_01D_30S_MO.rnx' r3gz = station9ch + '_R_' + str( year) + cdoy + '0000_01D_30S_MO.rnx.gz' r2 = station + cdoy + '0.' + cyy + 'o' if os.path.exists(r3gz): subprocess.call(['gunzip', r3gz]) if os.path.exists(r3): #print('RINEX 3 file exists locally') fexists = g.new_rinex3_rinex2(r3, r2) if fexists: #print('Rinex 3 to 2 conversion worked, now convert to snr format') conv2snr(year, doy, station, isnr, orbtype, rate, dec_rate, archive, fortran, translator) else: print( 'Something about the RINEX 3-2 conversion did not work' ) else: print( 'You Chose the No Look Option, but did not provide the needed RINEX3 file.' ) else: #print('will look for the RINEX file both locally and externally') if version == 3: #print('rinex 3 search with orbtype ', orbtype) srate = 30 # rate supported by CDDIS rinex2exists, rinex3name = g.cddis_rinex3( station9ch, year, doy, srate, orbtype) if not rinex2exists: # try again - unavco has 15 sec I believe srate = 15 rinex2exists, rinex3name = g.unavco_rinex3( station9ch, year, doy, srate, orbtype) subprocess.call(['rm', '-f', rinex3name]) # remove rinex3 file if rinex2exists: conv2snr(year, doy, station, isnr, orbtype, rate, dec_rate, archive, fortran, translator) else: print('RINEX file does not exist for ', year, doy) else: # this is rinex version 2 conv2snr(year, doy, station, isnr, orbtype, rate, dec_rate, archive, fortran, translator)
def run_rinex2snr(station, year_list, doy_list, isnr, orbtype, rate,dec_rate,archive,fortran,nol): """ runs the rinex 2 snr conversion inputs: station name year_list list of years to be analyzed doy_list list of doy to be analyzed isnr = integer file type choice orbtype = 3character orbit type rate = high or low dec_rate = integer for decimation archive = allows you to pick a specific archive fortran = boolean, whether you use fortran rinex translators nol = boolean for nolook, if set to True, then it will assume RINEX files are in local directory """ NS = len(station) if (NS == 4): print('Assume RINEX 2.11'); version = 2 station = station.lower() elif (NS == 9): print('Assume RINEX 3'); version = 3 station9ch = station.upper() station = station[0:4].lower() else: print('Illegal station input - Station must have 4 or 9 characters. Exiting') sys.exit() # loop thru years and days for year in year_list: ann = g.make_nav_dirs(year) for doy in doy_list: csnr = str(isnr) cdoy = '{:03d}'.format(doy) ; cyy = '{:02d}'.format(year-2000) # first, check to see if the SNR file exists snre = g.snr_exist(station,year,doy,csnr) if snre: print('snr file for ', station, str(year), cdoy, csnr, ' already exists') else: r = station + cdoy + '0.' + cyy + 'o' rgz = station + cdoy + '0.' + cyy + 'o.gz' print(station, year, doy, ': will try to find RINEX /make SNR ') if nol: if version == 2: if os.path.exists(r) or os.path.exists(rgz): print('RINEX 2 file exists locally') if not os.path.exists(r): subprocess.call(['gunzip', rgz]) conv2snr(year, doy, station, isnr, orbtype,rate,dec_rate,archive,fortran) else: print('You Chose the No Look Option, but did not provide the needed RINEX file.') if version == 3: r3 = station9ch + '_R_' + str(year) + cdoy + '0000_01D_30S_MO.rnx' r3gz = station9ch + '_R_' + str(year) + cdoy + '0000_01D_30S_MO.rnx.gz' r2 = station + cdoy + '0.' + cyy + 'o' if os.path.exists(r3gz): subprocess.call(['gunzip', r3gz]) if os.path.exists(r3): print('RINEX 3 file exists locally') fexists = g.new_rinex3_rinex2(r3,r2) if fexists: print('Rinex 3 to 2 conversion worked, now convert to snr format') conv2snr(year, doy, station, isnr, orbtype,rate,dec_rate,archive,fortran) else: print('Something about rinex 3-2 conversion did not work') else: print('You Chose the No Look Option, but did not provide the needed RINEX file.') else: print('will look for the RINEX file both locally and externally') if version == 3: print('rinex 3 search with orbtype ', orbtype) srate = 30 # rate supported by CDDIS rinex2exists, rinex3name = g.cddis_rinex3(station9ch, year, doy,srate,orbtype) if not rinex2exists: # try again - unavco has 15 sec I believe srate = 15 rinex2exists, rinex3name = g.unavco_rinex3(station9ch, year, doy,srate,orbtype) subprocess.call(['rm', '-f', rinex3name]) # remove rinex3 file if rinex2exists: conv2snr(year, doy, station, isnr, orbtype,rate,dec_rate,archive,fortran) else: print('rinex file does not exist for ', year, doy) else: print('rinex 2.11 conversion with ', orbtype) conv2snr(year, doy, station, isnr, orbtype,rate,dec_rate,archive,fortran) print('And I guess I am done now!')