##// END OF EJS Templates
Miguel Valdez -
r99:a87a6795637a
parent child
Show More
@@ -11,6 +11,9 import plplot
11
11
12 def cmap1_init(colormap="gray"):
12 def cmap1_init(colormap="gray"):
13
13
14 if colormap == None:
15 return
16
14 ncolor = None
17 ncolor = None
15 rgb_lvl = None
18 rgb_lvl = None
16
19
@@ -144,12 +147,45 def cmap1_init(colormap="gray"):
144
147
145 return rgb_lvl
148 return rgb_lvl
146
149
150 def setColormap(colormap="br_green"):
151 cmap1_init(colormap)
152
147 class BaseGraph:
153 class BaseGraph:
148 """
154 """
149
155
150 """
156 """
157 hasNotRange = True
158
159 xrange = None
160 yrange = None
161 zrange = None
151
162
152
163 xlabel = None
164 ylabel = None
165 title = None
166
167 legends = None
168
169 __name = None
170
171 __colormap = None
172 __colbox = None
173 __colleg = None
174
175 __xpos = None
176 __ypos = None
177
178 __xopt = None #"bcnst"
179 __yopt = None #"bcnstv"
180
181 __xlpos = None
182 __ylpos = None
183
184 __xrangeIsTime = False
185
186 #Advanced
187 __xg = None
188 __yg = None
153
189
154 def __init__(self):
190 def __init__(self):
155 """
191 """
@@ -323,31 +359,31 class BaseGraph:
323 plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg)
359 plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg)
324
360
325
361
326 class LinearPlot():
362 class LinearPlot:
363
364 linearGraphObj = BaseGraph()
327
365
328 __szchar = 1.0
366 __szchar = 1.0
367
329 __xrange = None
368 __xrange = None
369
330 __yrange = None
370 __yrange = None
331
371
332 m_BaseGraph = None
372 __subpage = 0
373 m_BaseGraph= BaseGraph()
374
375
333
376
334 def __init__(self):
377 def __init__(self):
335
378
336
379
337 key = "linearplot"
380 key = "linearplot"
338 self.m_BaseGraph = BaseGraph()
381 self.linearGraphObj = BaseGraph()
339 self.m_BaseGraph.setName(key)
382 self.linearGraphObj.setName(key)
340
383
341 self.__subpage = 0
384 self.__subpage = 0
342
385
343 def setColormap(self, colormap="br_green"):
386 def __iniSubpage(self):
344
345 if colormap == None:
346 colormap = self.__colormap
347
348 cmap1_init(colormap)
349
350 def iniSubpage(self):
351
387
352 if plplot.plgdev() == '':
388 if plplot.plgdev() == '':
353 raise ValueError, "Plot device has not been initialize"
389 raise ValueError, "Plot device has not been initialize"
@@ -355,7 +391,7 class LinearPlot():
355 plplot.pladv(self.__subpage)
391 plplot.pladv(self.__subpage)
356 plplot.plschr(0.0, self.__szchar)
392 plplot.plschr(0.0, self.__szchar)
357
393
358 self.setColormap()
394 setColormap()
359
395
360 def setScreenPos(self, width='small'):
396 def setScreenPos(self, width='small'):
361
397
@@ -368,14 +404,14 class LinearPlot():
368 xf = xi + xw
404 xf = xi + xw
369 yf = yi + yw
405 yf = yi + yw
370
406
371 self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf])
407 self.linearGraphObj.setScreenPos([xi, xf], [yi, yf])
372
408
373 def setup(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False):
409 def setup(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False):
374 """
410 """
375 """
411 """
376
412
377 self.m_BaseGraph.setOpt("bcnts","bcntsv")
413 self.linearGraphObj.setOpt("bcnts","bcntsv")
378 self.m_BaseGraph.setup(title,
414 self.linearGraphObj.setup(title,
379 xlabel,
415 xlabel,
380 ylabel
416 ylabel
381 )
417 )
@@ -383,12 +419,12 class LinearPlot():
383 self.setScreenPos(width='medium')
419 self.setScreenPos(width='medium')
384
420
385 if XAxisAsTime:
421 if XAxisAsTime:
386 self.m_BaseGraph.setXAxisAsTime()
422 self.linearGraphObj.setXAxisAsTime()
387
423
388 self.__subpage = subpage
424 self.__subpage = subpage
389 # def setRanges(self, xrange, yrange, zrange):
425 # def setRanges(self, xrange, yrange, zrange):
390 #
426 #
391 # self.m_BaseGraph.setRanges(xrange, yrange, zrange)
427 # self.linearGraphObj.setRanges(xrange, yrange, zrange)
392
428
393 def plotData(self, x, y=None, xmin=None, xmax=None, ymin=None, ymax=None, colline=1):
429 def plotData(self, x, y=None, xmin=None, xmax=None, ymin=None, ymax=None, colline=1):
394 """
430 """
@@ -411,8 +447,9 class LinearPlot():
411 if ymin == None: ymin = y[0]
447 if ymin == None: ymin = y[0]
412 if ymax == None: ymax = y[-1]
448 if ymax == None: ymax = y[-1]
413
449
414 self.m_BaseGraph.plotBox(xmin, xmax, ymin, ymax)
450 self.__iniSubpage()
415 self.m_BaseGraph.basicLineTimePlot(x, y, xmin, xmax, ymin, ymax, colline)
451 self.linearGraphObj.plotBox(xmin, xmax, ymin, ymax)
452 self.linearGraphObj.basicLineTimePlot(x, y, xmin, xmax, ymin, ymax, colline)
416
453
417 def plotComplexData(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1, type='power'):
454 def plotComplexData(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1, type='power'):
418 """
455 """
@@ -438,18 +475,40 class LinearPlot():
438 if ymin == None: ymin = y[0]
475 if ymin == None: ymin = y[0]
439 if ymax == None: ymax = y[-1]
476 if ymax == None: ymax = y[-1]
440
477
441 self.m_BaseGraph.plotBox(xmin, xmax, ymin, ymax)
478 self.__iniSubpage()
479 self.linearGraphObj.plotBox(xmin, xmax, ymin, ymax)
442
480
443 if type.lower() == 'power':
481 if type.lower() == 'power':
444 self.m_BaseGraph.basicLineTimePlot(x, abs(y), xmin, xmax, ymin, ymax, colline)
482 self.linearGraphObj.basicLineTimePlot(x, abs(y), xmin, xmax, ymin, ymax, colline)
445
483
446 if type.lower() == 'iq':
484 if type.lower() == 'iq':
447
485
448 self.m_BaseGraph.basicLineTimePlot(x, y.real, xmin, xmax, ymin, ymax, colline)
486 self.linearGraphObj.basicLineTimePlot(x, y.real, xmin, xmax, ymin, ymax, colline)
449 self.m_BaseGraph.basicLineTimePlot(x, y.imag, xmin, xmax, ymin, ymax, colline+1)
487 self.linearGraphObj.basicLineTimePlot(x, y.imag, xmin, xmax, ymin, ymax, colline+1)
450
488
451 class ColorPlot():
489 class ColorPlot:
490
491 colorGraphObj = BaseGraph()
492
493 graphObjDict = {}
452
494
495 __subpage = 0
496
497 __showColorbar = False
498
499 __showPowerProfile = True
500
501 __szchar = 0.65
502
503 __xrange = None
504
505 __yrange = None
506
507 __zrange = None
508 m_BaseGraph= BaseGraph()
509
510
511
453 def __init__(self):
512 def __init__(self):
454
513
455 self.graphObjDict = {}
514 self.graphObjDict = {}
@@ -464,15 +523,15 class ColorPlot():
464 self.__zrange = None
523 self.__zrange = None
465
524
466 key = "colorplot"
525 key = "colorplot"
467 self.m_BaseGraph = BaseGraph()
526 self.colorGraphObj = BaseGraph()
468 self.m_BaseGraph.setName(key)
527 self.colorGraphObj.setName(key)
469
528
470 def setup(self, subpage, title="", xlabel="Frequency", ylabel="Range", colormap="jet", showColorbar=False, showPowerProfile=False, XAxisAsTime=False):
529 def setup(self, subpage, title="", xlabel="Frequency", ylabel="Range", colormap="br_green", showColorbar=False, showPowerProfile=False, XAxisAsTime=False):
471 """
530 """
472 """
531 """
473
532
474 self.m_BaseGraph.setOpt("bcnts","bcntsv")
533 self.colorGraphObj.setOpt("bcnts","bcntsv")
475 self.m_BaseGraph.setup(title,
534 self.colorGraphObj.setup(title,
476 xlabel,
535 xlabel,
477 ylabel
536 ylabel
478 )
537 )
@@ -511,18 +570,9 class ColorPlot():
511 self.setScreenPos(width='small')
570 self.setScreenPos(width='small')
512
571
513 if XAxisAsTime:
572 if XAxisAsTime:
514 self.m_BaseGraph.setXAxisAsTime()
573 self.colorGraphObj.setXAxisAsTime()
515
574
516
575 def __iniSubpage(self):
517
518 def setColormap(self, colormap="br_green"):
519
520 if colormap == None:
521 colormap = self.__colormap
522
523 cmap1_init(colormap)
524
525 def iniSubpage(self):
526
576
527 if plplot.plgdev() == '':
577 if plplot.plgdev() == '':
528 raise ValueError, "Plot device has not been initialize"
578 raise ValueError, "Plot device has not been initialize"
@@ -530,7 +580,7 class ColorPlot():
530 plplot.pladv(self.__subpage)
580 plplot.pladv(self.__subpage)
531 plplot.plschr(0.0, self.__szchar)
581 plplot.plschr(0.0, self.__szchar)
532
582
533 self.setColormap()
583 setColormap(self.__colormap)
534
584
535 def setScreenPos(self, width='small'):
585 def setScreenPos(self, width='small'):
536
586
@@ -550,7 +600,7 class ColorPlot():
550 yf = yi + yw
600 yf = yi + yw
551 xcmapf = xf
601 xcmapf = xf
552
602
553 self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf])
603 self.colorGraphObj.setScreenPos([xi, xf], [yi, yf])
554
604
555 if self.__showColorbar:
605 if self.__showColorbar:
556 xcmapi = xf + deltaxcmap
606 xcmapi = xf + deltaxcmap
@@ -596,9 +646,9 class ColorPlot():
596 if zmax == None: zmax = numpy.nanmax(data)
646 if zmax == None: zmax = numpy.nanmax(data)
597
647
598 plplot.plschr(0.0, self.__szchar)
648 plplot.plschr(0.0, self.__szchar)
599
649 self.__iniSubpage()
600 self.m_BaseGraph.plotBox(xmin, xmax, ymin, ymax)
650 self.colorGraphObj.plotBox(xmin, xmax, ymin, ymax)
601 self.m_BaseGraph.basicPcolorPlot(data, x, y, xmin, xmax, ymin, ymax, zmin, zmax)
651 self.colorGraphObj.basicPcolorPlot(data, x, y, xmin, xmax, ymin, ymax, zmin, zmax)
602
652
603 if self.__showColorbar:
653 if self.__showColorbar:
604
654
@@ -632,7 +682,7 class ColorPlot():
632 plplot.plcol0(1)
682 plplot.plcol0(1)
633
683
634
684
635 class ColorPlotX():
685 class ColorPlotX:
636
686
637
687
638 graphObjDict = {}
688 graphObjDict = {}
@@ -644,25 +694,18 class ColorPlotX():
644 __yrange = None
694 __yrange = None
645 __zrange = None
695 __zrange = None
646
696
647 m_BaseGraph = BaseGraph()
697 colorGraphObj = BaseGraph()
648
698
649 def __init__(self):
699 def __init__(self):
650
700
651 key = "colorplot"
701 key = "colorplot"
652 self.m_BaseGraph.setName(key)
702 self.colorGraphObj.setName(key)
653
703
654 self.__subpage = 0
704 self.__subpage = 0
655
705
656 self.graphObjDict[key] = self.m_BaseGraph
706 self.graphObjDict[key] = self.colorGraphObj
657
707
658 def setColormap(self, colormap="br_green"):
708 def __iniSubpage(self):
659
660 if colormap == None:
661 colormap = self.__colormap
662
663 cmap1_init(colormap)
664
665 def iniSubpage(self):
666
709
667 if plplot.plgdev() == '':
710 if plplot.plgdev() == '':
668 raise ValueError, "Plot device has not been initialize"
711 raise ValueError, "Plot device has not been initialize"
@@ -670,16 +713,63 class ColorPlotX():
670 plplot.pladv(self.__subpage)
713 plplot.pladv(self.__subpage)
671 plplot.plschr(0.0, self.__szchar)
714 plplot.plschr(0.0, self.__szchar)
672
715
673 self.setColormap()
716 setColormap(self.__colormap)
717
718 def setScreenPos(self, xi = 0.12, yi = 0.14, xw = 0.78, yw = 0.80, xcmapw = 0.05, xpoww = 0.24, deltaxcmap = 0.02, deltaxpow = 0.06):
719
720 if self.showColorbar:
721 xw -= xcmapw + deltaxcmap
722
723 if self.showPowerProfile:
724 xw -= xpoww + deltaxpow
674
725
726 xf = xi + xw
727 yf = yi + yw
728 xcmapf = xf
729
730 self.colorGraphObj.setScreenPos([xi, xf], [yi, yf])
731
732 if self.showColorbar:
733 xcmapi = xf + deltaxcmap
734 xcmapf = xcmapi + xcmapw
735
736 key = "colorbar"
737 cmapObj = self.graphObjDict[key]
738 cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf])
739
740 if self.showPowerProfile:
741
742 xpowi = xcmapf + deltaxpow
743 xpowf = xpowi + xpoww
744
745 key = "powerprof"
746 powObj = self.graphObjDict[key]
747 powObj.setScreenPos([xpowi, xpowf], [yi, yf])
748
749 def setRanges(self, xrange, yrange, zrange):
750
751 self.colorGraphObj.setRanges(xrange, yrange, zrange)
752
753 keyList = self.graphObjDict.keys()
754
755 key = "colorbar"
756 if key in keyList:
757 cmapObj = self.graphObjDict[key]
758 cmapObj.setRanges([0., 1.], zrange)
759
760 key = "powerprof"
761 if key in keyList:
762 powObj = self.graphObjDict[key]
763 powObj.setRanges(zrange, yrange)
764
675 def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False, XAxisAsTime=False):
765 def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False, XAxisAsTime=False):
676 """
766 """
677 """
767 """
678
768
679 self.m_BaseGraph.setSubpage(subpage)
769 self.colorGraphObj.setSubpage(subpage)
680 self.m_BaseGraph.setSzchar(self.__szchar)
770 self.colorGraphObj.setSzchar(self.__szchar)
681 self.m_BaseGraph.setOpt("bcnts","bcntsv")
771 self.colorGraphObj.setOpt("bcnts","bcntsv")
682 self.m_BaseGraph.setup(title,
772 self.colorGraphObj.setup(title,
683 xlabel,
773 xlabel,
684 ylabel,
774 ylabel,
685 colormap)
775 colormap)
@@ -721,57 +811,10 class ColorPlotX():
721 self.setScreenPos()
811 self.setScreenPos()
722
812
723 if XAxisAsTime:
813 if XAxisAsTime:
724 self.m_BaseGraph.setXAxisAsTime()
814 self.colorGraphObj.setXAxisAsTime()
725 #self.setScreenPos(xi = 0.05, yi = 0.18, xw = 0.92, yw = 0.74, xcmapw = 0.015, xpoww = 0.14, deltaxcmap = 0.01, deltaxpow = 0.02)
815 #self.setScreenPos(xi = 0.05, yi = 0.18, xw = 0.92, yw = 0.74, xcmapw = 0.015, xpoww = 0.14, deltaxcmap = 0.01, deltaxpow = 0.02)
726
816
727
728 def setScreenPos(self, xi = 0.12, yi = 0.14, xw = 0.78, yw = 0.80, xcmapw = 0.05, xpoww = 0.24, deltaxcmap = 0.02, deltaxpow = 0.06):
729
730 if self.showColorbar:
731 xw -= xcmapw + deltaxcmap
732
733 if self.showPowerProfile:
734 xw -= xpoww + deltaxpow
735
736 xf = xi + xw
737 yf = yi + yw
738 xcmapf = xf
739
740 self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf])
741
742 if self.showColorbar:
743 xcmapi = xf + deltaxcmap
744 xcmapf = xcmapi + xcmapw
745
746 key = "colorbar"
747 cmapObj = self.graphObjDict[key]
748 cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf])
749
750 if self.showPowerProfile:
751
752 xpowi = xcmapf + deltaxpow
753 xpowf = xpowi + xpoww
754
755 key = "powerprof"
756 powObj = self.graphObjDict[key]
757 powObj.setScreenPos([xpowi, xpowf], [yi, yf])
758
759 def setRanges(self, xrange, yrange, zrange):
760
761 self.m_BaseGraph.setRanges(xrange, yrange, zrange)
762
817
763 keyList = self.graphObjDict.keys()
764
765 key = "colorbar"
766 if key in keyList:
767 cmapObj = self.graphObjDict[key]
768 cmapObj.setRanges([0., 1.], zrange)
769
770 key = "powerprof"
771 if key in keyList:
772 powObj = self.graphObjDict[key]
773 powObj.setRanges(zrange, yrange)
774
775 def plotData(self, data, x=None, y=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
818 def plotData(self, data, x=None, y=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
776 """
819 """
777 """
820 """
@@ -791,11 +834,11 class ColorPlotX():
791 if zmin == None: zmin = numpy.nanmin(data)
834 if zmin == None: zmin = numpy.nanmin(data)
792 if zmax == None: zmax = numpy.nanmax(data)
835 if zmax == None: zmax = numpy.nanmax(data)
793
836
794 if self.m_BaseGraph.hasNotRange:
837 if self.colorGraphObj.hasNotRange:
795 self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax])
838 self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax])
796
839
797 self.m_BaseGraph.initSubpage()
840 self.colorGraphObj.initSubpage()
798 self.m_BaseGraph.basicPcolorPlot(data, x, y, xmin, xmax, ymin, ymax, self.m_BaseGraph.zrange[0], self.m_BaseGraph.zrange[1])
841 self.colorGraphObj.basicPcolorPlot(data, x, y, xmin, xmax, ymin, ymax, self.colorGraphObj.zrange[0], self.colorGraphObj.zrange[1])
799
842
800 if self.showColorbar:
843 if self.showColorbar:
801 key = "colorbar"
844 key = "colorbar"
@@ -842,16 +885,12 if __name__ == '__main__':
842 data = numpy.random.uniform(-50,50,(nx,ny))
885 data = numpy.random.uniform(-50,50,(nx,ny))
843
886
844 plplot.plbop()
887 plplot.plbop()
845 baseObj.iniSubpage()
846 baseObj.plotData(data)
888 baseObj.plotData(data)
847
889
848 specObj.iniSubpage()
849 specObj.plotData(data)
890 specObj.plotData(data)
850
891
851 baseObj1.iniSubpage()
852 baseObj1.plotData(data)
892 baseObj1.plotData(data)
853
893
854 specObj1.iniSubpage()
855 specObj1.plotData(data)
894 specObj1.plotData(data)
856
895
857 plplot.plflush()
896 plplot.plflush()
@@ -16,8 +16,34 sys.path.append(path)
16 from Graphics.BaseGraph import *
16 from Graphics.BaseGraph import *
17 from Model.Spectra import Spectra
17 from Model.Spectra import Spectra
18
18
19 class Spectrum():
19 class Spectrum:
20
21 __isPlotConfig = False
22
23 __isPlotIni = False
24
25 __xrange = None
26
27 __yrange = None
20
28
29 nGraphs = 0
30
31 indexPlot = None
32
33 graphObjList = []
34
35 spectraObj = Spectra
36
37 colorGraphObj = ColorPlot()
38 m_Spectra= Spectra()
39
40
41 m_ColorPlot= ColorPlot()
42
43
44
45
46
21 def __init__(self, Spectra, index=0):
47 def __init__(self, Spectra, index=0):
22
48
23 """
49 """
@@ -42,7 +68,7 class Spectrum():
42
68
43 self.graphObjList = []
69 self.graphObjList = []
44
70
45 self.m_Spectra = Spectra
71 self.spectraObj = Spectra
46
72
47
73
48 def __addGraph(self, subpage, title="", xlabel="", ylabel="", showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
74 def __addGraph(self, subpage, title="", xlabel="", ylabel="", showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
@@ -61,7 +87,7 class Spectrum():
61
87
62 def setup(self, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
88 def setup(self, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
63
89
64 nChan = int(self.m_Spectra.m_SystemHeader.numChannels)
90 nChan = int(self.spectraObj.m_SystemHeader.numChannels)
65 channels = range(nChan)
91 channels = range(nChan)
66
92
67 myXlabel = "Radial Velocity (m/s)"
93 myXlabel = "Radial Velocity (m/s)"
@@ -73,8 +99,8 class Spectrum():
73 myXlabel = xlabelList[i]
99 myXlabel = xlabelList[i]
74 myYlabel = ylabelList[i]
100 myYlabel = ylabelList[i]
75
101
76 # if self.m_Spectra.m_NoiseObj != None:
102 # if self.spectraObj.m_NoiseObj != None:
77 # noise = '%4.2fdB' %(self.m_Spectra.m_NoiseObj[i])
103 # noise = '%4.2fdB' %(self.spectraObj.m_NoiseObj[i])
78 # else:
104 # else:
79 noise = '--'
105 noise = '--'
80
106
@@ -127,7 +153,7 class Spectrum():
127
153
128 plplot.plsstrm(self.indexPlot)
154 plplot.plsstrm(self.indexPlot)
129
155
130 data = 10.*numpy.log10(self.m_Spectra.data_spc)
156 data = 10.*numpy.log10(self.spectraObj.data_spc)
131
157
132 #data.shape = Channels x Heights x Profiles
158 #data.shape = Channels x Heights x Profiles
133 # data = numpy.transpose( data, (0,2,1) )
159 # data = numpy.transpose( data, (0,2,1) )
@@ -136,9 +162,9 class Spectrum():
136 nChan, nX, nY = numpy.shape(data)
162 nChan, nX, nY = numpy.shape(data)
137
163
138 x = numpy.arange(nX)
164 x = numpy.arange(nX)
139 y = self.m_Spectra.heightList
165 y = self.spectraObj.heightList
140
166
141 thisDatetime = datetime.datetime.fromtimestamp(self.m_Spectra.m_BasicHeader.utc)
167 thisDatetime = datetime.datetime.fromtimestamp(self.spectraObj.m_BasicHeader.utc)
142 txtDate = "Self Spectra - Date: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
168 txtDate = "Self Spectra - Date: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
143
169
144 if xmin == None: xmin = x[0]
170 if xmin == None: xmin = x[0]
@@ -152,7 +178,6 class Spectrum():
152
178
153 plplot.plssub(self.__nx, self.__ny)
179 plplot.plssub(self.__nx, self.__ny)
154 for i in range(self.nGraphs):
180 for i in range(self.nGraphs):
155 self.graphObjList[i].iniSubpage()
156 self.graphObjList[i].plotData(data[i,:,:],
181 self.graphObjList[i].plotData(data[i,:,:],
157 x,
182 x,
158 y,
183 y,
@@ -172,7 +197,7 class Spectrum():
172
197
173 def end(self):
198 def end(self):
174 plplot.plend()
199 plplot.plend()
175
200
176
201
177 if __name__ == '__main__':
202 if __name__ == '__main__':
178 pass No newline at end of file
203 pass
@@ -1,182 +1,207
1 '''
1 '''
2 Created on Feb 7, 2012
2 Created on Feb 7, 2012
3
3
4 @author $Author$
4 @author $Author$
5 @version $Id$
5 @version $Id$
6 '''
6 '''
7 import os, sys
7 import os, sys
8 import numpy
8 import numpy
9 import plplot
9 import plplot
10
10
11 path = os.path.split(os.getcwd())[0]
11 path = os.path.split(os.getcwd())[0]
12 sys.path.append(path)
12 sys.path.append(path)
13
13
14 from Graphics.BaseGraph import *
14 from Graphics.BaseGraph import *
15 from Model.Voltage import Voltage
15 from Model.Voltage import Voltage
16
16
17 class Osciloscope():
17 class Osciloscope:
18
18
19 def __init__(self, Voltage, index=0):
19 voltageObj = Voltage()
20
20
21 """
21 linearGraphObj = LinearPlot()
22
22
23 Inputs:
23 __isPlotConfig = False
24
24
25 type: "power" ->> Potencia
25 __isPlotIni = False
26 "iq" ->> Real + Imaginario
26
27 """
27 __xrange = None
28
28
29 self.__isPlotConfig = False
29 __yrange = None
30
30
31 self.__isPlotIni = False
31 voltageObj = Voltage()
32
32
33 self.__xrange = None
33 nGraphs = 0
34
34
35 self.__yrange = None
35 indexPlot = None
36
36
37 self.m_Voltage = None
37 graphObjList = []
38
38 m_LinearPlot= LinearPlot()
39 self.nGraphs = 0
39
40
40
41 self.indexPlot = index
41 m_Voltage= Voltage()
42
42
43 self.graphObjList = []
43
44
44
45 self.m_Voltage = Voltage
45 def __init__(self, Voltage, index=0):
46
46
47
47 """
48 def __addGraph(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False):
48
49
49 Inputs:
50 graphObj = LinearPlot()
50
51 graphObj.setup(subpage, title="", xlabel="", ylabel="", XAxisAsTime=False)
51 type: "power" ->> Potencia
52 #graphObj.setScreenPos()
52 "iq" ->> Real + Imaginario
53
53 """
54 self.graphObjList.append(graphObj)
54
55
55 self.__isPlotConfig = False
56 del graphObj
56
57
57 self.__isPlotIni = False
58 # def setXRange(self, xmin, xmax):
58
59 # self.__xrange = (xmin, xmax)
59 self.__xrange = None
60 #
60
61 # def setYRange(self, ymin, ymax):
61 self.__yrange = None
62 # self.__yrange = (ymin, ymax)
62
63
63 self.voltageObj = None
64
64
65 def setup(self, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False):
65 self.nGraphs = 0
66
66
67 nChan = int(self.m_Voltage.m_SystemHeader.numChannels)
67 self.indexPlot = index
68
68
69 myTitle = ""
69 self.graphObjList = []
70 myXlabel = ""
70
71 myYlabel = ""
71 self.voltageObj = Voltage
72
72
73 for chan in range(nChan):
73
74 if titleList != None:
74 def __addGraph(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False):
75 myTitle = titleList[chan]
75
76 myXlabel = xlabelList[chan]
76 graphObj = LinearPlot()
77 myYlabel = ylabelList[chan]
77 graphObj.setup(subpage, title="", xlabel="", ylabel="", XAxisAsTime=False)
78
78 #graphObj.setScreenPos()
79 self.__addGraph(chan+1, title=myTitle, xlabel=myXlabel, ylabel=myYlabel, XAxisAsTime=XAxisAsTime)
79
80
80 self.graphObjList.append(graphObj)
81 self.nGraphs = nChan
81
82 self.__isPlotConfig = True
82 del graphObj
83
83
84 def iniPlot(self, winTitle=""):
84 # def setXRange(self, xmin, xmax):
85
85 # self.__xrange = (xmin, xmax)
86 plplot.plsstrm(self.indexPlot)
86 #
87 plplot.plparseopts([winTitle], plplot.PL_PARSE_FULL)
87 # def setYRange(self, ymin, ymax):
88 plplot.plsetopt("geometry", "%dx%d" %(700, 115*self.nGraphs))
88 # self.__yrange = (ymin, ymax)
89 plplot.plsdev("xwin")
89
90 plplot.plscolbg(255,255,255)
90
91 plplot.plscol0(1,0,0,0)
91 def setup(self, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False):
92 plplot.plinit()
92
93 plplot.plspause(False)
93 nChan = int(self.voltageObj.m_SystemHeader.numChannels)
94 plplot.plssub(1, self.nGraphs)
94
95
95 myTitle = ""
96 self.__isPlotIni = True
96 myXlabel = ""
97
97 myYlabel = ""
98 def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, idProfile=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq', winTitle="Voltage"):
98
99
99 for chan in range(nChan):
100 if idProfile != None and idProfile != self.m_Voltage.idProfile:
100 if titleList != None:
101 return
101 myTitle = titleList[chan]
102
102 myXlabel = xlabelList[chan]
103 if not(self.__isPlotConfig):
103 myYlabel = ylabelList[chan]
104 self.setup(titleList, xlabelList, ylabelList, XAxisAsTime)
104
105
105 self.__addGraph(chan+1, title=myTitle, xlabel=myXlabel, ylabel=myYlabel, XAxisAsTime=XAxisAsTime)
106 if not(self.__isPlotIni):
106
107 self.iniPlot(winTitle)
107 self.nGraphs = nChan
108
108 self.__isPlotConfig = True
109 plplot.plsstrm(self.indexPlot)
109
110
110 def iniPlot(self, winTitle=""):
111 data = self.m_Voltage.data
111
112
112 plplot.plsstrm(self.indexPlot)
113 x = self.m_Voltage.heights
113 plplot.plparseopts([winTitle], plplot.PL_PARSE_FULL)
114
114 plplot.plsetopt("geometry", "%dx%d" %(700, 115*self.nGraphs))
115 if xmin == None: xmin = x[0]
115 plplot.plsdev("xwin")
116 if xmax == None: xmax = x[-1]
116 plplot.plscolbg(255,255,255)
117 if ymin == None: ymin = numpy.nanmin(abs(data))
117 plplot.plscol0(1,0,0,0)
118 if ymax == None: ymax = numpy.nanmax(abs(data))
118 plplot.plinit()
119
119 plplot.plspause(False)
120 plplot.plbop()
120 plplot.plssub(1, self.nGraphs)
121 for chan in range(self.nGraphs):
121
122 y = data[chan,:]
122 self.__isPlotIni = True
123
123
124 self.graphObjList[chan].iniSubpage()
124 def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, idProfile=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq', winTitle="Voltage"):
125 self.graphObjList[chan].plotComplexData(x, y, xmin, xmax, ymin, ymax, 8, type)
125
126
126 if idProfile != None and idProfile != self.voltageObj.idProfile:
127 plplot.plflush()
127 return
128 plplot.pleop()
128
129
129 if not(self.__isPlotConfig):
130 def end(self):
130 self.setup(titleList, xlabelList, ylabelList, XAxisAsTime)
131 plplot.plend()
131
132
132 if not(self.__isPlotIni):
133 class VoltagePlot(object):
133 self.iniPlot(winTitle)
134 '''
134
135 classdocs
135 plplot.plsstrm(self.indexPlot)
136 '''
136
137
137 data = self.voltageObj.data
138 __m_Voltage = None
138
139
139 x = self.voltageObj.heights
140 def __init__(self, m_Voltage):
140
141 '''
141 if xmin == None: xmin = x[0]
142 Constructor
142 if xmax == None: xmax = x[-1]
143 '''
143 if ymin == None: ymin = numpy.nanmin(abs(data))
144 self.__m_Voltage = m_Voltage
144 if ymax == None: ymax = numpy.nanmax(abs(data))
145
145
146 def setup(self):
146 plplot.plbop()
147 pass
147 for chan in range(self.nGraphs):
148
148 y = data[chan,:]
149 def addGraph(self, type, xrange=None, yrange=None, zrange=None):
149
150 pass
150 self.graphObjList[chan].plotComplexData(x, y, xmin, xmax, ymin, ymax, 8, type)
151
151
152 def plotData(self):
152 plplot.plflush()
153 pass
153 plplot.pleop()
154
154
155 if __name__ == '__main__':
155 def end(self):
156
156 plplot.plend()
157 import numpy
157
158
158 class VoltagePlot(object):
159 plplot.plsetopt("geometry", "%dx%d" %(450*2, 200*2))
159 '''
160 plplot.plsdev("xcairo")
160 classdocs
161 plplot.plscolbg(255,255,255)
161 '''
162 plplot.plscol0(1,0,0,0)
162
163 plplot.plinit()
163 __m_Voltage = None
164 plplot.plssub(1, 2)
164
165
165 def __init__(self, voltageObj):
166 nx = 64
166 '''
167 ny = 100
167 Constructor
168
168 '''
169 data = numpy.random.uniform(-50,50,(nx,ny))
169 self.__m_Voltage = voltageObj
170
170
171 baseObj = RTI()
171 def setup(self):
172 baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False)
172 pass
173 baseObj.plotData(data)
173
174
174 def addGraph(self, type, xrange=None, yrange=None, zrange=None):
175 data = numpy.random.uniform(-50,50,(nx,ny))
175 pass
176
176
177 base2Obj = RTI()
177 def plotData(self):
178 base2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True)
178 pass
179 base2Obj.plotData(data)
179
180
180 if __name__ == '__main__':
181 plplot.plend()
181
182 import numpy
183
184 plplot.plsetopt("geometry", "%dx%d" %(450*2, 200*2))
185 plplot.plsdev("xcairo")
186 plplot.plscolbg(255,255,255)
187 plplot.plscol0(1,0,0,0)
188 plplot.plinit()
189 plplot.plssub(1, 2)
190
191 nx = 64
192 ny = 100
193
194 data = numpy.random.uniform(-50,50,(nx,ny))
195
196 baseObj = RTI()
197 baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False)
198 baseObj.plotData(data)
199
200 data = numpy.random.uniform(-50,50,(nx,ny))
201
202 base2Obj = RTI()
203 base2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True)
204 base2Obj.plotData(data)
205
206 plplot.plend()
182 exit(0) No newline at end of file
207 exit(0)
@@ -15,4 +15,8 class CorrelationProcessor:
15 '''
15 '''
16 Constructor
16 Constructor
17 '''
17 '''
18 pass No newline at end of file
18 pass
19 m_Correlation= Correlation()
20
21 m_Voltage= Voltage()
22
@@ -1,112 +1,112
1 import numpy
1 import numpy
2 from Model.Spectra import Spectra
2 from Model.Spectra import Spectra
3
3
4 def hildebrand_sekhon(Data, navg=1):
4 def hildebrand_sekhon(Data, navg=1):
5 """
5 """
6 This method is for the objective determination of de noise level in Doppler spectra. This
6 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
7 implementation technique is based on the fact that the standard deviation of the spectral
8 densities is equal to the mean spectral density for white Gaussian noise
8 densities is equal to the mean spectral density for white Gaussian noise
9
9
10 Inputs:
10 Inputs:
11 Data : heights
11 Data : heights
12 navg : numbers of averages
12 navg : numbers of averages
13
13
14 Return:
14 Return:
15 -1 : any error
15 -1 : any error
16 anoise : noise's level
16 anoise : noise's level
17 """
17 """
18 divisor = 8
18 divisor = 8
19 ratio = 7 / divisor
19 ratio = 7 / divisor
20 data = Data.reshape(-1)
20 data = Data.reshape(-1)
21 npts = data.size #numbers of points of the data
21 npts = data.size #numbers of points of the data
22
22
23 if npts < 32:
23 if npts < 32:
24 print "error in noise - requires at least 32 points"
24 print "error in noise - requires at least 32 points"
25 return -1.0
25 return -1.0
26
26
27 # data sorted in ascending order
27 # data sorted in ascending order
28 nmin = int(npts/divisor + ratio);
28 nmin = int(npts/divisor + ratio);
29 s = 0.0
29 s = 0.0
30 s2 = 0.0
30 s2 = 0.0
31 data2 = data[:npts]
31 data2 = data[:npts]
32 data2.sort()
32 data2.sort()
33
33
34 for i in range(nmin):
34 for i in range(nmin):
35 s += data2[i]
35 s += data2[i]
36 s2 += data2[i]**2;
36 s2 += data2[i]**2;
37
37
38 icount = nmin
38 icount = nmin
39 iflag = 0
39 iflag = 0
40
40
41 for i in range(nmin, npts):
41 for i in range(nmin, npts):
42 s += data2[i];
42 s += data2[i];
43 s2 += data2[i]**2
43 s2 += data2[i]**2
44 icount=icount+1;
44 icount=icount+1;
45 p = s / float(icount);
45 p = s / float(icount);
46 p2 = p**2;
46 p2 = p**2;
47 q = s2 / float(icount) - p2;
47 q = s2 / float(icount) - p2;
48 leftc = p2;
48 leftc = p2;
49 rightc = q * float(navg);
49 rightc = q * float(navg);
50
50
51 if leftc > rightc:
51 if leftc > rightc:
52 iflag = 1; #No weather signal
52 iflag = 1; #No weather signal
53 # Signal detect: R2 < 1 (R2 = leftc/rightc)
53 # Signal detect: R2 < 1 (R2 = leftc/rightc)
54 if(leftc < rightc):
54 if(leftc < rightc):
55 if iflag:
55 if iflag:
56 break
56 break
57
57
58 anoise = 0.0;
58 anoise = 0.0;
59 for j in range(i):
59 for j in range(i):
60 anoise += data2[j];
60 anoise += data2[j];
61
61
62 anoise = anoise / float(i);
62 anoise = anoise / float(i);
63
63
64 return anoise;
64 return anoise;
65
65
66
66
67 class Noise():
67 class Noise:
68 """
68 """
69 Clase que implementa los metodos necesarios para deternimar el nivel de ruido en un Spectro Doppler
69 Clase que implementa los metodos necesarios para deternimar el nivel de ruido en un Spectro Doppler
70 """
70 """
71 m_DataObj = None
71 m_DataObj = None
72
72
73
73
74 def __init__(self, m_Spectra=None):
74 def __init__(self, m_Spectra=None):
75 """
75 """
76 Inicializador de la clase Noise para la la determinacion del nivel de ruido en un Spectro Doppler.
76 Inicializador de la clase Noise para la la determinacion del nivel de ruido en un Spectro Doppler.
77
77
78 Affected:
78 Affected:
79 self.m_DataObj
79 self.m_DataObj
80
80
81 Return:
81 Return:
82 None
82 None
83 """
83 """
84 if m_Spectra == None:
84 if m_Spectra == None:
85 m_Spectra = Spectra()
85 m_Spectra = Spectra()
86
86
87 if not(isinstance(m_Spectra, Spectra)):
87 if not(isinstance(m_Spectra, Spectra)):
88 raise ValueError, "in Noise class, m_Spectra must be an Spectra class object"
88 raise ValueError, "in Noise class, m_Spectra must be an Spectra class object"
89
89
90 self.m_DataObj = m_Spectra
90 self.m_DataObj = m_Spectra
91
91
92
92
93 def getNoiseLevelByHildebrandSekhon(self):
93 def getNoiseLevelByHildebrandSekhon(self):
94 """
94 """
95 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
95 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
96
96
97 Return:
97 Return:
98 noise level
98 noise level
99 """
99 """
100 data = self.m_DataObj.data_spc
100 data = self.m_DataObj.data_spc
101 daux = None
101 daux = None
102
102
103 for channel in range(self.m_DataObj.nChannels):
103 for channel in range(self.m_DataObj.nChannels):
104 daux = data[channel,:,:]
104 daux = data[channel,:,:]
105 noiselevel = hildebrand_sekhon(daux)
105 noiselevel = hildebrand_sekhon(daux)
106 print noiselevel
106 print noiselevel
107
107
108
108
109 for pair in range(self.m_DataObj.nPairs):
109 for pair in range(self.m_DataObj.nPairs):
110 daux = data[pair,:,:]
110 daux = data[pair,:,:]
111 noiselevel = hildebrand_sekhon(daux)
111 noiselevel = hildebrand_sekhon(daux)
112 print noiselevel
112 print noiselevel
@@ -20,6 +20,40 class SpectraProcessor:
20 classdocs
20 classdocs
21 '''
21 '''
22
22
23 dataInObj = None
24
25 dataOutObj = None
26
27 integratorObjIndex = None
28
29 decoderObjIndex = None
30
31 writerObjIndex = None
32
33 plotterObjIndex = None
34
35 integratorObjList = []
36
37 decoderObjList = []
38
39 writerObjList = []
40
41 plotterObjList = []
42
43 buffer = None
44
45 ptsId = 0
46
47 nFFTPoints = None
48
49 pairList = None
50 m_Spectra= Spectra()
51
52 m_Voltage= Voltage()
53
54 m_IncoherentIntegration= IncoherentIntegration()
55
56
23 def __init__(self, dataInObj, dataOutObj=None):
57 def __init__(self, dataInObj, dataOutObj=None):
24 '''
58 '''
25 Constructor
59 Constructor
@@ -31,25 +65,25 class SpectraProcessor:
31 else:
65 else:
32 self.dataOutObj = dataOutObj
66 self.dataOutObj = dataOutObj
33
67
34 self.integratorIndex = None
68 self.integratorObjIndex = None
35 self.decoderIndex = None
69 self.decoderObjIndex = None
36 self.writerIndex = None
70 self.writerObjIndex = None
37 self.plotterIndex = None
71 self.plotterObjIndex = None
38
72
39 self.integratorList = []
73 self.integratorObjList = []
40 self.decoderList = []
74 self.decoderObjList = []
41 self.writerList = []
75 self.writerObjList = []
42 self.plotterList = []
76 self.plotterObjList = []
43
77
44 self.buffer = None
78 self.buffer = None
45 self.ptsId = 0
79 self.ptsId = 0
46
80
47 def init(self, nFFTPoints, pairList=None):
81 def init(self, nFFTPoints, pairList=None):
48
82
49 self.integratorIndex = 0
83 self.integratorObjIndex = 0
50 self.decoderIndex = 0
84 self.decoderObjIndex = 0
51 self.writerIndex = 0
85 self.writerObjIndex = 0
52 self.plotterIndex = 0
86 self.plotterObjIndex = 0
53
87
54 if nFFTPoints == None:
88 if nFFTPoints == None:
55 nFFTPoints = self.dataOutObj.nFFTPoints
89 nFFTPoints = self.dataOutObj.nFFTPoints
@@ -179,54 +213,54 class SpectraProcessor:
179 def addWriter(self,wrpath):
213 def addWriter(self,wrpath):
180 objWriter = SpectraWriter(self.dataOutObj)
214 objWriter = SpectraWriter(self.dataOutObj)
181 objWriter.setup(wrpath)
215 objWriter.setup(wrpath)
182 self.writerList.append(objWriter)
216 self.writerObjList.append(objWriter)
183
217
184
218
185 def addPlotter(self, index=None):
219 def addPlotter(self, index=None):
186
220
187 if index==None:
221 if index==None:
188 index = self.plotterIndex
222 index = self.plotterObjIndex
189
223
190 plotObj = Spectrum(self.dataOutObj, index)
224 plotObj = Spectrum(self.dataOutObj, index)
191 self.plotterList.append(plotObj)
225 self.plotterObjList.append(plotObj)
192
226
193
227
194 def addIntegrator(self,N):
228 def addIntegrator(self,N):
195
229
196 objIncohInt = IncoherentIntegration(N)
230 objIncohInt = IncoherentIntegration(N)
197 self.integratorList.append(objIncohInt)
231 self.integratorObjList.append(objIncohInt)
198
232
199
233
200 def writeData(self, wrpath):
234 def writeData(self, wrpath):
201 if self.dataOutObj.flagNoData:
235 if self.dataOutObj.flagNoData:
202 return 0
236 return 0
203
237
204 if len(self.writerList) <= self.writerIndex:
238 if len(self.writerObjList) <= self.writerObjIndex:
205 self.addWriter(wrpath)
239 self.addWriter(wrpath)
206
240
207 self.writerList[self.writerIndex].putData()
241 self.writerObjList[self.writerObjIndex].putData()
208
242
209 self.writerIndex += 1
243 self.writerObjIndex += 1
210
244
211 def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, winTitle='', index=None):
245 def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, winTitle='', index=None):
212 if self.dataOutObj.flagNoData:
246 if self.dataOutObj.flagNoData:
213 return 0
247 return 0
214
248
215 if len(self.plotterList) <= self.plotterIndex:
249 if len(self.plotterObjList) <= self.plotterObjIndex:
216 self.addPlotter(index)
250 self.addPlotter(index)
217
251
218 self.plotterList[self.plotterIndex].plotData(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle)
252 self.plotterObjList[self.plotterObjIndex].plotData(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle)
219
253
220 self.plotterIndex += 1
254 self.plotterObjIndex += 1
221
255
222 def integrator(self, N):
256 def integrator(self, N):
223 if self.dataOutObj.flagNoData:
257 if self.dataOutObj.flagNoData:
224 return 0
258 return 0
225
259
226 if len(self.integratorList) <= self.integratorIndex:
260 if len(self.integratorObjList) <= self.integratorObjIndex:
227 self.addIntegrator(N)
261 self.addIntegrator(N)
228
262
229 myCohIntObj = self.integratorList[self.integratorIndex]
263 myCohIntObj = self.integratorObjList[self.integratorObjIndex]
230 myCohIntObj.exe(self.dataOutObj.data_spc)
264 myCohIntObj.exe(self.dataOutObj.data_spc)
231
265
232 if myCohIntObj.flag:
266 if myCohIntObj.flag:
@@ -237,7 +271,7 class SpectraProcessor:
237 else:
271 else:
238 self.dataOutObj.flagNoData = True
272 self.dataOutObj.flagNoData = True
239
273
240 self.integratorIndex += 1
274 self.integratorObjIndex += 1
241
275
242 def removeDC(self, type):
276 def removeDC(self, type):
243
277
@@ -485,7 +519,15 class SpectraProcessor:
485
519
486
520
487 class IncoherentIntegration:
521 class IncoherentIntegration:
522
523 profCounter = 1
524 data = None
525 buffer = None
526 flag = False
527 nIncohInt = None
528
488 def __init__(self, N):
529 def __init__(self, N):
530
489 self.profCounter = 1
531 self.profCounter = 1
490 self.data = None
532 self.data = None
491 self.buffer = None
533 self.buffer = None
@@ -19,134 +19,157 class VoltageProcessor:
19 '''
19 '''
20 classdocs
20 classdocs
21 '''
21 '''
22
23 dataInObj = None
24 dataOutObj = None
25
26 integratorObjIndex = None
27 decoderObjIndex = None
28 profSelectorObjIndex = None
29 writerObjIndex = None
30 plotterObjIndex = None
31
32 integratorObjList = []
33 decoderObjList = []
34 profileSelectorObjList = []
35 writerObjList = []
36 plotterObjList = []
37 m_Voltage= Voltage()
38
39 m_ProfileSelector= ProfileSelector()
22
40
23 def __init__(self, voltageInObj, voltageOutObj=None):
41 m_Decoder= Decoder()
42
43 m_CoherentIntegrator= CoherentIntegrator()
44
45
46 def __init__(self, dataInObj, dataOutObj=None):
24 '''
47 '''
25 Constructor
48 Constructor
26 '''
49 '''
27
50
28 self.voltageInObj = voltageInObj
51 self.dataInObj = dataInObj
29
52
30 if voltageOutObj == None:
53 if dataOutObj == None:
31 self.voltageOutObj = Voltage()
54 self.dataOutObj = Voltage()
32 else:
55 else:
33 self.voltageOutObj = voltageOutObj
56 self.dataOutObj = dataOutObj
34
57
35 self.integratorIndex = None
58 self.integratorObjIndex = None
36 self.decoderIndex = None
59 self.decoderObjIndex = None
37 self.profSelectorIndex = None
60 self.profSelectorObjIndex = None
38 self.writerIndex = None
61 self.writerObjIndex = None
39 self.plotterIndex = None
62 self.plotterObjIndex = None
40
63
41 self.integratorList = []
64 self.integratorObjList = []
42 self.decoderList = []
65 self.decoderObjList = []
43 self.profileSelectorList = []
66 self.profileSelectorObjList = []
44 self.writerList = []
67 self.writerObjList = []
45 self.plotterList = []
68 self.plotterObjList = []
46
69
47 def init(self):
70 def init(self):
48
71
49 self.integratorIndex = 0
72 self.integratorObjIndex = 0
50 self.decoderIndex = 0
73 self.decoderObjIndex = 0
51 self.profSelectorIndex = 0
74 self.profSelectorObjIndex = 0
52 self.writerIndex = 0
75 self.writerObjIndex = 0
53 self.plotterIndex = 0
76 self.plotterObjIndex = 0
54 self.voltageOutObj.copy(self.voltageInObj)
77 self.dataOutObj.copy(self.dataInObj)
55
78
56 def addWriter(self, wrpath):
79 def addWriter(self, wrpath):
57 objWriter = VoltageWriter(self.voltageOutObj)
80 objWriter = VoltageWriter(self.dataOutObj)
58 objWriter.setup(wrpath)
81 objWriter.setup(wrpath)
59 self.writerList.append(objWriter)
82 self.writerObjList.append(objWriter)
60
83
61 def addPlotter(self):
84 def addPlotter(self):
62
85
63 plotObj = Osciloscope(self.voltageOutObj,self.plotterIndex)
86 plotObj = Osciloscope(self.dataOutObj,self.plotterObjIndex)
64 self.plotterList.append(plotObj)
87 self.plotterObjList.append(plotObj)
65
88
66 def addIntegrator(self, nCohInt):
89 def addIntegrator(self, nCohInt):
67
90
68 objCohInt = CoherentIntegrator(nCohInt)
91 objCohInt = CoherentIntegrator(nCohInt)
69 self.integratorList.append(objCohInt)
92 self.integratorObjList.append(objCohInt)
70
93
71 def addDecoder(self, code, ncode, nbaud):
94 def addDecoder(self, code, ncode, nbaud):
72
95
73 objDecoder = Decoder(code,ncode,nbaud)
96 objDecoder = Decoder(code,ncode,nbaud)
74 self.decoderList.append(objDecoder)
97 self.decoderObjList.append(objDecoder)
75
98
76 def addProfileSelector(self, nProfiles):
99 def addProfileSelector(self, nProfiles):
77
100
78 objProfSelector = ProfileSelector(nProfiles)
101 objProfSelector = ProfileSelector(nProfiles)
79 self.profileSelectorList.append(objProfSelector)
102 self.profileSelectorObjList.append(objProfSelector)
80
103
81 def writeData(self,wrpath):
104 def writeData(self,wrpath):
82
105
83 if self.voltageOutObj.flagNoData:
106 if self.dataOutObj.flagNoData:
84 return 0
107 return 0
85
108
86 if len(self.writerList) <= self.writerIndex:
109 if len(self.writerObjList) <= self.writerObjIndex:
87 self.addWriter(wrpath)
110 self.addWriter(wrpath)
88
111
89 self.writerList[self.writerIndex].putData()
112 self.writerObjList[self.writerObjIndex].putData()
90
113
91 # myWrObj = self.writerList[self.writerIndex]
114 # myWrObj = self.writerObjList[self.writerObjIndex]
92 # myWrObj.putData()
115 # myWrObj.putData()
93
116
94 self.writerIndex += 1
117 self.writerObjIndex += 1
95
118
96 def plotData(self,idProfile, type, xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''):
119 def plotData(self,idProfile, type, xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''):
97 if self.voltageOutObj.flagNoData:
120 if self.dataOutObj.flagNoData:
98 return 0
121 return 0
99
122
100 if len(self.plotterList) <= self.plotterIndex:
123 if len(self.plotterObjList) <= self.plotterObjIndex:
101 self.addPlotter()
124 self.addPlotter()
102
125
103 self.plotterList[self.plotterIndex].plotData(type=type, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle)
126 self.plotterObjList[self.plotterObjIndex].plotData(type=type, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle)
104
127
105 self.plotterIndex += 1
128 self.plotterObjIndex += 1
106
129
107 def integrator(self, N):
130 def integrator(self, N):
108
131
109 if self.voltageOutObj.flagNoData:
132 if self.dataOutObj.flagNoData:
110 return 0
133 return 0
111
134
112 if len(self.integratorList) <= self.integratorIndex:
135 if len(self.integratorObjList) <= self.integratorObjIndex:
113 self.addIntegrator(N)
136 self.addIntegrator(N)
114
137
115 myCohIntObj = self.integratorList[self.integratorIndex]
138 myCohIntObj = self.integratorObjList[self.integratorObjIndex]
116 myCohIntObj.exe(self.voltageOutObj.data)
139 myCohIntObj.exe(self.dataOutObj.data)
117
140
118 if myCohIntObj.flag:
141 if myCohIntObj.flag:
119 self.voltageOutObj.data = myCohIntObj.data
142 self.dataOutObj.data = myCohIntObj.data
120 self.voltageOutObj.m_ProcessingHeader.coherentInt *= N
143 self.dataOutObj.m_ProcessingHeader.coherentInt *= N
121 self.voltageOutObj.flagNoData = False
144 self.dataOutObj.flagNoData = False
122
145
123 else:
146 else:
124 self.voltageOutObj.flagNoData = True
147 self.dataOutObj.flagNoData = True
125
148
126 self.integratorIndex += 1
149 self.integratorObjIndex += 1
127
150
128 def decoder(self,code=None,type = 0):
151 def decoder(self,code=None,type = 0):
129
152
130 if self.voltageOutObj.flagNoData:
153 if self.dataOutObj.flagNoData:
131 return 0
154 return 0
132
155
133 if code == None:
156 if code == None:
134 code = self.voltageOutObj.m_RadarControllerHeader.code
157 code = self.dataOutObj.m_RadarControllerHeader.code
135 ncode, nbaud = code.shape
158 ncode, nbaud = code.shape
136
159
137 if len(self.decoderList) <= self.decoderIndex:
160 if len(self.decoderObjList) <= self.decoderObjIndex:
138 self.addDecoder(code,ncode,nbaud)
161 self.addDecoder(code,ncode,nbaud)
139
162
140 myDecodObj = self.decoderList[self.decoderIndex]
163 myDecodObj = self.decoderObjList[self.decoderObjIndex]
141 myDecodObj.exe(data=self.voltageOutObj.data,type=type)
164 myDecodObj.exe(data=self.dataOutObj.data,type=type)
142
165
143 if myDecodObj.flag:
166 if myDecodObj.flag:
144 self.voltageOutObj.data = myDecodObj.data
167 self.dataOutObj.data = myDecodObj.data
145 self.voltageOutObj.flagNoData = False
168 self.dataOutObj.flagNoData = False
146 else:
169 else:
147 self.voltageOutObj.flagNoData = True
170 self.dataOutObj.flagNoData = True
148
171
149 self.decoderIndex += 1
172 self.decoderObjIndex += 1
150
173
151
174
152 def filterByHei(self, window):
175 def filterByHei(self, window):
@@ -162,36 +185,36 class VoltageProcessor:
162
185
163 Affected:
186 Affected:
164 self.dataOutObj.data
187 self.dataOutObj.data
165 self.voltageOutObj.channelList
188 self.dataOutObj.channelList
166 self.dataOutObj.nChannels
189 self.dataOutObj.nChannels
167 self.voltageOutObj.m_ProcessingHeader.totalSpectra
190 self.dataOutObj.m_ProcessingHeader.totalSpectra
168 self.dataOutObj.m_SystemHeader.numChannels
191 self.dataOutObj.m_SystemHeader.numChannels
169 self.voltageOutObj.m_ProcessingHeader.blockSize
192 self.dataOutObj.m_ProcessingHeader.blockSize
170
193
171 Return:
194 Return:
172 None
195 None
173 """
196 """
174 if self.voltageOutObj.flagNoData:
197 if self.dataOutObj.flagNoData:
175 return 0
198 return 0
176
199
177 for channel in channelList:
200 for channel in channelList:
178 if channel not in self.voltageOutObj.channelList:
201 if channel not in self.dataOutObj.channelList:
179 raise ValueError, "The value %d in channelList is not valid" %channel
202 raise ValueError, "The value %d in channelList is not valid" %channel
180
203
181 nchannels = len(channelList)
204 nchannels = len(channelList)
182 profiles = self.voltageOutObj.nProfiles
205 profiles = self.dataOutObj.nProfiles
183 heights = self.voltageOutObj.nHeights #m_ProcessingHeader.numHeights
206 heights = self.dataOutObj.nHeights #m_ProcessingHeader.numHeights
184
207
185 data = numpy.zeros( (nchannels,heights), dtype='complex' )
208 data = numpy.zeros( (nchannels,heights), dtype='complex' )
186 for index,channel in enumerate(channelList):
209 for index,channel in enumerate(channelList):
187 data[index,:] = self.voltageOutObj.data[channel,:]
210 data[index,:] = self.dataOutObj.data[channel,:]
188
211
189 self.voltageOutObj.data = data
212 self.dataOutObj.data = data
190 self.voltageOutObj.channelList = channelList
213 self.dataOutObj.channelList = channelList
191 self.voltageOutObj.nChannels = nchannels
214 self.dataOutObj.nChannels = nchannels
192 self.voltageOutObj.m_ProcessingHeader.totalSpectra = nchannels
215 self.dataOutObj.m_ProcessingHeader.totalSpectra = nchannels
193 self.voltageOutObj.m_SystemHeader.numChannels = nchannels
216 self.dataOutObj.m_SystemHeader.numChannels = nchannels
194 self.voltageOutObj.m_ProcessingHeader.blockSize = data.size
217 self.dataOutObj.m_ProcessingHeader.blockSize = data.size
195 return 1
218 return 1
196
219
197
220
@@ -210,18 +233,18 class VoltageProcessor:
210 Return:
233 Return:
211 1 si el metodo se ejecuto con exito caso contrario devuelve 0
234 1 si el metodo se ejecuto con exito caso contrario devuelve 0
212 """
235 """
213 if self.voltageOutObj.flagNoData:
236 if self.dataOutObj.flagNoData:
214 return 0
237 return 0
215
238
216 if (minHei < self.voltageOutObj.heightList[0]) or (minHei > maxHei):
239 if (minHei < self.dataOutObj.heightList[0]) or (minHei > maxHei):
217 raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
240 raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
218
241
219 if (maxHei > self.voltageOutObj.heightList[-1]):
242 if (maxHei > self.dataOutObj.heightList[-1]):
220 raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
243 raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
221
244
222 minIndex = 0
245 minIndex = 0
223 maxIndex = 0
246 maxIndex = 0
224 data = self.voltageOutObj.heightList
247 data = self.dataOutObj.heightList
225
248
226 for i,val in enumerate(data):
249 for i,val in enumerate(data):
227 if val < minHei:
250 if val < minHei:
@@ -250,41 +273,41 class VoltageProcessor:
250 maxIndex : valor de indice maximo de altura a considerar
273 maxIndex : valor de indice maximo de altura a considerar
251
274
252 Affected:
275 Affected:
253 self.voltageOutObj.data
276 self.dataOutObj.data
254 self.voltageOutObj.heightList
277 self.dataOutObj.heightList
255 self.voltageOutObj.nHeights
278 self.dataOutObj.nHeights
256 self.voltageOutObj.m_ProcessingHeader.blockSize
279 self.dataOutObj.m_ProcessingHeader.blockSize
257 self.voltageOutObj.m_ProcessingHeader.numHeights
280 self.dataOutObj.m_ProcessingHeader.numHeights
258 self.voltageOutObj.m_ProcessingHeader.firstHeight
281 self.dataOutObj.m_ProcessingHeader.firstHeight
259 self.voltageOutObj.m_RadarControllerHeader
282 self.dataOutObj.m_RadarControllerHeader
260
283
261 Return:
284 Return:
262 1 si el metodo se ejecuto con exito caso contrario devuelve 0
285 1 si el metodo se ejecuto con exito caso contrario devuelve 0
263 """
286 """
264 if self.voltageOutObj.flagNoData:
287 if self.dataOutObj.flagNoData:
265 return 0
288 return 0
266
289
267 if (minIndex < 0) or (minIndex > maxIndex):
290 if (minIndex < 0) or (minIndex > maxIndex):
268 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
291 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
269
292
270 if (maxIndex >= self.voltageOutObj.nHeights):
293 if (maxIndex >= self.dataOutObj.nHeights):
271 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
294 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
272
295
273 nHeights = maxIndex - minIndex + 1
296 nHeights = maxIndex - minIndex + 1
274 firstHeight = 0
297 firstHeight = 0
275
298
276 #voltage
299 #voltage
277 data = self.voltageOutObj.data[:,minIndex:maxIndex+1]
300 data = self.dataOutObj.data[:,minIndex:maxIndex+1]
278
301
279 firstHeight = self.voltageOutObj.heightList[minIndex]
302 firstHeight = self.dataOutObj.heightList[minIndex]
280
303
281 self.voltageOutObj.data = data
304 self.dataOutObj.data = data
282 self.voltageOutObj.heightList = self.voltageOutObj.heightList[minIndex:maxIndex+1]
305 self.dataOutObj.heightList = self.dataOutObj.heightList[minIndex:maxIndex+1]
283 self.voltageOutObj.nHeights = nHeights
306 self.dataOutObj.nHeights = nHeights
284 self.voltageOutObj.m_ProcessingHeader.blockSize = data.size
307 self.dataOutObj.m_ProcessingHeader.blockSize = data.size
285 self.voltageOutObj.m_ProcessingHeader.numHeights = nHeights
308 self.dataOutObj.m_ProcessingHeader.numHeights = nHeights
286 self.voltageOutObj.m_ProcessingHeader.firstHeight = firstHeight
309 self.dataOutObj.m_ProcessingHeader.firstHeight = firstHeight
287 self.voltageOutObj.m_RadarControllerHeader.numHeights = nHeights
310 self.dataOutObj.m_RadarControllerHeader.numHeights = nHeights
288 return 1
311 return 1
289
312
290
313
@@ -299,28 +322,28 class VoltageProcessor:
299 nProfiles : numero de profiles
322 nProfiles : numero de profiles
300
323
301 Affected:
324 Affected:
302 self.voltageOutObj.flagNoData
325 self.dataOutObj.flagNoData
303 self.profSelectorIndex
326 self.profSelectorObjIndex
304
327
305 Return:
328 Return:
306 1 si el metodo se ejecuto con exito caso contrario devuelve 0
329 1 si el metodo se ejecuto con exito caso contrario devuelve 0
307 """
330 """
308
331
309 if self.voltageOutObj.flagNoData:
332 if self.dataOutObj.flagNoData:
310 return 0
333 return 0
311
334
312 if self.profSelectorIndex >= len(self.profileSelectorList):
335 if self.profSelectorObjIndex >= len(self.profileSelectorObjList):
313 self.addProfileSelector(nProfiles)
336 self.addProfileSelector(nProfiles)
314
337
315 profileSelectorObj = self.profileSelectorList[self.profSelectorIndex]
338 profileSelectorObj = self.profileSelectorObjList[self.profSelectorObjIndex]
316
339
317 if profileSelectorObj.isProfileInRange(minIndex, maxIndex):
340 if profileSelectorObj.isProfileInRange(minIndex, maxIndex):
318 self.voltageOutObj.flagNoData = False
341 self.dataOutObj.flagNoData = False
319 self.profSelectorIndex += 1
342 self.profSelectorObjIndex += 1
320 return 1
343 return 1
321
344
322 self.voltageOutObj.flagNoData = True
345 self.dataOutObj.flagNoData = True
323 self.profSelectorIndex += 1
346 self.profSelectorObjIndex += 1
324
347
325 return 0
348 return 0
326
349
@@ -329,10 +352,20 class VoltageProcessor:
329
352
330
353
331 class Decoder:
354 class Decoder:
355
356 data = None
357 profCounter = 1
358 nCode = ncode
359 nBaud = nbaud
360 codeIndex = 0
361 code = code #this is a List
362 fft_code = None
363 flag = False
364 setCodeFft = False
332
365
333 def __init__(self,code, ncode, nbaud):
366 def __init__(self,code, ncode, nbaud):
334
367
335 self.buffer = None
368 self.data = None
336 self.profCounter = 1
369 self.profCounter = 1
337 self.nCode = ncode
370 self.nCode = ncode
338 self.nBaud = nbaud
371 self.nBaud = nbaud
@@ -400,6 +433,12 class Decoder:
400
433
401 class CoherentIntegrator:
434 class CoherentIntegrator:
402
435
436 profCounter = 1
437 data = None
438 buffer = None
439 flag = False
440 nCohInt = N
441
403 def __init__(self, N):
442 def __init__(self, N):
404
443
405 self.profCounter = 1
444 self.profCounter = 1
@@ -425,7 +464,7 class CoherentIntegrator:
425
464
426 self.profCounter += 1
465 self.profCounter += 1
427
466
428 class ProfileSelector():
467 class ProfileSelector:
429
468
430 indexProfile = None
469 indexProfile = None
431 # Tamanho total de los perfiles
470 # Tamanho total de los perfiles
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now