##// END OF EJS Templates
SkyMap new feature: tmin and tmax selection
Julio Valdez -
r787:20654310af23
parent child
Show More
@@ -1,1372 +1,1373
1 1 import os
2 2 import datetime
3 3 import numpy
4 4
5 5 from figure import Figure, isRealtime
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=None, tmax=None, 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[0,:]
276 276 error = arrayParameters[:,-1]
277 277 indValid = numpy.where(error == 0)[0]
278 278 finalMeteor = arrayParameters[indValid,:]
279 279 finalAzimuth = finalMeteor[:,4]
280 280 finalZenith = finalMeteor[:,5]
281 281
282 282 x = finalAzimuth*numpy.pi/180
283 283 y = finalZenith
284 284 x1 = dataOut.getTimeRange()
285 285
286 286 #thisDatetime = dataOut.datatime
287 287 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
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 self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange)
303 if self.xmin is None and self.xmax is None:
304 self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange)
304 305
305 306 if timerange != None:
306 307 self.timerange = timerange
307 308 else:
308 309 self.timerange = self.xmax - self.xmin
309 310
310 311 self.FTP_WEI = ftp_wei
311 312 self.EXP_CODE = exp_code
312 313 self.SUB_EXP_CODE = sub_exp_code
313 314 self.PLOT_POS = plot_pos
314 315 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
315 316 self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
316 317 self.__isConfig = True
317 318 update_figfile = True
318 319
319 320 self.setWinTitle(title)
320 321
321 322 i = 0
322 323 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
323 324
324 325 axes = self.axesList[i*self.__nsubplots]
325 326 nevents = axes.x_buffer.shape[0] + x.shape[0]
326 327 title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents)
327 328 axes.polar(x, y,
328 329 title=title, xlabel=xlabel, ylabel=ylabel,
329 330 ticksize=9, cblabel='')
330 331
331 332 self.draw()
332 333
333 334 self.save(figpath=figpath,
334 335 figfile=figfile,
335 336 save=save,
336 337 ftp=ftp,
337 338 wr_period=wr_period,
338 339 thisDatetime=thisDatetime,
339 340 update_figfile=update_figfile)
340 341
341 342 if dataOut.ltctime >= self.xmax:
342 343 self.counter_imagwr = wr_period
343 344 self.__isConfig = False
344 345 update_figfile = True
345 346 axes.__firsttime = True
346 347 self.xmin += self.timerange
347 348 self.xmax += self.timerange
348 349
349 350
350 351
351 352
352 353 class WindProfilerPlot(Figure):
353 354
354 355 __isConfig = None
355 356 __nsubplots = None
356 357
357 358 WIDTHPROF = None
358 359 HEIGHTPROF = None
359 360 PREFIX = 'wind'
360 361
361 362 def __init__(self):
362 363
363 364 self.timerange = None
364 365 self.__isConfig = False
365 366 self.__nsubplots = 1
366 367
367 368 self.WIDTH = 800
368 369 self.HEIGHT = 150
369 370 self.WIDTHPROF = 120
370 371 self.HEIGHTPROF = 0
371 372 self.counter_imagwr = 0
372 373
373 374 self.PLOT_CODE = WIND_CODE
374 375
375 376 self.FTP_WEI = None
376 377 self.EXP_CODE = None
377 378 self.SUB_EXP_CODE = None
378 379 self.PLOT_POS = None
379 380 self.tmin = None
380 381 self.tmax = None
381 382
382 383 self.xmin = None
383 384 self.xmax = None
384 385
385 386 self.figfile = None
386 387
387 388 def getSubplots(self):
388 389
389 390 ncol = 1
390 391 nrow = self.nplots
391 392
392 393 return nrow, ncol
393 394
394 395 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
395 396
396 397 self.__showprofile = showprofile
397 398 self.nplots = nplots
398 399
399 400 ncolspan = 1
400 401 colspan = 1
401 402
402 403 self.createFigure(id = id,
403 404 wintitle = wintitle,
404 405 widthplot = self.WIDTH + self.WIDTHPROF,
405 406 heightplot = self.HEIGHT + self.HEIGHTPROF,
406 407 show=show)
407 408
408 409 nrow, ncol = self.getSubplots()
409 410
410 411 counter = 0
411 412 for y in range(nrow):
412 413 if counter >= self.nplots:
413 414 break
414 415
415 416 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
416 417 counter += 1
417 418
418 419 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False',
419 420 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
420 421 zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None,
421 422 timerange=None, SNRthresh = None,
422 423 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
423 424 server=None, folder=None, username=None, password=None,
424 425 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
425 426 """
426 427
427 428 Input:
428 429 dataOut :
429 430 id :
430 431 wintitle :
431 432 channelList :
432 433 showProfile :
433 434 xmin : None,
434 435 xmax : None,
435 436 ymin : None,
436 437 ymax : None,
437 438 zmin : None,
438 439 zmax : None
439 440 """
440 441
441 442 if channelList == None:
442 443 channelIndexList = dataOut.channelIndexList
443 444 else:
444 445 channelIndexList = []
445 446 for channel in channelList:
446 447 if channel not in dataOut.channelList:
447 448 raise ValueError, "Channel %d is not in dataOut.channelList"
448 449 channelIndexList.append(dataOut.channelList.index(channel))
449 450
450 451 # if timerange is not None:
451 452 # self.timerange = timerange
452 453 #
453 454 # tmin = None
454 455 # tmax = None
455 456
456 457 x = dataOut.getTimeRange1()
457 458 # y = dataOut.heightList
458 459 y = dataOut.heightList
459 460
460 461 z = dataOut.data_output.copy()
461 462 nplots = z.shape[0] #Number of wind dimensions estimated
462 463 nplotsw = nplots
463 464
464 465 #If there is a SNR function defined
465 466 if dataOut.data_SNR is not None:
466 467 nplots += 1
467 468 SNR = dataOut.data_SNR
468 469 SNRavg = numpy.average(SNR, axis=0)
469 470
470 471 SNRdB = 10*numpy.log10(SNR)
471 472 SNRavgdB = 10*numpy.log10(SNRavg)
472 473
473 474 if SNRthresh == None: SNRthresh = -5.0
474 475 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
475 476
476 477 for i in range(nplotsw):
477 478 z[i,ind] = numpy.nan
478 479
479 480
480 481 # showprofile = False
481 482 # thisDatetime = dataOut.datatime
482 483 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
483 484 title = wintitle + "Wind"
484 485 xlabel = ""
485 486 ylabel = "Range (Km)"
486 487 update_figfile = False
487 488
488 489 if not self.__isConfig:
489 490
490 491 self.setup(id=id,
491 492 nplots=nplots,
492 493 wintitle=wintitle,
493 494 showprofile=showprofile,
494 495 show=show)
495 496
496 497 if timerange is not None:
497 498 self.timerange = timerange
498 499
499 500 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
500 501
501 502 if ymin == None: ymin = numpy.nanmin(y)
502 503 if ymax == None: ymax = numpy.nanmax(y)
503 504
504 505 if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:]))
505 506 #if numpy.isnan(zmax): zmax = 50
506 507 if zmin == None: zmin = -zmax
507 508
508 509 if nplotsw == 3:
509 510 if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:]))
510 511 if zmin_ver == None: zmin_ver = -zmax_ver
511 512
512 513 if dataOut.data_SNR is not None:
513 514 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
514 515 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
515 516
516 517
517 518 self.FTP_WEI = ftp_wei
518 519 self.EXP_CODE = exp_code
519 520 self.SUB_EXP_CODE = sub_exp_code
520 521 self.PLOT_POS = plot_pos
521 522
522 523 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
523 524 self.__isConfig = True
524 525 self.figfile = figfile
525 526 update_figfile = True
526 527
527 528 self.setWinTitle(title)
528 529
529 530 if ((self.xmax - x[1]) < (x[1]-x[0])):
530 531 x[1] = self.xmax
531 532
532 533 strWind = ['Zonal', 'Meridional', 'Vertical']
533 534 strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
534 535 zmaxVector = [zmax, zmax, zmax_ver]
535 536 zminVector = [zmin, zmin, zmin_ver]
536 537 windFactor = [1,1,100]
537 538
538 539 for i in range(nplotsw):
539 540
540 541 title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
541 542 axes = self.axesList[i*self.__nsubplots]
542 543
543 544 z1 = z[i,:].reshape((1,-1))*windFactor[i]
544 545
545 546 axes.pcolorbuffer(x, y, z1,
546 547 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
547 548 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
548 549 ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" )
549 550
550 551 if dataOut.data_SNR is not None:
551 552 i += 1
552 553 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
553 554 axes = self.axesList[i*self.__nsubplots]
554 555
555 556 SNRavgdB = SNRavgdB.reshape((1,-1))
556 557
557 558 axes.pcolorbuffer(x, y, SNRavgdB,
558 559 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
559 560 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
560 561 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
561 562
562 563 self.draw()
563 564
564 565 if dataOut.ltctime >= self.xmax:
565 566 self.counter_imagwr = wr_period
566 567 self.__isConfig = False
567 568 update_figfile = True
568 569
569 570 self.save(figpath=figpath,
570 571 figfile=figfile,
571 572 save=save,
572 573 ftp=ftp,
573 574 wr_period=wr_period,
574 575 thisDatetime=thisDatetime,
575 576 update_figfile=update_figfile)
576 577
577 578
578 579
579 580 class ParametersPlot(Figure):
580 581
581 582 __isConfig = None
582 583 __nsubplots = None
583 584
584 585 WIDTHPROF = None
585 586 HEIGHTPROF = None
586 587 PREFIX = 'prm'
587 588
588 589 def __init__(self):
589 590
590 591 self.timerange = 2*60*60
591 592 self.__isConfig = False
592 593 self.__nsubplots = 1
593 594
594 595 self.WIDTH = 800
595 596 self.HEIGHT = 150
596 597 self.WIDTHPROF = 120
597 598 self.HEIGHTPROF = 0
598 599 self.counter_imagwr = 0
599 600
600 601 self.PLOT_CODE = PARMS_CODE
601 602
602 603 self.FTP_WEI = None
603 604 self.EXP_CODE = None
604 605 self.SUB_EXP_CODE = None
605 606 self.PLOT_POS = None
606 607 self.tmin = None
607 608 self.tmax = None
608 609
609 610 self.xmin = None
610 611 self.xmax = None
611 612
612 613 self.figfile = None
613 614
614 615 def getSubplots(self):
615 616
616 617 ncol = 1
617 618 nrow = self.nplots
618 619
619 620 return nrow, ncol
620 621
621 622 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
622 623
623 624 self.__showprofile = showprofile
624 625 self.nplots = nplots
625 626
626 627 ncolspan = 1
627 628 colspan = 1
628 629
629 630 self.createFigure(id = id,
630 631 wintitle = wintitle,
631 632 widthplot = self.WIDTH + self.WIDTHPROF,
632 633 heightplot = self.HEIGHT + self.HEIGHTPROF,
633 634 show=show)
634 635
635 636 nrow, ncol = self.getSubplots()
636 637
637 638 counter = 0
638 639 for y in range(nrow):
639 640 for x in range(ncol):
640 641
641 642 if counter >= self.nplots:
642 643 break
643 644
644 645 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
645 646
646 647 if showprofile:
647 648 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
648 649
649 650 counter += 1
650 651
651 652 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
652 653 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None,
653 654 parameterIndex = None, onlyPositive = False,
654 655 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False,
655 656 DOP = True,
656 657 zlabel = "", parameterName = "", parameterObject = "data_param",
657 658 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
658 659 server=None, folder=None, username=None, password=None,
659 660 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
660 661
661 662 """
662 663
663 664 Input:
664 665 dataOut :
665 666 id :
666 667 wintitle :
667 668 channelList :
668 669 showProfile :
669 670 xmin : None,
670 671 xmax : None,
671 672 ymin : None,
672 673 ymax : None,
673 674 zmin : None,
674 675 zmax : None
675 676 """
676 677
677 678 data_param = getattr(dataOut, parameterObject)
678 679
679 680 if channelList == None:
680 681 channelIndexList = numpy.arange(data_param.shape[0])
681 682 else:
682 683 channelIndexList = numpy.array(channelList)
683 684
684 685 nchan = len(channelIndexList) #Number of channels being plotted
685 686
686 687 if nchan < 1:
687 688 return
688 689
689 690 nGraphsByChannel = 0
690 691
691 692 if SNR:
692 693 nGraphsByChannel += 1
693 694 if DOP:
694 695 nGraphsByChannel += 1
695 696
696 697 if nGraphsByChannel < 1:
697 698 return
698 699
699 700 nplots = nGraphsByChannel*nchan
700 701
701 702 if timerange is not None:
702 703 self.timerange = timerange
703 704
704 705 #tmin = None
705 706 #tmax = None
706 707 if parameterIndex == None:
707 708 parameterIndex = 1
708 709
709 710 x = dataOut.getTimeRange1()
710 711 y = dataOut.heightList
711 712 z = data_param[channelIndexList,parameterIndex,:].copy()
712 713
713 714 zRange = dataOut.abscissaList
714 715 # nChannels = z.shape[0] #Number of wind dimensions estimated
715 716 # thisDatetime = dataOut.datatime
716 717
717 718 if dataOut.data_SNR is not None:
718 719 SNRarray = dataOut.data_SNR[channelIndexList,:]
719 720 SNRdB = 10*numpy.log10(SNRarray)
720 721 # SNRavgdB = 10*numpy.log10(SNRavg)
721 722 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
722 723 z[ind] = numpy.nan
723 724
724 725 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
725 726 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
726 727 xlabel = ""
727 728 ylabel = "Range (Km)"
728 729
729 730 if (SNR and not onlySNR): nplots = 2*nplots
730 731
731 732 if onlyPositive:
732 733 colormap = "jet"
733 734 zmin = 0
734 735 else: colormap = "RdBu_r"
735 736
736 737 if not self.__isConfig:
737 738
738 739 self.setup(id=id,
739 740 nplots=nplots,
740 741 wintitle=wintitle,
741 742 showprofile=showprofile,
742 743 show=show)
743 744
744 745 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
745 746
746 747 if ymin == None: ymin = numpy.nanmin(y)
747 748 if ymax == None: ymax = numpy.nanmax(y)
748 749 if zmin == None: zmin = numpy.nanmin(zRange)
749 750 if zmax == None: zmax = numpy.nanmax(zRange)
750 751
751 752 if SNR:
752 753 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
753 754 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
754 755
755 756 self.FTP_WEI = ftp_wei
756 757 self.EXP_CODE = exp_code
757 758 self.SUB_EXP_CODE = sub_exp_code
758 759 self.PLOT_POS = plot_pos
759 760
760 761 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
761 762 self.__isConfig = True
762 763 self.figfile = figfile
763 764
764 765 self.setWinTitle(title)
765 766
766 767 if ((self.xmax - x[1]) < (x[1]-x[0])):
767 768 x[1] = self.xmax
768 769
769 770 for i in range(nchan):
770 771
771 772 if (SNR and not onlySNR): j = 2*i
772 773 else: j = i
773 774
774 775 j = nGraphsByChannel*i
775 776
776 777 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
777 778 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
778 779
779 780 if not onlySNR:
780 781 axes = self.axesList[j*self.__nsubplots]
781 782 z1 = z[i,:].reshape((1,-1))
782 783 axes.pcolorbuffer(x, y, z1,
783 784 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
784 785 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
785 786 ticksize=9, cblabel=zlabel, cbsize="1%")
786 787
787 788 if DOP:
788 789 title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
789 790
790 791 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
791 792 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
792 793 axes = self.axesList[j]
793 794 z1 = z[i,:].reshape((1,-1))
794 795 axes.pcolorbuffer(x, y, z1,
795 796 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
796 797 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
797 798 ticksize=9, cblabel=zlabel, cbsize="1%")
798 799
799 800 if SNR:
800 801 title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
801 802 axes = self.axesList[(j)*self.__nsubplots]
802 803 if not onlySNR:
803 804 axes = self.axesList[(j + 1)*self.__nsubplots]
804 805
805 806 axes = self.axesList[(j + nGraphsByChannel-1)]
806 807
807 808 z1 = SNRdB[i,:].reshape((1,-1))
808 809 axes.pcolorbuffer(x, y, z1,
809 810 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
810 811 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet",
811 812 ticksize=9, cblabel=zlabel, cbsize="1%")
812 813
813 814
814 815
815 816 self.draw()
816 817
817 818 if x[1] >= self.axesList[0].xmax:
818 819 self.counter_imagwr = wr_period
819 820 self.__isConfig = False
820 821 self.figfile = None
821 822
822 823 self.save(figpath=figpath,
823 824 figfile=figfile,
824 825 save=save,
825 826 ftp=ftp,
826 827 wr_period=wr_period,
827 828 thisDatetime=thisDatetime,
828 829 update_figfile=False)
829 830
830 831 class SpectralFittingPlot(Figure):
831 832
832 833 __isConfig = None
833 834 __nsubplots = None
834 835
835 836 WIDTHPROF = None
836 837 HEIGHTPROF = None
837 838 PREFIX = 'prm'
838 839
839 840
840 841 N = None
841 842 ippSeconds = None
842 843
843 844 def __init__(self):
844 845 self.__isConfig = False
845 846 self.__nsubplots = 1
846 847
847 848 self.PLOT_CODE = SPECFIT_CODE
848 849
849 850 self.WIDTH = 450
850 851 self.HEIGHT = 250
851 852 self.WIDTHPROF = 0
852 853 self.HEIGHTPROF = 0
853 854
854 855 def getSubplots(self):
855 856
856 857 ncol = int(numpy.sqrt(self.nplots)+0.9)
857 858 nrow = int(self.nplots*1./ncol + 0.9)
858 859
859 860 return nrow, ncol
860 861
861 862 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
862 863
863 864 showprofile = False
864 865 self.__showprofile = showprofile
865 866 self.nplots = nplots
866 867
867 868 ncolspan = 5
868 869 colspan = 4
869 870 if showprofile:
870 871 ncolspan = 5
871 872 colspan = 4
872 873 self.__nsubplots = 2
873 874
874 875 self.createFigure(id = id,
875 876 wintitle = wintitle,
876 877 widthplot = self.WIDTH + self.WIDTHPROF,
877 878 heightplot = self.HEIGHT + self.HEIGHTPROF,
878 879 show=show)
879 880
880 881 nrow, ncol = self.getSubplots()
881 882
882 883 counter = 0
883 884 for y in range(nrow):
884 885 for x in range(ncol):
885 886
886 887 if counter >= self.nplots:
887 888 break
888 889
889 890 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
890 891
891 892 if showprofile:
892 893 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
893 894
894 895 counter += 1
895 896
896 897 def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True,
897 898 xmin=None, xmax=None, ymin=None, ymax=None,
898 899 save=False, figpath='./', figfile=None, show=True):
899 900
900 901 """
901 902
902 903 Input:
903 904 dataOut :
904 905 id :
905 906 wintitle :
906 907 channelList :
907 908 showProfile :
908 909 xmin : None,
909 910 xmax : None,
910 911 zmin : None,
911 912 zmax : None
912 913 """
913 914
914 915 if cutHeight==None:
915 916 h=270
916 917 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
917 918 cutHeight = dataOut.heightList[heightindex]
918 919
919 920 factor = dataOut.normFactor
920 921 x = dataOut.abscissaList[:-1]
921 922 #y = dataOut.getHeiRange()
922 923
923 924 z = dataOut.data_pre[:,:,heightindex]/factor
924 925 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
925 926 avg = numpy.average(z, axis=1)
926 927 listChannels = z.shape[0]
927 928
928 929 #Reconstruct Function
929 930 if fit==True:
930 931 groupArray = dataOut.groupList
931 932 listChannels = groupArray.reshape((groupArray.size))
932 933 listChannels.sort()
933 934 spcFitLine = numpy.zeros(z.shape)
934 935 constants = dataOut.constants
935 936
936 937 nGroups = groupArray.shape[0]
937 938 nChannels = groupArray.shape[1]
938 939 nProfiles = z.shape[1]
939 940
940 941 for f in range(nGroups):
941 942 groupChann = groupArray[f,:]
942 943 p = dataOut.data_param[f,:,heightindex]
943 944 # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167])
944 945 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
945 946 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
946 947 spcFitLine[groupChann,:] = fitLineAux
947 948 # spcFitLine = spcFitLine/factor
948 949
949 950 z = z[listChannels,:]
950 951 spcFitLine = spcFitLine[listChannels,:]
951 952 spcFitLinedB = 10*numpy.log10(spcFitLine)
952 953
953 954 zdB = 10*numpy.log10(z)
954 955 #thisDatetime = dataOut.datatime
955 956 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
956 957 title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
957 958 xlabel = "Velocity (m/s)"
958 959 ylabel = "Spectrum"
959 960
960 961 if not self.__isConfig:
961 962
962 963 nplots = listChannels.size
963 964
964 965 self.setup(id=id,
965 966 nplots=nplots,
966 967 wintitle=wintitle,
967 968 showprofile=showprofile,
968 969 show=show)
969 970
970 971 if xmin == None: xmin = numpy.nanmin(x)
971 972 if xmax == None: xmax = numpy.nanmax(x)
972 973 if ymin == None: ymin = numpy.nanmin(zdB)
973 974 if ymax == None: ymax = numpy.nanmax(zdB)+2
974 975
975 976 self.__isConfig = True
976 977
977 978 self.setWinTitle(title)
978 979 for i in range(self.nplots):
979 980 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
980 981 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i])
981 982 axes = self.axesList[i*self.__nsubplots]
982 983 if fit == False:
983 984 axes.pline(x, zdB[i,:],
984 985 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
985 986 xlabel=xlabel, ylabel=ylabel, title=title
986 987 )
987 988 if fit == True:
988 989 fitline=spcFitLinedB[i,:]
989 990 y=numpy.vstack([zdB[i,:],fitline] )
990 991 legendlabels=['Data','Fitting']
991 992 axes.pmultilineyaxis(x, y,
992 993 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
993 994 xlabel=xlabel, ylabel=ylabel, title=title,
994 995 legendlabels=legendlabels, marker=None,
995 996 linestyle='solid', grid='both')
996 997
997 998 self.draw()
998 999
999 1000 self.save(figpath=figpath,
1000 1001 figfile=figfile,
1001 1002 save=save,
1002 1003 ftp=ftp,
1003 1004 wr_period=wr_period,
1004 1005 thisDatetime=thisDatetime)
1005 1006
1006 1007
1007 1008 class EWDriftsPlot(Figure):
1008 1009
1009 1010 __isConfig = None
1010 1011 __nsubplots = None
1011 1012
1012 1013 WIDTHPROF = None
1013 1014 HEIGHTPROF = None
1014 1015 PREFIX = 'drift'
1015 1016
1016 1017 def __init__(self):
1017 1018
1018 1019 self.timerange = 2*60*60
1019 1020 self.isConfig = False
1020 1021 self.__nsubplots = 1
1021 1022
1022 1023 self.WIDTH = 800
1023 1024 self.HEIGHT = 150
1024 1025 self.WIDTHPROF = 120
1025 1026 self.HEIGHTPROF = 0
1026 1027 self.counter_imagwr = 0
1027 1028
1028 1029 self.PLOT_CODE = EWDRIFT_CODE
1029 1030
1030 1031 self.FTP_WEI = None
1031 1032 self.EXP_CODE = None
1032 1033 self.SUB_EXP_CODE = None
1033 1034 self.PLOT_POS = None
1034 1035 self.tmin = None
1035 1036 self.tmax = None
1036 1037
1037 1038 self.xmin = None
1038 1039 self.xmax = None
1039 1040
1040 1041 self.figfile = None
1041 1042
1042 1043 def getSubplots(self):
1043 1044
1044 1045 ncol = 1
1045 1046 nrow = self.nplots
1046 1047
1047 1048 return nrow, ncol
1048 1049
1049 1050 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1050 1051
1051 1052 self.__showprofile = showprofile
1052 1053 self.nplots = nplots
1053 1054
1054 1055 ncolspan = 1
1055 1056 colspan = 1
1056 1057
1057 1058 self.createFigure(id = id,
1058 1059 wintitle = wintitle,
1059 1060 widthplot = self.WIDTH + self.WIDTHPROF,
1060 1061 heightplot = self.HEIGHT + self.HEIGHTPROF,
1061 1062 show=show)
1062 1063
1063 1064 nrow, ncol = self.getSubplots()
1064 1065
1065 1066 counter = 0
1066 1067 for y in range(nrow):
1067 1068 if counter >= self.nplots:
1068 1069 break
1069 1070
1070 1071 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1071 1072 counter += 1
1072 1073
1073 1074 def run(self, dataOut, id, wintitle="", channelList=None,
1074 1075 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1075 1076 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1076 1077 timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False,
1077 1078 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1078 1079 server=None, folder=None, username=None, password=None,
1079 1080 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1080 1081 """
1081 1082
1082 1083 Input:
1083 1084 dataOut :
1084 1085 id :
1085 1086 wintitle :
1086 1087 channelList :
1087 1088 showProfile :
1088 1089 xmin : None,
1089 1090 xmax : None,
1090 1091 ymin : None,
1091 1092 ymax : None,
1092 1093 zmin : None,
1093 1094 zmax : None
1094 1095 """
1095 1096
1096 1097 if timerange is not None:
1097 1098 self.timerange = timerange
1098 1099
1099 1100 tmin = None
1100 1101 tmax = None
1101 1102
1102 1103 x = dataOut.getTimeRange1()
1103 1104 # y = dataOut.heightList
1104 1105 y = dataOut.heightList
1105 1106
1106 1107 z = dataOut.data_output
1107 1108 nplots = z.shape[0] #Number of wind dimensions estimated
1108 1109 nplotsw = nplots
1109 1110
1110 1111 #If there is a SNR function defined
1111 1112 if dataOut.data_SNR is not None:
1112 1113 nplots += 1
1113 1114 SNR = dataOut.data_SNR
1114 1115
1115 1116 if SNR_1:
1116 1117 SNR += 1
1117 1118
1118 1119 SNRavg = numpy.average(SNR, axis=0)
1119 1120
1120 1121 SNRdB = 10*numpy.log10(SNR)
1121 1122 SNRavgdB = 10*numpy.log10(SNRavg)
1122 1123
1123 1124 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1124 1125
1125 1126 for i in range(nplotsw):
1126 1127 z[i,ind] = numpy.nan
1127 1128
1128 1129
1129 1130 showprofile = False
1130 1131 # thisDatetime = dataOut.datatime
1131 1132 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1132 1133 title = wintitle + " EW Drifts"
1133 1134 xlabel = ""
1134 1135 ylabel = "Height (Km)"
1135 1136
1136 1137 if not self.__isConfig:
1137 1138
1138 1139 self.setup(id=id,
1139 1140 nplots=nplots,
1140 1141 wintitle=wintitle,
1141 1142 showprofile=showprofile,
1142 1143 show=show)
1143 1144
1144 1145 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1145 1146
1146 1147 if ymin == None: ymin = numpy.nanmin(y)
1147 1148 if ymax == None: ymax = numpy.nanmax(y)
1148 1149
1149 1150 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1150 1151 if zminZonal == None: zminZonal = -zmaxZonal
1151 1152 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1152 1153 if zminVertical == None: zminVertical = -zmaxVertical
1153 1154
1154 1155 if dataOut.data_SNR is not None:
1155 1156 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1156 1157 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1157 1158
1158 1159 self.FTP_WEI = ftp_wei
1159 1160 self.EXP_CODE = exp_code
1160 1161 self.SUB_EXP_CODE = sub_exp_code
1161 1162 self.PLOT_POS = plot_pos
1162 1163
1163 1164 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1164 1165 self.__isConfig = True
1165 1166
1166 1167
1167 1168 self.setWinTitle(title)
1168 1169
1169 1170 if ((self.xmax - x[1]) < (x[1]-x[0])):
1170 1171 x[1] = self.xmax
1171 1172
1172 1173 strWind = ['Zonal','Vertical']
1173 1174 strCb = 'Velocity (m/s)'
1174 1175 zmaxVector = [zmaxZonal, zmaxVertical]
1175 1176 zminVector = [zminZonal, zminVertical]
1176 1177
1177 1178 for i in range(nplotsw):
1178 1179
1179 1180 title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1180 1181 axes = self.axesList[i*self.__nsubplots]
1181 1182
1182 1183 z1 = z[i,:].reshape((1,-1))
1183 1184
1184 1185 axes.pcolorbuffer(x, y, z1,
1185 1186 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
1186 1187 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1187 1188 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1188 1189
1189 1190 if dataOut.data_SNR is not None:
1190 1191 i += 1
1191 1192 if SNR_1:
1192 1193 title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1193 1194 else:
1194 1195 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1195 1196 axes = self.axesList[i*self.__nsubplots]
1196 1197 SNRavgdB = SNRavgdB.reshape((1,-1))
1197 1198
1198 1199 axes.pcolorbuffer(x, y, SNRavgdB,
1199 1200 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1200 1201 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1201 1202 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1202 1203
1203 1204 self.draw()
1204 1205
1205 1206 if x[1] >= self.axesList[0].xmax:
1206 1207 self.counter_imagwr = wr_period
1207 1208 self.__isConfig = False
1208 1209 self.figfile = None
1209 1210
1210 1211
1211 1212
1212 1213
1213 1214 class PhasePlot(Figure):
1214 1215
1215 1216 __isConfig = None
1216 1217 __nsubplots = None
1217 1218
1218 1219 PREFIX = 'mphase'
1219 1220
1220 1221 def __init__(self):
1221 1222
1222 1223 self.timerange = 24*60*60
1223 1224 self.__isConfig = False
1224 1225 self.__nsubplots = 1
1225 1226 self.counter_imagwr = 0
1226 1227 self.WIDTH = 600
1227 1228 self.HEIGHT = 300
1228 1229 self.WIDTHPROF = 120
1229 1230 self.HEIGHTPROF = 0
1230 1231 self.xdata = None
1231 1232 self.ydata = None
1232 1233
1233 1234 self.PLOT_CODE = MPHASE_CODE
1234 1235
1235 1236 self.FTP_WEI = None
1236 1237 self.EXP_CODE = None
1237 1238 self.SUB_EXP_CODE = None
1238 1239 self.PLOT_POS = None
1239 1240
1240 1241
1241 1242 self.filename_phase = None
1242 1243
1243 1244 self.figfile = None
1244 1245
1245 1246 def getSubplots(self):
1246 1247
1247 1248 ncol = 1
1248 1249 nrow = 1
1249 1250
1250 1251 return nrow, ncol
1251 1252
1252 1253 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1253 1254
1254 1255 self.__showprofile = showprofile
1255 1256 self.nplots = nplots
1256 1257
1257 1258 ncolspan = 7
1258 1259 colspan = 6
1259 1260 self.__nsubplots = 2
1260 1261
1261 1262 self.createFigure(id = id,
1262 1263 wintitle = wintitle,
1263 1264 widthplot = self.WIDTH+self.WIDTHPROF,
1264 1265 heightplot = self.HEIGHT+self.HEIGHTPROF,
1265 1266 show=show)
1266 1267
1267 1268 nrow, ncol = self.getSubplots()
1268 1269
1269 1270 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1270 1271
1271 1272
1272 1273 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1273 1274 xmin=None, xmax=None, ymin=None, ymax=None,
1274 1275 timerange=None,
1275 1276 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1276 1277 server=None, folder=None, username=None, password=None,
1277 1278 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1278 1279
1279 1280
1280 1281 tmin = None
1281 1282 tmax = None
1282 1283 x = dataOut.getTimeRange1()
1283 1284 y = dataOut.getHeiRange()
1284 1285
1285 1286
1286 1287 #thisDatetime = dataOut.datatime
1287 1288 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1288 1289 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1289 1290 xlabel = "Local Time"
1290 1291 ylabel = "Phase"
1291 1292
1292 1293
1293 1294 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1294 1295 phase_beacon = dataOut.data_output
1295 1296 update_figfile = False
1296 1297
1297 1298 if not self.__isConfig:
1298 1299
1299 1300 self.nplots = phase_beacon.size
1300 1301
1301 1302 self.setup(id=id,
1302 1303 nplots=self.nplots,
1303 1304 wintitle=wintitle,
1304 1305 showprofile=showprofile,
1305 1306 show=show)
1306 1307
1307 1308 if timerange is not None:
1308 1309 self.timerange = timerange
1309 1310
1310 1311 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1311 1312
1312 1313 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1313 1314 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1314 1315
1315 1316 self.FTP_WEI = ftp_wei
1316 1317 self.EXP_CODE = exp_code
1317 1318 self.SUB_EXP_CODE = sub_exp_code
1318 1319 self.PLOT_POS = plot_pos
1319 1320
1320 1321 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1321 1322 self.__isConfig = True
1322 1323 self.figfile = figfile
1323 1324 self.xdata = numpy.array([])
1324 1325 self.ydata = numpy.array([])
1325 1326
1326 1327 #open file beacon phase
1327 1328 path = '%s%03d' %(self.PREFIX, self.id)
1328 1329 beacon_file = os.path.join(path,'%s.txt'%self.name)
1329 1330 self.filename_phase = os.path.join(figpath,beacon_file)
1330 1331 update_figfile = True
1331 1332
1332 1333
1333 1334 #store data beacon phase
1334 1335 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1335 1336
1336 1337 self.setWinTitle(title)
1337 1338
1338 1339
1339 1340 title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1340 1341
1341 1342 legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)]
1342 1343
1343 1344 axes = self.axesList[0]
1344 1345
1345 1346 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1346 1347
1347 1348 if len(self.ydata)==0:
1348 1349 self.ydata = phase_beacon.reshape(-1,1)
1349 1350 else:
1350 1351 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1351 1352
1352 1353
1353 1354 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1354 1355 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1355 1356 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1356 1357 XAxisAsTime=True, grid='both'
1357 1358 )
1358 1359
1359 1360 self.draw()
1360 1361
1361 1362 if dataOut.ltctime >= self.xmax:
1362 1363 self.counter_imagwr = wr_period
1363 1364 self.__isConfig = False
1364 1365 update_figfile = True
1365 1366
1366 1367 self.save(figpath=figpath,
1367 1368 figfile=figfile,
1368 1369 save=save,
1369 1370 ftp=ftp,
1370 1371 wr_period=wr_period,
1371 1372 thisDatetime=thisDatetime,
1372 1373 update_figfile=update_figfile)
General Comments 0
You need to be logged in to leave comments. Login now