📄 ddplot
字号:
#!/usr/bin/env python
# $Id: ddPlot 513 2007-05-03 21:41:15Z tconn $
# A routine to plot the output of ddGen.
import sys, string, time, datetime, numpy, matplotlib, pylab
def main():
from optparse import OptionParser
parser = OptionParser()
usageString = "ddPlot [option]\n\n A routine to plot the output of ddGen.\n\n All double differences will be plotted by default, or\n you may specify plotting criteria using the command\n line options."
parser =OptionParser(usage=usageString)
parser.add_option("-d", "--debug", default=0, dest="debugLevel", action="count",
help="Increase the debugLevel.")
parser.add_option("-l", "--legend", dest="legend", action="count",
help="Include a legend.")
parser.add_option("-a","--averages", action="count", dest="plotAverages",
help="Plot the averages using the same plotting criteria. Use twice and only averages will be plotted.")
parser.add_option("-u","--no-unhlthy", dest="noUnhealthy",action="count",
help="Do not plot data from unhealthy SVs.")
parser.add_option("-r", "--range", dest="range", action="count",
help="Plot range double difference values.")
parser.add_option("-D", "--doppler", dest="doppler", action="count",
help="Plot Doppler double difference values.")
parser.add_option("-p", "--phase", dest="phase", action="count",
help="Plot phase double difference values.")
parser.add_option("-1", "--L1", dest="L1", action="count",
help="Plot data from L1 freq band.")
parser.add_option("-2", "--L2", dest="L2", action="count",
help="Plot data from L2 freq band.")
parser.add_option("-i", help="Input data file, defaults to stdin.", \
dest="inputFile", type="string", action="store")
parser.add_option("-t", help="Specify a title for the plot. "+\
"Defaults to the name of the input stream.", \
dest="title", type="string", action="store")
parser.add_option("-f", dest="saveFig", action="store", type="string",\
help="Save the figure to the indicated file")
parser.add_option("-y", dest="yRange", action="store", type="float",\
help="Fix the y range on the ords to be +- this value.")
parser.add_option("-s", dest="tStart", action="store",\
help="Start time. Format as \"YYYY DOY HH:MM:SS.S\" (Note\
the trailing decimal place).")
parser.add_option("-e", dest="tEnd", action="store",\
help="End time. Format as \"YYYY DOY HH:MM:SS.S\" (Note\
the trailing decimal place).")
(options, args) = parser.parse_args()
if (len(args) and options.inputFile == None):
options.inputFile = args[0]
inputFile = sys.stdin
if (options.inputFile):
inputFile = open(options.inputFile)
if (options.title == None):
options.title = inputFile.name
plotAvg = False
if (options.plotAverages):
plotAvg = True
plotUnhealthy = True
if (options.noUnhealthy):
plotUnhealthy = False
plotRange = True
plotPhase = True
plotDoppl = True
plotL1 = True
plotL2 = True
if (options.range or options.doppler or options.phase):
if (not options.range):
plotRange = False
if (not options.phase):
plotPhase = False
if (not options.doppler):
plotDoppl = False
if (options.L1 or options.L2):
if (not options.L1):
plotL1 = False
if (not options.L2):
plotL2 = False
if (options.debugLevel):
print "Processing: %s" % inputFile.name
print "Debug level: %d" % options.debugLevel
print "Title: %s" % options.title
if options.yRange:
print "Fixing y axis to +/- %4.4f meters" % options.yRange
if plotRange:
print "Plotting range double differences"
else:
print "Excluding range double differences from plot"
if plotPhase:
print "Plotting phase double differences"
else:
print "Excluding phase double differences from plot"
if plotDoppl:
print "Plotting doppler double differences"
else:
print "Excluding doppler double differences from plot"
if plotL1:
print "Plotting double differences from data collected on L1"
else:
print "Excluding double differences from data collected on L1"
if plotL2:
print "Plotting double differences from data collected on L2"
else:
print "Excluding double differences from data collected on L2"
if plotAvg:
print "Plotting double differnce averages"
else:
print "Not plotting averages"
# read in data.
# Not using SV or elevation data yet, but we may want to do
# something cool with it later
dataListL1 = ([],[],[],[],[],[],[],[],[]) # time, C/A range dd, P/Y range, phase dd, doppler dd, PRN1, el1, PRN2, el2
dataListL2 = ([],[],[],[],[],[],[],[]) # time, range dd, phase dd, doppler dd, PRN1, el1, PRN2, el2
avergsList = ([],[],[],[],[],[],[],[]) # time, C/A rng avg, L1 P/Y rng avg, L1 phs dd avg, L1 dopp dd avg...
# ...L2 rng dd avg, L2 phs dd avg, L2 dopp dd avg
#cycleSlips = # not quite sure how to work these in yet
for line in inputFile:
line = line.strip()
if options.debugLevel>1:
print line
if len(line)==0: continue
if line[0] == "#": continue
if line[0] == '>':
if line[1] == "c":
continue # we'll do something nifty with these later
if (line[1]=="a" and plotAvg):
words=line.split()
t = parse_time(words[1:4])
ordType = "%s %s %s"%(words[4], words[5], words[6])
mean = float(words[8])
if ordType[0:2] == "L1":
if ordType[3:6] == "C/A":
avergsList[0].append(t) # time
avergsList[1].append(mean) # C/A range dd mean
elif ordType[7:14] == "range":
avergsList[2].append(mean) # L1 P/Y/W range dd mean
elif ordType[7:14] == "phase":
avergsList[3].append(mean) # L1 P/Y/W phase dd mean
elif ordType[7:14] == "doppl":
avergsList[4].append(mean) # L1 P/Y/W Doppler dd mean
else:
if (options.debugLevel):
print "Didn't understand this line:"
print line
elif ordType[0:2] == "L2":
if ordType[7:14] == "range":
avergsList[5].append(mean) # L1 P/Y/W range dd mean
elif ordType[7:14] == "phase":
avergsList[6].append(mean) # L1 P/Y/W phase dd mean
elif ordType[7:14] == "doppl":
avergsList[7].append(mean) # L1 P/Y/W Doppler dd mean
else:
if (options.debugLevel):
print "Didn't understand this line:"
print line
else:
words=line.split()
t = parse_time(words[0:3])
ordType = "%s %s %s"%(words[3], words[4], words[5])
if (words[11] != "00" and (not plotUnhealthy)):
if options.debugLevel:
print "Not plotting data from unhealthy SV(s):"
print line
continue
# parse the line
sv1 = int(words[6])
sv2 = int(words[7])
elev1 = float(words[8])
elev2 = float(words[9])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -