##// END OF EJS Templates
cambio
Erick Valdez -
r870:bd8def453202
parent child
Show More
@@ -1,1951 +1,1955
1 1 import os
2 2 import datetime
3 3 import numpy
4 4
5 5 from figure import Figure, isRealtime, isTimeInHourRange
6 6 from plotting_codes import *
7
8 import matplotlib.pyplot as plt
7 from numpy import NaN
9 8
10 9 class MomentsPlot(Figure):
11 10
12 11 isConfig = None
13 12 __nsubplots = None
14 13
15 14 WIDTHPROF = None
16 15 HEIGHTPROF = None
17 16 PREFIX = 'prm'
18 17
19 18 def __init__(self):
20 19
21 20 self.isConfig = False
22 21 self.__nsubplots = 1
23 22
24 23 self.WIDTH = 280
25 24 self.HEIGHT = 250
26 25 self.WIDTHPROF = 120
27 26 self.HEIGHTPROF = 0
28 27 self.counter_imagwr = 0
29 28
30 29 self.PLOT_CODE = MOMENTS_CODE
31 30
32 31 self.FTP_WEI = None
33 32 self.EXP_CODE = None
34 33 self.SUB_EXP_CODE = None
35 34 self.PLOT_POS = None
36 35
37 36 def getSubplots(self):
38 37
39 38 ncol = int(numpy.sqrt(self.nplots)+0.9)
40 39 nrow = int(self.nplots*1./ncol + 0.9)
41 40
42 41 return nrow, ncol
43 42
44 43 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
45 44
46 45 self.__showprofile = showprofile
47 46 self.nplots = nplots
48 47
49 48 ncolspan = 1
50 49 colspan = 1
51 50 if showprofile:
52 51 ncolspan = 3
53 52 colspan = 2
54 53 self.__nsubplots = 2
55 54
56 55 self.createFigure(id = id,
57 56 wintitle = wintitle,
58 57 widthplot = self.WIDTH + self.WIDTHPROF,
59 58 heightplot = self.HEIGHT + self.HEIGHTPROF,
60 59 show=show)
61 60
62 61 nrow, ncol = self.getSubplots()
63 62
64 63 counter = 0
65 64 for y in range(nrow):
66 65 for x in range(ncol):
67 66
68 67 if counter >= self.nplots:
69 68 break
70 69
71 70 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
72 71
73 72 if showprofile:
74 73 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
75 74
76 75 counter += 1
77 76
78 77 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
79 78 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
80 79 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
81 80 server=None, folder=None, username=None, password=None,
82 81 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
83 82
84 83 """
85 84
86 85 Input:
87 86 dataOut :
88 87 id :
89 88 wintitle :
90 89 channelList :
91 90 showProfile :
92 91 xmin : None,
93 92 xmax : None,
94 93 ymin : None,
95 94 ymax : None,
96 95 zmin : None,
97 96 zmax : None
98 97 """
99 98
100 99 if dataOut.flagNoData:
101 100 return None
102 101
103 102 if realtime:
104 103 if not(isRealtime(utcdatatime = dataOut.utctime)):
105 104 print 'Skipping this plot function'
106 105 return
107 106
108 107 if channelList == None:
109 108 channelIndexList = dataOut.channelIndexList
110 109 else:
111 110 channelIndexList = []
112 111 for channel in channelList:
113 112 if channel not in dataOut.channelList:
114 113 raise ValueError, "Channel %d is not in dataOut.channelList"
115 114 channelIndexList.append(dataOut.channelList.index(channel))
116 115
117 116 factor = dataOut.normFactor
118 117 x = dataOut.abscissaList
119 118 y = dataOut.heightList
120 119
121 120 z = dataOut.data_pre[channelIndexList,:,:]/factor
122 121 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
123 122 avg = numpy.average(z, axis=1)
124 123 noise = dataOut.noise/factor
125 124
126 125 zdB = 10*numpy.log10(z)
127 126 avgdB = 10*numpy.log10(avg)
128 127 noisedB = 10*numpy.log10(noise)
129 128
130 129 #thisDatetime = dataOut.datatime
131 130 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
132 131 title = wintitle + " Parameters"
133 132 xlabel = "Velocity (m/s)"
134 133 ylabel = "Range (Km)"
135 134
136 135 update_figfile = False
137 136
138 137 if not self.isConfig:
139 138
140 139 nplots = len(channelIndexList)
141 140
142 141 self.setup(id=id,
143 142 nplots=nplots,
144 143 wintitle=wintitle,
145 144 showprofile=showprofile,
146 145 show=show)
147 146
148 147 if xmin == None: xmin = numpy.nanmin(x)
149 148 if xmax == None: xmax = numpy.nanmax(x)
150 149 if ymin == None: ymin = numpy.nanmin(y)
151 150 if ymax == None: ymax = numpy.nanmax(y)
152 151 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
153 152 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
154 153
155 154 self.FTP_WEI = ftp_wei
156 155 self.EXP_CODE = exp_code
157 156 self.SUB_EXP_CODE = sub_exp_code
158 157 self.PLOT_POS = plot_pos
159 158
160 159 self.isConfig = True
161 160 update_figfile = True
162 161
163 162 self.setWinTitle(title)
164 163
165 164 for i in range(self.nplots):
166 165 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
167 166 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime)
168 167 axes = self.axesList[i*self.__nsubplots]
169 168 axes.pcolor(x, y, zdB[i,:,:],
170 169 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
171 170 xlabel=xlabel, ylabel=ylabel, title=title,
172 171 ticksize=9, cblabel='')
173 172 #Mean Line
174 173 mean = dataOut.data_param[i, 1, :]
175 174 axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1)
176 175
177 176 if self.__showprofile:
178 177 axes = self.axesList[i*self.__nsubplots +1]
179 178 axes.pline(avgdB[i], y,
180 179 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
181 180 xlabel='dB', ylabel='', title='',
182 181 ytick_visible=False,
183 182 grid='x')
184 183
185 184 noiseline = numpy.repeat(noisedB[i], len(y))
186 185 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
187 186
188 187 self.draw()
189 188
190 189 self.save(figpath=figpath,
191 190 figfile=figfile,
192 191 save=save,
193 192 ftp=ftp,
194 193 wr_period=wr_period,
195 194 thisDatetime=thisDatetime)
196 195
197 196
198 197
199 198 class SkyMapPlot(Figure):
200 199
201 200 __isConfig = None
202 201 __nsubplots = None
203 202
204 203 WIDTHPROF = None
205 204 HEIGHTPROF = None
206 205 PREFIX = 'mmap'
207 206
208 207 def __init__(self):
209 208
210 209 self.isConfig = False
211 210 self.__nsubplots = 1
212 211
213 212 # self.WIDTH = 280
214 213 # self.HEIGHT = 250
215 214 self.WIDTH = 600
216 215 self.HEIGHT = 600
217 216 self.WIDTHPROF = 120
218 217 self.HEIGHTPROF = 0
219 218 self.counter_imagwr = 0
220 219
221 220 self.PLOT_CODE = MSKYMAP_CODE
222 221
223 222 self.FTP_WEI = None
224 223 self.EXP_CODE = None
225 224 self.SUB_EXP_CODE = None
226 225 self.PLOT_POS = None
227 226
228 227 def getSubplots(self):
229 228
230 229 ncol = int(numpy.sqrt(self.nplots)+0.9)
231 230 nrow = int(self.nplots*1./ncol + 0.9)
232 231
233 232 return nrow, ncol
234 233
235 234 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
236 235
237 236 self.__showprofile = showprofile
238 237 self.nplots = nplots
239 238
240 239 ncolspan = 1
241 240 colspan = 1
242 241
243 242 self.createFigure(id = id,
244 243 wintitle = wintitle,
245 244 widthplot = self.WIDTH, #+ self.WIDTHPROF,
246 245 heightplot = self.HEIGHT,# + self.HEIGHTPROF,
247 246 show=show)
248 247
249 248 nrow, ncol = 1,1
250 249 counter = 0
251 250 x = 0
252 251 y = 0
253 252 self.addAxes(1, 1, 0, 0, 1, 1, True)
254 253
255 254 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
256 255 tmin=0, tmax=24, timerange=None,
257 256 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
258 257 server=None, folder=None, username=None, password=None,
259 258 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
260 259
261 260 """
262 261
263 262 Input:
264 263 dataOut :
265 264 id :
266 265 wintitle :
267 266 channelList :
268 267 showProfile :
269 268 xmin : None,
270 269 xmax : None,
271 270 ymin : None,
272 271 ymax : None,
273 272 zmin : None,
274 273 zmax : None
275 274 """
276 275
277 276 arrayParameters = dataOut.data_param
278 277 error = arrayParameters[:,-1]
279 278 indValid = numpy.where(error == 0)[0]
280 279 finalMeteor = arrayParameters[indValid,:]
281 280 finalAzimuth = finalMeteor[:,3]
282 281 finalZenith = finalMeteor[:,4]
283 282
284 283 x = finalAzimuth*numpy.pi/180
285 284 y = finalZenith
286 285 x1 = [dataOut.ltctime, dataOut.ltctime]
287 286
288 287 #thisDatetime = dataOut.datatime
289 288 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
290 289 title = wintitle + " Parameters"
291 290 xlabel = "Zonal Zenith Angle (deg) "
292 291 ylabel = "Meridional Zenith Angle (deg)"
293 292 update_figfile = False
294 293
295 294 if not self.isConfig:
296 295
297 296 nplots = 1
298 297
299 298 self.setup(id=id,
300 299 nplots=nplots,
301 300 wintitle=wintitle,
302 301 showprofile=showprofile,
303 302 show=show)
304 303
305 304 if self.xmin is None and self.xmax is None:
306 305 self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange)
307 306
308 307 if timerange != None:
309 308 self.timerange = timerange
310 309 else:
311 310 self.timerange = self.xmax - self.xmin
312 311
313 312 self.FTP_WEI = ftp_wei
314 313 self.EXP_CODE = exp_code
315 314 self.SUB_EXP_CODE = sub_exp_code
316 315 self.PLOT_POS = plot_pos
317 316 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
318 317 self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
319 318 self.isConfig = True
320 319 update_figfile = True
321 320
322 321 self.setWinTitle(title)
323 322
324 323 i = 0
325 324 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
326 325
327 326 axes = self.axesList[i*self.__nsubplots]
328 327 nevents = axes.x_buffer.shape[0] + x.shape[0]
329 328 title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents)
330 329 axes.polar(x, y,
331 330 title=title, xlabel=xlabel, ylabel=ylabel,
332 331 ticksize=9, cblabel='')
333 332
334 333 self.draw()
335 334
336 335 self.save(figpath=figpath,
337 336 figfile=figfile,
338 337 save=save,
339 338 ftp=ftp,
340 339 wr_period=wr_period,
341 340 thisDatetime=thisDatetime,
342 341 update_figfile=update_figfile)
343 342
344 343 if dataOut.ltctime >= self.xmax:
345 344 self.isConfigmagwr = wr_period
346 345 self.isConfig = False
347 346 update_figfile = True
348 347 axes.__firsttime = True
349 348 self.xmin += self.timerange
350 349 self.xmax += self.timerange
351 350
352 351
353 352
354 353
355 354 class WindProfilerPlot(Figure):
356 355
357 356 __isConfig = None
358 357 __nsubplots = None
359 358
360 359 WIDTHPROF = None
361 360 HEIGHTPROF = None
362 361 PREFIX = 'wind'
363 362
364 363 def __init__(self):
365 364
366 365 self.timerange = None
367 366 self.isConfig = False
368 367 self.__nsubplots = 1
369 368
370 369 self.WIDTH = 800
371 370 self.HEIGHT = 300
372 371 self.WIDTHPROF = 120
373 372 self.HEIGHTPROF = 0
374 373 self.counter_imagwr = 0
375 374
376 375 self.PLOT_CODE = WIND_CODE
377 376
378 377 self.FTP_WEI = None
379 378 self.EXP_CODE = None
380 379 self.SUB_EXP_CODE = None
381 380 self.PLOT_POS = None
382 381 self.tmin = None
383 382 self.tmax = None
384 383
385 384 self.xmin = None
386 385 self.xmax = None
387 386
388 387 self.figfile = None
389 388
390 389 def getSubplots(self):
391 390
392 391 ncol = 1
393 392 nrow = self.nplots
394 393
395 394 return nrow, ncol
396 395
397 396 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
398 397
399 398 self.__showprofile = showprofile
400 399 self.nplots = nplots
401 400
402 401 ncolspan = 1
403 402 colspan = 1
404 403
405 404 self.createFigure(id = id,
406 405 wintitle = wintitle,
407 406 widthplot = self.WIDTH + self.WIDTHPROF,
408 407 heightplot = self.HEIGHT + self.HEIGHTPROF,
409 408 show=show)
410 409
411 410 nrow, ncol = self.getSubplots()
412 411
413 412 counter = 0
414 413 for y in range(nrow):
415 414 if counter >= self.nplots:
416 415 break
417 416
418 417 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
419 418 counter += 1
420 419
421 420 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False',
422 421 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
423 422 zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None,
424 423 timerange=None, SNRthresh = None,
425 424 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
426 425 server=None, folder=None, username=None, password=None,
427 426 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
428 427 """
429 428
430 429 Input:
431 430 dataOut :
432 431 id :
433 432 wintitle :
434 433 channelList :
435 434 showProfile :
436 435 xmin : None,
437 436 xmax : None,
438 437 ymin : None,
439 438 ymax : None,
440 439 zmin : None,
441 440 zmax : None
442 441 """
443 442
444 443 # if timerange is not None:
445 444 # self.timerange = timerange
446 445 #
447 446 # tmin = None
448 447 # tmax = None
449
450 x = dataOut.getTimeRange1(dataOut.outputInterval)
451 y = dataOut.heightList
448
449
450 x = dataOut.getTimeRange()
451 y = dataOut.getHeiRange()
452 #x = dataOut.getTimeRange1(dataOut.outputInterval)
453 #y = dataOut.heightList
454
452 455 z = dataOut.data_output.copy()
456 #print 'dataOut_JI',z
453 457 nplots = z.shape[0] #Number of wind dimensions estimated
454
455 458 nplotsw = nplots
459
456 460
457 461 #If there is a SNR function defined
458 462 if dataOut.data_SNR is not None:
459 463 nplots += 1
460 464 SNR = dataOut.data_SNR
461 465 SNRavg = numpy.average(SNR, axis=0)
462
466
463 467 SNRdB = 10*numpy.log10(SNR)
464 468 SNRavgdB = 10*numpy.log10(SNRavg)
465
469
466 470 if SNRthresh == None: SNRthresh = -5.0
467 471 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
468
472
469 473 for i in range(nplotsw):
470 474 z[i,ind] = numpy.nan
471
475
472 476
473 477 # showprofile = False
474 478 # thisDatetime = dataOut.datatime
475 #thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
476 thisDatetime = datetime.datetime.now()
479 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
477 480 title = wintitle + "Wind"
478 481 xlabel = ""
479 482 ylabel = "Height (km)"
480 483 update_figfile = False
481 484
482 485 if not self.isConfig:
483 486
484 487 self.setup(id=id,
485 488 nplots=nplots,
486 489 wintitle=wintitle,
487 490 showprofile=showprofile,
488 491 show=show)
489 492
490 493 if timerange is not None:
491 494 self.timerange = timerange
492 495
493 496 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
494 497
495 #if ymin == None: ymin = numpy.nanmin(y)
496 #if ymax == None: ymax = numpy.nanmax(y)
498 if ymin == None: ymin = numpy.nanmin(y)
499 if ymax == None: ymax = numpy.nanmax(y)
497 500
498 501 if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:]))
499 502 #if numpy.isnan(zmax): zmax = 50
500 503 if zmin == None: zmin = -zmax
501 504
502 505 if nplotsw == 3:
503 506 if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:]))
504 507 if zmin_ver == None: zmin_ver = -zmax_ver
505 508
506 # if dataOut.data_SNR is not None:
507 # if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
508 # if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
509 if dataOut.data_SNR is not None:
510 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
511 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
509 512
510 513
511 514 self.FTP_WEI = ftp_wei
512 515 self.EXP_CODE = exp_code
513 516 self.SUB_EXP_CODE = sub_exp_code
514 517 self.PLOT_POS = plot_pos
515 518
516 519 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
517 520 self.isConfig = True
518 521 self.figfile = figfile
519 522 update_figfile = True
520 523
521 524 self.setWinTitle(title)
522 525
523 #if ((self.xmax - x[1]) < (x[1]-x[0])):
524 # x[1] = self.xmax
526 if ((self.xmax - x[1]) < (x[1]-x[0])):
527 x[1] = self.xmax
525 528
526 529 strWind = ['Zonal', 'Meridional', 'Vertical']
527 530 strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
528 531 zmaxVector = [zmax, zmax, zmax_ver]
529 532 zminVector = [zmin, zmin, zmin_ver]
530 533 windFactor = [1,1,100]
531 534
532 535 for i in range(nplotsw):
533 536
534 537 title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
535 538 axes = self.axesList[i*self.__nsubplots]
536
537 z1 = z[i,:].reshape((1,-1))*windFactor[i]
539
540 z1 = z[i,:].reshape((1,-1))*windFactor[i]
541 #z1=numpy.ma.masked_where(z1==0.,z1)
538 542
539 543 axes.pcolorbuffer(x, y, z1,
540 544 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
541 545 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
542 ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" )
546 ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="seismic" )
543 547
544 548 if dataOut.data_SNR is not None:
545 549 i += 1
546 550 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
547 551 axes = self.axesList[i*self.__nsubplots]
548
552
549 553 SNRavgdB = SNRavgdB.reshape((1,-1))
550
554
551 555 axes.pcolorbuffer(x, y, SNRavgdB,
552 556 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
553 557 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
554 558 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
555
559
556 560 self.draw()
557 561
558 562 self.save(figpath=figpath,
559 563 figfile=figfile,
560 564 save=save,
561 565 ftp=ftp,
562 566 wr_period=wr_period,
563 567 thisDatetime=thisDatetime,
564 568 update_figfile=update_figfile)
565 569
566 if False and dataOut.ltctime + dataOut.outputInterval >= self.xmax:
567 self.counter_imagwr = wr_period
570 if dataOut.ltctime + dataOut.outputInterval >= self.xmax:
571 self.counter_imagwr = wr_period
568 572 self.isConfig = False
569 573 update_figfile = True
570 574
571 575
572 576 class ParametersPlot(Figure):
573 577
574 578 __isConfig = None
575 579 __nsubplots = None
576 580
577 581 WIDTHPROF = None
578 582 HEIGHTPROF = None
579 583 PREFIX = 'param'
580 584
581 585 nplots = None
582 586 nchan = None
583 587
584 588 def __init__(self):
585 589
586 590 self.timerange = None
587 591 self.isConfig = False
588 592 self.__nsubplots = 1
589 593
590 594 self.WIDTH = 800
591 595 self.HEIGHT = 180
592 596 self.WIDTHPROF = 120
593 597 self.HEIGHTPROF = 0
594 598 self.counter_imagwr = 0
595 599
596 600 self.PLOT_CODE = RTI_CODE
597 601
598 602 self.FTP_WEI = None
599 603 self.EXP_CODE = None
600 604 self.SUB_EXP_CODE = None
601 605 self.PLOT_POS = None
602 606 self.tmin = None
603 607 self.tmax = None
604 608
605 609 self.xmin = None
606 610 self.xmax = None
607 611
608 612 self.figfile = None
609 613
610 614 def getSubplots(self):
611 615
612 616 ncol = 1
613 617 nrow = self.nplots
614 618
615 619 return nrow, ncol
616 620
617 621 def setup(self, id, nplots, wintitle, show=True):
618 622
619 623 self.nplots = nplots
620 624
621 625 ncolspan = 1
622 626 colspan = 1
623 627
624 628 self.createFigure(id = id,
625 629 wintitle = wintitle,
626 630 widthplot = self.WIDTH + self.WIDTHPROF,
627 631 heightplot = self.HEIGHT + self.HEIGHTPROF,
628 632 show=show)
629 633
630 634 nrow, ncol = self.getSubplots()
631 635
632 636 counter = 0
633 637 for y in range(nrow):
634 638 for x in range(ncol):
635 639
636 640 if counter >= self.nplots:
637 641 break
638 642
639 643 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
640 644
641 645 counter += 1
642 646
643 647 def run(self, dataOut, id, wintitle="", channelList=None, paramIndex = 0, colormap=True,
644 648 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None,
645 649 showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None,
646 650 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
647 651 server=None, folder=None, username=None, password=None,
648 652 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
649 653
650 654 """
651 655
652 656 Input:
653 657 dataOut :
654 658 id :
655 659 wintitle :
656 660 channelList :
657 661 showProfile :
658 662 xmin : None,
659 663 xmax : None,
660 664 ymin : None,
661 665 ymax : None,
662 666 zmin : None,
663 667 zmax : None
664 668 """
665 669
666 670 if colormap:
667 671 colormap="jet"
668 672 else:
669 673 colormap="RdBu_r"
670 674
671 675 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
672 676 return
673 677
674 678 if channelList == None:
675 679 channelIndexList = range(dataOut.data_param.shape[0])
676 680 else:
677 681 channelIndexList = []
678 682 for channel in channelList:
679 683 if channel not in dataOut.channelList:
680 684 raise ValueError, "Channel %d is not in dataOut.channelList"
681 685 channelIndexList.append(dataOut.channelList.index(channel))
682 686
683 687 x = dataOut.getTimeRange1(dataOut.paramInterval)
684 688 y = dataOut.getHeiRange()
685 689
686 690 if dataOut.data_param.ndim == 3:
687 691 z = dataOut.data_param[channelIndexList,paramIndex,:]
688 692 else:
689 693 z = dataOut.data_param[channelIndexList,:]
690 694
691 695 if showSNR:
692 696 #SNR data
693 697 SNRarray = dataOut.data_SNR[channelIndexList,:]
694 698 SNRdB = 10*numpy.log10(SNRarray)
695 699 ind = numpy.where(SNRdB < SNRthresh)
696 700 z[ind] = numpy.nan
697 701
698 702 thisDatetime = dataOut.datatime
699 703 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
700 704 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
701 705 xlabel = ""
702 706 ylabel = "Range (Km)"
703 707
704 708 update_figfile = False
705 709
706 710 if not self.isConfig:
707 711
708 712 nchan = len(channelIndexList)
709 713 self.nchan = nchan
710 714 self.plotFact = 1
711 715 nplots = nchan
712 716
713 717 if showSNR:
714 718 nplots = nchan*2
715 719 self.plotFact = 2
716 720 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
717 721 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
718 722
719 723 self.setup(id=id,
720 724 nplots=nplots,
721 725 wintitle=wintitle,
722 726 show=show)
723 727
724 728 if timerange != None:
725 729 self.timerange = timerange
726 730
727 731 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
728 732
729 733 if ymin == None: ymin = numpy.nanmin(y)
730 734 if ymax == None: ymax = numpy.nanmax(y)
731 735 if zmin == None: zmin = numpy.nanmin(z)
732 736 if zmax == None: zmax = numpy.nanmax(z)
733 737
734 738 self.FTP_WEI = ftp_wei
735 739 self.EXP_CODE = exp_code
736 740 self.SUB_EXP_CODE = sub_exp_code
737 741 self.PLOT_POS = plot_pos
738 742
739 743 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
740 744 self.isConfig = True
741 745 self.figfile = figfile
742 746 update_figfile = True
743 747
744 748 self.setWinTitle(title)
745 749
746 750 for i in range(self.nchan):
747 751 index = channelIndexList[i]
748 752 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
749 753 axes = self.axesList[i*self.plotFact]
750 754 z1 = z[i,:].reshape((1,-1))
751 755 axes.pcolorbuffer(x, y, z1,
752 756 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
753 757 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
754 758 ticksize=9, cblabel='', cbsize="1%",colormap=colormap)
755 759
756 760 if showSNR:
757 761 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
758 762 axes = self.axesList[i*self.plotFact + 1]
759 763 SNRdB1 = SNRdB[i,:].reshape((1,-1))
760 764 axes.pcolorbuffer(x, y, SNRdB1,
761 765 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
762 766 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
763 767 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
764 768
765 769
766 770 self.draw()
767 771
768 772 if dataOut.ltctime >= self.xmax:
769 773 self.counter_imagwr = wr_period
770 774 self.isConfig = False
771 775 update_figfile = True
772 776
773 777 self.save(figpath=figpath,
774 778 figfile=figfile,
775 779 save=save,
776 780 ftp=ftp,
777 781 wr_period=wr_period,
778 782 thisDatetime=thisDatetime,
779 783 update_figfile=update_figfile)
780 784
781 785
782 786
783 class ParametersPlot(Figure):
787 class Parameters1Plot(Figure):
784 788
785 789 __isConfig = None
786 790 __nsubplots = None
787 791
788 792 WIDTHPROF = None
789 793 HEIGHTPROF = None
790 794 PREFIX = 'prm'
791 795
792 796 def __init__(self):
793 797
794 798 self.timerange = 2*60*60
795 799 self.isConfig = False
796 800 self.__nsubplots = 1
797 801
798 802 self.WIDTH = 800
799 803 self.HEIGHT = 150
800 804 self.WIDTHPROF = 120
801 805 self.HEIGHTPROF = 0
802 806 self.counter_imagwr = 0
803 807
804 808 self.PLOT_CODE = PARMS_CODE
805 809
806 810 self.FTP_WEI = None
807 811 self.EXP_CODE = None
808 812 self.SUB_EXP_CODE = None
809 813 self.PLOT_POS = None
810 814 self.tmin = None
811 815 self.tmax = None
812 816
813 817 self.xmin = None
814 818 self.xmax = None
815 819
816 820 self.figfile = None
817 821
818 822 def getSubplots(self):
819 823
820 824 ncol = 1
821 825 nrow = self.nplots
822 826
823 827 return nrow, ncol
824 828
825 829 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
826 830
827 831 self.__showprofile = showprofile
828 832 self.nplots = nplots
829 833
830 834 ncolspan = 1
831 835 colspan = 1
832 836
833 837 self.createFigure(id = id,
834 838 wintitle = wintitle,
835 839 widthplot = self.WIDTH + self.WIDTHPROF,
836 840 heightplot = self.HEIGHT + self.HEIGHTPROF,
837 841 show=show)
838 842
839 843 nrow, ncol = self.getSubplots()
840 844
841 845 counter = 0
842 846 for y in range(nrow):
843 847 for x in range(ncol):
844 848
845 849 if counter >= self.nplots:
846 850 break
847 851
848 852 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
849 853
850 854 if showprofile:
851 855 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
852 856
853 857 counter += 1
854 858
855 859 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
856 860 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None,
857 861 parameterIndex = None, onlyPositive = False,
858 862 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False,
859 863 DOP = True,
860 864 zlabel = "", parameterName = "", parameterObject = "data_param",
861 865 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
862 866 server=None, folder=None, username=None, password=None,
863 867 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
864 868
865 869 """
866 870
867 871 Input:
868 872 dataOut :
869 873 id :
870 874 wintitle :
871 875 channelList :
872 876 showProfile :
873 877 xmin : None,
874 878 xmax : None,
875 879 ymin : None,
876 880 ymax : None,
877 881 zmin : None,
878 882 zmax : None
879 883 """
880 884
881 885 data_param = getattr(dataOut, parameterObject)
882 886
883 887 if channelList == None:
884 888 channelIndexList = numpy.arange(data_param.shape[0])
885 889 else:
886 890 channelIndexList = numpy.array(channelList)
887 891
888 892 nchan = len(channelIndexList) #Number of channels being plotted
889 893
890 894 if nchan < 1:
891 895 return
892 896
893 897 nGraphsByChannel = 0
894 898
895 899 if SNR:
896 900 nGraphsByChannel += 1
897 901 if DOP:
898 902 nGraphsByChannel += 1
899 903
900 904 if nGraphsByChannel < 1:
901 905 return
902 906
903 907 nplots = nGraphsByChannel*nchan
904 908
905 909 if timerange is not None:
906 910 self.timerange = timerange
907 911
908 912 #tmin = None
909 913 #tmax = None
910 914 if parameterIndex == None:
911 915 parameterIndex = 1
912 916
913 917 x = dataOut.getTimeRange1(dataOut.paramInterval)
914 918 y = dataOut.heightList
915 919 z = data_param[channelIndexList,parameterIndex,:].copy()
916 920
917 921 zRange = dataOut.abscissaList
918 922 # nChannels = z.shape[0] #Number of wind dimensions estimated
919 923 # thisDatetime = dataOut.datatime
920 924
921 925 if dataOut.data_SNR is not None:
922 926 SNRarray = dataOut.data_SNR[channelIndexList,:]
923 927 SNRdB = 10*numpy.log10(SNRarray)
924 928 # SNRavgdB = 10*numpy.log10(SNRavg)
925 929 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
926 930 z[ind] = numpy.nan
927 931
928 932 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
929 933 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
930 934 xlabel = ""
931 935 ylabel = "Range (Km)"
932 936
933 937 if (SNR and not onlySNR): nplots = 2*nplots
934 938
935 939 if onlyPositive:
936 940 colormap = "jet"
937 941 zmin = 0
938 942 else: colormap = "RdBu_r"
939 943
940 944 if not self.isConfig:
941 945
942 946 self.setup(id=id,
943 947 nplots=nplots,
944 948 wintitle=wintitle,
945 949 showprofile=showprofile,
946 950 show=show)
947 951
948 952 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
949 953
950 954 if ymin == None: ymin = numpy.nanmin(y)
951 955 if ymax == None: ymax = numpy.nanmax(y)
952 956 if zmin == None: zmin = numpy.nanmin(zRange)
953 957 if zmax == None: zmax = numpy.nanmax(zRange)
954 958
955 959 if SNR:
956 960 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
957 961 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
958 962
959 963 self.FTP_WEI = ftp_wei
960 964 self.EXP_CODE = exp_code
961 965 self.SUB_EXP_CODE = sub_exp_code
962 966 self.PLOT_POS = plot_pos
963 967
964 968 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
965 969 self.isConfig = True
966 970 self.figfile = figfile
967 971
968 972 self.setWinTitle(title)
969 973
970 974 if ((self.xmax - x[1]) < (x[1]-x[0])):
971 975 x[1] = self.xmax
972 976
973 977 for i in range(nchan):
974 978
975 979 if (SNR and not onlySNR): j = 2*i
976 980 else: j = i
977 981
978 982 j = nGraphsByChannel*i
979 983
980 984 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
981 985 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
982 986
983 987 if not onlySNR:
984 988 axes = self.axesList[j*self.__nsubplots]
985 989 z1 = z[i,:].reshape((1,-1))
986 990 axes.pcolorbuffer(x, y, z1,
987 991 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
988 992 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
989 993 ticksize=9, cblabel=zlabel, cbsize="1%")
990 994
991 995 if DOP:
992 996 title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
993 997
994 998 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
995 999 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
996 1000 axes = self.axesList[j]
997 1001 z1 = z[i,:].reshape((1,-1))
998 1002 axes.pcolorbuffer(x, y, z1,
999 1003 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1000 1004 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
1001 1005 ticksize=9, cblabel=zlabel, cbsize="1%")
1002 1006
1003 1007 if SNR:
1004 1008 title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1005 1009 axes = self.axesList[(j)*self.__nsubplots]
1006 1010 if not onlySNR:
1007 1011 axes = self.axesList[(j + 1)*self.__nsubplots]
1008 1012
1009 1013 axes = self.axesList[(j + nGraphsByChannel-1)]
1010 1014
1011 1015 z1 = SNRdB[i,:].reshape((1,-1))
1012 1016 axes.pcolorbuffer(x, y, z1,
1013 1017 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1014 1018 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet",
1015 1019 ticksize=9, cblabel=zlabel, cbsize="1%")
1016 1020
1017 1021
1018 1022
1019 1023 self.draw()
1020 1024
1021 1025 if x[1] >= self.axesList[0].xmax:
1022 1026 self.counter_imagwr = wr_period
1023 1027 self.isConfig = False
1024 1028 self.figfile = None
1025 1029
1026 1030 self.save(figpath=figpath,
1027 1031 figfile=figfile,
1028 1032 save=save,
1029 1033 ftp=ftp,
1030 1034 wr_period=wr_period,
1031 1035 thisDatetime=thisDatetime,
1032 1036 update_figfile=False)
1033 1037
1034 1038 class SpectralFittingPlot(Figure):
1035 1039
1036 1040 __isConfig = None
1037 1041 __nsubplots = None
1038 1042
1039 1043 WIDTHPROF = None
1040 1044 HEIGHTPROF = None
1041 1045 PREFIX = 'prm'
1042 1046
1043 1047
1044 1048 N = None
1045 1049 ippSeconds = None
1046 1050
1047 1051 def __init__(self):
1048 1052 self.isConfig = False
1049 1053 self.__nsubplots = 1
1050 1054
1051 1055 self.PLOT_CODE = SPECFIT_CODE
1052 1056
1053 1057 self.WIDTH = 450
1054 1058 self.HEIGHT = 250
1055 1059 self.WIDTHPROF = 0
1056 1060 self.HEIGHTPROF = 0
1057 1061
1058 1062 def getSubplots(self):
1059 1063
1060 1064 ncol = int(numpy.sqrt(self.nplots)+0.9)
1061 1065 nrow = int(self.nplots*1./ncol + 0.9)
1062 1066
1063 1067 return nrow, ncol
1064 1068
1065 1069 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
1066 1070
1067 1071 showprofile = False
1068 1072 self.__showprofile = showprofile
1069 1073 self.nplots = nplots
1070 1074
1071 1075 ncolspan = 5
1072 1076 colspan = 4
1073 1077 if showprofile:
1074 1078 ncolspan = 5
1075 1079 colspan = 4
1076 1080 self.__nsubplots = 2
1077 1081
1078 1082 self.createFigure(id = id,
1079 1083 wintitle = wintitle,
1080 1084 widthplot = self.WIDTH + self.WIDTHPROF,
1081 1085 heightplot = self.HEIGHT + self.HEIGHTPROF,
1082 1086 show=show)
1083 1087
1084 1088 nrow, ncol = self.getSubplots()
1085 1089
1086 1090 counter = 0
1087 1091 for y in range(nrow):
1088 1092 for x in range(ncol):
1089 1093
1090 1094 if counter >= self.nplots:
1091 1095 break
1092 1096
1093 1097 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1094 1098
1095 1099 if showprofile:
1096 1100 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1097 1101
1098 1102 counter += 1
1099 1103
1100 1104 def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True,
1101 1105 xmin=None, xmax=None, ymin=None, ymax=None,
1102 1106 save=False, figpath='./', figfile=None, show=True):
1103 1107
1104 1108 """
1105 1109
1106 1110 Input:
1107 1111 dataOut :
1108 1112 id :
1109 1113 wintitle :
1110 1114 channelList :
1111 1115 showProfile :
1112 1116 xmin : None,
1113 1117 xmax : None,
1114 1118 zmin : None,
1115 1119 zmax : None
1116 1120 """
1117 1121
1118 1122 if cutHeight==None:
1119 1123 h=270
1120 1124 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
1121 1125 cutHeight = dataOut.heightList[heightindex]
1122 1126
1123 1127 factor = dataOut.normFactor
1124 1128 x = dataOut.abscissaList[:-1]
1125 1129 #y = dataOut.getHeiRange()
1126 1130
1127 1131 z = dataOut.data_pre[:,:,heightindex]/factor
1128 1132 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1129 1133 avg = numpy.average(z, axis=1)
1130 1134 listChannels = z.shape[0]
1131 1135
1132 1136 #Reconstruct Function
1133 1137 if fit==True:
1134 1138 groupArray = dataOut.groupList
1135 1139 listChannels = groupArray.reshape((groupArray.size))
1136 1140 listChannels.sort()
1137 1141 spcFitLine = numpy.zeros(z.shape)
1138 1142 constants = dataOut.constants
1139 1143
1140 1144 nGroups = groupArray.shape[0]
1141 1145 nChannels = groupArray.shape[1]
1142 1146 nProfiles = z.shape[1]
1143 1147
1144 1148 for f in range(nGroups):
1145 1149 groupChann = groupArray[f,:]
1146 1150 p = dataOut.data_param[f,:,heightindex]
1147 1151 # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167])
1148 1152 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
1149 1153 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
1150 1154 spcFitLine[groupChann,:] = fitLineAux
1151 1155 # spcFitLine = spcFitLine/factor
1152 1156
1153 1157 z = z[listChannels,:]
1154 1158 spcFitLine = spcFitLine[listChannels,:]
1155 1159 spcFitLinedB = 10*numpy.log10(spcFitLine)
1156 1160
1157 1161 zdB = 10*numpy.log10(z)
1158 1162 #thisDatetime = dataOut.datatime
1159 1163 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1160 1164 title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1161 1165 xlabel = "Velocity (m/s)"
1162 1166 ylabel = "Spectrum"
1163 1167
1164 1168 if not self.isConfig:
1165 1169
1166 1170 nplots = listChannels.size
1167 1171
1168 1172 self.setup(id=id,
1169 1173 nplots=nplots,
1170 1174 wintitle=wintitle,
1171 1175 showprofile=showprofile,
1172 1176 show=show)
1173 1177
1174 1178 if xmin == None: xmin = numpy.nanmin(x)
1175 1179 if xmax == None: xmax = numpy.nanmax(x)
1176 1180 if ymin == None: ymin = numpy.nanmin(zdB)
1177 1181 if ymax == None: ymax = numpy.nanmax(zdB)+2
1178 1182
1179 1183 self.isConfig = True
1180 1184
1181 1185 self.setWinTitle(title)
1182 1186 for i in range(self.nplots):
1183 1187 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
1184 1188 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i])
1185 1189 axes = self.axesList[i*self.__nsubplots]
1186 1190 if fit == False:
1187 1191 axes.pline(x, zdB[i,:],
1188 1192 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1189 1193 xlabel=xlabel, ylabel=ylabel, title=title
1190 1194 )
1191 1195 if fit == True:
1192 1196 fitline=spcFitLinedB[i,:]
1193 1197 y=numpy.vstack([zdB[i,:],fitline] )
1194 1198 legendlabels=['Data','Fitting']
1195 1199 axes.pmultilineyaxis(x, y,
1196 1200 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1197 1201 xlabel=xlabel, ylabel=ylabel, title=title,
1198 1202 legendlabels=legendlabels, marker=None,
1199 1203 linestyle='solid', grid='both')
1200 1204
1201 1205 self.draw()
1202 1206
1203 1207 self.save(figpath=figpath,
1204 1208 figfile=figfile,
1205 1209 save=save,
1206 1210 ftp=ftp,
1207 1211 wr_period=wr_period,
1208 1212 thisDatetime=thisDatetime)
1209 1213
1210 1214
1211 1215 class EWDriftsPlot(Figure):
1212 1216
1213 1217 __isConfig = None
1214 1218 __nsubplots = None
1215 1219
1216 1220 WIDTHPROF = None
1217 1221 HEIGHTPROF = None
1218 1222 PREFIX = 'drift'
1219 1223
1220 1224 def __init__(self):
1221 1225
1222 1226 self.timerange = 2*60*60
1223 1227 self.isConfig = False
1224 1228 self.__nsubplots = 1
1225 1229
1226 1230 self.WIDTH = 800
1227 1231 self.HEIGHT = 150
1228 1232 self.WIDTHPROF = 120
1229 1233 self.HEIGHTPROF = 0
1230 1234 self.counter_imagwr = 0
1231 1235
1232 1236 self.PLOT_CODE = EWDRIFT_CODE
1233 1237
1234 1238 self.FTP_WEI = None
1235 1239 self.EXP_CODE = None
1236 1240 self.SUB_EXP_CODE = None
1237 1241 self.PLOT_POS = None
1238 1242 self.tmin = None
1239 1243 self.tmax = None
1240 1244
1241 1245 self.xmin = None
1242 1246 self.xmax = None
1243 1247
1244 1248 self.figfile = None
1245 1249
1246 1250 def getSubplots(self):
1247 1251
1248 1252 ncol = 1
1249 1253 nrow = self.nplots
1250 1254
1251 1255 return nrow, ncol
1252 1256
1253 1257 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1254 1258
1255 1259 self.__showprofile = showprofile
1256 1260 self.nplots = nplots
1257 1261
1258 1262 ncolspan = 1
1259 1263 colspan = 1
1260 1264
1261 1265 self.createFigure(id = id,
1262 1266 wintitle = wintitle,
1263 1267 widthplot = self.WIDTH + self.WIDTHPROF,
1264 1268 heightplot = self.HEIGHT + self.HEIGHTPROF,
1265 1269 show=show)
1266 1270
1267 1271 nrow, ncol = self.getSubplots()
1268 1272
1269 1273 counter = 0
1270 1274 for y in range(nrow):
1271 1275 if counter >= self.nplots:
1272 1276 break
1273 1277
1274 1278 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1275 1279 counter += 1
1276 1280
1277 1281 def run(self, dataOut, id, wintitle="", channelList=None,
1278 1282 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1279 1283 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1280 1284 timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False,
1281 1285 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1282 1286 server=None, folder=None, username=None, password=None,
1283 1287 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1284 1288 """
1285 1289
1286 1290 Input:
1287 1291 dataOut :
1288 1292 id :
1289 1293 wintitle :
1290 1294 channelList :
1291 1295 showProfile :
1292 1296 xmin : None,
1293 1297 xmax : None,
1294 1298 ymin : None,
1295 1299 ymax : None,
1296 1300 zmin : None,
1297 1301 zmax : None
1298 1302 """
1299 1303
1300 1304 if timerange is not None:
1301 1305 self.timerange = timerange
1302 1306
1303 1307 tmin = None
1304 1308 tmax = None
1305 1309
1306 1310 x = dataOut.getTimeRange1(dataOut.outputInterval)
1307 1311 # y = dataOut.heightList
1308 1312 y = dataOut.heightList
1309 1313
1310 1314 z = dataOut.data_output
1311 1315 nplots = z.shape[0] #Number of wind dimensions estimated
1312 1316 nplotsw = nplots
1313 1317
1314 1318 #If there is a SNR function defined
1315 1319 if dataOut.data_SNR is not None:
1316 1320 nplots += 1
1317 1321 SNR = dataOut.data_SNR
1318 1322
1319 1323 if SNR_1:
1320 1324 SNR += 1
1321 1325
1322 1326 SNRavg = numpy.average(SNR, axis=0)
1323 1327
1324 1328 SNRdB = 10*numpy.log10(SNR)
1325 1329 SNRavgdB = 10*numpy.log10(SNRavg)
1326 1330
1327 1331 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1328 1332
1329 1333 for i in range(nplotsw):
1330 1334 z[i,ind] = numpy.nan
1331 1335
1332 1336
1333 1337 showprofile = False
1334 1338 # thisDatetime = dataOut.datatime
1335 1339 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1336 1340 title = wintitle + " EW Drifts"
1337 1341 xlabel = ""
1338 1342 ylabel = "Height (Km)"
1339 1343
1340 1344 if not self.isConfig:
1341 1345
1342 1346 self.setup(id=id,
1343 1347 nplots=nplots,
1344 1348 wintitle=wintitle,
1345 1349 showprofile=showprofile,
1346 1350 show=show)
1347 1351
1348 1352 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1349 1353
1350 1354 if ymin == None: ymin = numpy.nanmin(y)
1351 1355 if ymax == None: ymax = numpy.nanmax(y)
1352 1356
1353 1357 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1354 1358 if zminZonal == None: zminZonal = -zmaxZonal
1355 1359 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1356 1360 if zminVertical == None: zminVertical = -zmaxVertical
1357 1361
1358 1362 if dataOut.data_SNR is not None:
1359 1363 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1360 1364 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1361 1365
1362 1366 self.FTP_WEI = ftp_wei
1363 1367 self.EXP_CODE = exp_code
1364 1368 self.SUB_EXP_CODE = sub_exp_code
1365 1369 self.PLOT_POS = plot_pos
1366 1370
1367 1371 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1368 1372 self.isConfig = True
1369 1373
1370 1374
1371 1375 self.setWinTitle(title)
1372 1376
1373 1377 if ((self.xmax - x[1]) < (x[1]-x[0])):
1374 1378 x[1] = self.xmax
1375 1379
1376 1380 strWind = ['Zonal','Vertical']
1377 1381 strCb = 'Velocity (m/s)'
1378 1382 zmaxVector = [zmaxZonal, zmaxVertical]
1379 1383 zminVector = [zminZonal, zminVertical]
1380 1384
1381 1385 for i in range(nplotsw):
1382 1386
1383 1387 title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1384 1388 axes = self.axesList[i*self.__nsubplots]
1385 1389
1386 1390 z1 = z[i,:].reshape((1,-1))
1387 1391
1388 1392 axes.pcolorbuffer(x, y, z1,
1389 1393 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
1390 1394 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1391 1395 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1392 1396
1393 1397 if dataOut.data_SNR is not None:
1394 1398 i += 1
1395 1399 if SNR_1:
1396 1400 title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1397 1401 else:
1398 1402 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1399 1403 axes = self.axesList[i*self.__nsubplots]
1400 1404 SNRavgdB = SNRavgdB.reshape((1,-1))
1401 1405
1402 1406 axes.pcolorbuffer(x, y, SNRavgdB,
1403 1407 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1404 1408 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1405 1409 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1406 1410
1407 1411 self.draw()
1408 1412
1409 1413 if x[1] >= self.axesList[0].xmax:
1410 1414 self.counter_imagwr = wr_period
1411 1415 self.isConfig = False
1412 1416 self.figfile = None
1413 1417
1414 1418
1415 1419
1416 1420
1417 1421 class PhasePlot(Figure):
1418 1422
1419 1423 __isConfig = None
1420 1424 __nsubplots = None
1421 1425
1422 1426 PREFIX = 'mphase'
1423 1427
1424 1428 def __init__(self):
1425 1429
1426 1430 self.timerange = 24*60*60
1427 1431 self.isConfig = False
1428 1432 self.__nsubplots = 1
1429 1433 self.counter_imagwr = 0
1430 1434 self.WIDTH = 600
1431 1435 self.HEIGHT = 300
1432 1436 self.WIDTHPROF = 120
1433 1437 self.HEIGHTPROF = 0
1434 1438 self.xdata = None
1435 1439 self.ydata = None
1436 1440
1437 1441 self.PLOT_CODE = MPHASE_CODE
1438 1442
1439 1443 self.FTP_WEI = None
1440 1444 self.EXP_CODE = None
1441 1445 self.SUB_EXP_CODE = None
1442 1446 self.PLOT_POS = None
1443 1447
1444 1448
1445 1449 self.filename_phase = None
1446 1450
1447 1451 self.figfile = None
1448 1452
1449 1453 def getSubplots(self):
1450 1454
1451 1455 ncol = 1
1452 1456 nrow = 1
1453 1457
1454 1458 return nrow, ncol
1455 1459
1456 1460 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1457 1461
1458 1462 self.__showprofile = showprofile
1459 1463 self.nplots = nplots
1460 1464
1461 1465 ncolspan = 7
1462 1466 colspan = 6
1463 1467 self.__nsubplots = 2
1464 1468
1465 1469 self.createFigure(id = id,
1466 1470 wintitle = wintitle,
1467 1471 widthplot = self.WIDTH+self.WIDTHPROF,
1468 1472 heightplot = self.HEIGHT+self.HEIGHTPROF,
1469 1473 show=show)
1470 1474
1471 1475 nrow, ncol = self.getSubplots()
1472 1476
1473 1477 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1474 1478
1475 1479
1476 1480 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1477 1481 xmin=None, xmax=None, ymin=None, ymax=None,
1478 1482 timerange=None,
1479 1483 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1480 1484 server=None, folder=None, username=None, password=None,
1481 1485 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1482 1486
1483 1487
1484 1488 tmin = None
1485 1489 tmax = None
1486 1490 x = dataOut.getTimeRange1(dataOut.outputInterval)
1487 1491 y = dataOut.getHeiRange()
1488 1492
1489 1493
1490 1494 #thisDatetime = dataOut.datatime
1491 1495 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1492 1496 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1493 1497 xlabel = "Local Time"
1494 1498 ylabel = "Phase"
1495 1499
1496 1500
1497 1501 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1498 1502 phase_beacon = dataOut.data_output
1499 1503 update_figfile = False
1500 1504
1501 1505 if not self.isConfig:
1502 1506
1503 1507 self.nplots = phase_beacon.size
1504 1508
1505 1509 self.setup(id=id,
1506 1510 nplots=self.nplots,
1507 1511 wintitle=wintitle,
1508 1512 showprofile=showprofile,
1509 1513 show=show)
1510 1514
1511 1515 if timerange is not None:
1512 1516 self.timerange = timerange
1513 1517
1514 1518 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1515 1519
1516 1520 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1517 1521 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1518 1522
1519 1523 self.FTP_WEI = ftp_wei
1520 1524 self.EXP_CODE = exp_code
1521 1525 self.SUB_EXP_CODE = sub_exp_code
1522 1526 self.PLOT_POS = plot_pos
1523 1527
1524 1528 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1525 1529 self.isConfig = True
1526 1530 self.figfile = figfile
1527 1531 self.xdata = numpy.array([])
1528 1532 self.ydata = numpy.array([])
1529 1533
1530 1534 #open file beacon phase
1531 1535 path = '%s%03d' %(self.PREFIX, self.id)
1532 1536 beacon_file = os.path.join(path,'%s.txt'%self.name)
1533 1537 self.filename_phase = os.path.join(figpath,beacon_file)
1534 1538 update_figfile = True
1535 1539
1536 1540
1537 1541 #store data beacon phase
1538 1542 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1539 1543
1540 1544 self.setWinTitle(title)
1541 1545
1542 1546
1543 1547 title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1544 1548
1545 1549 legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)]
1546 1550
1547 1551 axes = self.axesList[0]
1548 1552
1549 1553 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1550 1554
1551 1555 if len(self.ydata)==0:
1552 1556 self.ydata = phase_beacon.reshape(-1,1)
1553 1557 else:
1554 1558 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1555 1559
1556 1560
1557 1561 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1558 1562 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1559 1563 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1560 1564 XAxisAsTime=True, grid='both'
1561 1565 )
1562 1566
1563 1567 self.draw()
1564 1568
1565 1569 self.save(figpath=figpath,
1566 1570 figfile=figfile,
1567 1571 save=save,
1568 1572 ftp=ftp,
1569 1573 wr_period=wr_period,
1570 1574 thisDatetime=thisDatetime,
1571 1575 update_figfile=update_figfile)
1572 1576
1573 1577 if dataOut.ltctime + dataOut.outputInterval >= self.xmax:
1574 1578 self.counter_imagwr = wr_period
1575 1579 self.isConfig = False
1576 1580 update_figfile = True
1577 1581
1578 1582
1579 1583
1580 1584 class NSMeteorDetection1Plot(Figure):
1581 1585
1582 1586 isConfig = None
1583 1587 __nsubplots = None
1584 1588
1585 1589 WIDTHPROF = None
1586 1590 HEIGHTPROF = None
1587 1591 PREFIX = 'nsm'
1588 1592
1589 1593 zminList = None
1590 1594 zmaxList = None
1591 1595 cmapList = None
1592 1596 titleList = None
1593 1597 nPairs = None
1594 1598 nChannels = None
1595 1599 nParam = None
1596 1600
1597 1601 def __init__(self):
1598 1602
1599 1603 self.isConfig = False
1600 1604 self.__nsubplots = 1
1601 1605
1602 1606 self.WIDTH = 750
1603 1607 self.HEIGHT = 250
1604 1608 self.WIDTHPROF = 120
1605 1609 self.HEIGHTPROF = 0
1606 1610 self.counter_imagwr = 0
1607 1611
1608 1612 self.PLOT_CODE = SPEC_CODE
1609 1613
1610 1614 self.FTP_WEI = None
1611 1615 self.EXP_CODE = None
1612 1616 self.SUB_EXP_CODE = None
1613 1617 self.PLOT_POS = None
1614 1618
1615 1619 self.__xfilter_ena = False
1616 1620 self.__yfilter_ena = False
1617 1621
1618 1622 def getSubplots(self):
1619 1623
1620 1624 ncol = 3
1621 1625 nrow = int(numpy.ceil(self.nplots/3.0))
1622 1626
1623 1627 return nrow, ncol
1624 1628
1625 1629 def setup(self, id, nplots, wintitle, show=True):
1626 1630
1627 1631 self.nplots = nplots
1628 1632
1629 1633 ncolspan = 1
1630 1634 colspan = 1
1631 1635
1632 1636 self.createFigure(id = id,
1633 1637 wintitle = wintitle,
1634 1638 widthplot = self.WIDTH + self.WIDTHPROF,
1635 1639 heightplot = self.HEIGHT + self.HEIGHTPROF,
1636 1640 show=show)
1637 1641
1638 1642 nrow, ncol = self.getSubplots()
1639 1643
1640 1644 counter = 0
1641 1645 for y in range(nrow):
1642 1646 for x in range(ncol):
1643 1647
1644 1648 if counter >= self.nplots:
1645 1649 break
1646 1650
1647 1651 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1648 1652
1649 1653 counter += 1
1650 1654
1651 1655 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
1652 1656 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
1653 1657 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
1654 1658 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1655 1659 server=None, folder=None, username=None, password=None,
1656 1660 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
1657 1661 xaxis="frequency"):
1658 1662
1659 1663 """
1660 1664
1661 1665 Input:
1662 1666 dataOut :
1663 1667 id :
1664 1668 wintitle :
1665 1669 channelList :
1666 1670 showProfile :
1667 1671 xmin : None,
1668 1672 xmax : None,
1669 1673 ymin : None,
1670 1674 ymax : None,
1671 1675 zmin : None,
1672 1676 zmax : None
1673 1677 """
1674 1678 #SEPARAR EN DOS PLOTS
1675 1679 nParam = dataOut.data_param.shape[1] - 3
1676 1680
1677 1681 utctime = dataOut.data_param[0,0]
1678 1682 tmet = dataOut.data_param[:,1].astype(int)
1679 1683 hmet = dataOut.data_param[:,2].astype(int)
1680 1684
1681 1685 x = dataOut.abscissaList
1682 1686 y = dataOut.heightList
1683 1687
1684 1688 z = numpy.zeros((nParam, y.size, x.size - 1))
1685 1689 z[:,:] = numpy.nan
1686 1690 z[:,hmet,tmet] = dataOut.data_param[:,3:].T
1687 1691 z[0,:,:] = 10*numpy.log10(z[0,:,:])
1688 1692
1689 1693 xlabel = "Time (s)"
1690 1694 ylabel = "Range (km)"
1691 1695
1692 1696 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1693 1697
1694 1698 if not self.isConfig:
1695 1699
1696 1700 nplots = nParam
1697 1701
1698 1702 self.setup(id=id,
1699 1703 nplots=nplots,
1700 1704 wintitle=wintitle,
1701 1705 show=show)
1702 1706
1703 1707 if xmin is None: xmin = numpy.nanmin(x)
1704 1708 if xmax is None: xmax = numpy.nanmax(x)
1705 1709 if ymin is None: ymin = numpy.nanmin(y)
1706 1710 if ymax is None: ymax = numpy.nanmax(y)
1707 1711 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
1708 1712 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
1709 1713 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
1710 1714 if vmin is None: vmin = -vmax
1711 1715 if wmin is None: wmin = 0
1712 1716 if wmax is None: wmax = 50
1713 1717
1714 1718 pairsList = dataOut.groupList
1715 1719 self.nPairs = len(dataOut.groupList)
1716 1720
1717 1721 zminList = [SNRmin, vmin, cmin] + [pmin]*self.nPairs
1718 1722 zmaxList = [SNRmax, vmax, cmax] + [pmax]*self.nPairs
1719 1723 titleList = ["SNR","Radial Velocity","Coherence"]
1720 1724 cmapList = ["jet","RdBu_r","jet"]
1721 1725
1722 1726 for i in range(self.nPairs):
1723 1727 strAux1 = "Phase Difference "+ str(pairsList[i][0]) + str(pairsList[i][1])
1724 1728 titleList = titleList + [strAux1]
1725 1729 cmapList = cmapList + ["RdBu_r"]
1726 1730
1727 1731 self.zminList = zminList
1728 1732 self.zmaxList = zmaxList
1729 1733 self.cmapList = cmapList
1730 1734 self.titleList = titleList
1731 1735
1732 1736 self.FTP_WEI = ftp_wei
1733 1737 self.EXP_CODE = exp_code
1734 1738 self.SUB_EXP_CODE = sub_exp_code
1735 1739 self.PLOT_POS = plot_pos
1736 1740
1737 1741 self.isConfig = True
1738 1742
1739 1743 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1740 1744
1741 1745 for i in range(nParam):
1742 1746 title = self.titleList[i] + ": " +str_datetime
1743 1747 axes = self.axesList[i]
1744 1748 axes.pcolor(x, y, z[i,:].T,
1745 1749 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
1746 1750 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
1747 1751 self.draw()
1748 1752
1749 1753 if figfile == None:
1750 1754 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
1751 1755 name = str_datetime
1752 1756 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1753 1757 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
1754 1758 figfile = self.getFilename(name)
1755 1759
1756 1760 self.save(figpath=figpath,
1757 1761 figfile=figfile,
1758 1762 save=save,
1759 1763 ftp=ftp,
1760 1764 wr_period=wr_period,
1761 1765 thisDatetime=thisDatetime)
1762 1766
1763 1767
1764 1768 class NSMeteorDetection2Plot(Figure):
1765 1769
1766 1770 isConfig = None
1767 1771 __nsubplots = None
1768 1772
1769 1773 WIDTHPROF = None
1770 1774 HEIGHTPROF = None
1771 1775 PREFIX = 'nsm'
1772 1776
1773 1777 zminList = None
1774 1778 zmaxList = None
1775 1779 cmapList = None
1776 1780 titleList = None
1777 1781 nPairs = None
1778 1782 nChannels = None
1779 1783 nParam = None
1780 1784
1781 1785 def __init__(self):
1782 1786
1783 1787 self.isConfig = False
1784 1788 self.__nsubplots = 1
1785 1789
1786 1790 self.WIDTH = 750
1787 1791 self.HEIGHT = 250
1788 1792 self.WIDTHPROF = 120
1789 1793 self.HEIGHTPROF = 0
1790 1794 self.counter_imagwr = 0
1791 1795
1792 1796 self.PLOT_CODE = SPEC_CODE
1793 1797
1794 1798 self.FTP_WEI = None
1795 1799 self.EXP_CODE = None
1796 1800 self.SUB_EXP_CODE = None
1797 1801 self.PLOT_POS = None
1798 1802
1799 1803 self.__xfilter_ena = False
1800 1804 self.__yfilter_ena = False
1801 1805
1802 1806 def getSubplots(self):
1803 1807
1804 1808 ncol = 3
1805 1809 nrow = int(numpy.ceil(self.nplots/3.0))
1806 1810
1807 1811 return nrow, ncol
1808 1812
1809 1813 def setup(self, id, nplots, wintitle, show=True):
1810 1814
1811 1815 self.nplots = nplots
1812 1816
1813 1817 ncolspan = 1
1814 1818 colspan = 1
1815 1819
1816 1820 self.createFigure(id = id,
1817 1821 wintitle = wintitle,
1818 1822 widthplot = self.WIDTH + self.WIDTHPROF,
1819 1823 heightplot = self.HEIGHT + self.HEIGHTPROF,
1820 1824 show=show)
1821 1825
1822 1826 nrow, ncol = self.getSubplots()
1823 1827
1824 1828 counter = 0
1825 1829 for y in range(nrow):
1826 1830 for x in range(ncol):
1827 1831
1828 1832 if counter >= self.nplots:
1829 1833 break
1830 1834
1831 1835 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1832 1836
1833 1837 counter += 1
1834 1838
1835 1839 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
1836 1840 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
1837 1841 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
1838 1842 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1839 1843 server=None, folder=None, username=None, password=None,
1840 1844 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
1841 1845 xaxis="frequency"):
1842 1846
1843 1847 """
1844 1848
1845 1849 Input:
1846 1850 dataOut :
1847 1851 id :
1848 1852 wintitle :
1849 1853 channelList :
1850 1854 showProfile :
1851 1855 xmin : None,
1852 1856 xmax : None,
1853 1857 ymin : None,
1854 1858 ymax : None,
1855 1859 zmin : None,
1856 1860 zmax : None
1857 1861 """
1858 1862 #Rebuild matrix
1859 1863 utctime = dataOut.data_param[0,0]
1860 1864 cmet = dataOut.data_param[:,1].astype(int)
1861 1865 tmet = dataOut.data_param[:,2].astype(int)
1862 1866 hmet = dataOut.data_param[:,3].astype(int)
1863 1867
1864 1868 nParam = 3
1865 1869 nChan = len(dataOut.groupList)
1866 1870 x = dataOut.abscissaList
1867 1871 y = dataOut.heightList
1868 1872
1869 1873 z = numpy.full((nChan, nParam, y.size, x.size - 1),numpy.nan)
1870 1874 z[cmet,:,hmet,tmet] = dataOut.data_param[:,4:]
1871 1875 z[:,0,:,:] = 10*numpy.log10(z[:,0,:,:]) #logarithmic scale
1872 1876 z = numpy.reshape(z, (nChan*nParam, y.size, x.size-1))
1873 1877
1874 1878 xlabel = "Time (s)"
1875 1879 ylabel = "Range (km)"
1876 1880
1877 1881 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1878 1882
1879 1883 if not self.isConfig:
1880 1884
1881 1885 nplots = nParam*nChan
1882 1886
1883 1887 self.setup(id=id,
1884 1888 nplots=nplots,
1885 1889 wintitle=wintitle,
1886 1890 show=show)
1887 1891
1888 1892 if xmin is None: xmin = numpy.nanmin(x)
1889 1893 if xmax is None: xmax = numpy.nanmax(x)
1890 1894 if ymin is None: ymin = numpy.nanmin(y)
1891 1895 if ymax is None: ymax = numpy.nanmax(y)
1892 1896 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
1893 1897 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
1894 1898 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
1895 1899 if vmin is None: vmin = -vmax
1896 1900 if wmin is None: wmin = 0
1897 1901 if wmax is None: wmax = 50
1898 1902
1899 1903 self.nChannels = nChan
1900 1904
1901 1905 zminList = []
1902 1906 zmaxList = []
1903 1907 titleList = []
1904 1908 cmapList = []
1905 1909 for i in range(self.nChannels):
1906 1910 strAux1 = "SNR Channel "+ str(i)
1907 1911 strAux2 = "Radial Velocity Channel "+ str(i)
1908 1912 strAux3 = "Spectral Width Channel "+ str(i)
1909 1913
1910 1914 titleList = titleList + [strAux1,strAux2,strAux3]
1911 1915 cmapList = cmapList + ["jet","RdBu_r","jet"]
1912 1916 zminList = zminList + [SNRmin,vmin,wmin]
1913 1917 zmaxList = zmaxList + [SNRmax,vmax,wmax]
1914 1918
1915 1919 self.zminList = zminList
1916 1920 self.zmaxList = zmaxList
1917 1921 self.cmapList = cmapList
1918 1922 self.titleList = titleList
1919 1923
1920 1924 self.FTP_WEI = ftp_wei
1921 1925 self.EXP_CODE = exp_code
1922 1926 self.SUB_EXP_CODE = sub_exp_code
1923 1927 self.PLOT_POS = plot_pos
1924 1928
1925 1929 self.isConfig = True
1926 1930
1927 1931 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1928 1932
1929 1933 for i in range(self.nplots):
1930 1934 title = self.titleList[i] + ": " +str_datetime
1931 1935 axes = self.axesList[i]
1932 1936 axes.pcolor(x, y, z[i,:].T,
1933 1937 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
1934 1938 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
1935 1939 self.draw()
1936 1940
1937 1941 if figfile == None:
1938 1942 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
1939 1943 name = str_datetime
1940 1944 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1941 1945 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
1942 1946 figfile = self.getFilename(name)
1943 1947
1944 1948 self.save(figpath=figpath,
1945 1949 figfile=figfile,
1946 1950 save=save,
1947 1951 ftp=ftp,
1948 1952 wr_period=wr_period,
1949 1953 thisDatetime=thisDatetime)
1950 1954
1951 1955
General Comments 0
You need to be logged in to leave comments. Login now