##// END OF EJS Templates
Parameters libraries reorganized, now each operation is a separated class
Julio Valdez -
r841:c38d03dda608
parent child
Show More
@@ -1,1569 +1,1947
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 self.HEIGHT = 150
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 ylabel = "Range (Km)"
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 556 if dataOut.ltctime >= self.xmax:
557 557 self.counter_imagwr = wr_period
558 558 self.isConfig = False
559 559 update_figfile = True
560 560
561 561 self.save(figpath=figpath,
562 562 figfile=figfile,
563 563 save=save,
564 564 ftp=ftp,
565 565 wr_period=wr_period,
566 566 thisDatetime=thisDatetime,
567 567 update_figfile=update_figfile)
568 568
569 569 class ParametersPlot(Figure):
570 570
571 571 __isConfig = None
572 572 __nsubplots = None
573 573
574 574 WIDTHPROF = None
575 575 HEIGHTPROF = None
576 576 PREFIX = 'param'
577 577
578 578 nplots = None
579 579 nchan = None
580 580
581 581 def __init__(self):
582 582
583 583 self.timerange = None
584 584 self.isConfig = False
585 585 self.__nsubplots = 1
586 586
587 587 self.WIDTH = 800
588 588 self.HEIGHT = 180
589 589 self.WIDTHPROF = 120
590 590 self.HEIGHTPROF = 0
591 591 self.counter_imagwr = 0
592 592
593 593 self.PLOT_CODE = RTI_CODE
594 594
595 595 self.FTP_WEI = None
596 596 self.EXP_CODE = None
597 597 self.SUB_EXP_CODE = None
598 598 self.PLOT_POS = None
599 599 self.tmin = None
600 600 self.tmax = None
601 601
602 602 self.xmin = None
603 603 self.xmax = None
604 604
605 605 self.figfile = None
606 606
607 607 def getSubplots(self):
608 608
609 609 ncol = 1
610 610 nrow = self.nplots
611 611
612 612 return nrow, ncol
613 613
614 614 def setup(self, id, nplots, wintitle, show=True):
615 615
616 616 self.nplots = nplots
617 617
618 618 ncolspan = 1
619 619 colspan = 1
620 620
621 621 self.createFigure(id = id,
622 622 wintitle = wintitle,
623 623 widthplot = self.WIDTH + self.WIDTHPROF,
624 624 heightplot = self.HEIGHT + self.HEIGHTPROF,
625 625 show=show)
626 626
627 627 nrow, ncol = self.getSubplots()
628 628
629 629 counter = 0
630 630 for y in range(nrow):
631 631 for x in range(ncol):
632 632
633 633 if counter >= self.nplots:
634 634 break
635 635
636 636 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
637 637
638 638 counter += 1
639 639
640 640 def run(self, dataOut, id, wintitle="", channelList=None, paramIndex = 0, colormap=True,
641 641 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None,
642 642 showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None,
643 643 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
644 644 server=None, folder=None, username=None, password=None,
645 645 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
646 646
647 647 """
648 648
649 649 Input:
650 650 dataOut :
651 651 id :
652 652 wintitle :
653 653 channelList :
654 654 showProfile :
655 655 xmin : None,
656 656 xmax : None,
657 657 ymin : None,
658 658 ymax : None,
659 659 zmin : None,
660 660 zmax : None
661 661 """
662 662
663 663 if colormap:
664 664 colormap="jet"
665 665 else:
666 666 colormap="RdBu_r"
667 667
668 668 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
669 669 return
670 670
671 671 if channelList == None:
672 channelIndexList = dataOut.channelIndexList
672 channelIndexList = range(dataOut.data_param.shape[0])
673 673 else:
674 674 channelIndexList = []
675 675 for channel in channelList:
676 676 if channel not in dataOut.channelList:
677 677 raise ValueError, "Channel %d is not in dataOut.channelList"
678 678 channelIndexList.append(dataOut.channelList.index(channel))
679 679
680 680 x = dataOut.getTimeRange1(dataOut.paramInterval)
681 681 y = dataOut.getHeiRange()
682 z = dataOut.data_param[channelIndexList,paramIndex,:]
683 682
683 if dataOut.data_param.ndim == 3:
684 z = dataOut.data_param[channelIndexList,paramIndex,:]
685 else:
686 z = dataOut.data_param[channelIndexList,:]
687
684 688 if showSNR:
685 689 #SNR data
686 690 SNRarray = dataOut.data_SNR[channelIndexList,:]
687 691 SNRdB = 10*numpy.log10(SNRarray)
688 692 ind = numpy.where(SNRdB < SNRthresh)
689 693 z[ind] = numpy.nan
690 694
691 695 thisDatetime = dataOut.datatime
692 696 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
693 697 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
694 698 xlabel = ""
695 699 ylabel = "Range (Km)"
696 700
697 701 update_figfile = False
698 702
699 703 if not self.isConfig:
700 704
701 705 nchan = len(channelIndexList)
702 706 self.nchan = nchan
703 707 self.plotFact = 1
704 708 nplots = nchan
705 709
706 710 if showSNR:
707 711 nplots = nchan*2
708 712 self.plotFact = 2
709 713 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
710 714 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
711 715
712 716 self.setup(id=id,
713 717 nplots=nplots,
714 718 wintitle=wintitle,
715 719 show=show)
716 720
717 721 if timerange != None:
718 722 self.timerange = timerange
719 723
720 724 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
721 725
722 726 if ymin == None: ymin = numpy.nanmin(y)
723 727 if ymax == None: ymax = numpy.nanmax(y)
724 if zmin == None: zmin = dataOut.abscissaList[0]
725 if zmax == None: zmax = dataOut.abscissaList[-1]
728 if zmin == None: zmin = numpy.nanmin(z)
729 if zmax == None: zmax = numpy.nanmax(z)
726 730
727 731 self.FTP_WEI = ftp_wei
728 732 self.EXP_CODE = exp_code
729 733 self.SUB_EXP_CODE = sub_exp_code
730 734 self.PLOT_POS = plot_pos
731 735
732 736 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
733 737 self.isConfig = True
734 738 self.figfile = figfile
735 739 update_figfile = True
736 740
737 741 self.setWinTitle(title)
738 742
739 743 for i in range(self.nchan):
740 744 index = channelIndexList[i]
741 745 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
742 746 axes = self.axesList[i*self.plotFact]
743 747 z1 = z[i,:].reshape((1,-1))
744 748 axes.pcolorbuffer(x, y, z1,
745 749 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
746 750 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
747 751 ticksize=9, cblabel='', cbsize="1%",colormap=colormap)
748 752
749 753 if showSNR:
750 754 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
751 755 axes = self.axesList[i*self.plotFact + 1]
752 756 SNRdB1 = SNRdB[i,:].reshape((1,-1))
753 757 axes.pcolorbuffer(x, y, SNRdB1,
754 758 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
755 759 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
756 760 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
757 761
758 762
759 763 self.draw()
760 764
761 765 if dataOut.ltctime >= self.xmax:
762 766 self.counter_imagwr = wr_period
763 767 self.isConfig = False
764 768 update_figfile = True
765 769
766 770 self.save(figpath=figpath,
767 771 figfile=figfile,
768 772 save=save,
769 773 ftp=ftp,
770 774 wr_period=wr_period,
771 775 thisDatetime=thisDatetime,
772 776 update_figfile=update_figfile)
773 777
774 778
775 779
776 780 class Parameters1Plot(Figure):
777 781
778 782 __isConfig = None
779 783 __nsubplots = None
780 784
781 785 WIDTHPROF = None
782 786 HEIGHTPROF = None
783 787 PREFIX = 'prm'
784 788
785 789 def __init__(self):
786 790
787 791 self.timerange = 2*60*60
788 792 self.isConfig = False
789 793 self.__nsubplots = 1
790 794
791 795 self.WIDTH = 800
792 796 self.HEIGHT = 150
793 797 self.WIDTHPROF = 120
794 798 self.HEIGHTPROF = 0
795 799 self.counter_imagwr = 0
796 800
797 801 self.PLOT_CODE = PARMS_CODE
798 802
799 803 self.FTP_WEI = None
800 804 self.EXP_CODE = None
801 805 self.SUB_EXP_CODE = None
802 806 self.PLOT_POS = None
803 807 self.tmin = None
804 808 self.tmax = None
805 809
806 810 self.xmin = None
807 811 self.xmax = None
808 812
809 813 self.figfile = None
810 814
811 815 def getSubplots(self):
812 816
813 817 ncol = 1
814 818 nrow = self.nplots
815 819
816 820 return nrow, ncol
817 821
818 822 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
819 823
820 824 self.__showprofile = showprofile
821 825 self.nplots = nplots
822 826
823 827 ncolspan = 1
824 828 colspan = 1
825 829
826 830 self.createFigure(id = id,
827 831 wintitle = wintitle,
828 832 widthplot = self.WIDTH + self.WIDTHPROF,
829 833 heightplot = self.HEIGHT + self.HEIGHTPROF,
830 834 show=show)
831 835
832 836 nrow, ncol = self.getSubplots()
833 837
834 838 counter = 0
835 839 for y in range(nrow):
836 840 for x in range(ncol):
837 841
838 842 if counter >= self.nplots:
839 843 break
840 844
841 845 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
842 846
843 847 if showprofile:
844 848 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
845 849
846 850 counter += 1
847 851
848 852 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
849 853 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None,
850 854 parameterIndex = None, onlyPositive = False,
851 855 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False,
852 856 DOP = True,
853 857 zlabel = "", parameterName = "", parameterObject = "data_param",
854 858 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
855 859 server=None, folder=None, username=None, password=None,
856 860 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
857 861
858 862 """
859 863
860 864 Input:
861 865 dataOut :
862 866 id :
863 867 wintitle :
864 868 channelList :
865 869 showProfile :
866 870 xmin : None,
867 871 xmax : None,
868 872 ymin : None,
869 873 ymax : None,
870 874 zmin : None,
871 875 zmax : None
872 876 """
873 877
874 878 data_param = getattr(dataOut, parameterObject)
875 879
876 880 if channelList == None:
877 881 channelIndexList = numpy.arange(data_param.shape[0])
878 882 else:
879 883 channelIndexList = numpy.array(channelList)
880 884
881 885 nchan = len(channelIndexList) #Number of channels being plotted
882 886
883 887 if nchan < 1:
884 888 return
885 889
886 890 nGraphsByChannel = 0
887 891
888 892 if SNR:
889 893 nGraphsByChannel += 1
890 894 if DOP:
891 895 nGraphsByChannel += 1
892 896
893 897 if nGraphsByChannel < 1:
894 898 return
895 899
896 900 nplots = nGraphsByChannel*nchan
897 901
898 902 if timerange is not None:
899 903 self.timerange = timerange
900 904
901 905 #tmin = None
902 906 #tmax = None
903 907 if parameterIndex == None:
904 908 parameterIndex = 1
905 909
906 910 x = dataOut.getTimeRange1(dataOut.paramInterval)
907 911 y = dataOut.heightList
908 912 z = data_param[channelIndexList,parameterIndex,:].copy()
909 913
910 914 zRange = dataOut.abscissaList
911 915 # nChannels = z.shape[0] #Number of wind dimensions estimated
912 916 # thisDatetime = dataOut.datatime
913 917
914 918 if dataOut.data_SNR is not None:
915 919 SNRarray = dataOut.data_SNR[channelIndexList,:]
916 920 SNRdB = 10*numpy.log10(SNRarray)
917 921 # SNRavgdB = 10*numpy.log10(SNRavg)
918 922 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
919 923 z[ind] = numpy.nan
920 924
921 925 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
922 926 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
923 927 xlabel = ""
924 928 ylabel = "Range (Km)"
925 929
926 930 if (SNR and not onlySNR): nplots = 2*nplots
927 931
928 932 if onlyPositive:
929 933 colormap = "jet"
930 934 zmin = 0
931 935 else: colormap = "RdBu_r"
932 936
933 937 if not self.isConfig:
934 938
935 939 self.setup(id=id,
936 940 nplots=nplots,
937 941 wintitle=wintitle,
938 942 showprofile=showprofile,
939 943 show=show)
940 944
941 945 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
942 946
943 947 if ymin == None: ymin = numpy.nanmin(y)
944 948 if ymax == None: ymax = numpy.nanmax(y)
945 949 if zmin == None: zmin = numpy.nanmin(zRange)
946 950 if zmax == None: zmax = numpy.nanmax(zRange)
947 951
948 952 if SNR:
949 953 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
950 954 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
951 955
952 956 self.FTP_WEI = ftp_wei
953 957 self.EXP_CODE = exp_code
954 958 self.SUB_EXP_CODE = sub_exp_code
955 959 self.PLOT_POS = plot_pos
956 960
957 961 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
958 962 self.isConfig = True
959 963 self.figfile = figfile
960 964
961 965 self.setWinTitle(title)
962 966
963 967 if ((self.xmax - x[1]) < (x[1]-x[0])):
964 968 x[1] = self.xmax
965 969
966 970 for i in range(nchan):
967 971
968 972 if (SNR and not onlySNR): j = 2*i
969 973 else: j = i
970 974
971 975 j = nGraphsByChannel*i
972 976
973 977 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
974 978 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
975 979
976 980 if not onlySNR:
977 981 axes = self.axesList[j*self.__nsubplots]
978 982 z1 = z[i,:].reshape((1,-1))
979 983 axes.pcolorbuffer(x, y, z1,
980 984 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
981 985 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
982 986 ticksize=9, cblabel=zlabel, cbsize="1%")
983 987
984 988 if DOP:
985 989 title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
986 990
987 991 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
988 992 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
989 993 axes = self.axesList[j]
990 994 z1 = z[i,:].reshape((1,-1))
991 995 axes.pcolorbuffer(x, y, z1,
992 996 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
993 997 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
994 998 ticksize=9, cblabel=zlabel, cbsize="1%")
995 999
996 1000 if SNR:
997 1001 title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
998 1002 axes = self.axesList[(j)*self.__nsubplots]
999 1003 if not onlySNR:
1000 1004 axes = self.axesList[(j + 1)*self.__nsubplots]
1001 1005
1002 1006 axes = self.axesList[(j + nGraphsByChannel-1)]
1003 1007
1004 1008 z1 = SNRdB[i,:].reshape((1,-1))
1005 1009 axes.pcolorbuffer(x, y, z1,
1006 1010 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1007 1011 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet",
1008 1012 ticksize=9, cblabel=zlabel, cbsize="1%")
1009 1013
1010 1014
1011 1015
1012 1016 self.draw()
1013 1017
1014 1018 if x[1] >= self.axesList[0].xmax:
1015 1019 self.counter_imagwr = wr_period
1016 1020 self.isConfig = False
1017 1021 self.figfile = None
1018 1022
1019 1023 self.save(figpath=figpath,
1020 1024 figfile=figfile,
1021 1025 save=save,
1022 1026 ftp=ftp,
1023 1027 wr_period=wr_period,
1024 1028 thisDatetime=thisDatetime,
1025 1029 update_figfile=False)
1026 1030
1027 1031 class SpectralFittingPlot(Figure):
1028 1032
1029 1033 __isConfig = None
1030 1034 __nsubplots = None
1031 1035
1032 1036 WIDTHPROF = None
1033 1037 HEIGHTPROF = None
1034 1038 PREFIX = 'prm'
1035 1039
1036 1040
1037 1041 N = None
1038 1042 ippSeconds = None
1039 1043
1040 1044 def __init__(self):
1041 1045 self.isConfig = False
1042 1046 self.__nsubplots = 1
1043 1047
1044 1048 self.PLOT_CODE = SPECFIT_CODE
1045 1049
1046 1050 self.WIDTH = 450
1047 1051 self.HEIGHT = 250
1048 1052 self.WIDTHPROF = 0
1049 1053 self.HEIGHTPROF = 0
1050 1054
1051 1055 def getSubplots(self):
1052 1056
1053 1057 ncol = int(numpy.sqrt(self.nplots)+0.9)
1054 1058 nrow = int(self.nplots*1./ncol + 0.9)
1055 1059
1056 1060 return nrow, ncol
1057 1061
1058 1062 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
1059 1063
1060 1064 showprofile = False
1061 1065 self.__showprofile = showprofile
1062 1066 self.nplots = nplots
1063 1067
1064 1068 ncolspan = 5
1065 1069 colspan = 4
1066 1070 if showprofile:
1067 1071 ncolspan = 5
1068 1072 colspan = 4
1069 1073 self.__nsubplots = 2
1070 1074
1071 1075 self.createFigure(id = id,
1072 1076 wintitle = wintitle,
1073 1077 widthplot = self.WIDTH + self.WIDTHPROF,
1074 1078 heightplot = self.HEIGHT + self.HEIGHTPROF,
1075 1079 show=show)
1076 1080
1077 1081 nrow, ncol = self.getSubplots()
1078 1082
1079 1083 counter = 0
1080 1084 for y in range(nrow):
1081 1085 for x in range(ncol):
1082 1086
1083 1087 if counter >= self.nplots:
1084 1088 break
1085 1089
1086 1090 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1087 1091
1088 1092 if showprofile:
1089 1093 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1090 1094
1091 1095 counter += 1
1092 1096
1093 1097 def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True,
1094 1098 xmin=None, xmax=None, ymin=None, ymax=None,
1095 1099 save=False, figpath='./', figfile=None, show=True):
1096 1100
1097 1101 """
1098 1102
1099 1103 Input:
1100 1104 dataOut :
1101 1105 id :
1102 1106 wintitle :
1103 1107 channelList :
1104 1108 showProfile :
1105 1109 xmin : None,
1106 1110 xmax : None,
1107 1111 zmin : None,
1108 1112 zmax : None
1109 1113 """
1110 1114
1111 1115 if cutHeight==None:
1112 1116 h=270
1113 1117 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
1114 1118 cutHeight = dataOut.heightList[heightindex]
1115 1119
1116 1120 factor = dataOut.normFactor
1117 1121 x = dataOut.abscissaList[:-1]
1118 1122 #y = dataOut.getHeiRange()
1119 1123
1120 1124 z = dataOut.data_pre[:,:,heightindex]/factor
1121 1125 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1122 1126 avg = numpy.average(z, axis=1)
1123 1127 listChannels = z.shape[0]
1124 1128
1125 1129 #Reconstruct Function
1126 1130 if fit==True:
1127 1131 groupArray = dataOut.groupList
1128 1132 listChannels = groupArray.reshape((groupArray.size))
1129 1133 listChannels.sort()
1130 1134 spcFitLine = numpy.zeros(z.shape)
1131 1135 constants = dataOut.constants
1132 1136
1133 1137 nGroups = groupArray.shape[0]
1134 1138 nChannels = groupArray.shape[1]
1135 1139 nProfiles = z.shape[1]
1136 1140
1137 1141 for f in range(nGroups):
1138 1142 groupChann = groupArray[f,:]
1139 1143 p = dataOut.data_param[f,:,heightindex]
1140 1144 # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167])
1141 1145 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
1142 1146 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
1143 1147 spcFitLine[groupChann,:] = fitLineAux
1144 1148 # spcFitLine = spcFitLine/factor
1145 1149
1146 1150 z = z[listChannels,:]
1147 1151 spcFitLine = spcFitLine[listChannels,:]
1148 1152 spcFitLinedB = 10*numpy.log10(spcFitLine)
1149 1153
1150 1154 zdB = 10*numpy.log10(z)
1151 1155 #thisDatetime = dataOut.datatime
1152 1156 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1153 1157 title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1154 1158 xlabel = "Velocity (m/s)"
1155 1159 ylabel = "Spectrum"
1156 1160
1157 1161 if not self.isConfig:
1158 1162
1159 1163 nplots = listChannels.size
1160 1164
1161 1165 self.setup(id=id,
1162 1166 nplots=nplots,
1163 1167 wintitle=wintitle,
1164 1168 showprofile=showprofile,
1165 1169 show=show)
1166 1170
1167 1171 if xmin == None: xmin = numpy.nanmin(x)
1168 1172 if xmax == None: xmax = numpy.nanmax(x)
1169 1173 if ymin == None: ymin = numpy.nanmin(zdB)
1170 1174 if ymax == None: ymax = numpy.nanmax(zdB)+2
1171 1175
1172 1176 self.isConfig = True
1173 1177
1174 1178 self.setWinTitle(title)
1175 1179 for i in range(self.nplots):
1176 1180 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
1177 1181 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i])
1178 1182 axes = self.axesList[i*self.__nsubplots]
1179 1183 if fit == False:
1180 1184 axes.pline(x, zdB[i,:],
1181 1185 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1182 1186 xlabel=xlabel, ylabel=ylabel, title=title
1183 1187 )
1184 1188 if fit == True:
1185 1189 fitline=spcFitLinedB[i,:]
1186 1190 y=numpy.vstack([zdB[i,:],fitline] )
1187 1191 legendlabels=['Data','Fitting']
1188 1192 axes.pmultilineyaxis(x, y,
1189 1193 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1190 1194 xlabel=xlabel, ylabel=ylabel, title=title,
1191 1195 legendlabels=legendlabels, marker=None,
1192 1196 linestyle='solid', grid='both')
1193 1197
1194 1198 self.draw()
1195 1199
1196 1200 self.save(figpath=figpath,
1197 1201 figfile=figfile,
1198 1202 save=save,
1199 1203 ftp=ftp,
1200 1204 wr_period=wr_period,
1201 1205 thisDatetime=thisDatetime)
1202 1206
1203 1207
1204 1208 class EWDriftsPlot(Figure):
1205 1209
1206 1210 __isConfig = None
1207 1211 __nsubplots = None
1208 1212
1209 1213 WIDTHPROF = None
1210 1214 HEIGHTPROF = None
1211 1215 PREFIX = 'drift'
1212 1216
1213 1217 def __init__(self):
1214 1218
1215 1219 self.timerange = 2*60*60
1216 1220 self.isConfig = False
1217 1221 self.__nsubplots = 1
1218 1222
1219 1223 self.WIDTH = 800
1220 1224 self.HEIGHT = 150
1221 1225 self.WIDTHPROF = 120
1222 1226 self.HEIGHTPROF = 0
1223 1227 self.counter_imagwr = 0
1224 1228
1225 1229 self.PLOT_CODE = EWDRIFT_CODE
1226 1230
1227 1231 self.FTP_WEI = None
1228 1232 self.EXP_CODE = None
1229 1233 self.SUB_EXP_CODE = None
1230 1234 self.PLOT_POS = None
1231 1235 self.tmin = None
1232 1236 self.tmax = None
1233 1237
1234 1238 self.xmin = None
1235 1239 self.xmax = None
1236 1240
1237 1241 self.figfile = None
1238 1242
1239 1243 def getSubplots(self):
1240 1244
1241 1245 ncol = 1
1242 1246 nrow = self.nplots
1243 1247
1244 1248 return nrow, ncol
1245 1249
1246 1250 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1247 1251
1248 1252 self.__showprofile = showprofile
1249 1253 self.nplots = nplots
1250 1254
1251 1255 ncolspan = 1
1252 1256 colspan = 1
1253 1257
1254 1258 self.createFigure(id = id,
1255 1259 wintitle = wintitle,
1256 1260 widthplot = self.WIDTH + self.WIDTHPROF,
1257 1261 heightplot = self.HEIGHT + self.HEIGHTPROF,
1258 1262 show=show)
1259 1263
1260 1264 nrow, ncol = self.getSubplots()
1261 1265
1262 1266 counter = 0
1263 1267 for y in range(nrow):
1264 1268 if counter >= self.nplots:
1265 1269 break
1266 1270
1267 1271 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1268 1272 counter += 1
1269 1273
1270 1274 def run(self, dataOut, id, wintitle="", channelList=None,
1271 1275 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1272 1276 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1273 1277 timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False,
1274 1278 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1275 1279 server=None, folder=None, username=None, password=None,
1276 1280 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1277 1281 """
1278 1282
1279 1283 Input:
1280 1284 dataOut :
1281 1285 id :
1282 1286 wintitle :
1283 1287 channelList :
1284 1288 showProfile :
1285 1289 xmin : None,
1286 1290 xmax : None,
1287 1291 ymin : None,
1288 1292 ymax : None,
1289 1293 zmin : None,
1290 1294 zmax : None
1291 1295 """
1292 1296
1293 1297 if timerange is not None:
1294 1298 self.timerange = timerange
1295 1299
1296 1300 tmin = None
1297 1301 tmax = None
1298 1302
1299 1303 x = dataOut.getTimeRange1(dataOut.outputInterval)
1300 1304 # y = dataOut.heightList
1301 1305 y = dataOut.heightList
1302 1306
1303 1307 z = dataOut.data_output
1304 1308 nplots = z.shape[0] #Number of wind dimensions estimated
1305 1309 nplotsw = nplots
1306 1310
1307 1311 #If there is a SNR function defined
1308 1312 if dataOut.data_SNR is not None:
1309 1313 nplots += 1
1310 1314 SNR = dataOut.data_SNR
1311 1315
1312 1316 if SNR_1:
1313 1317 SNR += 1
1314 1318
1315 1319 SNRavg = numpy.average(SNR, axis=0)
1316 1320
1317 1321 SNRdB = 10*numpy.log10(SNR)
1318 1322 SNRavgdB = 10*numpy.log10(SNRavg)
1319 1323
1320 1324 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1321 1325
1322 1326 for i in range(nplotsw):
1323 1327 z[i,ind] = numpy.nan
1324 1328
1325 1329
1326 1330 showprofile = False
1327 1331 # thisDatetime = dataOut.datatime
1328 1332 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1329 1333 title = wintitle + " EW Drifts"
1330 1334 xlabel = ""
1331 1335 ylabel = "Height (Km)"
1332 1336
1333 1337 if not self.isConfig:
1334 1338
1335 1339 self.setup(id=id,
1336 1340 nplots=nplots,
1337 1341 wintitle=wintitle,
1338 1342 showprofile=showprofile,
1339 1343 show=show)
1340 1344
1341 1345 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1342 1346
1343 1347 if ymin == None: ymin = numpy.nanmin(y)
1344 1348 if ymax == None: ymax = numpy.nanmax(y)
1345 1349
1346 1350 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1347 1351 if zminZonal == None: zminZonal = -zmaxZonal
1348 1352 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1349 1353 if zminVertical == None: zminVertical = -zmaxVertical
1350 1354
1351 1355 if dataOut.data_SNR is not None:
1352 1356 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1353 1357 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1354 1358
1355 1359 self.FTP_WEI = ftp_wei
1356 1360 self.EXP_CODE = exp_code
1357 1361 self.SUB_EXP_CODE = sub_exp_code
1358 1362 self.PLOT_POS = plot_pos
1359 1363
1360 1364 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1361 1365 self.isConfig = True
1362 1366
1363 1367
1364 1368 self.setWinTitle(title)
1365 1369
1366 1370 if ((self.xmax - x[1]) < (x[1]-x[0])):
1367 1371 x[1] = self.xmax
1368 1372
1369 1373 strWind = ['Zonal','Vertical']
1370 1374 strCb = 'Velocity (m/s)'
1371 1375 zmaxVector = [zmaxZonal, zmaxVertical]
1372 1376 zminVector = [zminZonal, zminVertical]
1373 1377
1374 1378 for i in range(nplotsw):
1375 1379
1376 1380 title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1377 1381 axes = self.axesList[i*self.__nsubplots]
1378 1382
1379 1383 z1 = z[i,:].reshape((1,-1))
1380 1384
1381 1385 axes.pcolorbuffer(x, y, z1,
1382 1386 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
1383 1387 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1384 1388 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1385 1389
1386 1390 if dataOut.data_SNR is not None:
1387 1391 i += 1
1388 1392 if SNR_1:
1389 1393 title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1390 1394 else:
1391 1395 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1392 1396 axes = self.axesList[i*self.__nsubplots]
1393 1397 SNRavgdB = SNRavgdB.reshape((1,-1))
1394 1398
1395 1399 axes.pcolorbuffer(x, y, SNRavgdB,
1396 1400 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1397 1401 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1398 1402 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1399 1403
1400 1404 self.draw()
1401 1405
1402 1406 if x[1] >= self.axesList[0].xmax:
1403 1407 self.counter_imagwr = wr_period
1404 1408 self.isConfig = False
1405 1409 self.figfile = None
1406 1410
1407 1411
1408 1412
1409 1413
1410 1414 class PhasePlot(Figure):
1411 1415
1412 1416 __isConfig = None
1413 1417 __nsubplots = None
1414 1418
1415 1419 PREFIX = 'mphase'
1416 1420
1417 1421 def __init__(self):
1418 1422
1419 1423 self.timerange = 24*60*60
1420 1424 self.isConfig = False
1421 1425 self.__nsubplots = 1
1422 1426 self.counter_imagwr = 0
1423 1427 self.WIDTH = 600
1424 1428 self.HEIGHT = 300
1425 1429 self.WIDTHPROF = 120
1426 1430 self.HEIGHTPROF = 0
1427 1431 self.xdata = None
1428 1432 self.ydata = None
1429 1433
1430 1434 self.PLOT_CODE = MPHASE_CODE
1431 1435
1432 1436 self.FTP_WEI = None
1433 1437 self.EXP_CODE = None
1434 1438 self.SUB_EXP_CODE = None
1435 1439 self.PLOT_POS = None
1436 1440
1437 1441
1438 1442 self.filename_phase = None
1439 1443
1440 1444 self.figfile = None
1441 1445
1442 1446 def getSubplots(self):
1443 1447
1444 1448 ncol = 1
1445 1449 nrow = 1
1446 1450
1447 1451 return nrow, ncol
1448 1452
1449 1453 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1450 1454
1451 1455 self.__showprofile = showprofile
1452 1456 self.nplots = nplots
1453 1457
1454 1458 ncolspan = 7
1455 1459 colspan = 6
1456 1460 self.__nsubplots = 2
1457 1461
1458 1462 self.createFigure(id = id,
1459 1463 wintitle = wintitle,
1460 1464 widthplot = self.WIDTH+self.WIDTHPROF,
1461 1465 heightplot = self.HEIGHT+self.HEIGHTPROF,
1462 1466 show=show)
1463 1467
1464 1468 nrow, ncol = self.getSubplots()
1465 1469
1466 1470 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1467 1471
1468 1472
1469 1473 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1470 1474 xmin=None, xmax=None, ymin=None, ymax=None,
1471 1475 timerange=None,
1472 1476 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1473 1477 server=None, folder=None, username=None, password=None,
1474 1478 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1475 1479
1476 1480
1477 1481 tmin = None
1478 1482 tmax = None
1479 1483 x = dataOut.getTimeRange1(dataOut.outputInterval)
1480 1484 y = dataOut.getHeiRange()
1481 1485
1482 1486
1483 1487 #thisDatetime = dataOut.datatime
1484 1488 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1485 1489 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1486 1490 xlabel = "Local Time"
1487 1491 ylabel = "Phase"
1488 1492
1489 1493
1490 1494 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1491 1495 phase_beacon = dataOut.data_output
1492 1496 update_figfile = False
1493 1497
1494 1498 if not self.isConfig:
1495 1499
1496 1500 self.nplots = phase_beacon.size
1497 1501
1498 1502 self.setup(id=id,
1499 1503 nplots=self.nplots,
1500 1504 wintitle=wintitle,
1501 1505 showprofile=showprofile,
1502 1506 show=show)
1503 1507
1504 1508 if timerange is not None:
1505 1509 self.timerange = timerange
1506 1510
1507 1511 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1508 1512
1509 1513 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1510 1514 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1511 1515
1512 1516 self.FTP_WEI = ftp_wei
1513 1517 self.EXP_CODE = exp_code
1514 1518 self.SUB_EXP_CODE = sub_exp_code
1515 1519 self.PLOT_POS = plot_pos
1516 1520
1517 1521 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1518 1522 self.isConfig = True
1519 1523 self.figfile = figfile
1520 1524 self.xdata = numpy.array([])
1521 1525 self.ydata = numpy.array([])
1522 1526
1523 1527 #open file beacon phase
1524 1528 path = '%s%03d' %(self.PREFIX, self.id)
1525 1529 beacon_file = os.path.join(path,'%s.txt'%self.name)
1526 1530 self.filename_phase = os.path.join(figpath,beacon_file)
1527 1531 update_figfile = True
1528 1532
1529 1533
1530 1534 #store data beacon phase
1531 1535 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1532 1536
1533 1537 self.setWinTitle(title)
1534 1538
1535 1539
1536 1540 title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1537 1541
1538 1542 legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)]
1539 1543
1540 1544 axes = self.axesList[0]
1541 1545
1542 1546 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1543 1547
1544 1548 if len(self.ydata)==0:
1545 1549 self.ydata = phase_beacon.reshape(-1,1)
1546 1550 else:
1547 1551 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1548 1552
1549 1553
1550 1554 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1551 1555 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1552 1556 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1553 1557 XAxisAsTime=True, grid='both'
1554 1558 )
1555 1559
1556 1560 self.draw()
1557 1561
1558 1562 if dataOut.ltctime >= self.xmax:
1559 1563 self.counter_imagwr = wr_period
1560 1564 self.isConfig = False
1561 1565 update_figfile = True
1562 1566
1563 1567 self.save(figpath=figpath,
1564 1568 figfile=figfile,
1565 1569 save=save,
1566 1570 ftp=ftp,
1567 1571 wr_period=wr_period,
1568 1572 thisDatetime=thisDatetime,
1569 1573 update_figfile=update_figfile)
1574
1575
1576 class NSMeteorDetection1Plot(Figure):
1577
1578 isConfig = None
1579 __nsubplots = None
1580
1581 WIDTHPROF = None
1582 HEIGHTPROF = None
1583 PREFIX = 'nsm'
1584
1585 zminList = None
1586 zmaxList = None
1587 cmapList = None
1588 titleList = None
1589 nPairs = None
1590 nChannels = None
1591 nParam = None
1592
1593 def __init__(self):
1594
1595 self.isConfig = False
1596 self.__nsubplots = 1
1597
1598 self.WIDTH = 750
1599 self.HEIGHT = 250
1600 self.WIDTHPROF = 120
1601 self.HEIGHTPROF = 0
1602 self.counter_imagwr = 0
1603
1604 self.PLOT_CODE = SPEC_CODE
1605
1606 self.FTP_WEI = None
1607 self.EXP_CODE = None
1608 self.SUB_EXP_CODE = None
1609 self.PLOT_POS = None
1610
1611 self.__xfilter_ena = False
1612 self.__yfilter_ena = False
1613
1614 def getSubplots(self):
1615
1616 ncol = 3
1617 nrow = int(numpy.ceil(self.nplots/3.0))
1618
1619 return nrow, ncol
1620
1621 def setup(self, id, nplots, wintitle, show=True):
1622
1623 self.nplots = nplots
1624
1625 ncolspan = 1
1626 colspan = 1
1627
1628 self.createFigure(id = id,
1629 wintitle = wintitle,
1630 widthplot = self.WIDTH + self.WIDTHPROF,
1631 heightplot = self.HEIGHT + self.HEIGHTPROF,
1632 show=show)
1633
1634 nrow, ncol = self.getSubplots()
1635
1636 counter = 0
1637 for y in range(nrow):
1638 for x in range(ncol):
1639
1640 if counter >= self.nplots:
1641 break
1642
1643 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1644
1645 counter += 1
1646
1647 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
1648 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
1649 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
1650 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1651 server=None, folder=None, username=None, password=None,
1652 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
1653 xaxis="frequency"):
1654
1655 """
1656
1657 Input:
1658 dataOut :
1659 id :
1660 wintitle :
1661 channelList :
1662 showProfile :
1663 xmin : None,
1664 xmax : None,
1665 ymin : None,
1666 ymax : None,
1667 zmin : None,
1668 zmax : None
1669 """
1670 #SEPARAR EN DOS PLOTS
1671 nParam = dataOut.data_param.shape[1] - 3
1672
1673 utctime = dataOut.data_param[0,0]
1674 tmet = dataOut.data_param[:,1].astype(int)
1675 hmet = dataOut.data_param[:,2].astype(int)
1676
1677 x = dataOut.abscissaList
1678 y = dataOut.heightList
1679
1680 z = numpy.zeros((nParam, y.size, x.size - 1))
1681 z[:,:] = numpy.nan
1682 z[:,hmet,tmet] = dataOut.data_param[:,3:].T
1683 z[0,:,:] = 10*numpy.log10(z[0,:,:])
1684
1685 xlabel = "Time (s)"
1686 ylabel = "Range (km)"
1687
1688 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1689
1690 if not self.isConfig:
1691
1692 nplots = nParam
1693
1694 self.setup(id=id,
1695 nplots=nplots,
1696 wintitle=wintitle,
1697 show=show)
1698
1699 if xmin is None: xmin = numpy.nanmin(x)
1700 if xmax is None: xmax = numpy.nanmax(x)
1701 if ymin is None: ymin = numpy.nanmin(y)
1702 if ymax is None: ymax = numpy.nanmax(y)
1703 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
1704 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
1705 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
1706 if vmin is None: vmin = -vmax
1707 if wmin is None: wmin = 0
1708 if wmax is None: wmax = 50
1709
1710 pairsList = dataOut.groupList
1711 self.nPairs = len(dataOut.groupList)
1712
1713 zminList = [SNRmin, vmin, cmin] + [pmin]*self.nPairs
1714 zmaxList = [SNRmax, vmax, cmax] + [pmax]*self.nPairs
1715 titleList = ["SNR","Radial Velocity","Coherence"]
1716 cmapList = ["jet","RdBu_r","jet"]
1717
1718 for i in range(self.nPairs):
1719 strAux1 = "Phase Difference "+ str(pairsList[i][0]) + str(pairsList[i][1])
1720 titleList = titleList + [strAux1]
1721 cmapList = cmapList + ["RdBu_r"]
1722
1723 self.zminList = zminList
1724 self.zmaxList = zmaxList
1725 self.cmapList = cmapList
1726 self.titleList = titleList
1727
1728 self.FTP_WEI = ftp_wei
1729 self.EXP_CODE = exp_code
1730 self.SUB_EXP_CODE = sub_exp_code
1731 self.PLOT_POS = plot_pos
1732
1733 self.isConfig = True
1734
1735 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1736
1737 for i in range(nParam):
1738 title = self.titleList[i] + ": " +str_datetime
1739 axes = self.axesList[i]
1740 axes.pcolor(x, y, z[i,:].T,
1741 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
1742 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
1743 self.draw()
1744
1745 if figfile == None:
1746 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
1747 name = str_datetime
1748 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1749 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
1750 figfile = self.getFilename(name)
1751
1752 self.save(figpath=figpath,
1753 figfile=figfile,
1754 save=save,
1755 ftp=ftp,
1756 wr_period=wr_period,
1757 thisDatetime=thisDatetime)
1758
1759
1760 class NSMeteorDetection2Plot(Figure):
1761
1762 isConfig = None
1763 __nsubplots = None
1764
1765 WIDTHPROF = None
1766 HEIGHTPROF = None
1767 PREFIX = 'nsm'
1768
1769 zminList = None
1770 zmaxList = None
1771 cmapList = None
1772 titleList = None
1773 nPairs = None
1774 nChannels = None
1775 nParam = None
1776
1777 def __init__(self):
1778
1779 self.isConfig = False
1780 self.__nsubplots = 1
1781
1782 self.WIDTH = 750
1783 self.HEIGHT = 250
1784 self.WIDTHPROF = 120
1785 self.HEIGHTPROF = 0
1786 self.counter_imagwr = 0
1787
1788 self.PLOT_CODE = SPEC_CODE
1789
1790 self.FTP_WEI = None
1791 self.EXP_CODE = None
1792 self.SUB_EXP_CODE = None
1793 self.PLOT_POS = None
1794
1795 self.__xfilter_ena = False
1796 self.__yfilter_ena = False
1797
1798 def getSubplots(self):
1799
1800 ncol = 3
1801 nrow = int(numpy.ceil(self.nplots/3.0))
1802
1803 return nrow, ncol
1804
1805 def setup(self, id, nplots, wintitle, show=True):
1806
1807 self.nplots = nplots
1808
1809 ncolspan = 1
1810 colspan = 1
1811
1812 self.createFigure(id = id,
1813 wintitle = wintitle,
1814 widthplot = self.WIDTH + self.WIDTHPROF,
1815 heightplot = self.HEIGHT + self.HEIGHTPROF,
1816 show=show)
1817
1818 nrow, ncol = self.getSubplots()
1819
1820 counter = 0
1821 for y in range(nrow):
1822 for x in range(ncol):
1823
1824 if counter >= self.nplots:
1825 break
1826
1827 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1828
1829 counter += 1
1830
1831 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
1832 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
1833 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
1834 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1835 server=None, folder=None, username=None, password=None,
1836 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
1837 xaxis="frequency"):
1838
1839 """
1840
1841 Input:
1842 dataOut :
1843 id :
1844 wintitle :
1845 channelList :
1846 showProfile :
1847 xmin : None,
1848 xmax : None,
1849 ymin : None,
1850 ymax : None,
1851 zmin : None,
1852 zmax : None
1853 """
1854 #Rebuild matrix
1855 utctime = dataOut.data_param[0,0]
1856 cmet = dataOut.data_param[:,1].astype(int)
1857 tmet = dataOut.data_param[:,2].astype(int)
1858 hmet = dataOut.data_param[:,3].astype(int)
1859
1860 nParam = 3
1861 nChan = len(dataOut.groupList)
1862 x = dataOut.abscissaList
1863 y = dataOut.heightList
1864
1865 z = numpy.full((nChan, nParam, y.size, x.size - 1),numpy.nan)
1866 z[cmet,:,hmet,tmet] = dataOut.data_param[:,4:]
1867 z[:,0,:,:] = 10*numpy.log10(z[:,0,:,:]) #logarithmic scale
1868 z = numpy.reshape(z, (nChan*nParam, y.size, x.size-1))
1869
1870 xlabel = "Time (s)"
1871 ylabel = "Range (km)"
1872
1873 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1874
1875 if not self.isConfig:
1876
1877 nplots = nParam*nChan
1878
1879 self.setup(id=id,
1880 nplots=nplots,
1881 wintitle=wintitle,
1882 show=show)
1883
1884 if xmin is None: xmin = numpy.nanmin(x)
1885 if xmax is None: xmax = numpy.nanmax(x)
1886 if ymin is None: ymin = numpy.nanmin(y)
1887 if ymax is None: ymax = numpy.nanmax(y)
1888 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
1889 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
1890 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
1891 if vmin is None: vmin = -vmax
1892 if wmin is None: wmin = 0
1893 if wmax is None: wmax = 50
1894
1895 self.nChannels = nChan
1896
1897 zminList = []
1898 zmaxList = []
1899 titleList = []
1900 cmapList = []
1901 for i in range(self.nChannels):
1902 strAux1 = "SNR Channel "+ str(i)
1903 strAux2 = "Radial Velocity Channel "+ str(i)
1904 strAux3 = "Spectral Width Channel "+ str(i)
1905
1906 titleList = titleList + [strAux1,strAux2,strAux3]
1907 cmapList = cmapList + ["jet","RdBu_r","jet"]
1908 zminList = zminList + [SNRmin,vmin,wmin]
1909 zmaxList = zmaxList + [SNRmax,vmax,wmax]
1910
1911 self.zminList = zminList
1912 self.zmaxList = zmaxList
1913 self.cmapList = cmapList
1914 self.titleList = titleList
1915
1916 self.FTP_WEI = ftp_wei
1917 self.EXP_CODE = exp_code
1918 self.SUB_EXP_CODE = sub_exp_code
1919 self.PLOT_POS = plot_pos
1920
1921 self.isConfig = True
1922
1923 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1924
1925 for i in range(self.nplots):
1926 title = self.titleList[i] + ": " +str_datetime
1927 axes = self.axesList[i]
1928 axes.pcolor(x, y, z[i,:].T,
1929 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
1930 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
1931 self.draw()
1932
1933 if figfile == None:
1934 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
1935 name = str_datetime
1936 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1937 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
1938 figfile = self.getFilename(name)
1939
1940 self.save(figpath=figpath,
1941 figfile=figfile,
1942 save=save,
1943 ftp=ftp,
1944 wr_period=wr_period,
1945 thisDatetime=thisDatetime)
1946
1947
General Comments 0
You need to be logged in to leave comments. Login now