##// END OF EJS Templates
Adicion del factor de normalizacion en la clase Spectra....
Daniel Valdez -
r245:0a5b40329524
parent child
Show More
@@ -315,6 +315,11 class Axes:
315 315 ylabel=ylabel,
316 316 title=title,
317 317 **kwargs)
318 if self.xmin == None: self.xmin = xmin
319 if self.xmax == None: self.xmax = xmax
320 if self.ymin == None: self.ymin = ymin
321 if self.ymax == None: self.ymax = ymax
322
318 323 self.__firsttime = False
319 324 return
320 325
@@ -1,7 +1,11
1 1 import numpy
2 2 import datetime
3 import sys
3 4 import matplotlib
4 matplotlib.use("GTKAgg")
5 if sys.platform == 'linux':
6 matplotlib.use("GTKAgg")
7 if sys.platform == 'darwin':
8 matplotlib.use("TKAgg")
5 9 import matplotlib.pyplot
6 10 import matplotlib.dates
7 11 #import scitools.numpyutils
@@ -161,6 +161,8 class JROData:
161 161
162 162 noise = None
163 163
164 windowOfFilter = 1
165
164 166 #Speed of ligth
165 167 C = 3e8
166 168
@@ -448,7 +450,7 class Spectra(JROData):
448 450 if type == 3:
449 451 noise = self.getNoisebyWindow()
450 452
451 return 10*numpy.log10(noise)
453 return noise
452 454
453 455
454 456 def getFreqRange(self, extrapoints=0):
@@ -473,8 +475,17 class Spectra(JROData):
473 475
474 476 return range(self.nPairs)
475 477
478 def getNormFactor(self):
479 pwcode = 1
480 if self.flagDecodeData:
481 pwcode = numpy.sum(self.code[0]**2)
482 normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*self.windowOfFilter*pwcode
483
484 return normFactor
485
476 486 nPairs = property(getNPairs, "I'm the 'nPairs' property.")
477 487 pairsIndexList = property(getPairsIndexList, "I'm the 'pairsIndexList' property.")
488 normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.")
478 489
479 490 class SpectraHeis(JROData):
480 491
@@ -86,14 +86,18 class CrossSpectraPlot(Figure):
86 86
87 87 if len(pairsIndexList) > 4:
88 88 pairsIndexList = pairsIndexList[0:4]
89
89 factor = dataOut.normFactor
90 90 x = dataOut.getVelRange(1)
91 91 y = dataOut.getHeiRange()
92 z = 10.*numpy.log10(dataOut.data_spc[:,:,:])
92 z = dataOut.data_spc[:,:,:]/factor
93 93 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
94 94 avg = numpy.average(numpy.abs(z), axis=1)
95 noise = dataOut.getNoise()/factor
96
97 zdB = 10*numpy.log10(z)
98 avgdB = 10*numpy.log10(avg)
99 noisedB = 10*numpy.log10(noise)
95 100
96 noise = dataOut.getNoise()
97 101
98 102 thisDatetime = dataOut.datatime
99 103 title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
@@ -113,8 +117,8 class CrossSpectraPlot(Figure):
113 117 if xmax == None: xmax = numpy.nanmax(x)
114 118 if ymin == None: ymin = numpy.nanmin(y)
115 119 if ymax == None: ymax = numpy.nanmax(y)
116 if zmin == None: zmin = numpy.nanmin(avg)*0.9
117 if zmax == None: zmax = numpy.nanmax(avg)*0.9
120 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
121 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
118 122
119 123 self.__isConfig = True
120 124
@@ -123,18 +127,18 class CrossSpectraPlot(Figure):
123 127 for i in range(self.nplots):
124 128 pair = dataOut.pairsList[pairsIndexList[i]]
125 129
126 title = "Channel %d: %4.2fdB" %(pair[0], noise[pair[0]])
127 z = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:])
130 title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]])
131 zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor)
128 132 axes0 = self.axesList[i*self.__nsubplots]
129 axes0.pcolor(x, y, z,
133 axes0.pcolor(x, y, zdB,
130 134 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
131 135 xlabel=xlabel, ylabel=ylabel, title=title,
132 136 ticksize=9, cblabel='')
133 137
134 title = "Channel %d: %4.2fdB" %(pair[1], noise[pair[1]])
135 z = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:])
138 title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]])
139 zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor)
136 140 axes0 = self.axesList[i*self.__nsubplots+1]
137 axes0.pcolor(x, y, z,
141 axes0.pcolor(x, y, zdB,
138 142 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
139 143 xlabel=xlabel, ylabel=ylabel, title=title,
140 144 ticksize=9, cblabel='')
@@ -265,13 +269,18 class RTIPlot(Figure):
265 269
266 270 tmin = None
267 271 tmax = None
272 factor = dataOut.normFactor
268 273 x = dataOut.getTimeRange()
269 274 y = dataOut.getHeiRange()
270 z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:])
271 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
275
276 z = dataOut.data_spc[channelIndexList,:,:]/factor
277 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
272 278 avg = numpy.average(z, axis=1)
279 noise = dataOut.getNoise()/factor
273 280
274 noise = dataOut.getNoise()
281 # zdB = 10.*numpy.log10(z)
282 avgdB = 10.*numpy.log10(avg)
283 noisedB = 10.*numpy.log10(noise)
275 284
276 285 thisDatetime = dataOut.datatime
277 286 title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y"))
@@ -290,8 +299,8 class RTIPlot(Figure):
290 299 tmin, tmax = self.getTimeLim(x, xmin, xmax)
291 300 if ymin == None: ymin = numpy.nanmin(y)
292 301 if ymax == None: ymax = numpy.nanmax(y)
293 if zmin == None: zmin = numpy.nanmin(avg)*0.9
294 if zmax == None: zmax = numpy.nanmax(avg)*0.9
302 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
303 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
295 304
296 305 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
297 306 self.__isConfig = True
@@ -302,15 +311,15 class RTIPlot(Figure):
302 311 for i in range(self.nplots):
303 312 title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
304 313 axes = self.axesList[i*self.__nsubplots]
305 z = avg[i].reshape((1,-1))
306 axes.pcolor(x, y, z,
314 zdB = avgdB[i].reshape((1,-1))
315 axes.pcolor(x, y, zdB,
307 316 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
308 317 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
309 318 ticksize=9, cblabel='', cbsize="1%")
310 319
311 320 if self.__showprofile:
312 321 axes = self.axesList[i*self.__nsubplots +1]
313 axes.pline(avg[i], y,
322 axes.pline(avgdB[i], y,
314 323 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
315 324 xlabel='dB', ylabel='', title='',
316 325 ytick_visible=False,
@@ -415,15 +424,18 class SpectraPlot(Figure):
415 424 if channel not in dataOut.channelList:
416 425 raise ValueError, "Channel %d is not in dataOut.channelList"
417 426 channelIndexList.append(dataOut.channelList.index(channel))
418
427 factor = dataOut.normFactor
419 428 x = dataOut.getVelRange(1)
420 429 y = dataOut.getHeiRange()
421 430
422 z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:])
423 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
431 z = dataOut.data_spc[channelIndexList,:,:]/factor
432 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
424 433 avg = numpy.average(z, axis=1)
434 noise = dataOut.getNoise()/factor
425 435
426 noise = dataOut.getNoise()
436 zdB = 10*numpy.log10(z)
437 avgdB = 10*numpy.log10(avg)
438 noisedB = 10*numpy.log10(noise)
427 439
428 440 thisDatetime = dataOut.datatime
429 441 title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
@@ -443,30 +455,30 class SpectraPlot(Figure):
443 455 if xmax == None: xmax = numpy.nanmax(x)
444 456 if ymin == None: ymin = numpy.nanmin(y)
445 457 if ymax == None: ymax = numpy.nanmax(y)
446 if zmin == None: zmin = numpy.nanmin(avg)*0.9
447 if zmax == None: zmax = numpy.nanmax(avg)*0.9
458 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
459 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
448 460
449 461 self.__isConfig = True
450 462
451 463 self.setWinTitle(title)
452 464
453 465 for i in range(self.nplots):
454 title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noise[i])
466 title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noisedB[i])
455 467 axes = self.axesList[i*self.__nsubplots]
456 axes.pcolor(x, y, z[i,:,:],
468 axes.pcolor(x, y, zdB[i,:,:],
457 469 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
458 470 xlabel=xlabel, ylabel=ylabel, title=title,
459 471 ticksize=9, cblabel='')
460 472
461 473 if self.__showprofile:
462 474 axes = self.axesList[i*self.__nsubplots +1]
463 axes.pline(avg[i], y,
475 axes.pline(avgdB[i], y,
464 476 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
465 477 xlabel='dB', ylabel='', title='',
466 478 ytick_visible=False,
467 479 grid='x')
468 480
469 noiseline = numpy.repeat(noise[i], len(y))
481 noiseline = numpy.repeat(noisedB[i], len(y))
470 482 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
471 483
472 484 self.draw()
@@ -631,11 +643,14 class ProfilePlot(Figure):
631 643 raise ValueError, "Channel %d is not in dataOut.channelList"
632 644 channelIndexList.append(dataOut.channelList.index(channel))
633 645
634
635 y = dataOut.getHeiRange()
636 x = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:])
646 factor = dataOut.normFactor
647 y = dataOut.getHeiRange()
648 x = dataOut.data_spc[channelIndexList,:,:]/factor
649 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
637 650 avg = numpy.average(x, axis=1)
638 651
652 avgdB = 10*numpy.log10(avg)
653
639 654 thisDatetime = dataOut.datatime
640 655 title = "Power Profile"
641 656 xlabel = "dB"
@@ -651,8 +666,8 class ProfilePlot(Figure):
651 666
652 667 if ymin == None: ymin = numpy.nanmin(y)
653 668 if ymax == None: ymax = numpy.nanmax(y)
654 if xmin == None: xmin = numpy.nanmin(avg)*0.9
655 if xmax == None: xmax = numpy.nanmax(avg)*0.9
669 if xmin == None: xmin = numpy.nanmin(avgdB)*0.9
670 if xmax == None: xmax = numpy.nanmax(avgdB)*0.9
656 671
657 672 self.__isConfig = True
658 673
@@ -663,7 +678,7 class ProfilePlot(Figure):
663 678 axes = self.axesList[0]
664 679
665 680 legendlabels = ["channel %d"%x for x in channelList]
666 axes.pmultiline(avg, y,
681 axes.pmultiline(avgdB, y,
667 682 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
668 683 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
669 684 ytick_visible=True, nxticks=5,
@@ -852,6 +867,10 class RTIfromNoise(Figure):
852 867
853 868 self.WIDTH = 820
854 869 self.HEIGHT = 200
870 self.WIDTHPROF = 120
871 self.HEIGHTPROF = 0
872 self.xdata = None
873 self.ydata = None
855 874
856 875 def getSubplots(self):
857 876
@@ -865,17 +884,19 class RTIfromNoise(Figure):
865 884 self.__showprofile = showprofile
866 885 self.nplots = nplots
867 886
868 ncolspan = 1
869 colspan = 1
870
887 ncolspan = 7
888 colspan = 6
889 self.__nsubplots = 2
890
871 891 self.createFigure(idfigure = idfigure,
872 892 wintitle = wintitle,
873 widthplot = self.WIDTH,
874 heightplot = self.HEIGHT)
893 widthplot = self.WIDTH+self.WIDTHPROF,
894 heightplot = self.HEIGHT+self.HEIGHTPROF)
875 895
876 896 nrow, ncol = self.getSubplots()
877
878 self.addAxes(nrow, ncol, 0, 0, 1, 1)
897
898 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
899
879 900
880 901 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
881 902 xmin=None, xmax=None, ymin=None, ymax=None,
@@ -899,12 +920,13 class RTIfromNoise(Figure):
899 920 tmax = None
900 921 x = dataOut.getTimeRange()
901 922 y = dataOut.getHeiRange()
902
903 noise = dataOut.getNoise()
923 factor = dataOut.normFactor
924 noise = dataOut.getNoise()/factor
925 noisedB = 10*numpy.log10(noise)
904 926
905 927 thisDatetime = dataOut.datatime
906 928 title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y"))
907 xlabel = "Velocity (m/s)"
929 xlabel = ""
908 930 ylabel = "Range (Km)"
909 931
910 932 if not self.__isConfig:
@@ -917,12 +939,14 class RTIfromNoise(Figure):
917 939 showprofile=showprofile)
918 940
919 941 tmin, tmax = self.getTimeLim(x, xmin, xmax)
920 if ymin == None: ymin = numpy.nanmin(noise)
921 if ymax == None: ymax = numpy.nanmax(noise)
942 if ymin == None: ymin = numpy.nanmin(noisedB)
943 if ymax == None: ymax = numpy.nanmax(noisedB)
922 944
923 945 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
924 946 self.__isConfig = True
925 947
948 self.xdata = numpy.array([])
949 self.ydata = numpy.array([])
926 950
927 951 self.setWinTitle(title)
928 952
@@ -931,15 +955,21 class RTIfromNoise(Figure):
931 955
932 956 legendlabels = ["channel %d"%idchannel for idchannel in channelList]
933 957 axes = self.axesList[0]
934 xdata = x[0:1]
935 ydata = noise[channelIndexList].reshape(-1,1)
936 axes.pmultilineyaxis(x=xdata, y=ydata,
958
959 self.xdata = numpy.hstack((self.xdata, x[0:1]))
960
961 if len(self.ydata)==0:
962 self.ydata = noisedB[channelIndexList].reshape(-1,1)
963 else:
964 self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1)))
965
966
967 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
937 968 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
938 969 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
939 970 XAxisAsTime=True
940 971 )
941 972
942
943 973 self.draw()
944 974
945 975 if save:
@@ -951,4 +981,6 class RTIfromNoise(Figure):
951 981
952 982 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
953 983 self.__isConfig = False
984 del self.xdata
985 del self.ydata
954 986 No newline at end of file
@@ -359,9 +359,10 class VoltageProc(ProcessingUnit):
359 359 r = self.dataOut.data.shape[1] % window
360 360 buffer = self.dataOut.data[:,0:self.dataOut.data.shape[1]-r]
361 361 buffer = buffer.reshape(self.dataOut.data.shape[0],self.dataOut.data.shape[1]/window,window)
362 buffer = numpy.average(buffer,2)
362 buffer = numpy.sum(buffer,2)
363 363 self.dataOut.data = buffer
364 364 self.dataOut.heightList = numpy.arange(self.dataOut.heightList[0],newdelta*self.dataOut.nHeights/window-newdelta,newdelta)
365 self.dataOut.windowOfFilter = window
365 366
366 367 def deFlip(self):
367 368 self.dataOut.data *= self.flip
@@ -694,6 +695,7 class SpectraProc(ProcessingUnit):
694 695 self.dataOut.nCohInt = self.dataIn.nCohInt
695 696 self.dataOut.nIncohInt = 1
696 697 self.dataOut.ippSeconds = self.dataIn.ippSeconds
698 self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
697 699
698 700 self.dataOut.timeInterval = self.dataIn.timeInterval*self.dataOut.nFFTPoints*self.dataOut.nIncohInt
699 701
@@ -1086,9 +1088,9 class IncohInt(Operation):
1086 1088
1087 1089 if self.__dataReady:
1088 1090
1089 dataOut.data_spc = avgdata_spc / self.n
1090 dataOut.data_cspc = avgdata_cspc / self.n
1091 dataOut.data_dc = avgdata_dc / self.n
1091 dataOut.data_spc = avgdata_spc
1092 dataOut.data_cspc = avgdata_cspc
1093 dataOut.data_dc = avgdata_dc
1092 1094
1093 1095 dataOut.nIncohInt *= self.n
1094 1096 dataOut.utctime = avgdatatime
General Comments 0
You need to be logged in to leave comments. Login now