def observedSatellites(colSVIDs, verbose): """ Creates an index of observed satellites Parameters: colSVIDs: contains the SVIDs Returns: Ordered list of observed SVIDs """ if verbose: sys.stdout.write(' Extracting list of observed satellites: ') listSVIDs = sorted(list(set(colSVIDs))) if verbose: for index, SVPRN in enumerate(listSVIDs): gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(SVPRN) sys.stdout.write('%s%d (%d)' % (gnssSystShort, gnssPRN, SVPRN)) if index < len(listSVIDs) - 1: sys.stdout.write(', ') sys.stdout.write('\n') return listSVIDs
sys.exit(E_WRONG_OPTION) # check whether the same signaltypes are on corresponsing lines after sorting if not sbf2stf.verifySignalTypeOrder(dataMeas['MEAS_SIGNALTYPE'], dataExtra['EXTRA_SIGNALTYPE'], dataMeas['MEAS_TOW'], verbose): sys.exit(E_SIGNALTYPE_MISMATCH) # correct the smoothed PR Code and work with the raw PR dataMeas['MEAS_CODE'] = sbf2stf.removeSmoothing(dataMeas['MEAS_CODE'], dataExtra['EXTRA_SMOOTHINGCORR'], dataExtra['EXTRA_MPCORR']) # print('dataMeas['MEAS_CODE'] = %s\n' % dataMeas['MEAS_CODE']) # find list of SVIDs observed SVIDs = sbf2stf.observedSatellites(dataMeas['MEAS_SVID'], verbose) for SVID in SVIDs: print('=' * 50) gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(SVID) print('SVID = %d - %s - %s%d' % (SVID, gnssSyst, gnssSystShort, gnssPRN)) indexSVID = sbf2stf.indicesSatellite(SVID, dataMeas['MEAS_SVID'], verbose) dataMeasSVID = dataMeas[indexSVID] print("indexSVID = %s" % indexSVID) # store temporaray results ONLY for inspection nameDataMeasSVID = str(SVID) + '.csv' print('nameDataMeasSVID = %s' % nameDataMeasSVID) print('dataMeasSVID = %s' % dataMeasSVID) np.savetxt(nameDataMeasSVID, dataMeasSVID, fmt='%i,%.1f,%i,%i,%i,%i,%i,%.2f,%.2f,%.2f,%.2f,%i,%i,%i') signalTypesSVID = sbf2stf.observedSignalTypes(dataMeasSVID['MEAS_SIGNALTYPE'], verbose) print('signalTypesSVID = %s' % signalTypesSVID)
def plotLockTime(SVID, signalTypes, dataMeasSVID, lliIndices, lliTOWs, verbose): """ plotLockTime creates a plot of the locktime and indicates loss of locks Parameters: SVID: satellite ID signalTypes: signal types to represent dataMeasSVID: data from MeasEpoch_2 but for one SVs indexLossOfLock: indices for the occurance of loss of lock verbose: display interactive plot """ # print('\nplotLockTime' + '-' * 25) gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(SVID) # for i, signalType in enumerate(signalTypes): # print('PLT: signalType[%d] = %s' % (i, signalType)) # print('PLT: TOW = %s (%d)' % (dataMeasSVID[i]['MEAS_TOW'], len(dataMeasSVID[i]['MEAS_TOW']))) # print('PLT: lockTimes = %s (%d)\n' % (dataMeasSVID[i]['MEAS_LOCKTIME'], len(dataMeasSVID[i]['MEAS_LOCKTIME']))) # print("PLT: indexLossOfLock[%d] = %s (Nr = %d)" % (i, lliIndices[i], len(lliIndices[i]))) # # myData2 = dataMeasSVID[i][lliIndices[i]] # # print("PLT: myData2 = %s (len = %d)" % (myData2['MEAS_TOW'], len(myData2['MEAS_TOW']))) # # print("PLT: idemand = %s (len = %d)\n" % (dataMeasSVID[i][lliIndices[i]]['MEAS_TOW'], len(dataMeasSVID[i][)lliIndices[i]]['MEAS_TOW'])) # create the plot window # plt.style.use('BEGPIOS') plt.style.use('ggplot') plt.figure(1) subPlot = plt.subplot(1, 1, 1) # titles and axis-labels dateString = gpstime.UTCFromWT( float(dataMeasSVID[0]['MEAS_WNC'][0]), float(dataMeasSVID[0]['MEAS_TOW'][0])).strftime("%d/%m/%Y") plt.title('Lock Times for %s PRN %d (%d)' % (gnssSyst, gnssPRN, SVID)) # , fontsize='18' plt.ylabel('Lock Time [s]') plt.xlabel('Time [hh:mm] (' + dateString + ')') for index, signalType in enumerate(signalTypes): # lockTime = dataMeasSVID[index]['MEAS_LOCKTIME'] # print("index = %d lockTime.size = %d" % (index, len(lockTime))) sigTypeColor = mPlt.getSignalTypeColor(signalType) utc = [] for count in range(0, len(dataMeasSVID[index])): utc.append( gpstime.UTCFromWT( float(dataMeasSVID[index]['MEAS_WNC'][count]), float(dataMeasSVID[index]['MEAS_TOW'][count]))) plt.plot(utc, dataMeasSVID[index]['MEAS_LOCKTIME'], color=sigTypeColor, linestyle='', markersize=0.75, marker='.') # add a marker at the LLI utc2 = [] for count2 in range(0, len(dataMeasSVID[index][lliIndices[index]])): utc2.append( gpstime.UTCFromWT( float(dataMeasSVID[index][lliIndices[index]]['MEAS_WNC'] [count2]), float(dataMeasSVID[index][lliIndices[index]]['MEAS_TOW'] [count2]))) plt.plot(utc2, dataMeasSVID[index][lliIndices[index]]['MEAS_LOCKTIME'], color=sigTypeColor, linestyle='', markersize=7, markerfacecolor=sigTypeColor, marker=mPlt.mFilledMarkers[signalType % len(mPlt.mFilledMarkers)]) # annotate the plot annotateTxt = mSSN.GNSSSignals[signalType]['name'] + str( ': %d LLI' % len(lliIndices[index])) subPlot.text(0.02, 0.95 - index * 0.0375, annotateTxt, verticalalignment='bottom', horizontalalignment='left', transform=subPlot.transAxes, color=sigTypeColor, fontsize=12) # make x-axis a hh:mm:ss ax = plt.gca() xfmt = md.DateFormatter('%H:%M:%S') ax.xaxis.set_major_formatter(xfmt) # adjust range for Y axis axes = plt.gca() axes.set_ylim(mPlt.adjustYAxisLimits(axes)) axes.set_xlim(mPlt.adjustXAxisLimits(axes)) plt.text(0, -0.125, r'$\copyright$ Alain Muls ([email protected])', horizontalalignment='left', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') plt.text(1, -0.125, r'$\copyright$ Frederic Snyers ([email protected])', horizontalalignment='right', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') # mPlt.annotateText(r'$\copyright$ Alain Muls ([email protected])', subPlot, 0, -0.12, 'left', fontsize='x-small') # mPlt.annotateText(r'$\copyright$ Frederic Snyers ([email protected])', subPlot, 1, -0.12, 'right', fontsize='x-small') fig = plt.gcf() # fig.set_size_inches(12*2.5, 9*2.5) fig.savefig('%s-%s%d-locktime.png' % (gnssSyst, gnssSystShort, gnssPRN), dpi=fig.dpi) if verbose: plt.show(block=False) # block=False)
dataExtra['EXTRA_SIGNALTYPE'], dataMeas['MEAS_TOW'], verbose): sys.exit(E_SIGNALTYPE_MISMATCH) # correct the smoothed PR Code and work with the raw PR dataMeas['MEAS_CODE'] = sbf2stf.removeSmoothing( dataMeas['MEAS_CODE'], dataExtra['EXTRA_SMOOTHINGCORR'], dataExtra['EXTRA_MPCORR']) # print 'dataMeas['MEAS_CODE'] = %s\n' % dataMeas['MEAS_CODE'] # find list of SVIDs observed SVIDs = sbf2stf.observedSatellites(dataMeas['MEAS_SVID'], verbose) for SVID in SVIDs: print('=' * 50) gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(SVID) print('SVID = %d - %s - %s%d' % (SVID, gnssSyst, gnssSystShort, gnssPRN)) indexSVID = sbf2stf.indicesSatellite(SVID, dataMeas['MEAS_SVID'], verbose) dataMeasSVID = dataMeas[indexSVID] # print "indexSVID = %s" % indexSVID # store temporaray results ONLY for inspection # nameDataMeasSVID = str(SVID) + '.csv' # np.savetxt(nameDataMeasSVID, dataMeasSVID, fmt=colFmtMeasEpoch) signalTypesSVID = sbf2stf.observedSignalTypes( dataMeasSVID['MEAS_SIGNALTYPE'], verbose) # print 'signalTypesSVID = %s' % signalTypesSVID
def plotSidePeaks(SVID, signalTypesSVID, WkNr, iTOW, deltaPR, sidePeaksTOW, sidePeakDPR, jumpDPRNear97Indices, jumpDPRNear1465Indices, lliTOWs, strDate, verbose): """ plotSidePeaks plots the difference between the code measurements on L1A (reference) and E6A and indicates where a possible side peak is noticed Parameters: SVID: SSN SVID of satellite signalTypesSVID; the signal types for this SVID WkNt: week number iTOW: common TOWs where both code measurements are available deltaPR: difference between PR on L1A and E61 sidePeaksTOW: list of TOWs which could be indicators of SidePeaks sidePeakDPR: delta PR at these TOWs jumpDPRNear97Indices: indices in sidePeaksTOW, sidePeakDPR which are closest to integer multipe of 9.7m jumpDPRNear1465Indices: indices in sidePeaksTOW, sidePeakDPR which are closest to integer multipe of 14.65m lliTOWs: TOW that indicate a loss of lock per signal type strDate: observation date verbose: ok """ print '-' * 50 # get info for GNSS satellite gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(SVID) SVIDColor = mPlt.getSVIDColor(SVID) # create the plot window # plt.style.use('BEGPIOS') plt.style.use('ggplot') plt.figure(2) subPlot = plt.subplot(1, 1, 1) # titles and axis-labels plt.title('Side Peak Indicator for %s PRN %d (%d)' % (gnssSyst, gnssPRN, SVID)) # , fontsize='18' plt.ylabel(r'$\Delta$ PR (%s - %s)' % (mSSN.GNSSSignals[16]['name'], mSSN.GNSSSignals[18]['name'])) plt.xlabel('Time [hh:mm] (' + strDate + ')') # plot the deltaPRs vs iTOW print 'iTOW = %s (%d)' % (iTOW, len(iTOW)) print 'deltaPR = %s (%d)' % (deltaPR, len(deltaPR)) # plot the indicators for the sidepeaks after conversion to utc utc2 = [] # used for all possible detections utc3 = [] # used for those that are multiple of 9.7m utc4 = [] # used for those that are multiple of 14.65m for count in range(0, len(sidePeaksTOW)): utc2.append(gpstime.UTCFromWT(float(WkNr), float(sidePeaksTOW[count]))) if count in jumpDPRNear97Indices: utc3.append(utc2[-1]) if count in jumpDPRNear1465Indices: utc4.append(utc2[-1]) plt.plot(utc2, sidePeakDPR, color='orange', linestyle='', markersize=7, marker='o', markeredgecolor='orange', markerfacecolor=None) print 'utc2 = %s (#%d)' % (utc2, len(utc2)) print 'sidePeakDPR = %s (#%d)' % (sidePeakDPR, len(sidePeakDPR)) print 'jumpDPRNear97Indices = %s (#%d)' % (jumpDPRNear97Indices, len(jumpDPRNear97Indices)) print 'sidePeakDPR = %s (#%d)' % (sidePeakDPR[jumpDPRNear97Indices], len(sidePeakDPR[jumpDPRNear97Indices])) print 'utc3 = %s (#%d)' % (utc3, len(utc3)) plt.plot(utc3, sidePeakDPR[jumpDPRNear97Indices], color='red', linestyle='', markersize=7, marker='o', markeredgecolor='red', markerfacecolor=None) plt.plot(utc4, sidePeakDPR[jumpDPRNear1465Indices], color='blue', linestyle='', markersize=7, marker='o', markeredgecolor='blue', markerfacecolor=None) # annotate to signal number of detections and number of integer multiple of 9.7m annotateTxt = 'Side Peaks on E1A: %d' % len(utc3) subPlot.text(0.95, 0.95, annotateTxt, verticalalignment='bottom', horizontalalignment='right', transform=subPlot.transAxes, color='red', fontsize=12) # annotate to signal number of detections and number of integer multiple of 14.65m annotateTxt = 'Side Peaks on E6A: %d' % len(utc4) subPlot.text(0.95, 0.92, annotateTxt, verticalalignment='bottom', horizontalalignment='right', transform=subPlot.transAxes, color='blue', fontsize=12) annotateTxt = 'Other: %d' % (len(utc2) - len(utc3) - len(utc4)) subPlot.text(0.95, 0.89, annotateTxt, verticalalignment='bottom', horizontalalignment='right', transform=subPlot.transAxes, color='orange', fontsize=12) # transform WkNr, TOW to UTC time utc = [] for i in range(0, len(iTOW)): utc.append(gpstime.UTCFromWT(float(WkNr), float(iTOW[i]))) # plot the deltaPR vs UTC time plt.plot(utc, deltaPR, color=SVIDColor, linestyle='-', linewidth=0.5, marker='.', markersize=3.5) # , linestyle='', marker='.', markersize=1) for i, lliTOWsST in enumerate(lliTOWs): print 'lliTOWs[%d] = %s' % (i, lliTOWsST) utc2 = [] sigTypeColor = mPlt.getSignalTypeColor(signalTypesSVID[i]) # annotate the plot annotateTxt = mSSN.GNSSSignals[signalTypesSVID[i]]['name'] + ' LLI' subPlot.text(0.02, 0.95 - i * 0.0375, annotateTxt, verticalalignment='bottom', horizontalalignment='left', transform=subPlot.transAxes, color=sigTypeColor, fontsize=12) # drax vertical line for the LLI indicators for j, lliTOWST in enumerate(lliTOWsST): utc2.append(gpstime.UTCFromWT(float(WkNr), lliTOWST)) # print 'lliTOWs[%d] = %s utc = %s' % (j, lliTOWST, utc2[j]) # draw a vertical line in the color of the signal type plt.axvline(utc2[j], color=sigTypeColor) print 'sidePeaksTOW = %s (%d)' % (sidePeaksTOW, len(sidePeaksTOW)) # print 'utc2 = %s (%d)' % (utc2, len(utc2)) # plt.plot(sidePeaksTOW, 0.5, color='red', linestyle='', markersize=7, marker=mPlt.mFilledMarkers[SVID % len(mPlt.mFilledMarkers)]) # adjust the axes to represent hh:mm:ss ax = plt.gca() xfmt = md.DateFormatter('%H:%M:%S') ax.xaxis.set_major_formatter(xfmt) # adjust range for Y axis axes = plt.gca() axes.set_ylim(mPlt.adjustYAxisLimits(axes)) axes.set_xlim(mPlt.adjustXAxisLimits(axes)) plt.text(0, -0.125, r'$\copyright$ Alain Muls ([email protected])', horizontalalignment='left', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') plt.text(1, -0.125, r'$\copyright$ Frederic Snyers ([email protected])', horizontalalignment='right', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') fig = plt.gcf() # fig.set_size_inches(12*2.5, 9*2.5) fig.savefig('%s-%s%d-sidepeak.png' % (gnssSyst, gnssSystShort, gnssPRN), dpi=fig.dpi) if verbose: plt.show() # close the figure plt.close() print '-' * 50
def plotCN0(k, firstSV, listSVIDs, listST, spanElevation, spanUTC, spanJammingStart, spanJammingEnd, CN0meas, dataVisibilitySVprn, dataJammingValues, dateStr, verbose=False): """ plotCN0 plots the CN0 values for SVs per signalType observed Parameters: k is the coresponding satellite from the Visibility block listSVIDs is list of SVIDs we have data for listST is list of signaltypes spanTElevation is the GPS time representation of satellites from Elevation file spanUTC is the UTC representation of spanElevation CN0meas contains observed CN0 for all SVs and all signalTypes """ # plt.style.use('ggplot') # plt.style.use('BEGPIOS') # first plot all SVs per signalType # get unique list of signaltypes to determine the number of plots we have to make uniqSTs = list(set(listST)) uniqSVs = list(set(listSVIDs)) figNr = len(uniqSTs) # nr of figures already used # print('uniqSTs = %s' % uniqSTs) # loop over the signalTypes if k == firstSV: for i, uniqSTi in enumerate(uniqSTs): plt.figure(i) ax = plt.gca() ax.set_color_cycle(['purple', 'black', 'green', 'cyan', 'violet']) # create label for identify SV and plot its CN0 value for this signalType satLabel = [] # colors = iter(cm.rainbow(np.linspace(0, 1, len(listSVIDs)))) for j, STj in enumerate(listST): if STj == uniqSTi: satLabel.append(mSSN.svPRN(listSVIDs[j])[1] + str(mSSN.svPRN(listSVIDs[j])[2])) plt.plot(spanUTC, CN0meas[j], linestyle='-', linewidth=0.5, alpha=0.75, label=satLabel[-1]) print('i = %d len = %d' % (i, np.size(uniqSTs))) # plot annotation plt.title('Signaltype: %s' % mSSN.GNSSSignals[uniqSTi]['name'], fontsize='x-large') plt.xlabel('Time of ' + dateStr) plt.ylabel('C/N0') # adjust the X-axis to represent readable time ax.xaxis.set_major_formatter(md.DateFormatter('%H:%M:%S')) plt.xlim(spanUTC[0], spanUTC[-1]) # annotate for copyright plt.text(0, -0.125, r'$\copyright$ Alain Muls ([email protected])', horizontalalignment='left', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') plt.text(1, -0.125, r'$\copyright$ Andrei Alex ([email protected])', horizontalalignment='right', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') # add the legend # Shrink current axis's height by x% on the bottom box = ax.get_position() # print('box.x0 = %f' % box.x0) # print('box.y0 = %f' % box.y0) # print('box.width = %f' % box.width) # print('box.height = %f' % box.height) # ax = plt.subplot(111) ax.set_position([box.x0, box.y0 + box.height * 0.3, box.width, box.height * 0.7]) box = ax.get_position() # print('after\nbox.x0 = %f' % box.x0) # print('box.y0 = %f' % box.y0) # print('box.width = %f' % box.width) # print('box.height = %f' % box.height) plt.legend(bbox_to_anchor=(box.x0 + box.width*0.2, -0.15, box.width*0.6, 0.15), loc='lower center', ncol=np.size(satLabel), fontsize='xx-small') llines = plt.gca().get_legend().get_lines() # all the lines.Line2D instance in the legend plt.setp(llines, linewidth=4) # the legend linewidth # ggplot2.rstyle(ax) fig = plt.gcf() if verbose: print('\nfigname = %s -- %s' % (STj, mSSN.GNSSSignals[uniqSTi]['name'])) fig.savefig('%s-CN0.png' % (mSSN.GNSSSignals[uniqSTi]['name']), dpi=fig.dpi) if i != len(uniqSTs) - 1: if verbose: plt.show(block=False) else: if verbose: plt.show() # second plot all signalTypes per SVs # find the SV identifiers ans make them unique for i, uniqSVi in enumerate(uniqSVs): plt.figure(i + figNr) ax = plt.gca() # create label for signalType and plot its SN0 for this uniqSVi stLabel = [] colors = iter(cm.rainbow(np.linspace(0, 1, len(listST)))) for j, SVj in enumerate(listSVIDs): if SVj == uniqSVi: stLabel.append(mSSN.GNSSSignals[listST[j]]['name']) print('mSSN.GNSSSignals[listST[%d]][name] = %s' % (j, mSSN.GNSSSignals[listST[j]]['name'])) print('spanUTC = %s ==> %s' % (spanUTC[0], spanUTC[-1])) plt.plot(spanUTC, CN0meas[j], linestyle='-', color=next(colors), linewidth=0.25, alpha=0.75, label=stLabel[-1]) ax.set_ylim(0, 60) # plot annotation gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(SVj) textSVID = gnssSystShort + str(gnssPRN) print('j = %d - SV = %s, uniqSVi = %s\n' % (i, textSVID, uniqSVi)) plt.title('Satellite: %s' % textSVID) plt.xlabel('Time of ' + dateStr) plt.ylabel('C/N0') # adjust the X-axis to represent readable time ax.xaxis.set_major_formatter(md.DateFormatter('%H:%M:%S')) plt.xlim(spanUTC[0], spanUTC[-1]) # annotate for copyright plt.text(0, -0.125, r'$\copyright$ Alain Muls ([email protected])', horizontalalignment='left', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') plt.text(1, -0.125, r'$\copyright$ Andrei Alex ([email protected])', horizontalalignment='right', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') # add the legend # Shrink current axis's height by x% on the bottom box = ax.get_position() # print('box.x0 = %f' % box.x0) # print('box.y0 = %f' % box.y0) # print('box.width = %f' % box.width) # print('box.height = %f' % box.height) # ax = plt.subplot(111) ax.set_position([box.x0, box.y0 + box.height * 0.4, box.width, box.height * 0.6]) box = ax.get_position() # print('after\nbox.x0 = %f' % box.x0) # print('box.y0 = %f' % box.y0) # print('box.width = %f' % box.width) # print('box.height = %f' % box.height) plt.legend(bbox_to_anchor=(box.x0 + box.width*0.2, -0.15, box.width*0.6, 0.15), loc='lower center', ncol=np.size(stLabel), fontsize='xx-small') llines = plt.gca().get_legend().get_lines() # all the lines.Line2D instance in the legend plt.setp(llines, linewidth=4) # the legend linewidth # plt.legend(bbox_to_anchor=(0., 1.052, 1., .052), loc='lower left', ncol=np.size(stLabel), mode="expand", borderaxespad=0., fontsize=9) plt.tight_layout(rect=(0, 0, 1, 1)) # Shrink current axis's height by 10% on the bottom box = ax.get_position() ax = plt.subplot(111) ax.set_position([box.x0, box.y0 + box.height * 0.1, box.width, box.height * 0.9]) fig = plt.gcf() fig.savefig('%s-%s%d-CN0.png' % (gnssSyst, gnssSystShort, gnssPRN), dpi=fig.dpi) if i != len(uniqSVs)-1: if verbose: plt.show(block=False) else: if verbose: plt.show() # close the figure plt.close() for i, uniqSVi in enumerate(uniqSVs): if k == uniqSVi: fig = plt.figure(i + figNr) ax = plt.gca() ax.set_color_cycle(['purple', 'black', 'green', 'cyan', 'violet']) # create label for signalType and plot its SN0 for this uniqSVi stLabel = [] for j, SVj in enumerate(listSVIDs): if SVj == uniqSVi: stLabel.append(mSSN.GNSSSignals[listST[j]]['name']) print('mSSN.GNSSSignals[listST[%d]][name] = %s' % (j, mSSN.GNSSSignals[listST[j]]['name'])) print('spanUTC = %s ==> %s' % (spanUTC[0], spanUTC[-1])) # plotting CNO ax.plot(spanUTC, CN0meas[j], linestyle='-', linewidth=0.5, alpha=1, label=stLabel[-1]) ax.set_ylim(0, 60) # plot annotation for CN0 gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(SVj) textSVID = gnssSystShort + str(gnssPRN) print('j = %d - SV = %s, uniqSVi = %s\n' % (i, textSVID, uniqSVi)) plt.title('Satellite: %s' % textSVID) plt.xlabel('Time of ' + dateStr) # plotting Elevation ax2 = ax.twinx() ax2.set_ylim(0, 90) ax2.plot(spanElevation, dataVisibilitySVprn, linestyle='-', color='red', linewidth=0.5, alpha=0.75, label='Elevation') ax.set_ylabel('C/NO', fontsize='x-large') ax2.set_ylabel('Elevation', fontsize='x-large') y_min, y_max = ax.get_ylim() # plotting vertical lines corresponding the jamming starting and ending time for i, j, k in zip(spanJammingStart, spanJammingEnd, dataJammingValues): ax.axvline(i, color='k', linestyle='-') ax.axvline(j, color='K', linestyle='-') ax.text(i, y_min + 2, k, horizontalalignment='right', rotation='90') ax.fill([i, i, j, j], [y_min, y_max, y_max, y_min], color='gray', alpha=0.2) # adjust the X-axis to represent readable time ax.xaxis.set_major_formatter(md.DateFormatter('%H:%M:%S')) plt.xlim(spanUTC[0], spanUTC[-1]) # if k == uniqSVi: # ax2 = plt.gca() # ax2.xaxis.set_major_formatter(md.DateFormatter('%H:%M:%S')) # ax2.xlim(spanUTC[0], spanUTC[-1]) # annotate for copyright plt.text(0, -0.125, r'$\copyright$ Alain Muls ([email protected])', horizontalalignment='left', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') plt.text(1, -0.125, r'$\copyright$ Andrei Alex ([email protected])', horizontalalignment='right', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') # add the legend # Shrink current axis's height by x% on the bottom box = ax.get_position() # print('box.x0 =a%f' % box.x0) # print('box.y0 = %f' % box.y0) # print('box.width = %f' % box.width) # print('box.height = %f' % box.height) ax.set_position([box.x0, box.y0 + box.height * 0.4, box.width, box.height * 0.6]) box = ax.get_position() # print('after\nbox.x0 = %f' % box.x0) # print('box.y0 = %f' % box.y0) # print('box.width = %f' % box.width) # print('box.height = %f' % box.height) ax.legend(bbox_to_anchor=(box.x0 + box.width*0.2, -0.15, box.width*0.6, 0.15), loc='lower center', ncol=np.size(stLabel), fontsize='xx-small') # ax2.legend(bbox_to_anchor=(box.x0 + box.width*0.2, -0.15, box.width*0.6, 0.15), loc='best', ncol=np.size(stLabel), fontsize='xx-small') # plt.legend(bbox_to_anchor=(0., 1.052, 1., .052), loc='lower left', ncol=np.size(stLabel), mode="expand", borderaxespad=0., fontsize=9) # llines = plt.gca().get_legend().get_lines() # all the lines.Line2D instance in the legend # plt.setp(llines, linewidth=4) # the legend linewidth plt.tight_layout(rect=(0, 0, 1, 1)) # Shrink current axis's height by 10% on the bottom box = ax.get_position() ax.set_position([box.x0, box.y0 + box.height * 0.1, box.width, box.height * 0.9]) fig.subplots_adjust(wspace=.2, hspace=.1) fig = plt.gcf() fig.savefig('%s-%s%d-CN0.png' % (gnssSyst, gnssSystShort, gnssPRN), dpi=fig.dpi, bbox_inches='tight') if i != len(uniqSVs)-1: if verbose: plt.show(block=False) else: if verbose: plt.show() # close the figure plt.close()
for i, SVID in enumerate(SVIDlist): print('Observed SV %d - SignalType = %d' % (SVID, STlist[i])) # adjust the measCNO arrays to fill with NaN as to fit the TOWall array for plotting measCN0span = [] for i in range(len(measCN0)): measCN0span.append(fillDataGaps(TOWspan, measTOW[i], measCN0[i])) for i in range(len(measCN0)): print('measCN0span[%d] = %s (%d)' % (i, measCN0span[i], len(measCN0span[i]))) # creates the lists of CN0 diff measCN0diff = [] for i in range(len(measCN0span)): measCN0diff.append(np.diff(measCN0span[i])) # adjust the length of time span to fit the CN0 diff UTCspan.remove(UTCspan[0]) # create the plots for each signaltype plotCN0diff.plotCN0diff(SVIDlist, STlist, UTCspan, measCN0diff, dateString, verbose) # calculating the mean elevation for each signal type meanElev = [] for i in SVIDlistElev: ELEVATIONVisibility = extractELEVATION(i, dataVisibility, verbose) mean = np.mean(ELEVATIONVisibility) meanElev.append(mean) # determine the maximum difference of CN0 for i in range(len(measCN0diff)): gnssSystCN0, gnssSystShortCN0, gnssPRNCN0 = mSSN.svPRN(SVIDlist[i]) print('Satellite %d signaltype %s has %s maximum var. at the elev. of %s ' % (gnssPRNCN0, mSSN.GNSSSignals[STlist[i]]['name'], np.nanmin(measCN0diff[i]), meanElev[i])) sys.exit(E_SUCCESS)
def plotLockTime(SVID, signalTypes, dataMeasSVID, lliIndices, lliTOWs, verbose): """ plotLockTime creates a plot of the locktime and indicates loss of locks Parameters: SVID: satellite ID signalTypes: signal types to represent dataMeasSVID: data from MeasEpoch_2 but for one SVs indexLossOfLock: indices for the occurance of loss of lock verbose: display interactive plot """ # print('\nplotLockTime' + '-' * 25) gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(SVID) # for i, signalType in enumerate(signalTypes): # print('PLT: signalType[%d] = %s' % (i, signalType)) # print('PLT: TOW = %s (%d)' % (dataMeasSVID[i]['MEAS_TOW'], len(dataMeasSVID[i]['MEAS_TOW']))) # print('PLT: lockTimes = %s (%d)\n' % (dataMeasSVID[i]['MEAS_LOCKTIME'], len(dataMeasSVID[i]['MEAS_LOCKTIME']))) # print("PLT: indexLossOfLock[%d] = %s (Nr = %d)" % (i, lliIndices[i], len(lliIndices[i]))) # # myData2 = dataMeasSVID[i][lliIndices[i]] # # print("PLT: myData2 = %s (len = %d)" % (myData2['MEAS_TOW'], len(myData2['MEAS_TOW']))) # # print("PLT: idemand = %s (len = %d)\n" % (dataMeasSVID[i][lliIndices[i]]['MEAS_TOW'], len(dataMeasSVID[i][)lliIndices[i]]['MEAS_TOW'])) # create the plot window # plt.style.use('BEGPIOS') plt.style.use('ggplot') plt.figure(1) subPlot = plt.subplot(1, 1, 1) # titles and axis-labels dateString = gpstime.UTCFromWT(float(dataMeasSVID[0]['MEAS_WNC'][0]), float(dataMeasSVID[0]['MEAS_TOW'][0])).strftime("%d/%m/%Y") plt.title('Lock Times for %s PRN %d (%d)' % (gnssSyst, gnssPRN, SVID)) # , fontsize='18' plt.ylabel('Lock Time [s]') plt.xlabel('Time [hh:mm] (' + dateString + ')') for index, signalType in enumerate(signalTypes): # lockTime = dataMeasSVID[index]['MEAS_LOCKTIME'] # print("index = %d lockTime.size = %d" % (index, len(lockTime))) sigTypeColor = mPlt.getSignalTypeColor(signalType) utc = [] for count in range(0, len(dataMeasSVID[index])): utc.append(gpstime.UTCFromWT(float(dataMeasSVID[index]['MEAS_WNC'][count]), float(dataMeasSVID[index]['MEAS_TOW'][count]))) plt.plot(utc, dataMeasSVID[index]['MEAS_LOCKTIME'], color=sigTypeColor, linestyle='', markersize=0.75, marker='.') # add a marker at the LLI utc2 = [] for count2 in range(0, len(dataMeasSVID[index][lliIndices[index]])): utc2.append(gpstime.UTCFromWT(float(dataMeasSVID[index][lliIndices[index]]['MEAS_WNC'][count2]), float(dataMeasSVID[index][lliIndices[index]]['MEAS_TOW'][count2]))) plt.plot(utc2, dataMeasSVID[index][lliIndices[index]]['MEAS_LOCKTIME'], color=sigTypeColor, linestyle='', markersize=7, markerfacecolor=sigTypeColor, marker=mPlt.mFilledMarkers[signalType % len(mPlt.mFilledMarkers)]) # annotate the plot annotateTxt = mSSN.GNSSSignals[signalType]['name'] + str(': %d LLI' % len(lliIndices[index])) subPlot.text(0.02, 0.95 - index * 0.0375, annotateTxt, verticalalignment='bottom', horizontalalignment='left', transform=subPlot.transAxes, color=sigTypeColor, fontsize=12) # make x-axis a hh:mm:ss ax = plt.gca() xfmt = md.DateFormatter('%H:%M:%S') ax.xaxis.set_major_formatter(xfmt) # adjust range for Y axis axes = plt.gca() axes.set_ylim(mPlt.adjustYAxisLimits(axes)) axes.set_xlim(mPlt.adjustXAxisLimits(axes)) plt.text(0, -0.125, r'$\copyright$ Alain Muls ([email protected])', horizontalalignment='left', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') plt.text(1, -0.125, r'$\copyright$ Frederic Snyers ([email protected])', horizontalalignment='right', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') # mPlt.annotateText(r'$\copyright$ Alain Muls ([email protected])', subPlot, 0, -0.12, 'left', fontsize='x-small') # mPlt.annotateText(r'$\copyright$ Frederic Snyers ([email protected])', subPlot, 1, -0.12, 'right', fontsize='x-small') fig = plt.gcf() # fig.set_size_inches(12*2.5, 9*2.5) fig.savefig('%s-%s%d-locktime.png' % (gnssSyst, gnssSystShort, gnssPRN), dpi=fig.dpi) if verbose: plt.show(block=False) # block=False)
def findSidePeaks(SVID, signalTypes, dataMeasSVID, verbose): ''' findSidePeaks finds the side peak correlation by differencing the code measurements on E1A and E6 Parameters: SVID: identifies the satellite signalTypes: the signals observed for that satellite (ordered list!! so 16 (L1A) before 18 (E6A)) dataMeasSVID: the data observed for that satellite Returns: iTOW: the TOWs for which both signals are present dPR: the difference between the E1A and E6A Pseudo Range measurements sidePeakIndex: the index at which a jump in dPR is detected (exluding the first value) jumpDPR: the difference between dPR at detected side peak and its previous value (thus jump in dPR detected) jumpDPRNear97Indices: indices in jumpDPR identifying the elements nearest to 9.7 integer multiple ''' print('-' * 50) if verbose: sys.stdout.write(' Looking for Side Peaks\n') gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(SVID) # define limits for delta PR for detecting 'possible' and 'probable' sidePeak indicators dPRlimit = 4.0 # meter jumpMargin = 0.05 # 5 percent margin on multiple of 9.7 m # deterimine the intersection and get the indices on both signal types for that intersection indexTOWIntersect = [] iMeas = [] # intersection on TOW between the signaltypes for this SVID # get the TOW that are present for bith SignalTypes iTOW = np.intersect1d(dataMeasSVID[0]['MEAS_TOW'], dataMeasSVID[1]['MEAS_TOW']) # print('iTOW %s ()' % (iTOW, len(iTOW))) for index, dataSVIDMeas in enumerate(dataMeasSVID): mask = np.in1d(dataSVIDMeas['MEAS_TOW'], iTOW) indexTOWIntersect.append(np.argwhere(mask).flatten()) # create intersection views on data iMeas.append(dataSVIDMeas[indexTOWIntersect[index]]) print('indexTOWIntersect[%d] = %s (#%d)' % (index, indexTOWIntersect[index], len(indexTOWIntersect[index]))) print('iMeas[%d][MEAS_TOW] = %s (#%d)\n' % (index, iMeas[index]['MEAS_TOW'], len(iMeas[index]['MEAS_CODE']))) # # save for debugging purposes # fileName = 'meas%s%d-st%d.csv' % (gnssSystShort, gnssPRN, signalTypes[index]) # np.savetxt(fileName, iMeas[index], fmt=mSSN.colFmtMeasEpoch) # determine difference between observed CODE measurements at each intersecting TOW dPR = iMeas[0]['MEAS_CODE'] - iMeas[1]['MEAS_CODE'] print('dPR = %s (#%d)' % (dPR, len(dPR))) # look for side-peak indicators when dPR > dPRlimit sidePeakIndex = np.where(np.fabs(np.ediff1d(np.concatenate((np.array([0]), dPR)))) > dPRlimit)[0] print('sidePeakIndex = %s (#%d)\n' % (sidePeakIndex, len(sidePeakIndex))) sidePeakIndex = [] sidePeakIndex = np.where(np.fabs(np.ediff1d(dPR[0:])) > dPRlimit)[0] + 1 # add 1 since we ignore the first value for ediff1d print('sidePeakIndex = %s (#%d)\n' % (sidePeakIndex, len(sidePeakIndex))) print(np.ediff1d(np.concatenate((np.array([0]), dPR)))) print(np.ediff1d(dPR[0:])) print('sidePeakIndex = %s (#%d)\n' % (sidePeakIndex, len(sidePeakIndex))) # create array for the TOW/dPR based on the index indicators for sidePeaks sidePeakTOWs = dataMeasSVID[0][indexTOWIntersect[0]]['MEAS_TOW'][sidePeakIndex] sidePeakDPR = dPR[sidePeakIndex] print('sidePeakTOWs = %s (#%d)' % (sidePeakTOWs, len(sidePeakTOWs))) print('sidePeakDPR = %s (#%d)\n' % (sidePeakDPR, len(sidePeakDPR))) # calculate the difference between the detected sidePeak dPR and the previous observed value of dPR prevIndex = sidePeakIndex - 1 jumpDPR = dPR[sidePeakIndex] - dPR[prevIndex] print('jumpDPR = %s (#%d)' % (jumpDPR, len(jumpDPR))) print('jumpDPR = %s (#%d)' % ((abs(jumpDPR) / 9.7), len(jumpDPR))) print('jumpDPR = %s (#%d)' % (np.rint((abs(jumpDPR) / 9.7)), len(jumpDPR))) jumpDPRNear97 = abs((abs(jumpDPR) / 9.7) - np.rint((abs(jumpDPR) / 9.7))) jumpDPRNear97Indices = np.where(jumpDPRNear97 < jumpMargin)[0] print('jumpDPRNear97 = %s (#%d)' % (jumpDPRNear97Indices, len(jumpDPRNear97Indices))) jumpDPRNear1465 = abs((abs(jumpDPR) / 14.65) - np.rint((abs(jumpDPR) / 14.65))) jumpDPRNear1465Indices = np.where(jumpDPRNear1465 < jumpMargin)[0] print('jumpDPRNear1465 = %s (#%d)' % (jumpDPRNear1465Indices, len(jumpDPRNear1465Indices))) print('-' * 50) return iTOW, dPR, sidePeakTOWs, sidePeakDPR, jumpDPR, jumpDPRNear97Indices, jumpDPRNear1465Indices
def plotCN0diff(listSVIDs, listST, spanUTC, CN0measdiff, dateStr, verbose=False): ''' plotCN0 plots the CN0 values for SVs per signalType observed Parameters: listSVIDs is list of SVIDs we have data for listST is list of signaltypes spanUTC is the UTC representation of spanElevation CN0measdiff contains observed CN0 variation for all SVs and all signalTypes dateStr is the respective day of observations ''' # get unique list of signaltypes to determine the number of plots we have to make uniqSVs = list(set(listSVIDs)) for i, uniqSVi in enumerate(uniqSVs): plt.figure(i) ax = plt.gca() # create label for signalType and plot its SN0 for this uniqSVi stLabel = [] ax.set_color_cycle(['black', 'yellow', 'blue', 'pink']) for j, SVj in enumerate(listSVIDs): if SVj == uniqSVi: stLabel.append(mSSN.GNSSSignals[listST[j]]['name']) print('mSSN.GNSSSignals[listST[%d]][name] = %s' % (j, mSSN.GNSSSignals[listST[j]]['name'])) print('spanUTC = %s ==> %s' % (spanUTC[0], spanUTC[-1])) print(len(spanUTC), len(CN0measdiff[j])) plt.plot(spanUTC, CN0measdiff[j], linestyle='-', linewidth=0.25, alpha=0.75, label=stLabel[-1]) ax.set_ylim(-4, 4) # plot annotation gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(SVj) textSVID = gnssSystShort + str(gnssPRN) print('j = %d - SV = %s, uniqSVi = %s\n' % (i, textSVID, uniqSVi)) plt.title('Satellite: %s' % textSVID) plt.xlabel('Time of ' + dateStr) plt.ylabel('C/N0 variation') # adjust the X-axis to represent readable time ax.xaxis.set_major_formatter(md.DateFormatter('%H:%M:%S')) plt.xlim(spanUTC[0], spanUTC[-1]) # annotate for copyright plt.text(0, -0.125, r'$\copyright$ Alain Muls ([email protected])', horizontalalignment='left', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') plt.text(1, -0.125, r'$\copyright$ Andrei Alexandru ([email protected])', horizontalalignment='right', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') # Shrink current axis's height by x% on the bottom box = ax.get_position() ax.set_position([box.x0, box.y0 + box.height * 0.4, box.width, box.height * 0.6]) box = ax.get_position() plt.legend(bbox_to_anchor=(box.x0 + box.width*0.2, -0.15, box.width*0.6, 0.15), loc='lower center', ncol=np.size(stLabel), fontsize='xx-small') llines = plt.gca().get_legend().get_lines() # all the lines.Line2D instance in the legend plt.setp(llines, linewidth=4) # the legend linewidth plt.tight_layout(rect=(0, 0, 1, 1)) # Shrink current axis's height by 10% on the bottom box = ax.get_position() ax = plt.subplot(111) ax.set_position([box.x0, box.y0 + box.height * 0.1, box.width, box.height * 0.9]) fig = plt.gcf() fig.savefig('%s-%s%d-CN0.png' % (gnssSyst, gnssSystShort, gnssPRN), dpi=fig.dpi) if i != len(uniqSVs)-1: if verbose: plt.show(block=False) else: if verbose: plt.show() # close the figure plt.close()
def skyview(PRNs, azimuths, elevations, dateStr, hours, hoursAzims, hoursElevs): ''' skyview creates the skyview plot for observed satellites Parameters: PRNs is list of PRNs of observed satellites azimuths is aziumuts with which these satellites were observed (in degrees) elevations is elevation angle with which these satellites were observed (in degrees) dateStr contains the current date hours contain the TOWs that correspond to a multiple of hours hoursAzims, hoursElevs contain the corersponding azimuth/elevation (in degrees) Returns: fig is reference to created plot ''' plt.style.use('BEGPIOS') # rc('grid', color='#999999', linewidth=1, linestyle='-', alpha=[0].6) rc('xtick', labelsize='x-small') rc('ytick', labelsize='x-small') # force square figure and square axes looks better for polar, IMO width, height = rcParams['figure.figsize'] size = min(width, height) # make a square figure fig = figure(figsize=(size, size)) # set the axis (0 azimuth is North direction, azimuth indirect angle) ax = fig.add_axes([0.10, 0.15, 0.8, 0.8], projection=u'polar') # , axisbg='#CCCCCC', alpha=0.6) ax.set_theta_zero_location('N') ax.set_theta_direction(-1) # Define the xticks ax.set_xticks(np.linspace(0, 2 * np.pi, 13)) xLabel = ['N', '30', '60', 'E', '120', '150', 'S', '210', '240', 'W', '300', '330'] ax.set_xticklabels(xLabel) # Define the yticks ax.set_yticks(np.linspace(0, 90, 7)) yLabel = ['', '75', '60', '45', '30', '15', ''] ax.set_yticklabels(yLabel) # annotate for copyright and put the currecnt date text(-0.1, 1, dateStr, horizontalalignment='left', verticalalignment='bottom', transform=ax.transAxes, fontsize='large') text(1.1, 1, r'$\copyright$ Alain Muls ([email protected])', horizontalalignment='right', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') # draw a grid grid(True) # treat the sky track of the satellites # for (PRN, E, Az) in sat_positions: # ax.annotate(str(PRN), # xy=(radians(Az), 90-E), # theta, radius # bbox=dict(boxstyle="round", fc='green', alpha=0.5), # horizontalalignment='center', # verticalalignment='center') # plot the skytracks for each PRN colors = iter(plt.cm.rainbow(np.linspace(0, 1, len(PRNs)))) satLabel = [] for i, prn in enumerate(PRNs): gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(prn) satLabel.append('%s%d (%d)' % (gnssSystShort, gnssPRN, prn)) azims = [radians(az) for az in azimuths[i]] elevs = [(90 - el) for el in elevations[i]] # print('PRN = %d' % prn) # print('elev = %s' % elevs) # print('azim = %s' % azims) # ax.plot(azims, elevs, color=next(colors), linewidth=0.35, alpha=0.85, label=satLabel[-1]) ax.plot(azims, elevs, color=next(colors), marker='.', markersize=1, linestyle='None', alpha=0.85, label=satLabel[-1]) # annotate with the hour labels hrAzims = [radians(az + 2) for az in hoursAzims[i]] hrElevs = [(90 - el) for el in hoursElevs[i]] for j, hr in enumerate(hours[i]): hrAz = hrAzims[j] hrEl = hrElevs[j] # print('hr = %s' % hr) hr = int((np.fmod(hr, gpstime.secsInDay)) / 3600.) # print('hr = %s' % hr) # print('hrAz = %d' % hrAz) # print('hrEl = %d' % hrEl) text(hrAz, hrEl, hr, fontsize='x-small') # adjust the legend location mLeg = ax.legend(bbox_to_anchor=(0.5, -0.15), loc='lower center', ncol=np.size(satLabel), fontsize='small', markerscale=4) for legobj in mLeg.legendHandles: legobj.set_linewidth(5.0) # needed for having radial axis span from 0 => 90 degrees and y-labels along north axis ax.set_rmax(90) ax.set_rmin(0) ax.set_rlabel_position(0) return fig
def plotCN0diff(listSVIDs, listST, spanUTC, CN0measdiff, dateStr, verbose=False): ''' plotCN0 plots the CN0 values for SVs per signalType observed Parameters: listSVIDs is list of SVIDs we have data for listST is list of signaltypes spanUTC is the UTC representation of spanElevation CN0measdiff contains observed CN0 variation for all SVs and all signalTypes dateStr is the respective day of observations ''' # get unique list of signaltypes to determine the number of plots we have to make uniqSVs = list(set(listSVIDs)) for i, uniqSVi in enumerate(uniqSVs): plt.figure(i) ax = plt.gca() # create label for signalType and plot its SN0 for this uniqSVi stLabel = [] ax.set_color_cycle(['black', 'yellow', 'blue', 'pink']) for j, SVj in enumerate(listSVIDs): if SVj == uniqSVi: stLabel.append(mSSN.GNSSSignals[listST[j]]['name']) print('mSSN.GNSSSignals[listST[%d]][name] = %s' % (j, mSSN.GNSSSignals[listST[j]]['name'])) print('spanUTC = %s ==> %s' % (spanUTC[0], spanUTC[-1])) print(len(spanUTC), len(CN0measdiff[j])) plt.plot(spanUTC, CN0measdiff[j], linestyle='-', linewidth=0.25, alpha=0.75, label=stLabel[-1]) ax.set_ylim(-4, 4) # plot annotation gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(SVj) textSVID = gnssSystShort + str(gnssPRN) print('j = %d - SV = %s, uniqSVi = %s\n' % (i, textSVID, uniqSVi)) plt.title('Satellite: %s' % textSVID) plt.xlabel('Time of ' + dateStr) plt.ylabel('C/N0 variation') # adjust the X-axis to represent readable time ax.xaxis.set_major_formatter(md.DateFormatter('%H:%M:%S')) plt.xlim(spanUTC[0], spanUTC[-1]) # annotate for copyright plt.text(0, -0.125, r'$\copyright$ Alain Muls ([email protected])', horizontalalignment='left', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') plt.text(1, -0.125, r'$\copyright$ Andrei Alexandru ([email protected])', horizontalalignment='right', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') # Shrink current axis's height by x% on the bottom box = ax.get_position() ax.set_position( [box.x0, box.y0 + box.height * 0.4, box.width, box.height * 0.6]) box = ax.get_position() plt.legend(bbox_to_anchor=(box.x0 + box.width * 0.2, -0.15, box.width * 0.6, 0.15), loc='lower center', ncol=np.size(stLabel), fontsize='xx-small') llines = plt.gca().get_legend().get_lines( ) # all the lines.Line2D instance in the legend plt.setp(llines, linewidth=4) # the legend linewidth plt.tight_layout(rect=(0, 0, 1, 1)) # Shrink current axis's height by 10% on the bottom box = ax.get_position() ax = plt.subplot(111) ax.set_position( [box.x0, box.y0 + box.height * 0.1, box.width, box.height * 0.9]) fig = plt.gcf() fig.savefig('%s-%s%d-CN0.png' % (gnssSyst, gnssSystShort, gnssPRN), dpi=fig.dpi) if i != len(uniqSVs) - 1: if verbose: plt.show(block=False) else: if verbose: plt.show() # close the figure plt.close()
def plotCN0(listSVIDs, listST, spanTOW, spanUTC, CN0meas, dateStr, verbose=False): ''' plotCN0 plots the CN0 values for SVs per signalType observed Parameters: listSVIDs is list of SVIDs we have data for listST is list of signaltypes spanTOW is the full observation time span spanUTC is the UTC representation of spanTOW CN0meas contains observed CN0 for all SVs and all signalTypes ''' # plt.style.use('ggplot') plt.style.use('BEGPIOS') # first plot all SVs per signalType # get unique list of signaltypes to determine the number of plots we have to make uniqSTs = list(set(listST)) # print('uniqSTs = %s' % uniqSTs) # loop over the signalTypes for i, uniqSTi in enumerate(uniqSTs): plt.figure(i) ax = plt.gca() # create label for identify SV and plot its CN0 value for this signalType satLabel = [] colors = iter(cm.rainbow(np.linspace(0, 1, len(listSVIDs)))) for j, STj in enumerate(listST): if STj == uniqSTi: satLabel.append(mSSN.svPRN(listSVIDs[j])[1] + str(mSSN.svPRN(listSVIDs[j])[2])) plt.plot(spanUTC, CN0meas[j], linestyle='-', color=next(colors), linewidth=0.25, alpha=0.75, label=satLabel[-1]) print('i = %d len = %d' % (i, np.size(uniqSTs))) # plot annotation plt.title('Signaltype: %s' % mSSN.GNSSSignals[uniqSTi]['name'], fontsize='x-large') plt.xlabel('Time of ' + dateStr) plt.ylabel('C/N0') # adjust the X-axis to represent readable time ax.xaxis.set_major_formatter(md.DateFormatter('%H:%M:%S')) plt.xlim(spanUTC[0], spanUTC[-1]) # annotate for copyright plt.text(0, -0.125, r'$\copyright$ Alain Muls ([email protected])', horizontalalignment='left', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') plt.text(1, -0.125, r'$\copyright$ Frederic Snyers ([email protected])', horizontalalignment='right', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') # add the legend # Shrink current axis's height by x% on the bottom box = ax.get_position() print('box.x0 = %f' % box.x0) print('box.y0 = %f' % box.y0) print('box.width = %f' % box.width) print('box.height = %f' % box.height) # ax = plt.subplot(111) ax.set_position([box.x0, box.y0 + box.height * 0.3, box.width, box.height * 0.7]) box = ax.get_position() print('after\nbox.x0 = %f' % box.x0) print('box.y0 = %f' % box.y0) print('box.width = %f' % box.width) print('box.height = %f' % box.height) plt.legend(bbox_to_anchor=(box.x0 + box.width*0.2, -0.15, box.width*0.6, 0.15), loc='lower center', ncol=np.size(satLabel), fontsize='xx-small') llines = plt.gca().get_legend().get_lines() # all the lines.Line2D instance in the legend plt.setp(llines, linewidth=4) # the legend linewidth # ggplot2.rstyle(ax) fig = plt.gcf() if verbose: print('\nfigname = %s -- %s' % (STj, mSSN.GNSSSignals[uniqSTi]['name'])) fig.savefig('%s-CN0.png' % (mSSN.GNSSSignals[uniqSTi]['name']), dpi=fig.dpi) if i != len(uniqSTs)-1: if verbose: plt.show(block=False) else: if verbose: plt.show() # sys.exit(0) # second plot all signalTypes per SVs # find the SV identifiers ans make them unique uniqSVs = list(set(listSVIDs)) print('uniqSVs = %s' % uniqSVs) figNr = len(uniqSTs) # nr of figures already used for i, uniqSVi in enumerate(uniqSVs): plt.figure(i + figNr) ax = plt.gca() # create label for signalType and plot its SN0 for this uniqSVi stLabel = [] colors = iter(cm.rainbow(np.linspace(0, 1, len(listST)))) for j, SVj in enumerate(listSVIDs): if SVj == uniqSVi: stLabel.append(mSSN.GNSSSignals[listST[j]]['name']) print('mSSN.GNSSSignals[listST[%d]][name] = %s' % (j, mSSN.GNSSSignals[listST[j]]['name'])) print('spanUTC = %s ==> %s' % (spanUTC[0], spanUTC[-1])) plt.plot(spanUTC, CN0meas[j],linestyle='-', color=next(colors), linewidth=0.25, alpha=0.75, label=stLabel[-1]) # plot annotation gnssSyst, gnssSystShort, gnssPRN = mSSN.svPRN(SVj) textSVID = gnssSystShort + str(gnssPRN) print('j = %d - SV = %s, uniqSVi = %s\n' % (i, textSVID, uniqSVi)) plt.title('Satellite: %s' % textSVID) plt.xlabel('Time of ' + dateStr) plt.ylabel('C/N0') # adjust the X-axis to represent readable time ax.xaxis.set_major_formatter(md.DateFormatter('%H:%M:%S')) plt.xlim(spanUTC[0], spanUTC[-1]) # annotate for copyright plt.text(0, -0.125, r'$\copyright$ Alain Muls ([email protected])', horizontalalignment='left', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') plt.text(1, -0.125, r'$\copyright$ Frederic Snyers ([email protected])', horizontalalignment='right', verticalalignment='bottom', transform=ax.transAxes, alpha=0.5, fontsize='x-small') # add the legend # Shrink current axis's height by x% on the bottom box = ax.get_position() print('box.x0 = %f' % box.x0) print('box.y0 = %f' % box.y0) print('box.width = %f' % box.width) print('box.height = %f' % box.height) # ax = plt.subplot(111) ax.set_position([box.x0, box.y0 + box.height * 0.4, box.width, box.height * 0.6]) box = ax.get_position() print('after\nbox.x0 = %f' % box.x0) print('box.y0 = %f' % box.y0) print('box.width = %f' % box.width) print('box.height = %f' % box.height) plt.legend(bbox_to_anchor=(box.x0 + box.width*0.2, -0.15, box.width*0.6, 0.15), loc='lower center', ncol=np.size(stLabel), fontsize='xx-small') llines = plt.gca().get_legend().get_lines() # all the lines.Line2D instance in the legend plt.setp(llines, linewidth=4) # the legend linewidth # plt.legend(bbox_to_anchor=(0., 1.052, 1., .052), loc='lower left', ncol=np.size(stLabel), mode="expand", borderaxespad=0., fontsize=9) # Shrink current axis's height by 10% on the bottom box = ax.get_position() ax = plt.subplot(111) ax.set_position([box.x0, box.y0 + box.height * 0.1, box.width, box.height * 0.9]) fig = plt.gcf() fig.savefig('%s-%s%d-CN0.png' % (gnssSyst, gnssSystShort, gnssPRN), dpi=fig.dpi) if i != len(uniqSVs)-1: if verbose: plt.show(block=False) else: if verbose: plt.show() # close the figure plt.close()