def gnssir_guts(station, year, doy, snr_type, extension, lsp): """ my attempt to separate the inputs to the code and the guts of the code inputs are station name, year, day of year (integers) snr_type is an integer (99, 66, etc). lsp is a json """ # make sure environment variables exist. set to current directory if not g.check_environ_variables() e1 = lsp['e1'] e2 = lsp['e2'] minH = lsp['minH'] maxH = lsp['maxH'] ediff = lsp['ediff'] NReg = lsp['NReg'] PkNoise = lsp['PkNoise'] azval = lsp['azval'] naz = int(len(azval) / 2) freqs = lsp['freqs'] reqAmp = lsp['reqAmp'] plot_screen = lsp['plt_screen'] onesat = lsp['onesat'] screenstats = lsp['screenstats'] azval = lsp['azval'] d = g.doy2ymd(year, doy) month = d.month day = d.day dmjd, fracS = g.mjd(year, month, day, 0, 0, 0) xdir = os.environ['REFL_CODE'] ann = g.make_nav_dirs(year) # make sure directories are there for orbits g.result_directories(station, year, extension) # make directories for the LSP results # this defines the minimum number of points in an arc. This depends entirely on the sampling # rate for the receiver, so you should not assume this value is relevant to your case. minNumPts = 20 p, T, irefr = set_refraction_params(station, dmjd, lsp) # only doing one day at a time for now - but have started defining the needed inputs for using it twoDays = False obsfile2 = '' # dummy value for name of file for the day before, when we get to that fname, resultExist = g.LSPresult_name(station, year, doy, extension) if (resultExist): print('Results already exist on disk') if (lsp['overwriteResults'] == False) & (resultExist == True): allGood = 0 print( '>>>>> The result file exists for this day and you have selected the do not overwrite option' ) sys.exit() print('go ahead and access SNR data - first define SNR filename') obsfile, obsfileCmp, snre = g.define_and_xz_snr(station, year, doy, snr_type) print(obsfile, 'snrexistence', snre, ' and ', snr_type) if (not snre) and (not lsp['seekRinex']): print( 'SNR file does not exist and you have set the seekRinex variable to False' ) print('Use rinex2snr.py to make SNR files') sys.exit() if (not snre) and lsp['seekRinex']: print('SNR file does not exist. I will try to make a GPS only file.') rate = 'low' dec_rate = 0 orbtype = 'nav' g.quick_rinex_snrC(year, doy, station, snr_type, orbtype, rate, dec_rate) allGood, sat, ele, azi, t, edot, s1, s2, s5, s6, s7, s8, snrE = snr.read_snr_multiday( obsfile, obsfile2, twoDays) snr.compress_snr_files(lsp['wantCompression'], obsfile, obsfile2, twoDays) # SNR exists - go ahead if (allGood == 1): ele = apply_refraction_corr(lsp, ele, p, T) fout, frej = g.open_outputfile(station, year, doy, extension) # main loop a given list of frequencies total_arcs = 0 ct = 0 for f in freqs: if plot_screen: fig, (ax1, ax2) = plt.subplots(2, 1) rj = 0 gj = 0 print('**** looking at frequency ', f, ' ReqAmp', reqAmp[ct], ' doy ', doy, 'YYYY/MM/DD', year, month, day) # get the list of satellites for this frequency if onesat == None: satlist = g.find_satlist(f, snrE) else: satlist = onesat if (int(satlist[0]) < 100) and (f > 100): print('wrong satellite name for this frequency') for satNu in satlist: #if screenstats: print('Satellite', satNu) for a in range(naz): az1 = azval[(a * 2)] az2 = azval[(a * 2 + 1)] x, y, Nv, cf, UTCtime, avgAzim, avgEdot, Edot2, delT = g.window_data( s1, s2, s5, s6, s7, s8, sat, ele, azi, t, edot, f, az1, az2, e1, e2, satNu, lsp['polyV'], lsp['pele'], screenstats) MJD = g.getMJD(year, month, day, UTCtime) if Nv > minNumPts: maxF, maxAmp, eminObs, emaxObs, riseSet, px, pz = g.strip_compute( x, y, cf, maxH, lsp['desiredP'], lsp['polyV'], minH) nij = pz[(px > NReg[0]) & (px < NReg[1])] Noise = 0 if (len(nij) > 0): Noise = np.mean(nij) iAzim = int(avgAzim) okPk = True if abs(maxF - minH) < 0.10: # peak too close to min value okPk = False print( 'found a peak too close to the edge of the restricted RH region' ) if okPk & (delT < lsp['delTmax']) & ( eminObs < (e1 + ediff)) & (emaxObs > (e2 - ediff)) & ( maxAmp > reqAmp[ct]) & (maxAmp / Noise > PkNoise): fout.write( " {0:4.0f} {1:3.0f} {2:6.3f} {3:3.0f} {4:6.3f} {5:6.2f} {6:6.2f} {7:6.2f} {8:6.2f} {9:4.0f} {10:3.0f} {11:2.0f} {12:8.5f} {13:6.2f} {14:7.2f} {15:12.6f} {16:1.0f} \n" .format(year, doy, maxF, satNu, UTCtime, avgAzim, maxAmp, eminObs, emaxObs, Nv, f, riseSet, Edot2, maxAmp / Noise, delT, MJD, irefr)) gj += 1 if screenstats: T = g.nicerTime(UTCtime) print( 'SUCCESS Azimuth {0:3.0f} Sat {1:3.0f} RH {2:7.3f} m PkNoise {3:4.1f} Amp {4:4.1f} Fr{5:3.0f} UTC {6:5s} DT {7:3.0f} ' .format(iAzim, satNu, maxF, maxAmp / Noise, maxAmp, f, T, round(delT))) if plot_screen: local_update_plot(x, y, px, pz, ax1, ax2) else: rj += 1 if screenstats: print( 'FAILED QC for Azimuth {0:.1f} Satellite {1:2.0f} UTC {2:5.2f}' .format(iAzim, satNu, UTCtime)) g.write_QC_fails(delT, lsp['delTmax'], eminObs, emaxObs, e1, e2, ediff, maxAmp, Noise, PkNoise, reqAmp[ct]) print( '=================================================================================' ) print(' Frequency ', f, ' good arcs:', gj, ' rejected arcs:', rj) print( '=================================================================================' ) total_arcs = gj + total_arcs # close the output files ct += 1 #'Yes' if fruit == 'Apple' else 'No' if plot_screen: plot2screen(station, f, ax1, ax2, lsp['pltname']) fout.close()
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 quickLook_function(station, year, doy, snr_type, f, e1, e2, minH, maxH, reqAmp, pele, satsel, PkNoise, fortran, pltscreen): """ inputs: station name (4 char), year, day of year snr_type is the file extension (i.e. 99, 66 etc) f is frequency (1, 2, 5), etc e1 and e2 are the elevation angle limits in degrees for the LSP minH and maxH are the allowed LSP limits in meters reqAmp is LSP amplitude significance criterion pele is the elevation angle limits for the polynomial removal. units: degrees KL 20may10 pk2noise value is now sent from main function, which can be set online KL 20aug07 added fortran boolean KL 21feb06 return data from the plots so that Jupyter notebooks can use them. also added pltscreen variable so that the default plots are not always displayed """ # return data to Jupyter Notebook people, good results nw = {} sw = {} ne = {} se = {} # failed periodograms failnw = {} failsw = {} failne = {} failse = {} list1 = {} # list of satellites in each quadrant list1['NW'] = [] list1['NE'] = [] list1['SW'] = [] list1['SE'] = [] list1['failNW'] = [] list1['failNE'] = [] list1['failSW'] = [] list1['failSE'] = [] # try the kelly way data = { 'NW': {}, 'SW': {}, 'NE': {}, 'SE': {}, 'fNW': {}, 'fSW': {}, 'fNE': {}, 'fSE': {} } # make sure environment variables exist g.check_environ_variables() if not os.path.isdir('logs'): subprocess.call(['mkdir', 'logs']) webapp = False # orbit directories ann = g.make_nav_dirs(year) # titles in 4 quadrants - for webApp titles = ['Northwest', 'Southwest', 'Northeast', 'Southeast'] stitles = ['NW', 'SW', 'NE', 'SE'] # define where the axes are located bx = [0, 1, 0, 1] by = [0, 0, 1, 1] bz = [1, 3, 2, 4] # various defaults - ones the user doesn't change in this quick Look code delTmax = 70 polyV = 4 # polynomial order for the direct signal desiredP = 0.01 # 1 cm precision ediff = 2 # this is a QC value, eliminates small arcs #four_in_one = True # put the plots together minNumPts = 20 #noise region for LSP QC. these are meters NReg = [minH, maxH] #print('Refl. Ht. Noise Region used: ', NReg) # for quickLook, we use the four geographic quadrants - these are azimuth angles in degrees azval = [270, 360, 180, 270, 0, 90, 90, 180] naz = int(len(azval) / 2) # number of azimuth pairs pltname = 'temp.png' # default plot requireAmp = reqAmp[0] screenstats = True # to avoid having to do all the indenting over again # this allows snr file to live in main directory # not sure that that is all that useful as I never let that happen obsfile = g.define_quick_filename(station, year, doy, snr_type) if os.path.isfile(obsfile): print('>>>> The snr file exists ', obsfile) else: if True: #print('looking for the SNR file on disk') obsfile, obsfileCmp, snre = g.define_and_xz_snr( station, year, doy, snr_type) if snre: dkfjaklj = True #print('file exists on disk') else: print('>>>> The SNR the file does not exist ', obsfile) print( 'This code used to try and make one for you, but I have removed this option.' ) print('Please us rinex2snr and make a SNR file') sys.exit() allGood, sat, ele, azi, t, edot, s1, s2, s5, s6, s7, s8, snrE = read_snr_simple( obsfile) if allGood == 1: # make output file for the quickLook RRH values, just so you can give them a quick look see rhout = open('logs/rh.txt', 'w+') amax = 0 minEdataset = np.min(ele) print('minimum elevation angle (degrees) for this dataset: ', minEdataset) if minEdataset > (e1 + 0.5): print('It looks like the receiver had an elevation mask') e1 = minEdataset if pltscreen: plt.figure(figsize=(10, 6)) for a in range(naz): if pltscreen: plt.subplot(2, 2, bz[a]) plt.title(titles[a]) az1 = azval[(a * 2)] az2 = azval[(a * 2 + 1)] # this means no satellite list was given, so get them all if satsel == None: satlist = g.find_satlist(f, snrE) else: satlist = [satsel] for satNu in satlist: x, y, Nv, cf, UTCtime, avgAzim, avgEdot, Edot2, delT = g.window_data( s1, s2, s5, s6, s7, s8, sat, ele, azi, t, edot, f, az1, az2, e1, e2, satNu, polyV, pele, screenstats) if Nv > minNumPts: maxF, maxAmp, eminObs, emaxObs, riseSet, px, pz = g.strip_compute( x, y, cf, maxH, desiredP, polyV, minH) nij = pz[(px > NReg[0]) & (px < NReg[1])] Noise = 0 iAzim = int(avgAzim) if (len(nij) > 0): Noise = np.mean(nij) else: Noise = 1 iAzim = 0 # made up numbers if (delT < delTmax) & (eminObs < (e1 + ediff)) & ( emaxObs > (e2 - ediff)) & (maxAmp > requireAmp) & (maxAmp / Noise > PkNoise): T = g.nicerTime(UTCtime) rhout.write( 'SUCCESS Azimuth {0:3.0f} RH {1:6.3f} m, Sat {2:3.0f} Freq {3:3.0f} Amp {4:4.1f} PkNoise {5:3.1f} UTC {6:5s} \n ' .format(avgAzim, maxF, satNu, f, maxAmp, maxAmp / Noise, T)) if pltscreen: plt.plot(px, pz, linewidth=1.5) if a == 0: nw[satNu] = [px, pz] list1['NW'].append(satNu) elif a == 1: sw[satNu] = [px, pz] list1['SW'].append(satNu) elif a == 2: ne[satNu] = [px, pz] list1['NE'].append(satNu) elif a == 3: se[satNu] = [px, pz] list1['SE'].append(satNu) idc = stitles[a] data[idc][satNu] = [px, pz] else: # these are failed tracks if pltscreen: plt.plot(px, pz, 'gray', linewidth=0.5) if a == 0: failnw[satNu] = [px, pz] list1['failNW'].append(satNu) elif a == 1: failsw[satNu] = [px, pz] list1['failSW'].append(satNu) elif a == 2: failne[satNu] = [px, pz] list1['failNE'].append(satNu) elif a == 3: failse[satNu] = [px, pz] list1['failSE'].append(satNu) idc = 'f' + stitles[a] data[idc][satNu] = [px, pz] # i do not know how to add a grid using these version of matplotlib tt = 'GNSS-IR results: ' + station.upper() + ' Freq:' + g.ftitle( f) + ' Year/DOY:' + str(year) + ',' + str(doy) if pltscreen: aaa, bbb = plt.ylim() amax = max(amax, bbb) # do not know how to implement this ... if (a == 3) or (a == 1): plt.xlabel('reflector height (m)') if (a == 1) or (a == 0): plt.ylabel('volts/volts') rhout.close() print( 'preliminary reflector height results are stored in a file called logs/rh.txt' ) # do not plot if sending data to Jupyter Notebooks if pltscreen: plt.suptitle(tt, fontsize=12) plt.show() else: print( 'some kind of problem with SNR file, so I am exiting the code politely.' ) return data
def quickLook_function(station, year, doy, snr_type,f,e1,e2,minH,maxH,reqAmp,pele,satsel,PkNoise,fortran): """ inputs: station name (4 char), year, day of year snr_type is the file extension (i.e. 99, 66 etc) f is frequency (1, 2, 5), etc e1 and e2 are the elevation angle limits in degrees for the LSP minH and maxH are the allowed LSP limits in meters reqAmp is LSP amplitude significance criterion pele is the elevation angle limits for the polynomial removal. units: degrees KL 20may10 pk2noise value is now sent from main function, which can be set online KL 20aug07 added fortran boolean """ # make sure environment variables exist g.check_environ_variables() if not os.path.isdir('logs'): subprocess.call(['mkdir', 'logs']) webapp = False # orbit directories ann = g.make_nav_dirs(year) # titles in 4 quadrants - for webApp titles = ['Northwest', 'Southwest','Northeast', 'Southeast'] # define where the axes are located bx = [0,1,0,1]; by = [0,0,1,1]; bz = [1,3,2,4] # various defaults - ones the user doesn't change in this quick Look code delTmax = 70 polyV = 4 # polynomial order for the direct signal desiredP = 0.01 # 1 cm precision ediff = 2 # this is a QC value, eliminates small arcs #four_in_one = True # put the plots together minNumPts = 20 #noise region for LSP QC. these are meters NReg = [minH, maxH] #print('Refl. Ht. Noise Region used: ', NReg) # for quickLook, we use the four geographic quadrants - these are azimuth angles in degrees azval = [270, 360, 180, 270, 0, 90, 90, 180] naz = int(len(azval)/2) # number of azimuth pairs pltname = 'temp.png' # default plot requireAmp = reqAmp[0] screenstats = True # to avoid having to do all the indenting over again # this allows snr file to live in main directory # not sure that that is all that useful as I never let that happen obsfile = g.define_quick_filename(station,year,doy,snr_type) if os.path.isfile(obsfile): print('>>>> The snr file exists ',obsfile) else: if True: #print('looking for the SNR file on disk') obsfile, obsfileCmp, snre = g.define_and_xz_snr(station,year,doy,snr_type) if snre: dkfjaklj = True #print('file exists on disk') else: print('>>>> The SNR the file does not exist ',obsfile) print('This code used to try and make one for you, but I have removed this option.') print('Please us rinex2snr and make a SNR file') sys.exit() #print('I will try to pick up a RINEX file ') #print('and translate it for you. This will be GPS only.') #print('For now I will check all the official archives for you.') #rate = 'low'; dec_rate = 0; archive = 'all'; #rinex.conv2snr(year, doy, station, int(snr_type), 'nav',rate,dec_rate,archive,fortran) #if os.path.isfile(obsfile): # print('the SNR file now exists') #else: # print('the RINEX file did not exist, had no SNR data, or failed to convert, so exiting.') allGood,sat,ele,azi,t,edot,s1,s2,s5,s6,s7,s8,snrE = read_snr_simple(obsfile) if allGood == 1: # make output file for the quickLook RRH values, just so you can give them a quick look see rhout = open('logs/rh.txt','w+') amax = 0 minEdataset = np.min(ele) print('minimum elevation angle (degrees) for this dataset: ', minEdataset) if minEdataset > (e1+0.5): print('It looks like the receiver had an elevation mask') e1 = minEdataset if webapp: fig = Figure(figsize=(10,6), dpi=120) axes = fig.subplots(2, 2) else: #plt.figure() # trying to help Kelly plt.figure(figsize=(10,6)) for a in range(naz): if not webapp: plt.subplot(2,2,bz[a]) plt.title(titles[a]) az1 = azval[(a*2)] ; az2 = azval[(a*2 + 1)] # this means no satellite list was given, so get them all if satsel == None: satlist = g.find_satlist(f,snrE) else: satlist = [satsel] for satNu in satlist: x,y,Nv,cf,UTCtime,avgAzim,avgEdot,Edot2,delT= g.window_data(s1,s2,s5,s6,s7,s8,sat,ele,azi,t,edot,f,az1,az2,e1,e2,satNu,polyV,pele,screenstats) if Nv > minNumPts: maxF, maxAmp, eminObs, emaxObs,riseSet,px,pz= g.strip_compute(x,y,cf,maxH,desiredP,polyV,minH) nij = pz[(px > NReg[0]) & (px < NReg[1])] Noise = 0 iAzim = int(avgAzim) if (len(nij) > 0): Noise = np.mean(nij) else: Noise = 1; iAzim = 0 # made up numbers if (delT < delTmax) & (eminObs < (e1 + ediff)) & (emaxObs > (e2 - ediff)) & (maxAmp > requireAmp) & (maxAmp/Noise > PkNoise): T = g.nicerTime(UTCtime) rhout.write('SUCCESS Azimuth {0:3.0f} RH {1:6.3f} m, Sat {2:3.0f} Freq {3:3.0f} Amp {4:4.1f} PkNoise {5:3.1f} UTC {6:5s} \n '.format( avgAzim,maxF,satNu,f,maxAmp,maxAmp/Noise,T)) if not webapp: plt.plot(px,pz,linewidth=1.5) else: axes[bx[a],by[a]].plot(px,pz,linewidth=2) axes[bx[a],by[a]].set_title(titles[a]) else: if not webapp: plt.plot(px,pz,'gray',linewidth=0.5) # i do not know how to add a grid using these version of matplotlib tt = 'GNSS-IR results: ' + station.upper() + ' Freq:' + str(f) + ' ' + str(year) + '/' + str(doy) aaa, bbb = plt.ylim() amax = max(amax, bbb) # do not know how to implement this ... if (a == 3) or (a==1): plt.xlabel('reflector height (m)') plt.suptitle(tt, fontsize=12) rhout.close() print('Reflector Height results are stored in a file called logs/rh.txt') if webapp: fig.savefig('temp.png', format="png") else: plt.show() else: print('some kind of problem with SNR file, so I am exiting the code politely.')
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!')