@@ -199,7 +199,6 def savePlplot(filename,width,height): | |||||
199 | plplot.plsfnam(filename) |
|
199 | plplot.plsfnam(filename) | |
200 | plplot.plcpstrm(curr_strm,0) |
|
200 | plplot.plcpstrm(curr_strm,0) | |
201 | plplot.plreplot() |
|
201 | plplot.plreplot() | |
202 | plplot.plclear() |
|
|||
203 | plplot.plend1() |
|
202 | plplot.plend1() | |
204 | plplot.plsstrm(curr_strm) |
|
203 | plplot.plsstrm(curr_strm) | |
205 |
|
204 | |||
@@ -215,6 +214,13 def initPlplot(indexPlot,ncol,nrow,winTitle,width,height): | |||||
215 | plplot.plspause(False) |
|
214 | plplot.plspause(False) | |
216 | plplot.plssub(ncol,nrow) |
|
215 | plplot.plssub(ncol,nrow) | |
217 |
|
216 | |||
|
217 | def setNewPage(): | |||
|
218 | plplot.plbop() | |||
|
219 | plplot.pladv(0) | |||
|
220 | ||||
|
221 | def closePage(): | |||
|
222 | plplot.pleop() | |||
|
223 | ||||
218 | def clearData(objGraph): |
|
224 | def clearData(objGraph): | |
219 | objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], "bc", "bc") |
|
225 | objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], "bc", "bc") | |
220 |
|
226 | |||
@@ -238,7 +244,7 def setStrm(indexPlot): | |||||
238 | def plFlush(): |
|
244 | def plFlush(): | |
239 | plplot.plflush() |
|
245 | plplot.plflush() | |
240 |
|
246 | |||
241 | def setPlTitle(pltitle,color): |
|
247 | def setPlTitle(pltitle,color, szchar=0.7): | |
242 | setSubpages(1, 0) |
|
248 | setSubpages(1, 0) | |
243 | plplot.pladv(0) |
|
249 | plplot.pladv(0) | |
244 | plplot.plvpor(0., 1., 0., 1.) |
|
250 | plplot.plvpor(0., 1., 0., 1.) | |
@@ -248,12 +254,14 def setPlTitle(pltitle,color): | |||||
248 | if color == "white": |
|
254 | if color == "white": | |
249 | plplot.plcol0(15) |
|
255 | plplot.plcol0(15) | |
250 |
|
256 | |||
|
257 | plplot.plschr(0.0,szchar) | |||
251 | plplot.plmtex("t",-1., 0.5, 0.5, pltitle) |
|
258 | plplot.plmtex("t",-1., 0.5, 0.5, pltitle) | |
252 |
|
259 | |||
253 | def setSubpages(ncol,nrow): |
|
260 | def setSubpages(ncol,nrow): | |
254 | plplot.plssub(ncol,nrow) |
|
261 | plplot.plssub(ncol,nrow) | |
255 |
|
262 | |||
256 | class BaseGraph: |
|
263 | class BaseGraph: | |
|
264 | ||||
257 | __name = None |
|
265 | __name = None | |
258 | __xpos = None |
|
266 | __xpos = None | |
259 | __ypos = None |
|
267 | __ypos = None | |
@@ -267,7 +275,9 class BaseGraph: | |||||
267 | deltax = None |
|
275 | deltax = None | |
268 | xmin = None |
|
276 | xmin = None | |
269 | xmax = None |
|
277 | xmax = None | |
|
278 | ||||
270 | def __init__(self,name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange=None,deltax=1.0): |
|
279 | def __init__(self,name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange=None,deltax=1.0): | |
|
280 | ||||
271 | self.setName(name) |
|
281 | self.setName(name) | |
272 | self.setScreenPos(xpos, ypos) |
|
282 | self.setScreenPos(xpos, ypos) | |
273 | self.setLabels(xlabel,ylabel,title) |
|
283 | self.setLabels(xlabel,ylabel,title) | |
@@ -553,7 +563,7 class LinearPlot: | |||||
553 |
|
563 | |||
554 |
|
564 | |||
555 |
|
565 | |||
556 |
class |
|
566 | class PcolorPlot: | |
557 | pcolorObjDic = {} |
|
567 | pcolorObjDic = {} | |
558 | colorbarObjDic = {} |
|
568 | colorbarObjDic = {} | |
559 | pwprofileObjDic = {} |
|
569 | pwprofileObjDic = {} | |
@@ -577,11 +587,9 class SpectraPlot: | |||||
577 | self.showPowerProfile = showPowerProfile |
|
587 | self.showPowerProfile = showPowerProfile | |
578 | self.XAxisAsTime = XAxisAsTime |
|
588 | self.XAxisAsTime = XAxisAsTime | |
579 |
|
589 | |||
580 |
|
|
590 | ||
581 | if (nsubplot%2)==0: |
|
591 | ncol = int(numpy.sqrt(nsubplot)+0.9) | |
582 |
|
|
592 | nrow = int(nsubplot*1./ncol + 0.9) | |
583 | else: |
|
|||
584 | ncol = int(nsubplot)/nrow + 1 |
|
|||
585 |
|
593 | |||
586 | initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height) |
|
594 | initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height) | |
587 | setColormap(colormap) |
|
595 | setColormap(colormap) | |
@@ -630,8 +638,13 class SpectraPlot: | |||||
630 |
|
638 | |||
631 | return xpos,ypos |
|
639 | return xpos,ypos | |
632 |
|
640 | |||
633 |
def |
|
641 | def createObjects(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel): | |
|
642 | """ | |||
|
643 | Crea los objetos necesarios para un subplot | |||
|
644 | """ | |||
|
645 | ||||
634 | # Config Spectra plot |
|
646 | # Config Spectra plot | |
|
647 | ||||
635 | szchar = 0.7 |
|
648 | szchar = 0.7 | |
636 | name = "spc" |
|
649 | name = "spc" | |
637 | key = name + "%d"%subplot |
|
650 | key = name + "%d"%subplot | |
@@ -641,7 +654,6 class SpectraPlot: | |||||
641 |
|
654 | |||
642 | xpos,ypos = self.setSpectraPos() |
|
655 | xpos,ypos = self.setSpectraPos() | |
643 | pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange) |
|
656 | pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange) | |
644 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcnst", "bcnstv") |
|
|||
645 | self.pcolorObjDic[key] = pcolorObj |
|
657 | self.pcolorObjDic[key] = pcolorObj | |
646 |
|
658 | |||
647 | # Config Colorbar |
|
659 | # Config Colorbar | |
@@ -654,9 +666,6 class SpectraPlot: | |||||
654 | xrange = [0.,1.] |
|
666 | xrange = [0.,1.] | |
655 | yrange = [zmin,zmax] |
|
667 | yrange = [zmin,zmax] | |
656 | cmapObj = BaseGraph(name,subplot,xpos,ypos,"","","dB",szchar,xrange,yrange) |
|
668 | cmapObj = BaseGraph(name,subplot,xpos,ypos,"","","dB",szchar,xrange,yrange) | |
657 | cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcm") |
|
|||
658 | cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1]) |
|
|||
659 | cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv") |
|
|||
660 | self.colorbarObjDic[key] = cmapObj |
|
669 | self.colorbarObjDic[key] = cmapObj | |
661 |
|
670 | |||
662 | # Config Power profile |
|
671 | # Config Power profile | |
@@ -669,21 +678,59 class SpectraPlot: | |||||
669 | xrange = [zmin,zmax] |
|
678 | xrange = [zmin,zmax] | |
670 | yrange = [ymin,ymax] |
|
679 | yrange = [ymin,ymax] | |
671 | powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange) |
|
680 | powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange) | |
|
681 | self.pwprofileObjDic[key] = powObj | |||
|
682 | ||||
|
683 | def setNewPage(self, pltitle='No title'): | |||
|
684 | szchar = 0.7 | |||
|
685 | setNewPage() | |||
|
686 | setPlTitle(pltitle,"black", szchar=szchar) | |||
|
687 | setSubpages(self.ncol, self.nrow) | |||
|
688 | ||||
|
689 | def closePage(self): | |||
|
690 | closePage() | |||
|
691 | ||||
|
692 | def iniPlot(self,subplot): | |||
|
693 | """ | |||
|
694 | Inicializa los subplots con su frame, titulo, etc | |||
|
695 | """ | |||
|
696 | ||||
|
697 | # Config Spectra plot | |||
|
698 | name = "spc" | |||
|
699 | key = name + "%d"%subplot | |||
|
700 | ||||
|
701 | pcolorObj = self.pcolorObjDic[key] | |||
|
702 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcnst", "bcnstv") | |||
|
703 | ||||
|
704 | # Config Colorbar | |||
|
705 | if self.showColorbar: | |||
|
706 | name = "colorbar" | |||
|
707 | key = name + "%d"%subplot | |||
|
708 | ||||
|
709 | cmapObj = self.colorbarObjDic[key] | |||
|
710 | cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv") | |||
|
711 | cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1]) | |||
|
712 | # cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv") | |||
|
713 | ||||
|
714 | # Config Power profile | |||
|
715 | if self.showPowerProfile: | |||
|
716 | name = "pwprofile" | |||
|
717 | key = name + "%d"%subplot | |||
|
718 | ||||
|
719 | powObj = self.pwprofileObjDic[key] | |||
672 | powObj.setLineStyle(2) |
|
720 | powObj.setLineStyle(2) | |
673 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc") |
|
721 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc") | |
674 | powObj.setLineStyle(1) |
|
722 | powObj.setLineStyle(1) | |
675 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc") |
|
723 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc") | |
676 | self.pwprofileObjDic[key] = powObj |
|
|||
677 |
|
724 | |||
678 | def printTitle(self,pltitle): |
|
725 | def printTitle(self,pltitle): | |
679 | if self.__lastTitle != None: |
|
726 | # if self.__lastTitle != None: | |
680 | setPlTitle(self.__lastTitle,"white") |
|
727 | # setPlTitle(self.__lastTitle,"white") | |
681 |
|
728 | # | ||
682 | self.__lastTitle = pltitle |
|
729 | # self.__lastTitle = pltitle | |
683 |
|
730 | |||
684 | setPlTitle(pltitle,"black") |
|
731 | setPlTitle(pltitle,"black") | |
685 |
|
732 | |||
686 | setSubpages(self.ncol,self.nrow) |
|
733 | # setSubpages(self.ncol,self.nrow) | |
687 |
|
734 | |||
688 | def plot(self,subplot,x,y,z,subtitle): |
|
735 | def plot(self,subplot,x,y,z,subtitle): | |
689 | # Spectra plot |
|
736 | # Spectra plot | |
@@ -693,8 +740,10 class SpectraPlot: | |||||
693 |
|
740 | |||
694 | # newx = [x[0],x[-1]] |
|
741 | # newx = [x[0],x[-1]] | |
695 | pcolorObj = self.pcolorObjDic[key] |
|
742 | pcolorObj = self.pcolorObjDic[key] | |
|
743 | ||||
696 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst") |
|
744 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst") | |
697 | pcolorObj.delLabels() |
|
745 | ||
|
746 | #pcolorObj.delLabels() | |||
698 | pcolorObj.setLabels(title=subtitle) |
|
747 | pcolorObj.setLabels(title=subtitle) | |
699 |
|
748 | |||
700 | deltax = None; deltay = None |
|
749 | deltax = None; deltay = None | |
@@ -712,9 +761,10 class SpectraPlot: | |||||
712 | deltay=deltay, |
|
761 | deltay=deltay, | |
713 | getGrid=pcolorObj.getGrid) |
|
762 | getGrid=pcolorObj.getGrid) | |
714 |
|
763 | |||
|
764 | #Solo se calcula la primera vez que se ingresa a la funcion | |||
715 | pcolorObj.getGrid = False |
|
765 | pcolorObj.getGrid = False | |
716 |
|
766 | |||
717 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst") |
|
767 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst", nolabels=True) | |
718 |
|
768 | |||
719 | # Power Profile |
|
769 | # Power Profile | |
720 | if self.showPowerProfile: |
|
770 | if self.showPowerProfile: | |
@@ -724,7 +774,7 class SpectraPlot: | |||||
724 | powObj = self.pwprofileObjDic[key] |
|
774 | powObj = self.pwprofileObjDic[key] | |
725 |
|
775 | |||
726 | if powObj.setXYData() != None: |
|
776 | if powObj.setXYData() != None: | |
727 | clearData(powObj) |
|
777 | #clearData(powObj) | |
728 | powObj.setLineStyle(2) |
|
778 | powObj.setLineStyle(2) | |
729 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc") |
|
779 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc") | |
730 | powObj.setLineStyle(1) |
|
780 | powObj.setLineStyle(1) | |
@@ -735,16 +785,11 class SpectraPlot: | |||||
735 | powObj.basicXYPlot(power,y) |
|
785 | powObj.basicXYPlot(power,y) | |
736 | powObj.setXYData(power,y) |
|
786 | powObj.setXYData(power,y) | |
737 |
|
787 | |||
738 |
def savePlot(self,indexPlot, |
|
788 | def savePlot(self,indexPlot,filename): | |
739 |
|
789 | |||
740 | now = datetime.datetime.now().timetuple() |
|
|||
741 | file = "spc_img%02d_%03d_%02d%02d%02d"%(indexPlot,now[7],now[3],now[4],now[5]) |
|
|||
742 | filename = os.path.join(path,file+".png") |
|
|||
743 | width = self.width*self.ncol |
|
790 | width = self.width*self.ncol | |
744 | hei = self.height*self.nrow |
|
791 | hei = self.height*self.nrow | |
745 | savePlplot(filename,width,hei) |
|
792 | savePlplot(filename,width,hei) | |
746 |
|
||||
747 |
|
||||
748 |
|
793 | |||
749 | def refresh(self): |
|
794 | def refresh(self): | |
750 | plFlush() |
|
795 | plFlush() |
@@ -25,22 +25,45 class Spectrum: | |||||
25 | self.__isPlotIni = False |
|
25 | self.__isPlotIni = False | |
26 | self.__xrange = None |
|
26 | self.__xrange = None | |
27 | self.__yrange = None |
|
27 | self.__yrange = None | |
28 |
self.n |
|
28 | self.nsubplots = 0 | |
29 | self.indexPlot = index |
|
29 | self.indexPlot = index | |
30 | self.spectraObj = Spectra |
|
30 | self.spectraObj = Spectra | |
31 |
|
31 | |||
32 | def setup(self,indexPlot,nsubplot,winTitle='',colormap="br_green",showColorbar=False,showPowerProfile=False,XAxisAsTime=False): |
|
32 | def setup(self,indexPlot, nsubplots, winTitle='', colormap="br_green", showColorbar=False, showPowerProfile=False, XAxisAsTime=False): | |
33 | self.colorplotObj = SpectraPlot(indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime) |
|
33 | """ | |
34 |
|
34 | Crea un objeto colorPlot con las opciones seleccinoadas | ||
35 | def initPlot(self,xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList): |
|
35 | """ | |
36 | nsubplot = self.spectraObj.nChannels |
|
36 | ||
|
37 | self.nsubplots = nsubplots | |||
|
38 | self.colorplotObj = PcolorPlot(indexPlot, | |||
|
39 | nsubplots, | |||
|
40 | winTitle, | |||
|
41 | colormap, | |||
|
42 | showColorbar, | |||
|
43 | showPowerProfile, | |||
|
44 | XAxisAsTime) | |||
|
45 | ||||
|
46 | def createObjects(self,xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList): | |||
|
47 | """ | |||
|
48 | Configura cada subplot con los valores maximos y minimos incluyendo los subtitulos | |||
|
49 | """ | |||
37 |
|
50 | |||
38 | for index in range(nsubplot): |
|
51 | for index in range(self.nsubplots): | |
39 | title = titleList[index] |
|
52 | title = titleList[index] | |
40 | xlabel = xlabelList[index] |
|
53 | xlabel = xlabelList[index] | |
41 | ylabel = ylabelList[index] |
|
54 | ylabel = ylabelList[index] | |
42 | subplot = index |
|
55 | subplot = index | |
43 |
self.colorplotObj. |
|
56 | self.colorplotObj.createObjects(subplot+1,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel) | |
|
57 | ||||
|
58 | def initPlot(self): | |||
|
59 | """ | |||
|
60 | Configura cada subplot con los valores maximos y minimos incluyendo los subtitulos | |||
|
61 | """ | |||
|
62 | ||||
|
63 | ||||
|
64 | for index in range(self.nsubplots): | |||
|
65 | subplot = index | |||
|
66 | self.colorplotObj.iniPlot(subplot+1) | |||
44 |
|
67 | |||
45 |
|
68 | |||
46 | def plotData(self, |
|
69 | def plotData(self, | |
@@ -58,13 +81,24 class Spectrum: | |||||
58 | showColorbar = True, |
|
81 | showColorbar = True, | |
59 | showPowerProfile = True, |
|
82 | showPowerProfile = True, | |
60 | XAxisAsTime = False, |
|
83 | XAxisAsTime = False, | |
61 |
save = False |
|
84 | save = False, | |
|
85 | channelList=[]): | |||
|
86 | ||||
|
87 | if channelList == []: | |||
|
88 | channelList = numpy.arange(self.spectraObj.nChannels) | |||
|
89 | ||||
62 |
|
90 | |||
63 | databuffer = 10.*numpy.log10(self.spectraObj.data_spc) |
|
91 | nsubplots = len(channelList) | |
64 |
n |
|
92 | nX = self.spectraObj.nFFTPoints | |
|
93 | nY = self.spectraObj.nHeights | |||
65 |
|
94 | |||
66 |
|
|
95 | if self.spectraObj.noise == None: | |
67 | nsubplot, nX, nY = numpy.shape(databuffer) |
|
96 | noise = numpy.ones(nsubplots) | |
|
97 | else: | |||
|
98 | noise = 10.*numpy.log10(self.spectraObj.noise[channelList]) | |||
|
99 | ||||
|
100 | datadB = 10.*numpy.log10(self.spectraObj.data_spc[channelList,:,:]) | |||
|
101 | noisedB = 10.*numpy.log10(noise) | |||
68 |
|
102 | |||
69 | x = numpy.arange(nX) |
|
103 | x = numpy.arange(nX) | |
70 | y = self.spectraObj.heightList |
|
104 | y = self.spectraObj.heightList | |
@@ -72,23 +106,31 class Spectrum: | |||||
72 | indexPlot = self.indexPlot |
|
106 | indexPlot = self.indexPlot | |
73 |
|
107 | |||
74 | if not(self.__isPlotConfig): |
|
108 | if not(self.__isPlotConfig): | |
75 | self.setup(indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime) |
|
109 | self.setup(indexPlot, | |
|
110 | nsubplots, | |||
|
111 | winTitle, | |||
|
112 | colormap, | |||
|
113 | showColorbar, | |||
|
114 | showPowerProfile, | |||
|
115 | XAxisAsTime) | |||
|
116 | ||||
|
117 | ||||
76 | self.__isPlotConfig = True |
|
118 | self.__isPlotConfig = True | |
77 |
|
119 | |||
78 | if not(self.__isPlotIni): |
|
120 | if not(self.__isPlotIni): | |
79 | if titleList == None: |
|
121 | if titleList == None: | |
80 | titleList = [] |
|
122 | titleList = [] | |
81 | for i in range(nsubplot): |
|
123 | for i in range(nsubplots): | |
82 | titleList.append("Channel: %d - Noise: %.2f" %(i, noise[i])) |
|
124 | titleList.append("Channel: %d - Noise: %.2f" %(i, noise[i])) | |
83 |
|
125 | |||
84 | if xlabelList == None: |
|
126 | if xlabelList == None: | |
85 | xlabelList = [] |
|
127 | xlabelList = [] | |
86 | for i in range(nsubplot): |
|
128 | for i in range(nsubplots): | |
87 | xlabelList.append("") |
|
129 | xlabelList.append("") | |
88 |
|
130 | |||
89 | if ylabelList == None: |
|
131 | if ylabelList == None: | |
90 | ylabelList = [] |
|
132 | ylabelList = [] | |
91 | for i in range(nsubplot): |
|
133 | for i in range(nsubplots): | |
92 | ylabelList.append("Range (Km)") |
|
134 | ylabelList.append("Range (Km)") | |
93 |
|
135 | |||
94 | if xmin == None: xmin = x[0] |
|
136 | if xmin == None: xmin = x[0] | |
@@ -98,29 +140,31 class Spectrum: | |||||
98 | if zmin == None: zmin = 0 |
|
140 | if zmin == None: zmin = 0 | |
99 | if zmax == None: zmax = 120 |
|
141 | if zmax == None: zmax = 120 | |
100 |
|
142 | |||
101 |
self. |
|
143 | self.createObjects(xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList) | |
102 | self.__isPlotIni = True |
|
144 | self.__isPlotIni = True | |
103 |
|
145 | |||
104 | self.colorplotObj.setFigure(indexPlot) |
|
|||
105 |
|
||||
106 | thisDatetime = datetime.datetime.fromtimestamp(self.spectraObj.m_BasicHeader.utc) |
|
146 | thisDatetime = datetime.datetime.fromtimestamp(self.spectraObj.m_BasicHeader.utc) | |
107 | pltitle = "Self Spectra - Date: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
147 | pltitle = "Self Spectra - Date: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
108 |
|
148 | |||
109 | self.colorplotObj.printTitle(pltitle) #setPlTitle(pltitle) |
|
149 | self.colorplotObj.setFigure(indexPlot) | |
110 |
|
150 | self.colorplotObj.setNewPage(pltitle) | ||
111 | for index in range(nsubplot): |
|
151 | self.initPlot() | |
112 | data = databuffer[index,:,:] |
|
|||
113 | subtitle = "Channel: %d - Noise: %.2f" %(index, noise[index]) |
|
|||
114 | self.colorplotObj.plot(index+1,x,y,data,subtitle) |
|
|||
115 |
|
||||
116 |
|
152 | |||
|
153 | for channel in range(nsubplots): | |||
|
154 | data = datadB[channel,:,:] | |||
|
155 | subtitle = "Channel: %d - Noise: %.2f" %(channel, noise[channel]) | |||
|
156 | self.colorplotObj.plot(channel+1, x, y, data, subtitle) | |||
117 |
|
157 | |||
118 | self.colorplotObj.refresh() |
|
158 | self.colorplotObj.refresh() | |
119 |
|
159 | |||
120 | if save: |
|
160 | if save: | |
121 | self.colorplotObj.setFigure(indexPlot) |
|
161 | self.colorplotObj.setFigure(indexPlot) | |
122 |
path |
|
162 | path = "/home/roj-idl71/tmp/" | |
123 | self.colorplotObj.savePlot(indexPlot,path4plot) |
|
163 | now = datetime.datetime.now().timetuple() | |
124 |
|
164 | file = "spc_img%02d_%03d_%02d%02d%02d.png"%(indexPlot,now[7],now[3],now[4],now[5]) | ||
|
165 | filename = os.path.join(path,file) | |||
|
166 | self.colorplotObj.savePlot(indexPlot, filename) | |||
|
167 | ||||
|
168 | self.colorplotObj.closePage() | |||
125 |
|
169 | |||
126 |
|
170 |
@@ -94,13 +94,6 class Osciloscope: | |||||
94 |
|
94 | |||
95 | self.linearplotObj.refresh() |
|
95 | self.linearplotObj.refresh() | |
96 |
|
96 | |||
97 |
|
||||
98 |
|
||||
99 |
|
||||
100 |
|
||||
101 |
|
||||
102 |
|
||||
103 |
|
||||
104 | class RTI: |
|
97 | class RTI: | |
105 | colorplotObj = None |
|
98 | colorplotObj = None | |
106 |
|
99 |
@@ -1,7 +1,6 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | from Model.Spectra import Spectra |
|
|||
3 |
|
2 | |||
4 |
def hildebrand_sekhon( |
|
3 | def hildebrand_sekhon(data, navg): | |
5 | """ |
|
4 | """ | |
6 | This method is for the objective determination of de noise level in Doppler spectra. This |
|
5 | This method is for the objective determination of de noise level in Doppler spectra. This | |
7 | implementation technique is based on the fact that the standard deviation of the spectral |
|
6 | implementation technique is based on the fact that the standard deviation of the spectral | |
@@ -16,51 +15,39 def hildebrand_sekhon(Data, navg): | |||||
16 | anoise : noise's level |
|
15 | anoise : noise's level | |
17 | """ |
|
16 | """ | |
18 |
|
17 | |||
19 | divisor = 8 |
|
18 | dataflat = data.reshape(-1) | |
20 | ratio = 7 / divisor |
|
19 | dataflat.sort() | |
21 | data = Data.reshape(-1) |
|
20 | npts = dataflat.size #numbers of points of the data | |
22 | npts = data.size #numbers of points of the data |
|
|||
23 |
|
21 | |||
24 | if npts < 32: |
|
22 | if npts < 32: | |
25 | print "error in noise - requires at least 32 points" |
|
23 | print "error in noise - requires at least 32 points" | |
26 | return -1.0 |
|
24 | return -1.0 | |
27 |
|
25 | |||
|
26 | dataflat2 = numpy.power(dataflat,2) | |||
|
27 | ||||
|
28 | cs = numpy.cumsum(dataflat) | |||
|
29 | cs2 = numpy.cumsum(dataflat2) | |||
|
30 | ||||
28 | # data sorted in ascending order |
|
31 | # data sorted in ascending order | |
29 |
nmin = int(npts |
|
32 | nmin = int((npts + 7.)/8) | |
30 | s = 0.0 |
|
|||
31 | s2 = 0.0 |
|
|||
32 | data2 = data[:npts] |
|
|||
33 | data2.sort() |
|
|||
34 |
|
||||
35 | for i in range(nmin): |
|
|||
36 | s += data2[i] |
|
|||
37 | s2 += data2[i]**2; |
|
|||
38 |
|
||||
39 | icount = nmin |
|
|||
40 | iflag = 0 |
|
|||
41 |
|
33 | |||
42 | for i in range(nmin, npts): |
|
34 | for i in range(nmin, npts): | |
43 |
s |
|
35 | s = cs[i] | |
44 |
s2 |
|
36 | s2 = cs2[i] | |
45 | icount=icount+1; |
|
37 | p = s / float(i); | |
46 | p = s / float(icount); |
|
|||
47 | p2 = p**2; |
|
38 | p2 = p**2; | |
48 |
q = s2 / float(i |
|
39 | q = s2 / float(i) - p2; | |
49 | leftc = p2; |
|
40 | leftc = p2; | |
50 | rightc = q * float(navg); |
|
41 | rightc = q * float(navg); | |
51 |
|
42 | R2 = leftc/rightc | ||
52 | if leftc > rightc: |
|
43 | ||
53 | iflag = 1; #No weather signal |
|
|||
54 | # Signal detect: R2 < 1 (R2 = leftc/rightc) |
|
44 | # Signal detect: R2 < 1 (R2 = leftc/rightc) | |
55 |
if |
|
45 | if R2 < 1: | |
56 |
|
|
46 | npts_noise = i | |
57 |
|
|
47 | break | |
58 |
|
48 | |||
59 | anoise = 0.0; |
|
49 | ||
60 | for j in range(i): |
|
50 | anoise = numpy.average(dataflat[0:npts_noise]) | |
61 | anoise += data2[j]; |
|
|||
62 |
|
||||
63 | anoise = anoise / float(i); |
|
|||
64 |
|
51 | |||
65 | return anoise; |
|
52 | return anoise; | |
66 |
|
53 |
@@ -6,6 +6,7 Created on Feb 7, 2012 | |||||
6 | ''' |
|
6 | ''' | |
7 | import os, sys |
|
7 | import os, sys | |
8 | import numpy |
|
8 | import numpy | |
|
9 | import time | |||
9 |
|
10 | |||
10 | path = os.path.split(os.getcwd())[0] |
|
11 | path = os.path.split(os.getcwd())[0] | |
11 | sys.path.append(path) |
|
12 | sys.path.append(path) | |
@@ -163,7 +164,7 class SpectraProcessor: | |||||
163 | self.buffer[:,self.profIndex,:] = self.dataInObj.data |
|
164 | self.buffer[:,self.profIndex,:] = self.dataInObj.data | |
164 | self.profIndex += 1 |
|
165 | self.profIndex += 1 | |
165 |
|
166 | |||
166 |
if self.profIndex == self.nFFTPoints: |
|
167 | if self.profIndex == self.nFFTPoints: | |
167 | self.__getFft() |
|
168 | self.__getFft() | |
168 | self.dataOutObj.flagNoData = False |
|
169 | self.dataOutObj.flagNoData = False | |
169 |
|
170 | |||
@@ -210,6 +211,7 class SpectraProcessor: | |||||
210 | self.dataOutObj.m_ProcessingHeader.spectraComb |
|
211 | self.dataOutObj.m_ProcessingHeader.spectraComb | |
211 | self.dataOutObj.m_ProcessingHeader.shif_fft |
|
212 | self.dataOutObj.m_ProcessingHeader.shif_fft | |
212 | """ |
|
213 | """ | |
|
214 | ||||
213 | if self.dataInObj.flagNoData: |
|
215 | if self.dataInObj.flagNoData: | |
214 | return 0 |
|
216 | return 0 | |
215 |
|
217 | |||
@@ -218,7 +220,8 class SpectraProcessor: | |||||
218 |
|
220 | |||
219 | #calculo de self-spectra |
|
221 | #calculo de self-spectra | |
220 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) |
|
222 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) | |
221 |
spc = |
|
223 | spc = fft_volt * numpy.conjugate(fft_volt) | |
|
224 | spc = spc.real | |||
222 |
|
225 | |||
223 | blocksize = 0 |
|
226 | blocksize = 0 | |
224 | blocksize += dc.size |
|
227 | blocksize += dc.size | |
@@ -240,7 +243,7 class SpectraProcessor: | |||||
240 | self.dataOutObj.m_ProcessingHeader.blockSize = blocksize |
|
243 | self.dataOutObj.m_ProcessingHeader.blockSize = blocksize | |
241 | self.dataOutObj.m_BasicHeader.utc = self.dataInObj.m_BasicHeader.utc |
|
244 | self.dataOutObj.m_BasicHeader.utc = self.dataInObj.m_BasicHeader.utc | |
242 |
|
245 | |||
243 | self.getNoise() |
|
246 | # self.getNoise() | |
244 |
|
247 | |||
245 | def addWriter(self,wrpath): |
|
248 | def addWriter(self,wrpath): | |
246 | objWriter = SpectraWriter(self.dataOutObj) |
|
249 | objWriter = SpectraWriter(self.dataOutObj) | |
@@ -286,7 +289,8 class SpectraProcessor: | |||||
286 | showPowerProfile=False, |
|
289 | showPowerProfile=False, | |
287 | XAxisAsTime=False, |
|
290 | XAxisAsTime=False, | |
288 | save=False, |
|
291 | save=False, | |
289 |
index=None |
|
292 | index=None, | |
|
293 | channelList=[]): | |||
290 |
|
294 | |||
291 | if self.dataOutObj.flagNoData: |
|
295 | if self.dataOutObj.flagNoData: | |
292 | return 0 |
|
296 | return 0 | |
@@ -308,7 +312,8 class SpectraProcessor: | |||||
308 | showColorbar, |
|
312 | showColorbar, | |
309 | showPowerProfile, |
|
313 | showPowerProfile, | |
310 | XAxisAsTime, |
|
314 | XAxisAsTime, | |
311 |
save |
|
315 | save, | |
|
316 | channelList) | |||
312 |
|
317 | |||
313 | self.plotterObjIndex += 1 |
|
318 | self.plotterObjIndex += 1 | |
314 |
|
319 | |||
@@ -330,16 +335,14 class SpectraProcessor: | |||||
330 | #print "myIncohIntObj.navg: ",myIncohIntObj.navg |
|
335 | #print "myIncohIntObj.navg: ",myIncohIntObj.navg | |
331 | self.dataOutObj.flagNoData = False |
|
336 | self.dataOutObj.flagNoData = False | |
332 |
|
|
337 | ||
333 | self.getNoise(type="hildebrand") |
|
338 | """Calcular el ruido""" | |
334 |
|
|
339 | self.getNoise() | |
335 |
|
||||
336 | else: |
|
340 | else: | |
337 | self.dataOutObj.flagNoData = True |
|
341 | self.dataOutObj.flagNoData = True | |
338 |
|
342 | |||
339 | self.integratorObjIndex += 1 |
|
343 | self.integratorObjIndex += 1 | |
340 |
|
344 | |||
341 | """Calcular el ruido""" |
|
345 | ||
342 | # self.getNoise(type="hildebrand", parm=1) |
|
|||
343 |
|
346 | |||
344 | def removeDC(self, type): |
|
347 | def removeDC(self, type): | |
345 |
|
348 |
General Comments 0
You need to be logged in to leave comments.
Login now