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