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