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