##// END OF EJS Templates
vuelta a una version anterior
Daniel Valdez -
r278:14f44b742449
parent child
Show More
@@ -53,9 +53,8 class CrossSpectraPlot(Figure):
53 53 counter += 1
54 54
55 55 def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True',
56 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, normalize=True,
57 save=False, figpath='./', figfile=None,
58 power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r'):
56 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
57 save=False, figpath='./', figfile=None):
59 58
60 59 """
61 60
@@ -87,15 +86,12 class CrossSpectraPlot(Figure):
87 86
88 87 if len(pairsIndexList) > 4:
89 88 pairsIndexList = pairsIndexList[0:4]
90
91 factor = 1
92 if normalize:
93 factor = dataOut.normFactor
89 factor = dataOut.normFactor
94 90 x = dataOut.getVelRange(1)
95 91 y = dataOut.getHeiRange()
96 92 z = dataOut.data_spc[:,:,:]/factor
97
98 avg = numpy.average(z, axis=1)
93 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
94 avg = numpy.average(numpy.abs(z), axis=1)
99 95 noise = dataOut.getNoise()/factor
100 96
101 97 zdB = 10*numpy.log10(z)
@@ -137,7 +133,7 class CrossSpectraPlot(Figure):
137 133 axes0.pcolor(x, y, zdB,
138 134 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
139 135 xlabel=xlabel, ylabel=ylabel, title=title,
140 ticksize=9, colormap=power_cmap, cblabel='')
136 ticksize=9, cblabel='')
141 137
142 138 title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]])
143 139 zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor)
@@ -145,26 +141,26 class CrossSpectraPlot(Figure):
145 141 axes0.pcolor(x, y, zdB,
146 142 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
147 143 xlabel=xlabel, ylabel=ylabel, title=title,
148 ticksize=9, colormap=power_cmap, cblabel='')
144 ticksize=9, cblabel='')
149 145
150 146 coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
151 147 coherence = numpy.abs(coherenceComplex)
152 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
153 phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi
148 phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
149
154 150
155 151 title = "Coherence %d%d" %(pair[0], pair[1])
156 152 axes0 = self.axesList[i*self.__nsubplots+2]
157 153 axes0.pcolor(x, y, coherence,
158 154 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1,
159 155 xlabel=xlabel, ylabel=ylabel, title=title,
160 ticksize=9, colormap=coherence_cmap, cblabel='')
156 ticksize=9, cblabel='')
161 157
162 158 title = "Phase %d%d" %(pair[0], pair[1])
163 159 axes0 = self.axesList[i*self.__nsubplots+3]
164 160 axes0.pcolor(x, y, phase,
165 161 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
166 162 xlabel=xlabel, ylabel=ylabel, title=title,
167 ticksize=9, colormap=phase_cmap, cblabel='')
163 ticksize=9, cblabel='', colormap='RdBu_r')
168 164
169 165
170 166
@@ -182,7 +178,7 class RTIPlot(Figure):
182 178
183 179 __isConfig = None
184 180 __nsubplots = None
185 __missing = 1E30
181
186 182 WIDTHPROF = None
187 183 HEIGHTPROF = None
188 184 PREFIX = 'rti'
@@ -194,11 +190,9 class RTIPlot(Figure):
194 190 self.__nsubplots = 1
195 191
196 192 self.WIDTH = 800
197 self.HEIGHT = 180
193 self.HEIGHT = 200
198 194 self.WIDTHPROF = 120
199 195 self.HEIGHTPROF = 0
200 self.x_buffer = None
201 self.avgdB_buffer = None
202 196
203 197 def getSubplots(self):
204 198
@@ -214,19 +208,15 class RTIPlot(Figure):
214 208
215 209 ncolspan = 1
216 210 colspan = 1
217 widthplot = self.WIDTH
218 heightplot = self.HEIGHT
219 211 if showprofile:
220 212 ncolspan = 7
221 213 colspan = 6
222 214 self.__nsubplots = 2
223 widthplot += self.WIDTHPROF
224 heightplot += self.HEIGHTPROF
225 215
226 216 self.createFigure(idfigure = idfigure,
227 217 wintitle = wintitle,
228 widthplot = widthplot,
229 heightplot = heightplot)
218 widthplot = self.WIDTH + self.WIDTHPROF,
219 heightplot = self.HEIGHT + self.HEIGHTPROF)
230 220
231 221 nrow, ncol = self.getSubplots()
232 222
@@ -245,7 +235,7 class RTIPlot(Figure):
245 235 counter += 1
246 236
247 237 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
248 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, normalize=True,
238 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
249 239 timerange=None,
250 240 save=False, figpath='./', figfile=None):
251 241
@@ -279,18 +269,18 class RTIPlot(Figure):
279 269
280 270 tmin = None
281 271 tmax = None
282 factor = 1
283 if normalize:
284 factor = dataOut.normFactor
272 factor = dataOut.normFactor
285 273 x = dataOut.getTimeRange()
286 274 y = dataOut.getHeiRange()
287 275
288 276 z = dataOut.data_spc[channelIndexList,:,:]/factor
289 277 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
290 278 avg = numpy.average(z, axis=1)
279 noise = dataOut.getNoise()/factor
291 280
281 # zdB = 10.*numpy.log10(z)
292 282 avgdB = 10.*numpy.log10(avg)
293
283 noisedB = 10.*numpy.log10(noise)
294 284
295 285 thisDatetime = dataOut.datatime
296 286 title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y"))
@@ -313,36 +303,16 class RTIPlot(Figure):
313 303 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
314 304
315 305 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
316 self.x_buffer = numpy.array([])
317 self.avgdB_buffer = numpy.array([])
318 306 self.__isConfig = True
319 307
320 308
321 309 self.setWinTitle(title)
322
323 if len(self.avgdB_buffer)==0:
324 self.avgdB_buffer = avgdB
325 newxdim = 1
326 newydim = -1
327 else:
328 if x[0]>self.x_buffer[-1]:
329 gap = avgdB.copy()
330 gap[:] = self.__missing
331 self.avgdB_buffer = numpy.hstack((self.avgdB_buffer, gap))
332 310
333 self.avgdB_buffer = numpy.hstack((self.avgdB_buffer, avgdB))
334 newxdim = -1
335 newydim = len(y)
336
337 self.x_buffer = numpy.hstack((self.x_buffer, x))
338
339 self.avgdB_buffer = numpy.ma.masked_inside(self.avgdB_buffer,0.99*self.__missing,1.01*self.__missing)
340
341 311 for i in range(self.nplots):
342 312 title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
343 313 axes = self.axesList[i*self.__nsubplots]
344 zdB = self.avgdB_buffer[i].reshape(newxdim,newydim)
345 axes.pcolor(self.x_buffer, y, zdB,
314 zdB = avgdB[i].reshape((1,-1))
315 axes.pcolor(x, y, zdB,
346 316 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
347 317 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
348 318 ticksize=9, cblabel='', cbsize="1%")
@@ -381,7 +351,7 class SpectraPlot(Figure):
381 351 self.__isConfig = False
382 352 self.__nsubplots = 1
383 353
384 self.WIDTH = 250
354 self.WIDTH = 230
385 355 self.HEIGHT = 250
386 356 self.WIDTHPROF = 120
387 357 self.HEIGHTPROF = 0
@@ -400,19 +370,15 class SpectraPlot(Figure):
400 370
401 371 ncolspan = 1
402 372 colspan = 1
403 widthplot = self.WIDTH
404 heightplot = self.HEIGHT
405 373 if showprofile:
406 374 ncolspan = 3
407 375 colspan = 2
408 376 self.__nsubplots = 2
409 widthplot += self.WIDTHPROF
410 heightplot += self.HEIGHTPROF
411
377
412 378 self.createFigure(idfigure = idfigure,
413 379 wintitle = wintitle,
414 widthplot = widthplot,
415 heightplot = heightplot)
380 widthplot = self.WIDTH + self.WIDTHPROF,
381 heightplot = self.HEIGHT + self.HEIGHTPROF)
416 382
417 383 nrow, ncol = self.getSubplots()
418 384
@@ -431,7 +397,7 class SpectraPlot(Figure):
431 397 counter += 1
432 398
433 399 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
434 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, normalize=True,
400 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
435 401 save=False, figpath='./', figfile=None):
436 402
437 403 """
@@ -458,9 +424,7 class SpectraPlot(Figure):
458 424 if channel not in dataOut.channelList:
459 425 raise ValueError, "Channel %d is not in dataOut.channelList"
460 426 channelIndexList.append(dataOut.channelList.index(channel))
461 factor = 1
462 if normalize:
463 factor = dataOut.normFactor
427 factor = dataOut.normFactor
464 428 x = dataOut.getVelRange(1)
465 429 y = dataOut.getHeiRange()
466 430
@@ -666,7 +630,7 class ProfilePlot(Figure):
666 630 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
667 631
668 632 def run(self, dataOut, idfigure, wintitle="", channelList=None,
669 xmin=None, xmax=None, ymin=None, ymax=None, normalize=True,
633 xmin=None, xmax=None, ymin=None, ymax=None,
670 634 save=False, figpath='./', figfile=None):
671 635
672 636 if channelList == None:
@@ -679,9 +643,7 class ProfilePlot(Figure):
679 643 raise ValueError, "Channel %d is not in dataOut.channelList"
680 644 channelIndexList.append(dataOut.channelList.index(channel))
681 645
682 factor = 1
683 if normalize:
684 factor = dataOut.normFactor
646 factor = dataOut.normFactor
685 647 y = dataOut.getHeiRange()
686 648 x = dataOut.data_spc[channelIndexList,:,:]/factor
687 649 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
@@ -737,8 +699,7 class CoherenceMap(Figure):
737 699
738 700 WIDTHPROF = None
739 701 HEIGHTPROF = None
740 PREFIX = 'cmap'
741 __missing = 1E30
702 PREFIX = 'coherencemap'
742 703
743 704 def __init__(self):
744 705 self.timerange = 2*60*60
@@ -749,9 +710,6 class CoherenceMap(Figure):
749 710 self.HEIGHT = 200
750 711 self.WIDTHPROF = 120
751 712 self.HEIGHTPROF = 0
752 self.x_buffer = None
753 self.coherence_buffer = None
754 self.phase_buffer = None
755 713
756 714 def getSubplots(self):
757 715 ncol = 1
@@ -788,8 +746,7 class CoherenceMap(Figure):
788 746 def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True',
789 747 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
790 748 timerange=None,
791 save=False, figpath='./', figfile=None,
792 coherence_cmap='jet', phase_cmap='RdBu_r'):
749 save=False, figpath='./', figfile=None):
793 750
794 751 if pairsList == None:
795 752 pairsIndexList = dataOut.pairsIndexList
@@ -831,82 +788,53 class CoherenceMap(Figure):
831 788 if ymax == None: ymax = numpy.nanmax(y)
832 789
833 790 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
834 self.x_buffer = numpy.array([])
835 self.coherence_buffer = numpy.array([])
836 self.phase_buffer = numpy.array([])
791
837 792 self.__isConfig = True
838 793
839 794 self.setWinTitle(title)
840 795
796 for i in range(self.nplots):
797
798 pair = dataOut.pairsList[pairsIndexList[i]]
799 coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
800 coherence = numpy.abs(coherenceComplex)
801 avg = numpy.average(coherence, axis=0)
802 z = avg.reshape((1,-1))
841 803
842 pairArray = numpy.array(dataOut.pairsList)
843 pairArray = pairArray[pairsIndexList]
844 pair0ids = pairArray[:,0]
845 pair1ids = pairArray[:,1]
846
847 coherenceComplex = dataOut.data_cspc[pairsIndexList,:,:]/numpy.sqrt(dataOut.data_spc[pair0ids,:,:]*dataOut.data_spc[pair1ids,:,:])
848 avgcoherenceComplex = numpy.average(coherenceComplex, axis=1)
849 coherence = numpy.abs(avgcoherenceComplex)
850
851 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
852
853 if len(self.coherence_buffer)==0:
854 self.coherence_buffer = coherence
855 self.phase_buffer = phase
856 newxdim = 1
857 newydim = -1
858 else:
859 if x[0]>self.x_buffer[-1]:
860 gap = coherence.copy()
861 gap[:] = self.__missing
862 self.coherence_buffer = numpy.hstack((self.coherence_buffer, gap))
863 self.phase_buffer = numpy.hstack((self.phase_buffer, gap))
804 counter = 0
864 805
865 self.coherence_buffer = numpy.hstack((self.coherence_buffer, coherence))
866 self.phase_buffer = numpy.hstack((self.phase_buffer, phase))
867 newxdim = -1
868 newydim = len(y)
869
870 self.x_buffer = numpy.hstack((self.x_buffer, x))
871
872 self.coherence_buffer = numpy.ma.masked_inside(self.coherence_buffer,0.99*self.__missing,1.01*self.__missing)
873 self.phase_buffer = numpy.ma.masked_inside(self.phase_buffer,0.99*self.__missing,1.01*self.__missing)
874
875
876 for i in range(self.nplots):
877 counter = 0
878 z = self.coherence_buffer[i,:].reshape((newxdim,newydim))
879 title = "Coherence %d%d: %s" %(pair0ids[i], pair1ids[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
806 title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
880 807 axes = self.axesList[i*self.__nsubplots*2]
881 axes.pcolor(self.x_buffer, y, z,
808 axes.pcolor(x, y, z,
882 809 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1,
883 810 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
884 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
811 ticksize=9, cblabel='', cbsize="1%")
885 812
886 813 if self.__showprofile:
887 814 counter += 1
888 815 axes = self.axesList[i*self.__nsubplots*2 + counter]
889 axes.pline(coherence[i,:], y,
816 axes.pline(avg, y,
890 817 xmin=0, xmax=1, ymin=ymin, ymax=ymax,
891 818 xlabel='', ylabel='', title='', ticksize=7,
892 819 ytick_visible=False, nxticks=5,
893 820 grid='x')
894 821
895 822 counter += 1
896
897 z = self.phase_buffer[i,:].reshape((newxdim,newydim))
823 phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
824 avg = numpy.average(phase, axis=0)
825 z = avg.reshape((1,-1))
898 826
899 title = "Phase %d%d: %s" %(pair0ids[i], pair1ids[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
827 title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
900 828 axes = self.axesList[i*self.__nsubplots*2 + counter]
901 axes.pcolor(self.x_buffer, y, z,
829 axes.pcolor(x, y, z,
902 830 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
903 831 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
904 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
832 ticksize=9, cblabel='', colormap='RdBu', cbsize="1%")
905 833
906 834 if self.__showprofile:
907 835 counter += 1
908 836 axes = self.axesList[i*self.__nsubplots*2 + counter]
909 axes.pline(phase[i,:], y,
837 axes.pline(avg, y,
910 838 xmin=-180, xmax=180, ymin=ymin, ymax=ymax,
911 839 xlabel='', ylabel='', title='', ticksize=7,
912 840 ytick_visible=False, nxticks=4,
@@ -971,7 +899,7 class RTIfromNoise(Figure):
971 899
972 900
973 901 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
974 xmin=None, xmax=None, ymin=None, ymax=None, normalize=True,
902 xmin=None, xmax=None, ymin=None, ymax=None,
975 903 timerange=None,
976 904 save=False, figpath='./', figfile=None):
977 905
@@ -992,9 +920,7 class RTIfromNoise(Figure):
992 920 tmax = None
993 921 x = dataOut.getTimeRange()
994 922 y = dataOut.getHeiRange()
995 factor = 1
996 if normalize:
997 factor = dataOut.normFactor
923 factor = dataOut.normFactor
998 924 noise = dataOut.getNoise()/factor
999 925 noisedB = 10*numpy.log10(noise)
1000 926
General Comments 0
You need to be logged in to leave comments. Login now