基于PYTHON的TEQC图形化展示(COMPACT3)1、拷贝以下代码另存为teqcplot.py2、需要在Python环境运行说明:teqcplotversion1.4.2,7Sep.2014.程序作者:StuartK.Wierimportosimportsysimportstringimportdatetimeimportnumpyasnpimportmatplotlibasmptlimportmatplotlib.cmascmimportmatplotlib.pyplotaspltfromnumpyimport*fromdatetimeimporttimedeltafromdatetimeimportdatetimefrommatplotlib.pyplotimportgrid,figure,plot,savefigazifile=elefile=parmfile=parmtype=debug=Falsedogps=Truedoglonass=Truedogalileo=Truedosbas=Truedobeidou=Truedoqzss=TruetrackCountLimit=6colorMax=1.234567colorMin=1.234567maxHour=-999.0minHour=-999.0globallineSizecolorname=showLegend=FalseshowLabel=TruedoParmPlot=Falsesvs=[]svslist=[]parmsvslist=[]options=[]files=[]SVpositionList=[]SVparmList=[]SVidList=[]SVparmidList=[]doShowSVslist=[]doNotShowSVslist=[]globalasciiStartTimeglobalmaxTglobalminTwidthDistance=7.3#forwidthofplot;inchesisunitsofdistanceinmatplotlib;pixeldensity=100defread_input_files():globalasciiStartTime#opentheazifiledatapath1=os.path.dirname(azifile)filename1=os.path.basename(azifile)fileext=string.split(filename1,.)file1=open(azifile)#opentheelevationfiledatapath2=os.path.dirname(elefile)filename2=os.path.basename(elefile)fileext=string.split(filename2,.)file2=open(elefile)#handletheparmfile,ifanyiflen(parmfile)5:datapathp=os.path.dirname(parmfile)pfilename=os.path.basename(parmfile)ifplottype!=Time-parameterplot:printColorbyvaluethe+parmtype+datafrom+pfilenamepfile=open(parmfile)#countlinesininputfilesallLines=file1.readlines()file1linecount=len(allLines)file1.seek(0)#checkelefileallLines=file2.readlines()iflen(allLines)!=file1linecount:printProblem:theinput'.azi'and'.ele'fileshavedifferingcountoflines;shouldbethesame.\nExit.\nsys.exit(1)file2.seek(0)iflen(parmfile)5:allLines=pfile.readlines()iflen(allLines)!=file1linecount:printProblem:theinput.aziandparmfileshavedifferingcountoflines;shouldbethesame.\nExit.\nsys.exit(1)pfile.seek(0)epoch=Nonegotepoch=False#stepthrougheachlinein2files;orin3filesifdoParmPlotforlninrange(file1linecount):#readequivalentlinesfrom2or3files,atindexln(linenumber);0baseline=file1.readline()file2line=file2.readline()ifdoParmPlot:pfileline=pfile.readline()#thiscodeassumesthattheaziandelefilestructuresareidenticalinstructure,#exceptforthevaluesinthethevaluelinesaftertheepoch-svlines.#theepoch-svlinesmustbeidenticalinaziandelefiles.#iffirstlineisnotCOMPACT3,breakifln==0:ifline[0:8]!=COMPACT3:printProblem:inputfile+file1+isnotCOMPACT3format.Exit.\nsys.exit(1)iffile2line[0:8]!=COMPACT3:printProblem:inputfile+file2+isnotCOMPACT3format.Exit.\nsys.exit(1)ifdoParmPlotandpfileline[0:8]!=COMPACT3:printProblem:inputfile+pfile+isnotCOMPACT3format.Exit.\nsys.exit(1)#makesurestarttime,inlineindex1,issameforallfiles;getthestarttimeasadatetimeifln==1:ifline[0:-1]!=file2line[0:-1]:printProblem:azifile,line2(starttime)doesnotmatcheleline2.\nExit\nsys.exit(1)ifdoParmPlotandline[0:-1]!=pfileline[0:-1]:printProblem:azifilestarttimedoesnotmatchparmfilestarttime.\nExit\nsys.exit()#getstartepochtimefromazifile,lineindex1st1=line[15:-1]st1=st1[0:19]starttimeDT=datetime.strptime(st1,'%Y%m%d%H%M%S')asciiStartTime=starttimeDT.strftime('%Y%m%d%H:%M:%S')gotepoch=False#readthenextvaluesline(in2or3files)whichcorrespondtoajust-readepoch-svline(nextcodeblock)ifgotepoch:gotepoch=Falseazis=line[:-1]azis=azis.replace(,)azis=azis.replace(,)azis=azis.replace(,)azis=azis[1:-1]azislist=string.split(azis,)#ifdebug:printthereare+`len(azislist)`+azis#theListazislistforthislinemustcorrespondtotheListofSVSsvslistiflen(azislist)!=len(svslist):printProblem:numberofSVsdoesnotmatchnumberofazimuthsatline+`ln`+\nExitsys.exit()#forthisepoch,makeaList'eles'oftheelevationvaluesateachSVintheListsvslist#ifdebug:printelevationslineis_+file2line[0:-1]eles=file2line[:-1]eles=eles.replace(,)eles=eles.replace(,)eles=eles.replace(,)eles=eles[1:-1]eleslist=string.split(eles,)#splitonwhitespace;makesaList#theListeleslistforthislineshouldcorrespondtotheListofSVSsvslistiflen(eleslist)!=len(svslist):printProblem:numberofSVsdoesnotmatchnumberofelevationsinfile2atline+`ln`+\nExitsys.exit()ifnotdoParmPlot:#composethetuplesfortheListsofvaluestouseinmakingplotsforistinrange(len(svslist)):posituple=(svslist[ist],epoch,azislist[ist],eleslist[ist])SVpositionList.append(posituple)elifdoParmPlot:ifdebug:printparmline+`ln`+isatepochorsecondsoffset=+`dt`+_ifdebug:printline+`ln`+parmdatalineis_+pfileline[0:-1]parms=pfileline[:-1]parms=parms.replace(,)parms=parms.replace(,)parms=parms.replace(,)parms=parms[1:-1]parmslist=string.split(parms,)#splitonwhitespace;makesaList#theListparmslistforthislineshouldcorrespondtotheListofSVSparmsvslistnnn#print'thelinesparmListis'+','.join(parmslist)iflen(parmslist)!=len(parmsvslist):printProblem:numberofparmSVsdoesnotmatchnumberofparmvaluesinparmfileatline+`ln`+\nsys.exit()foristinrange(len(parmsvslist)):psv=parmsvslist[ist]ifpsvinsvslist:fori,objinenumerate(svslist):ifobj==psv:svindex=ibreak#gottheindexofthatSVintheaziandelefiles;ist!=svindexusually#makeoneofthesetupleswithONEvalueofSV,time,azi,el