def returnTEC(data, sv, navfile, yamlfile, timelim=None, el_mask=30, leap_seconds=18, alt=300, sattype='G', el=False, lla=False, vertical=False, svbias=False, fN=0): obstimes = np.array((data.major_axis)) obstimes = pandas.to_datetime(obstimes) - datetime.timedelta(seconds=leap_seconds) stream = yaml.load(open(yamlfile, 'r')) rx_xyz = stream.get('APPROX POSITION XYZ') if timelim is not None: idt = np.where( (obstimes>timelim[0]) & (obstimes<timelim[1]) ) [0] # print (idt) t = obstimes[idt] # print (t.shape) # print (sv) L1 = np.array(data['L1', sv, :, 'data']) L2 = np.array(data['L2', sv, :, 'data']) C1 = np.array(data['C1', sv, :, 'data']) C2 = np.array(data['P2', sv, :, 'data']) L1 = L1[idt] L2 = L2[idt] C1 = C1[idt] C2 = C2[idt] if sattype == 'R': aer = pyGps.getIonosphericPiercingPoints(rx_xyz, sv-32, t, alt, navfile, cs='aer', sattype=sattype) llt = pyGps.getIonosphericPiercingPoints(rx_xyz, sv-32, t, alt, navfile, cs='wsg84', sattype=sattype) else: aer = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, t, alt, navfile, cs='aer', sattype='G') llt = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, t, alt, navfile, cs='wsg84', sattype='G') ## filter by Elevation angle idel = np.where((aer[1] > el_mask))[0] if vertical == False: tec = pyGps.getPhaseCorrTEC(L1[idel],L2[idel], C1[idel], C2[idel]) else: if svbias: bstream = yaml.load(open('/media/smrak/Eclipse2017/Eclipse/jplg2330.yaml', 'r')) bias = float(bstream.get(sv)) tec = pyGps.getPhaseCorrTEC(L1[idel],L2[idel],C1[idel],C2[idel]) tec = pyGps.getVerticalTEC(tec+bias, aer[1][idel], alt) else: tec = pyGps.getPhaseCorrTEC(L1[idel],L2[idel],C1[idel],C2[idel]) tec = pyGps.getVerticalTEC(tec, aer[1][idel], alt) t = t[idel] #Return time, TEC and respective third argumnet masked by an elavation mask angle if el==False and lla==False: return t, tec elif el==True and lla==False: return t, tec, aer[:,idel] elif el==False and lla ==True: return t, tec, llt[:,idel] else: return t, tec, aer[:,idel] else: L1 = np.array(data['L1', sv, :, 'data']) L2 = np.array(data['L2', sv, :, 'data']) C1 = np.array(data['C1', sv, :, 'data']) C2 = np.array(data['P2', sv, :, 'data'])
def plotObservationDay(): # Green keogram ipp_aer = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, navfname, cs='aer') ipp = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, navfname, cs='wsg84') t, el, i, el_out4 = asi.getASIKeogramIPP(asi_folder3, ipp_aer[0], ipp_alt, timelim, '558', obstimes=obstimes, elevation=ipp[1]) # Magnetic Field mag_folder = '/home/smrak/Documents/TheMahali/magnetometer/poker_2015_10_07.csv' mag = magnetometer.readMag(mag_folder, '2015-10-07') #mag_start = np.datetime64('2015-10-07T00:00:00') #mag_stop = np.datetime64('2015-10-07T22:00:00') #idx = np.where( (mag[0] > mag_start) & (mag[0] < mag_stop) ) mag_xyz = magnetometer.magHDZ2XYZ(mag, angle=True) plotting.plot2subplotK_xy(t, el, i / 1000, mag[0][8000:], mag_xyz[0][8000:] / 1000, obstimes=obstimes, ipp=ipp_aer[1], xlabel='UT', ylim1=[45, 85], ylabel1='Elevation[deg]', ylabel2='Bx [uT]', ytick1=[45, 55, 65, 75, 85], ylim2=[12.2, 13.1], ytick2=[12, 12.2, 12.4, 12.6, 12.8, 13], pcolorbar=True, cbartick=[0, 2, 4, 6, 8], cbartitle='558nm [kR]', xlim=[ datetime.datetime(2015, 10, 7, 6, 10, 0), datetime.datetime(2015, 10, 7, 6, 40, 0) ])
def p2kg(): #Get keograms ipp = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, navfname, cs='aer') t5, el5, i5, el_out4 = asi.getASIKeogramIPP(asi_folder3, ipp[0], ipp_alt, timelim, '558', obstimes=obstimes, elevation=ipp[1]) t4, el4, i4, el_out5 = asi.getASIKeogramIPP(asi_folder3, ipp[0], ipp_alt, timelim, '428', obstimes=obstimes, elevation=ipp[1]) t6, el6, i6, el_out6 = asi.getASIKeogramIPP(asi_folder3, ipp[0], ipp_alt, timelim, '630', obstimes=obstimes, elevation=ipp[1]) plotoptics.plot2Keogram(t5, t6, el5, el6, i5 / 1000, i6 / i4, ylim=[45, 85], pcolorbar=True, ytick2=[45, 55, 65, 75], ytick1=[45, 55, 65, 75, 85], cmap='viridis', cbartick1=[0, 2, 4, 6, 8], cbartick2=[0, 0.4, 0.8, 1.2, 1.6, 2], cbartitle1='558nm [kR]', cbartitle2='red/blue', xtick=[ datetime.datetime(2015, 10, 7, 6, 10, 0), datetime.datetime(2015, 10, 7, 6, 15, 0), datetime.datetime(2015, 10, 7, 6, 20, 0), datetime.datetime(2015, 10, 7, 6, 25, 0), datetime.datetime(2015, 10, 7, 6, 30, 0), datetime.datetime(2015, 10, 7, 6, 35, 0), datetime.datetime(2015, 10, 7, 6, 40, 0) ], xlim=[ datetime.datetime(2015, 10, 7, 6, 10, 0), datetime.datetime(2015, 10, 7, 6, 40, 0) ])
def pkg(): #Get keograms ipp = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, navfname, cs='aer') t5, el5, i5, el_out4 = asi.getASIKeogramIPP(asi_folder3, ipp[0], ipp_alt, timelim, '558', obstimes=obstimes, elevation=ipp[1]) t4, el4, i4, el_out5 = asi.getASIKeogramIPP(asi_folder3, ipp[0], ipp_alt, timelim, '428', obstimes=obstimes, elevation=ipp[1]) t6, el6, i6, el_out6 = asi.getASIKeogramIPP(asi_folder3, ipp[0], ipp_alt, timelim, '630', obstimes=obstimes, elevation=ipp[1]) plotoptics.plotKeogram(t5, el5, i5 / 1E3, ylim=[45, 85], title='Green line intensity', pcolorbar=True, cmap='viridis', cbartick=[0, 2, 4, 6, 8], cbartitle='kR', ytick=[45, 55, 65, 75, 85], xtick=[ datetime.datetime(2015, 10, 7, 6, 10, 0), datetime.datetime(2015, 10, 7, 6, 15, 0), datetime.datetime(2015, 10, 7, 6, 20, 0), datetime.datetime(2015, 10, 7, 6, 25, 0), datetime.datetime(2015, 10, 7, 6, 30, 0), datetime.datetime(2015, 10, 7, 6, 35, 0), datetime.datetime(2015, 10, 7, 6, 40, 0) ], xlim=[ datetime.datetime(2015, 10, 7, 6, 10, 0), datetime.datetime(2015, 10, 7, 6, 40, 0) ])
def pInt(): ipp = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, navfname) t, d = asi.getAllSkyIntensity(asi_folder3, ipp[0], ipp[1], 120, timelim, '558', obstimes=obstimes) t4, d4 = asi.getAllSkyIntensity(asi_folder3, ipp[0], ipp[1], 90, timelim, '428', obstimes=obstimes) t6, d6 = asi.getAllSkyIntensity(asi_folder3, ipp[0], ipp[1], 250, timelim, '630', obstimes=obstimes) plotoptics.plotIntensity(t, d, ylabel='Intensity [R]', xlabel='UT', label1='558nm', t2=t4, y2=d4, t3=t6, y3=d6, label2='428nm', label3='630nm', color1='g', color2='b', color3='r', title='All-sky imager intensity', ylim=[300, 2500], legend=True, xlim=[ datetime.datetime(2015, 10, 7, 6, 10, 0), datetime.datetime(2015, 10, 7, 6, 40, 0) ])
def plotGlobalMap(): start = datetime.datetime(2015, 10, 7, 6, 10, 0) stop = datetime.datetime(2015, 10, 7, 6, 40, 0) idx = np.where((obstimes >= start) & (obstimes <= stop))[0] ipp = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, navfname, cs='wsg84') #print (obstimes[idx]) plotSatellite.plotSatelliteGlobalMap(rx_xyz, sv, obstimes[idx], width=5000000, height=3000000, center=[-130, 60]) plotSatellite.plotIPPGlobalMap(ipp[0][idx], ipp[1][idx], width=5000000, height=3000000, center=[-130, 60]) plotSatellite.plotSatelliteGlobalMap(rx_xyz, 23, obstimes[0:6000], color='green', lw=2, width=5000000, height=3000000, center=[-130, 60]) plotSatellite.plotSatelliteGlobalMap(rx_xyz, 23, obstimes[idx], color='red', lw=3, width=5000000, height=3000000, center=[-130, 60])
def tec_keogram_intensity5(): N_roti = 100 aer = pyGps.getSatellitePosition(np.asarray(rx_xyz), sv, obstimes, navfname, cs='aer') L1 = np.array(data['L1', sv, :, 'data']) L2 = np.array(data['L2', sv, :, 'data']) P1 = np.array(data['C1', sv, :, 'data']) P2 = np.array(data['P2', sv, :, 'data']) l2_lli = np.array(data['L2', sv, :, 'lli']) #Phase corrected TEC sTECp = pyGps.getPhaseCorrTEC(L1, L2, P1, P2) vTECp = pyGps.getVerticalTEC(sTECp, aer[1], 130) tec_norm = vTECp - vTECp[np.isfinite(vTECp[0:1000])].min() # Rate of TEC Index roti = pyGps.getROTI(vTECp, N_roti) roti_t = obstimes[0:-N_roti] #ASI Intensity data # Piercing point for all-sky data aer = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, navfname, cs='aer') #ipp = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, navfname, cs='wsg84') #Asi intensity: t5, intensity5 = asi.getAllSkyIntensityAER(asi_folder3, aer[0], aer[1], ipp_alt, timelim, '558', obstimes=obstimes) t6, intensity6 = asi.getAllSkyIntensityAER(asi_folder3, aer[0], aer[1], ipp_alt, timelim, '630', obstimes=obstimes) t4, intensity4 = asi.getAllSkyIntensityAER(asi_folder3, aer[0], aer[1], ipp_alt, timelim, '428', obstimes=obstimes) # Asi Keogram ipp_aer = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, navfname, cs='aer') t, el, i, el_out4 = asi.getASIKeogramIPP(asi_folder3, ipp_aer[0], ipp_alt, timelim, '558', obstimes=obstimes, elevation=aer[1]) # Magnetometer mag_folder = '/home/smrak/Documents/TheMahali/magnetometer/poker_2015_10_07.csv' mag = magnetometer.readMag(mag_folder, '2015-10-07') b_t = mag[0][5000:] mag_xyz = magnetometer.magHDZ2XYZ(mag, angle=True) plotting.plot5subplot(t, t5, obstimes, roti_t, i / 1E3, np.array(intensity5) / 1E3, tec_norm, roti, el1=el, ylabel1='Elevation [deg]', ylabel3='vTEC [TECU]', ylabel2='Intensity [kR]', ylabel4='ROTI[TECU/10s]', xlabel='UT', ylim1=[45, 85], color5='b', ytick1=[45, 55, 65, 75, 85], pcolorbar=True, cbartick=[0, 2, 4, 6, 8], cbartitle='Intensity [kR]', t31=t6, t32=t4, y31=np.array(intensity6) / 1E3, y32=np.array(intensity4) / 1E3, color2='g', color3='r', color4='b', legend1=True, label2='558nm', label3='630nm', label4='428nm', lli1=l2_lli, ylim2=[0, 3.5], ylim4=[0, 3.5], ylim3=[0, 18], ipp_elevation=aer[1], ytick2=[0, 1, 2, 3], ytick3=[0, 4, 8, 12, 16], ytick4=[0, 0.5, 1, 1.5, 2, 2.5, 3], Bt=b_t, Bx=mag_xyz[0][5000:] / 1000, ylabel5='Bx [uT]', cbx='b', ylim5=[12.2, 13], ytick5=[12.2, 12.4, 12.6, 12.8], xlim=[ datetime.datetime(2015, 10, 7, 6, 10, 0), datetime.datetime(2015, 10, 7, 6, 40, 0) ])
def tec_keogram_intensity3(): aer = pyGps.getSatellitePosition(np.asarray(rx_xyz), sv, obstimes, navfname, cs='aer') L1 = np.array(data['L1', sv, :, 'data']) L2 = np.array(data['L2', sv, :, 'data']) P1 = np.array(data['C1', sv, :, 'data']) P2 = np.array(data['P2', sv, :, 'data']) l2_lli = np.array(data['L2', sv, :, 'lli']) #Phase corrected TEC sTECp = pyGps.getPhaseCorrTEC(L1, L2, P1, P2) vTECp = pyGps.getVerticalTEC(sTECp, aer[1], 130) tec_norm = vTECp - vTECp[np.isfinite(vTECp[0:1000])].min() # Rate of TEC Index roti = pyGps.getROTI(vTECp, 10) roti_t = obstimes[0:-10] #ASI Intensity data # Piercing point for all-sky data aer = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, navfname, cs='aer') ipp = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, navfname, cs='wsg84') #Asi intensity: t5, intensity5 = asi.getAllSkyIntensityAER(asi_folder3, aer[0], aer[1], ipp_alt, timelim, '558', obstimes=obstimes) t5a, intensity5a = asi.getAllSkyIntensity(asi_folder3, ipp[0], ipp[1], ipp_alt, timelim, '558', obstimes=obstimes) # Asi Keogram ipp_aer = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, navfname, cs='aer') t, el, i, el_out4 = asi.getASIKeogramIPP(asi_folder3, ipp_aer[0], ipp_alt, timelim, '558', obstimes=obstimes, elevation=ipp[1]) plotting.plot4subplot(t, obstimes, t5, roti_t, i / 1E3, tec_norm, np.array(intensity5) / 1E3, roti, el1=el, ylabel1='Elevation [deg]', ylabel2='vTEC [TECU]', ylabel3='Intensity [kR]', ylabel4='ROTI[TECU/10s]', xlabel='UT', ylim1=[45, 85], color5='b', title1='Rx8 - PRN23, Poker Flat 10/07/2015', ytick1=[45, 55, 65, 75, 85], pcolorbar=True, cbartick=[0, 2, 4, 6, 8], cbartitle='Intensity [kR]', t31=t5a, y31=np.array(intensity5a) / 1E3, color2='g', color3='r', legend2=True, label2='org', label3='int', label4='630nm', lli1=l2_lli, ylim3=[0, 3.5], ylim4=[0, 3.5], ylim2=[0, 18], ipp_elevation=aer[1], ytick3=[0, 1, 2, 3], ytick2=[0, 4, 8, 12, 16], ytick4=[0, 0.5, 1, 1.5, 2, 2.5, 3], xlim=[ datetime.datetime(2015, 10, 7, 6, 10, 0), datetime.datetime(2015, 10, 7, 6, 40, 0) ])
def tec_vs_asi(): aer = pyGps.getSatellitePosition(np.asarray(rx_xyz), sv, obstimes, navfname, cs='aer') L1 = np.array(data['L1', sv, :, 'data']) L2 = np.array(data['L2', sv, :, 'data']) P1 = np.array(data['C1', sv, :, 'data']) P2 = np.array(data['P2', sv, :, 'data']) l2_lli = np.array(data['L2', sv, :, 'lli']) #Phase corrected TEC sTECp = pyGps.getPhaseCorrTEC(L1, L2, P1, P2) vTECp = pyGps.getVerticalTEC(sTECp, aer[1], 130) tec_norm = vTECp - vTECp[np.isfinite(vTECp[0:1000])].min() #ASI Intensity data # Piercing point for all-sky data # aer = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, ipp_alt, # navfname, cs='aer') ipp = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, 130E3, navfname, cs='wsg84') #Asi intensity: t5, intensity5 = asi.getAllSkyIntensity(asi_folder3, ipp[0], ipp[1], 130, timelim, '558', obstimes=obstimes) t4, intensity4 = asi.getAllSkyIntensity(asi_folder3, ipp[0], ipp[1], 130, timelim, '428', obstimes=obstimes) t6, intensity6 = asi.getAllSkyIntensity(asi_folder3, ipp[0], ipp[1], 130, timelim, '630', obstimes=obstimes) #Plot 2 subplots plotting.plot2subplot(obstimes, t5, tec_norm, (np.array(intensity5) / 1E3), ylabel1='vTEC [TECU]', ylabel2='Intensity [kR]', xlabel='UT', lli1=l2_lli, ylim2=[0.2, 2.6], lm='line', color2='g', lli2=l2_lli, t21=t4, y21=(np.array(intensity4) / 1E3), t22=t6, y22=(np.array(intensity6) / 1E3), label4='630nm', color4='r', color3='b', label2='558nm', label3='428nm', legend2=True, xlim=[ datetime.datetime(2015, 10, 7, 6, 10, 0), datetime.datetime(2015, 10, 7, 6, 40, 0) ])
def singleStation(day, el_mask, state, station=''): #Find HDF5 filename if station == '': wlstr = '*' + str(day) + '*.h5' else: wlstr = state + station + str(day) + '*.h5' filestr = os.path.join(obsfolder + state + '/' + str(day) + '/', wlstr) flistHDF = glob.glob(filestr) #Find NAV filename wlstr = '*' + str(day) + '*.17n' filestr = os.path.join(navfolder, wlstr) flistNAV = glob.glob(filestr) #Find YAML filename if station == '': wlstr = '*' + str(day) + '*.yaml' else: wlstr = state + station + str(day) + '*.yaml' filestr = os.path.join(obsfolder + state + '/' + str(day) + '/', wlstr) flistYML = glob.glob(filestr) #filenames hdffn = flistHDF[0] navfn = flistNAV[0] ymlfn = flistYML[0] # Processing per station # YAML import header stream = yaml.load(open(ymlfn, 'r')) rx_xyz = stream.get('APPROX POSITION XYZ') # HDF Observations data = read_hdf(hdffn) obstimes = np.array((data.major_axis)) obstimes = pandas.to_datetime(obstimes) - datetime.timedelta(seconds=18) dumb = data['L1', :, 1, 'data'] svlist = dumb.axes[0] fig1 = plt.figure(figsize=(12, 12)) formatter = mdates.DateFormatter('%H:%M') ax1 = fig1.add_subplot(311) #fig2 = plt.figure(figsize=(12,4)) ax2 = fig1.add_subplot(312, sharex=ax1) #fig3 = plt.figure(figsize=(12,4)) ax3 = fig1.add_subplot(313, sharex=ax1) for sv in svlist: # GPS only svnum <=32 if sv <= 32: C1 = np.array(data['C1', sv, :, 'data']) C2 = np.array(data['P2', sv, :, 'data']) L1 = np.array(data['L1', sv, :, 'data']) L2 = np.array(data['L2', sv, :, 'data']) aer = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, 120, navfn, cs='aer') #filter by Elevation angle idel = np.where((aer[1] > el_mask))[0] t = obstimes[idel] #Get TEC # Calc only if there is more than 30min of data if (np.isfinite(L1[idel]).shape[0] > 1000): tec, intervals = pyGps.getPhaseCorrTEC(L1[idel], L2[idel], C1[idel], C2[idel], intervals=True) l = [] for ran in intervals: l.append(ran[1] - ran[0]) idl = np.where(np.array(l) < 1000)[0] # print (idl) if len(idl) > 0: idLL = intervals[idl[0]] tec[idLL[0]:idLL[1]] = np.nan # Detrend data without NaNs if np.sum(np.isfinite(tec)) > 100: idf = np.isfinite(tec) tec_recovery = np.nan * np.zeros(tec.shape[0]) # techpf_recovery = np.nan * np.zeros(tec.shape[0]) diff_tec = pyGps.phaseDetrend(tec[idf], order=3) # sigma_phi = pyGps.phaseScintillation(C1[idel], polyfit_order=3, skip=40) tec_recovery[idf] = diff_tec # Plottings ax2.plot(t, tec_recovery, label='sv' + str(sv)) ax3.plot(t[:-1], np.diff(tec), label='sv' + str(sv)) ax1.plot(t, C1[idel], label='sv' + str(sv)) ax3.set_ylim([-1, 1]) ax1.set_xlim([obstimes[0], obstimes[-1]]) ax2.set_ylabel('Detr. tec') ax3.set_ylabel('Delta tec') ax1.set_ylabel('C1') ax3.set_xlabel('time [UTC]') ax1.set_title('Missouri, day ' + str(day) + ' Rx: ' + hdffn[-11:-7]) plt.setp(ax1.get_xticklabels(), visible=False) plt.setp(ax2.get_xticklabels(), visible=False) #ax3.legend(bbox_to_anchor=(1.1, 1.1)) ax1.xaxis.set(major_formatter=formatter) ax2.xaxis.set(major_formatter=formatter) ax3.xaxis.set(major_formatter=formatter) plt.savefig('/home/smrak/Documents/eclipse/plots/mo/' + hdffn[-11:-3] + '.png', dpi=300)
def runSateListRaw(day, el_mask, state): #Find HDF5 filename wlstr = '*' + str(day) + '*.h5' filestr = os.path.join(obsfolder + state + '/' + str(day) + '/', wlstr) flistHDF = glob.glob(filestr) #Find NAV filename wlstr = '*' + str(day) + '*.17n' filestr = os.path.join(navfolder, wlstr) flistNAV = glob.glob(filestr) #Find YAML filenamE wlstr = '*' + str(day) + '*.yaml' filestr = os.path.join(obsfolder + state + '/' + str(day) + '/', wlstr) flistYML = glob.glob(filestr) for i in range(len(flistHDF)): #filenames hdffn = flistHDF[i] navfn = flistNAV[0] ymlfn = flistYML[i] # Processing per station # YAML import header stream = yaml.load(open(ymlfn, 'r')) rx_xyz = stream.get('APPROX POSITION XYZ') # HDF Observations data = read_hdf(hdffn) obstimes = np.array((data.major_axis)) obstimes = pandas.to_datetime(obstimes) - datetime.timedelta( seconds=18) dumb = data['L1', :, 1, 'data'] svlist = dumb.axes[0] fig1 = plt.figure(figsize=(12, 12)) formatter = mdates.DateFormatter('%H:%M') ax1 = fig1.add_subplot(411) #fig2 = plt.figure(figsize=(12,4)) ax2 = fig1.add_subplot(412, sharex=ax1) #fig3 = plt.figure(figsize=(12,4)) ax3 = fig1.add_subplot(413, sharex=ax1) ax4 = fig1.add_subplot(414, sharex=ax1) for sv in svlist: # GPS only svnum <=32 if sv <= 32: C1 = np.array(data['C1', sv, :, 'data']) C2 = np.array(data['P2', sv, :, 'data']) L1 = np.array(data['L1', sv, :, 'data']) L2 = np.array(data['L2', sv, :, 'data']) aer = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, 120, navfn, cs='aer') #filter by Elevation angle idel = np.where((aer[1] > el_mask))[0] t = obstimes[idel] #Get TEC ax1.plot(t, C1[idel], label='sv' + str(sv)) ax2.plot(t, C2[idel], label='sv' + str(sv)) ax3.plot(t, L1[idel], label='sv' + str(sv)) ax4.plot(t, L2[idel], label='sv' + str(sv)) ax1.set_xlim([obstimes[0], obstimes[-1]]) ax1.set_ylabel('C1 [m]') ax2.set_ylabel('P2 [m]') ax3.set_ylabel('L1 [cycle]') ax4.set_ylabel('L2 [cycle]') ax3.set_xlabel('time [UTC]') ax1.set_title(state + ', day ' + str(day) + ' Rx: ' + hdffn[-11:-7]) plt.setp(ax1.get_xticklabels(), visible=False) plt.setp(ax2.get_xticklabels(), visible=False) plt.setp(ax3.get_xticklabels(), visible=False) #ax3.legend(bbox_to_anchor=(1.1, 1.1)) # ax1.xaxis.set(major_formatter = formatter) # ax2.xaxis.set(major_formatter = formatter) ax4.xaxis.set(major_formatter=formatter) plt.savefig('/home/smrak/Documents/eclipse/plots/' + state + '/' + hdffn[-11:-3] + '.png', dpi=300)
def saveTrajectories2HDF(day='184', state='tn', el_mask=30, altitude=100, hdffilename='trajectories_tn.h5', loop=True): hdffolder = '/home/smrak/sharedrive/cors/' navfolder = '/home/smrak/sharedrive/cors/nav/' ymlfolder = '/home/smrak/sharedrive/cors/' #Find HDF5 filename wlstr = '*' + day + '*.h5' filestr = os.path.join(hdffolder + state + '/' + day + '/', wlstr) flistHDF = glob.glob(filestr) #Find NAV filename wlstr = '*' + str(day) + '*.17n' filestr = os.path.join(navfolder, wlstr) flistNAV = glob.glob(filestr) #Find YAML filenamE wlstr = '*' + str(day) + '*.yaml' filestr = os.path.join(ymlfolder + state + '/' + day + '/', wlstr) flistYML = glob.glob(filestr) h5file = h5py.File(hdffilename, 'w') gr = h5file.create_group(day) h5state = gr.create_group(state) if loop: for i in range(len(flistHDF)): hdffn = flistHDF[i] navfn = flistNAV[0] ymlfn = flistYML[i] # YAML import header stream = yaml.load(open(ymlfn, 'r')) rx_xyz = stream.get('APPROX POSITION XYZ') rx_llt = ecef2geodetic(rx_xyz[0], rx_xyz[1], rx_xyz[2]) #Timelim timelim = [ datetime.datetime(2017, 7, 3, 15, 30, 0), datetime.datetime(2017, 7, 3, 19, 30, 0) ] h5rx = h5state.create_group(hdffn[-11:-7]) h5rx.create_dataset('rxpos', data=rx_llt) # HDF Observations try: data = read_hdf(hdffn) obstimes = np.array((data.major_axis)) obstimes = pandas.to_datetime( obstimes[::10]) - datetime.timedelta(seconds=18) idt = np.where((obstimes > timelim[0]) & (obstimes < timelim[1])) obstimes = obstimes[idt] # h5rx.create_dataset('time', data=pyGps.datetime2posix(obstimes)) # dumb = data['L1', :, 1, 'data'] svlist = dumb.axes[0] for sv in svlist: # GPS only svnum <=32 az = np.nan * np.zeros(obstimes.shape[0]) el = np.nan * np.zeros(obstimes.shape[0]) lat = np.nan * np.zeros(obstimes.shape[0]) lon = np.nan * np.zeros(obstimes.shape[0]) if sv <= 32: h5sv = h5rx.create_group('sv' + str(sv)) aer = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, altitude, navfn, cs='aer') llt = pyGps.getIonosphericPiercingPoints(rx_xyz, sv, obstimes, altitude, navfn, cs='wsg84') idel = np.where(aer[1] > el_mask)[0] az[idel] = aer[0][idel] el[idel] = aer[1][idel] lat[idel] = llt[0][idel] lon[idel] = llt[1][idel] h5sv.create_dataset('az', data=az) h5sv.create_dataset('el', data=el) h5sv.create_dataset('lat', data=lat) h5sv.create_dataset('lon', data=lon) print('Saving data for sat: ' + str(sv)) else: break except: raise ValueError h5file.close()