##// END OF EJS Templates
Bug fixed plotting RTI, CoherenceMap, Noise and BeaconPhase: It were not working properly when xmin and xmax were defined and more than one day selected.
Miguel Valdez -
r760:4d4218b17f73
parent child
Show More
@@ -1,624 +1,655
1 1 import os
2 2 import numpy
3 3 import time, datetime
4 4 import mpldriver
5 5
6 6 from schainpy.model.proc.jroproc_base import Operation
7 7
8 def isTimeInHourRange(datatime, xmin, xmax):
9
10 if xmin == None or xmax == None:
11 return 1
12 hour = datatime.hour + datatime.minute/60.0
13
14 if xmin < (xmax % 24):
15
16 if hour >= xmin and hour <= xmax:
17 return 1
18 else:
19 return 0
20
21 else:
22
23 if hour >= xmin or hour <= (xmax % 24):
24 return 1
25 else:
26 return 0
27
28 return 0
29
8 30 def isRealtime(utcdatatime):
9 31
10 32 utcnow = time.mktime(time.localtime())
11 33 delta = abs(utcnow - utcdatatime) # abs
12 34 if delta >= 30.:
13 35 return False
14 36 return True
15 37
16 38 class Figure(Operation):
17 39
18 40 __driver = mpldriver
19 41 fig = None
20 42
21 43 id = None
22 44 wintitle = None
23 45 width = None
24 46 height = None
25 47 nplots = None
26 48 timerange = None
27 49
28 50 axesObjList = []
29 51
30 52 WIDTH = 300
31 53 HEIGHT = 200
32 54 PREFIX = 'fig'
33 55
34 56 xmin = None
35 57 xmax = None
36 58
37 59 counter_imagwr = 0
38 60
39 61 figfile = None
40 62
63 created = False
64
41 65 def __init__(self):
42 66
43 67 raise NotImplementedError
44 68
45 69 def __del__(self):
46 70
47 71 self.__driver.closeFigure()
48 72
49 73 def getFilename(self, name, ext='.png'):
50 74
51 75 path = '%s%03d' %(self.PREFIX, self.id)
52 76 filename = '%s_%s%s' %(self.PREFIX, name, ext)
53 77 return os.path.join(path, filename)
54 78
55 79 def getAxesObjList(self):
56 80
57 81 return self.axesObjList
58 82
59 83 def getSubplots(self):
60 84
61 85 raise NotImplementedError
62 86
63 87 def getScreenDim(self, widthplot, heightplot):
64 88
65 89 nrow, ncol = self.getSubplots()
66 90
67 91 widthscreen = widthplot*ncol
68 92 heightscreen = heightplot*nrow
69 93
70 94 return widthscreen, heightscreen
71 95
72 96 def getTimeLim(self, x, xmin=None, xmax=None, timerange=None):
73 97
74 if self.xmin != None and self.xmax != None:
75 if timerange == None:
76 timerange = self.xmax - self.xmin
77 xmin = self.xmin + timerange
78 xmax = self.xmax + timerange
79
80 return xmin, xmax
98 # if self.xmin != None and self.xmax != None:
99 # if timerange == None:
100 # timerange = self.xmax - self.xmin
101 # xmin = self.xmin + timerange
102 # xmax = self.xmax + timerange
103 #
104 # return xmin, xmax
81 105
82 106 if timerange == None and (xmin==None or xmax==None):
83 107 timerange = 14400 #seconds
84 108
85 109 if timerange != None:
86 110 txmin = x[0] #- x[0] % min(timerange/10, 10*60)
87 111 else:
88 112 txmin = x[0] #- x[0] % 10*60
89 113
90 114 thisdatetime = datetime.datetime.utcfromtimestamp(txmin)
91 115 thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0))
92 116
93 117 if timerange != None:
94 118 xmin = (thisdatetime - thisdate).seconds/(60*60.)
95 119 xmax = xmin + timerange/(60*60.)
96 120
97 121 mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone)
98 122 xmin_sec = time.mktime(mindt.timetuple())
99 123
100 124 maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone)
101 125 xmax_sec = time.mktime(maxdt.timetuple())
102 126
103 127 return xmin_sec, xmax_sec
104 128
105 129 def init(self, id, nplots, wintitle):
106 130
107 131 raise NotImplementedError, "This method has been replaced with createFigure"
108 132
109 133 def createFigure(self, id, wintitle, widthplot=None, heightplot=None, show=True):
110 134
111 135 """
112 136 Crea la figura de acuerdo al driver y parametros seleccionados seleccionados.
113 137 Las dimensiones de la pantalla es calculada a partir de los atributos self.WIDTH
114 138 y self.HEIGHT y el numero de subplots (nrow, ncol)
115 139
116 140 Input:
117 141 id : Los parametros necesarios son
118 142 wintitle :
119 143
120 144 """
121 145
122 146 if widthplot == None:
123 147 widthplot = self.WIDTH
124 148
125 149 if heightplot == None:
126 150 heightplot = self.HEIGHT
127 151
128 152 self.id = id
129 153
130 154 self.wintitle = wintitle
131 155
132 156 self.widthscreen, self.heightscreen = self.getScreenDim(widthplot, heightplot)
133 157
134 self.fig = self.__driver.createFigure(id=self.id,
135 wintitle=self.wintitle,
136 width=self.widthscreen,
137 height=self.heightscreen,
138 show=show)
158 # if self.created:
159 # self.__driver.closeFigure(self.fig)
160
161 if not self.created:
162 self.fig = self.__driver.createFigure(id=self.id,
163 wintitle=self.wintitle,
164 width=self.widthscreen,
165 height=self.heightscreen,
166 show=show)
167 else:
168 self.__driver.clearFigure(self.fig)
139 169
140 170 self.axesObjList = []
141 171 self.counter_imagwr = 0
142 172
173 self.created = True
143 174
144 175 def setDriver(self, driver=mpldriver):
145 176
146 177 self.__driver = driver
147 178
148 179 def setTitle(self, title):
149 180
150 181 self.__driver.setTitle(self.fig, title)
151 182
152 183 def setWinTitle(self, title):
153 184
154 185 self.__driver.setWinTitle(self.fig, title=title)
155 186
156 187 def setTextFromAxes(self, text):
157 188
158 189 raise NotImplementedError, "This method has been replaced with Axes.setText"
159 190
160 191 def makeAxes(self, nrow, ncol, xpos, ypos, colspan, rowspan):
161 192
162 193 raise NotImplementedError, "This method has been replaced with Axes.addAxes"
163 194
164 195 def addAxes(self, *args):
165 196 """
166 197
167 198 Input:
168 199 *args : Los parametros necesarios son
169 200 nrow, ncol, xpos, ypos, colspan, rowspan
170 201 """
171 202
172 203 axesObj = Axes(self.fig, *args)
173 204 self.axesObjList.append(axesObj)
174 205
175 206 def saveFigure(self, figpath, figfile, *args):
176 207
177 208 filename = os.path.join(figpath, figfile)
178 209
179 210 fullpath = os.path.split(filename)[0]
180 211
181 212 if not os.path.exists(fullpath):
182 213 subpath = os.path.split(fullpath)[0]
183 214
184 215 if not os.path.exists(subpath):
185 216 os.mkdir(subpath)
186 217
187 218 os.mkdir(fullpath)
188 219
189 220 self.__driver.saveFigure(self.fig, filename, *args)
190 221
191 222 def save(self, figpath, figfile=None, save=True, ftp=False, wr_period=1, thisDatetime=None, update_figfile=True):
192 223
193 224 self.counter_imagwr += 1
194 225 if self.counter_imagwr < wr_period:
195 226 return
196 227
197 228 self.counter_imagwr = 0
198 229
199 230 if save:
200 231
201 232 if not figfile:
202 233
203 234 if not thisDatetime:
204 235 raise ValueError, "Saving figure: figfile or thisDatetime should be defined"
205 236 return
206 237
207 238 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
208 239 figfile = self.getFilename(name = str_datetime)
209 240
210 241 if self.figfile == None:
211 242 self.figfile = figfile
212 243
213 244 if update_figfile:
214 245 self.figfile = figfile
215 246
216 247 # store png plot to local folder
217 248 self.saveFigure(figpath, self.figfile)
218 249
219 250
220 251 if not ftp:
221 252 return
222 253
223 254 if not thisDatetime:
224 255 return
225 256
226 257 # store png plot to FTP server according to RT-Web format
227 258 ftp_filename = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
228 259 # ftp_filename = os.path.join(figpath, name)
229 260 self.saveFigure(figpath, ftp_filename)
230 261
231 262 def getNameToFtp(self, thisDatetime, FTP_WEI, EXP_CODE, SUB_EXP_CODE, PLOT_CODE, PLOT_POS):
232 263 YEAR_STR = '%4.4d'%thisDatetime.timetuple().tm_year
233 264 DOY_STR = '%3.3d'%thisDatetime.timetuple().tm_yday
234 265 FTP_WEI = '%2.2d'%FTP_WEI
235 266 EXP_CODE = '%3.3d'%EXP_CODE
236 267 SUB_EXP_CODE = '%2.2d'%SUB_EXP_CODE
237 268 PLOT_CODE = '%2.2d'%PLOT_CODE
238 269 PLOT_POS = '%2.2d'%PLOT_POS
239 270 name = YEAR_STR + DOY_STR + FTP_WEI + EXP_CODE + SUB_EXP_CODE + PLOT_CODE + PLOT_POS
240 271 return name
241 272
242 273 def draw(self):
243 274
244 275 self.__driver.draw(self.fig)
245 276
246 277 def run(self):
247 278
248 279 raise NotImplementedError
249 280
250 281 def close(self, show=False):
251 282
252 283 self.__driver.closeFigure(show=show, fig=self.fig)
253 284
254 285 axesList = property(getAxesObjList)
255 286
256 287
257 288 class Axes:
258 289
259 290 __driver = mpldriver
260 291 fig = None
261 292 ax = None
262 293 plot = None
263 294 __missing = 1E30
264 295 __firsttime = None
265 296
266 297 __showprofile = False
267 298
268 299 xmin = None
269 300 xmax = None
270 301 ymin = None
271 302 ymax = None
272 303 zmin = None
273 304 zmax = None
274 305
275 306 x_buffer = None
276 307 z_buffer = None
277 308
278 309 decimationx = None
279 310 decimationy = None
280 311
281 312 __MAXNUMX = 300
282 313 __MAXNUMY = 150
283 314
284 315 def __init__(self, *args):
285 316
286 317 """
287 318
288 319 Input:
289 320 *args : Los parametros necesarios son
290 321 fig, nrow, ncol, xpos, ypos, colspan, rowspan
291 322 """
292 323
293 324 ax = self.__driver.createAxes(*args)
294 325 self.fig = args[0]
295 326 self.ax = ax
296 327 self.plot = None
297 328
298 329 self.__firsttime = True
299 330 self.idlineList = []
300 331
301 332 self.x_buffer = numpy.array([])
302 333 self.z_buffer = numpy.array([])
303 334
304 335 def setText(self, text):
305 336
306 337 self.__driver.setAxesText(self.ax, text)
307 338
308 339 def setXAxisAsTime(self):
309 340 pass
310 341
311 342 def pline(self, x, y,
312 343 xmin=None, xmax=None,
313 344 ymin=None, ymax=None,
314 345 xlabel='', ylabel='',
315 346 title='',
316 347 **kwargs):
317 348
318 349 """
319 350
320 351 Input:
321 352 x :
322 353 y :
323 354 xmin :
324 355 xmax :
325 356 ymin :
326 357 ymax :
327 358 xlabel :
328 359 ylabel :
329 360 title :
330 361 **kwargs : Los parametros aceptados son
331 362
332 363 ticksize
333 364 ytick_visible
334 365 """
335 366
336 367 if self.__firsttime:
337 368
338 369 if xmin == None: xmin = numpy.nanmin(x)
339 370 if xmax == None: xmax = numpy.nanmax(x)
340 371 if ymin == None: ymin = numpy.nanmin(y)
341 372 if ymax == None: ymax = numpy.nanmax(y)
342 373
343 374 self.plot = self.__driver.createPline(self.ax, x, y,
344 375 xmin, xmax,
345 376 ymin, ymax,
346 377 xlabel=xlabel,
347 378 ylabel=ylabel,
348 379 title=title,
349 380 **kwargs)
350 381
351 382 self.idlineList.append(0)
352 383 self.__firsttime = False
353 384 return
354 385
355 386 self.__driver.pline(self.plot, x, y, xlabel=xlabel,
356 387 ylabel=ylabel,
357 388 title=title)
358 389
359 390 # self.__driver.pause()
360 391
361 392 def addpline(self, x, y, idline, **kwargs):
362 393 lines = self.ax.lines
363 394
364 395 if idline in self.idlineList:
365 396 self.__driver.set_linedata(self.ax, x, y, idline)
366 397
367 398 if idline not in(self.idlineList):
368 399 self.__driver.addpline(self.ax, x, y, **kwargs)
369 400 self.idlineList.append(idline)
370 401
371 402 return
372 403
373 404 def pmultiline(self, x, y,
374 405 xmin=None, xmax=None,
375 406 ymin=None, ymax=None,
376 407 xlabel='', ylabel='',
377 408 title='',
378 409 **kwargs):
379 410
380 411 if self.__firsttime:
381 412
382 413 if xmin == None: xmin = numpy.nanmin(x)
383 414 if xmax == None: xmax = numpy.nanmax(x)
384 415 if ymin == None: ymin = numpy.nanmin(y)
385 416 if ymax == None: ymax = numpy.nanmax(y)
386 417
387 418 self.plot = self.__driver.createPmultiline(self.ax, x, y,
388 419 xmin, xmax,
389 420 ymin, ymax,
390 421 xlabel=xlabel,
391 422 ylabel=ylabel,
392 423 title=title,
393 424 **kwargs)
394 425 self.__firsttime = False
395 426 return
396 427
397 428 self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel,
398 429 ylabel=ylabel,
399 430 title=title)
400 431
401 432 # self.__driver.pause()
402 433
403 434 def pmultilineyaxis(self, x, y,
404 435 xmin=None, xmax=None,
405 436 ymin=None, ymax=None,
406 437 xlabel='', ylabel='',
407 438 title='',
408 439 **kwargs):
409 440
410 441 if self.__firsttime:
411 442
412 443 if xmin == None: xmin = numpy.nanmin(x)
413 444 if xmax == None: xmax = numpy.nanmax(x)
414 445 if ymin == None: ymin = numpy.nanmin(y)
415 446 if ymax == None: ymax = numpy.nanmax(y)
416 447
417 448 self.plot = self.__driver.createPmultilineYAxis(self.ax, x, y,
418 449 xmin, xmax,
419 450 ymin, ymax,
420 451 xlabel=xlabel,
421 452 ylabel=ylabel,
422 453 title=title,
423 454 **kwargs)
424 455 if self.xmin == None: self.xmin = xmin
425 456 if self.xmax == None: self.xmax = xmax
426 457 if self.ymin == None: self.ymin = ymin
427 458 if self.ymax == None: self.ymax = ymax
428 459
429 460 self.__firsttime = False
430 461 return
431 462
432 463 self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel,
433 464 ylabel=ylabel,
434 465 title=title)
435 466
436 467 # self.__driver.pause()
437 468
438 469 def pcolor(self, x, y, z,
439 470 xmin=None, xmax=None,
440 471 ymin=None, ymax=None,
441 472 zmin=None, zmax=None,
442 473 xlabel='', ylabel='',
443 474 title='', rti = False, colormap='jet',
444 475 **kwargs):
445 476
446 477 """
447 478 Input:
448 479 x :
449 480 y :
450 481 x :
451 482 xmin :
452 483 xmax :
453 484 ymin :
454 485 ymax :
455 486 zmin :
456 487 zmax :
457 488 xlabel :
458 489 ylabel :
459 490 title :
460 491 **kwargs : Los parametros aceptados son
461 492 ticksize=9,
462 493 cblabel=''
463 494 rti = True or False
464 495 """
465 496
466 497 if self.__firsttime:
467 498
468 499 if xmin == None: xmin = numpy.nanmin(x)
469 500 if xmax == None: xmax = numpy.nanmax(x)
470 501 if ymin == None: ymin = numpy.nanmin(y)
471 502 if ymax == None: ymax = numpy.nanmax(y)
472 503 if zmin == None: zmin = numpy.nanmin(z)
473 504 if zmax == None: zmax = numpy.nanmax(z)
474 505
475 506
476 507 self.plot = self.__driver.createPcolor(self.ax, x, y, z,
477 508 xmin, xmax,
478 509 ymin, ymax,
479 510 zmin, zmax,
480 511 xlabel=xlabel,
481 512 ylabel=ylabel,
482 513 title=title,
483 514 colormap=colormap,
484 515 **kwargs)
485 516
486 517 if self.xmin == None: self.xmin = xmin
487 518 if self.xmax == None: self.xmax = xmax
488 519 if self.ymin == None: self.ymin = ymin
489 520 if self.ymax == None: self.ymax = ymax
490 521 if self.zmin == None: self.zmin = zmin
491 522 if self.zmax == None: self.zmax = zmax
492 523
493 524 self.__firsttime = False
494 525 return
495 526
496 527 if rti:
497 528 self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax,
498 529 xlabel=xlabel,
499 530 ylabel=ylabel,
500 531 title=title,
501 532 colormap=colormap)
502 533 return
503 534
504 535 self.__driver.pcolor(self.plot, z,
505 536 xlabel=xlabel,
506 537 ylabel=ylabel,
507 538 title=title)
508 539
509 540 # self.__driver.pause()
510 541
511 542 def pcolorbuffer(self, x, y, z,
512 543 xmin=None, xmax=None,
513 544 ymin=None, ymax=None,
514 545 zmin=None, zmax=None,
515 546 xlabel='', ylabel='',
516 547 title='', rti = True, colormap='jet',
517 548 maxNumX = None, maxNumY = None,
518 549 **kwargs):
519 550
520 551 if maxNumX == None:
521 552 maxNumX = self.__MAXNUMX
522 553
523 554 if maxNumY == None:
524 555 maxNumY = self.__MAXNUMY
525 556
526 557 if self.__firsttime:
527 558 self.z_buffer = z
528 559 self.x_buffer = numpy.hstack((self.x_buffer, x))
529 560
530 561 if xmin == None: xmin = numpy.nanmin(x)
531 562 if xmax == None: xmax = numpy.nanmax(x)
532 563 if ymin == None: ymin = numpy.nanmin(y)
533 564 if ymax == None: ymax = numpy.nanmax(y)
534 565 if zmin == None: zmin = numpy.nanmin(z)
535 566 if zmax == None: zmax = numpy.nanmax(z)
536 567
537 568
538 569 self.plot = self.__driver.createPcolor(self.ax, self.x_buffer, y, z,
539 570 xmin, xmax,
540 571 ymin, ymax,
541 572 zmin, zmax,
542 573 xlabel=xlabel,
543 574 ylabel=ylabel,
544 575 title=title,
545 576 colormap=colormap,
546 577 **kwargs)
547 578
548 579 if self.xmin == None: self.xmin = xmin
549 580 if self.xmax == None: self.xmax = xmax
550 581 if self.ymin == None: self.ymin = ymin
551 582 if self.ymax == None: self.ymax = ymax
552 583 if self.zmin == None: self.zmin = zmin
553 584 if self.zmax == None: self.zmax = zmax
554 585
555 586 self.__firsttime = False
556 587 return
557 588
558 589 self.x_buffer = numpy.hstack((self.x_buffer, x[-1]))
559 590 self.z_buffer = numpy.hstack((self.z_buffer, z))
560 591
561 592 if self.decimationx == None:
562 593 deltax = float(self.xmax - self.xmin)/maxNumX
563 594 deltay = float(self.ymax - self.ymin)/maxNumY
564 595
565 596 resolutionx = self.x_buffer[2]-self.x_buffer[0]
566 597 resolutiony = y[1]-y[0]
567 598
568 599 self.decimationx = numpy.ceil(deltax / resolutionx)
569 600 self.decimationy = numpy.ceil(deltay / resolutiony)
570 601
571 602 z_buffer = self.z_buffer.reshape(-1,len(y))
572 603
573 604 x_buffer = self.x_buffer[::self.decimationx]
574 605 y_buffer = y[::self.decimationy]
575 606 z_buffer = z_buffer[::self.decimationx, ::self.decimationy]
576 607 #===================================================
577 608
578 609 x_buffer, y_buffer, z_buffer = self.__fillGaps(x_buffer, y_buffer, z_buffer)
579 610
580 611 self.__driver.addpcolorbuffer(self.ax, x_buffer, y_buffer, z_buffer, self.zmin, self.zmax,
581 612 xlabel=xlabel,
582 613 ylabel=ylabel,
583 614 title=title,
584 615 colormap=colormap)
585 616
586 617 # self.__driver.pause()
587 618
588 619 def polar(self, x, y,
589 620 title='', xlabel='',ylabel='',**kwargs):
590 621
591 622 if self.__firsttime:
592 623 self.plot = self.__driver.createPolar(self.ax, x, y, title = title, xlabel = xlabel, ylabel = ylabel)
593 624 self.__firsttime = False
594 625 self.x_buffer = x
595 626 self.y_buffer = y
596 627 return
597 628
598 629 self.x_buffer = numpy.hstack((self.x_buffer,x))
599 630 self.y_buffer = numpy.hstack((self.y_buffer,y))
600 631 self.__driver.polar(self.plot, self.x_buffer, self.y_buffer, xlabel=xlabel,
601 632 ylabel=ylabel,
602 633 title=title)
603 634
604 635 # self.__driver.pause()
605 636
606 637 def __fillGaps(self, x_buffer, y_buffer, z_buffer):
607 638
608 639 if x_buffer.shape[0] < 2:
609 640 return x_buffer, y_buffer, z_buffer
610 641
611 642 deltas = x_buffer[1:] - x_buffer[0:-1]
612 643 x_median = numpy.median(deltas)
613 644
614 645 index = numpy.where(deltas > 5*x_median)
615 646
616 647 if len(index[0]) != 0:
617 648 z_buffer[index[0],::] = self.__missing
618 649 z_buffer = numpy.ma.masked_inside(z_buffer,0.99*self.__missing,1.01*self.__missing)
619 650
620 651 return x_buffer, y_buffer, z_buffer
621 652
622 653
623 654
624 655 No newline at end of file
@@ -1,1341 +1,1363
1 1 '''
2 2 Created on Jul 9, 2014
3 3
4 4 @author: roj-idl71
5 5 '''
6 6 import os
7 7 import datetime
8 8 import numpy
9 9
10 from figure import Figure, isRealtime
10 from figure import Figure, isRealtime, isTimeInHourRange
11 11 from plotting_codes import *
12 12
13 13 class SpectraPlot(Figure):
14 14
15 15 isConfig = None
16 16 __nsubplots = None
17 17
18 18 WIDTHPROF = None
19 19 HEIGHTPROF = None
20 20 PREFIX = 'spc'
21 21
22 22 def __init__(self):
23 23
24 24 self.isConfig = False
25 25 self.__nsubplots = 1
26 26
27 27 self.WIDTH = 250
28 28 self.HEIGHT = 250
29 29 self.WIDTHPROF = 120
30 30 self.HEIGHTPROF = 0
31 31 self.counter_imagwr = 0
32 32
33 33 self.PLOT_CODE = SPEC_CODE
34 34
35 35 self.FTP_WEI = None
36 36 self.EXP_CODE = None
37 37 self.SUB_EXP_CODE = None
38 38 self.PLOT_POS = None
39 39
40 40 self.__xfilter_ena = False
41 41 self.__yfilter_ena = False
42 42
43 43 def getSubplots(self):
44 44
45 45 ncol = int(numpy.sqrt(self.nplots)+0.9)
46 46 nrow = int(self.nplots*1./ncol + 0.9)
47 47
48 48 return nrow, ncol
49 49
50 50 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
51 51
52 52 self.__showprofile = showprofile
53 53 self.nplots = nplots
54 54
55 55 ncolspan = 1
56 56 colspan = 1
57 57 if showprofile:
58 58 ncolspan = 3
59 59 colspan = 2
60 60 self.__nsubplots = 2
61 61
62 62 self.createFigure(id = id,
63 63 wintitle = wintitle,
64 64 widthplot = self.WIDTH + self.WIDTHPROF,
65 65 heightplot = self.HEIGHT + self.HEIGHTPROF,
66 66 show=show)
67 67
68 68 nrow, ncol = self.getSubplots()
69 69
70 70 counter = 0
71 71 for y in range(nrow):
72 72 for x in range(ncol):
73 73
74 74 if counter >= self.nplots:
75 75 break
76 76
77 77 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
78 78
79 79 if showprofile:
80 80 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
81 81
82 82 counter += 1
83 83
84 84 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
85 85 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
86 86 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
87 87 server=None, folder=None, username=None, password=None,
88 88 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
89 89
90 90 """
91 91
92 92 Input:
93 93 dataOut :
94 94 id :
95 95 wintitle :
96 96 channelList :
97 97 showProfile :
98 98 xmin : None,
99 99 xmax : None,
100 100 ymin : None,
101 101 ymax : None,
102 102 zmin : None,
103 103 zmax : None
104 104 """
105 105
106 106 if realtime:
107 107 if not(isRealtime(utcdatatime = dataOut.utctime)):
108 108 print 'Skipping this plot function'
109 109 return
110 110
111 111 if channelList == None:
112 112 channelIndexList = dataOut.channelIndexList
113 113 else:
114 114 channelIndexList = []
115 115 for channel in channelList:
116 116 if channel not in dataOut.channelList:
117 117 raise ValueError, "Channel %d is not in dataOut.channelList" %channel
118 118 channelIndexList.append(dataOut.channelList.index(channel))
119 119
120 120 factor = dataOut.normFactor
121 121
122 122 x = dataOut.getVelRange(1)
123 123 y = dataOut.getHeiRange()
124 124
125 125 z = dataOut.data_spc/factor
126 126 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
127 127 zdB = 10*numpy.log10(z)
128 128
129 129 avg = numpy.average(z, axis=1)
130 130 avgdB = 10*numpy.log10(avg)
131 131
132 132 noise = dataOut.getNoise()/factor
133 133 noisedB = 10*numpy.log10(noise)
134 134
135 135 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
136 136 title = wintitle + " Spectra"
137 137 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
138 138 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
139 139
140 140 xlabel = "Velocity (m/s)"
141 141 ylabel = "Range (Km)"
142 142
143 143 if not self.isConfig:
144 144
145 145 nplots = len(channelIndexList)
146 146
147 147 self.setup(id=id,
148 148 nplots=nplots,
149 149 wintitle=wintitle,
150 150 showprofile=showprofile,
151 151 show=show)
152 152
153 153 if xmin == None: xmin = numpy.nanmin(x)
154 154 if xmax == None: xmax = numpy.nanmax(x)
155 155 if ymin == None: ymin = numpy.nanmin(y)
156 156 if ymax == None: ymax = numpy.nanmax(y)
157 157 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
158 158 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
159 159
160 160 self.FTP_WEI = ftp_wei
161 161 self.EXP_CODE = exp_code
162 162 self.SUB_EXP_CODE = sub_exp_code
163 163 self.PLOT_POS = plot_pos
164 164
165 165 self.isConfig = True
166 166
167 167 self.setWinTitle(title)
168 168
169 169 for i in range(self.nplots):
170 170 index = channelIndexList[i]
171 171 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
172 172 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime)
173 173 if len(dataOut.beam.codeList) != 0:
174 174 title = "Ch%d:%4.2fdB,%2.2f,%2.2f:%s" %(dataOut.channelList[index], noisedB[index], dataOut.beam.azimuthList[index], dataOut.beam.zenithList[index], str_datetime)
175 175
176 176 axes = self.axesList[i*self.__nsubplots]
177 177 axes.pcolor(x, y, zdB[index,:,:],
178 178 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
179 179 xlabel=xlabel, ylabel=ylabel, title=title,
180 180 ticksize=9, cblabel='')
181 181
182 182 if self.__showprofile:
183 183 axes = self.axesList[i*self.__nsubplots +1]
184 184 axes.pline(avgdB[index,:], y,
185 185 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
186 186 xlabel='dB', ylabel='', title='',
187 187 ytick_visible=False,
188 188 grid='x')
189 189
190 190 noiseline = numpy.repeat(noisedB[index], len(y))
191 191 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
192 192
193 193 self.draw()
194 194
195 195 if figfile == None:
196 196 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
197 197 name = str_datetime
198 198 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
199 199 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
200 200 figfile = self.getFilename(name)
201 201
202 202 self.save(figpath=figpath,
203 203 figfile=figfile,
204 204 save=save,
205 205 ftp=ftp,
206 206 wr_period=wr_period,
207 207 thisDatetime=thisDatetime)
208 208
209 209 class CrossSpectraPlot(Figure):
210 210
211 211 isConfig = None
212 212 __nsubplots = None
213 213
214 214 WIDTH = None
215 215 HEIGHT = None
216 216 WIDTHPROF = None
217 217 HEIGHTPROF = None
218 218 PREFIX = 'cspc'
219 219
220 220 def __init__(self):
221 221
222 222 self.isConfig = False
223 223 self.__nsubplots = 4
224 224 self.counter_imagwr = 0
225 225 self.WIDTH = 250
226 226 self.HEIGHT = 250
227 227 self.WIDTHPROF = 0
228 228 self.HEIGHTPROF = 0
229 229
230 230 self.PLOT_CODE = CROSS_CODE
231 231 self.FTP_WEI = None
232 232 self.EXP_CODE = None
233 233 self.SUB_EXP_CODE = None
234 234 self.PLOT_POS = None
235 235
236 236 def getSubplots(self):
237 237
238 238 ncol = 4
239 239 nrow = self.nplots
240 240
241 241 return nrow, ncol
242 242
243 243 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
244 244
245 245 self.__showprofile = showprofile
246 246 self.nplots = nplots
247 247
248 248 ncolspan = 1
249 249 colspan = 1
250 250
251 251 self.createFigure(id = id,
252 252 wintitle = wintitle,
253 253 widthplot = self.WIDTH + self.WIDTHPROF,
254 254 heightplot = self.HEIGHT + self.HEIGHTPROF,
255 255 show=True)
256 256
257 257 nrow, ncol = self.getSubplots()
258 258
259 259 counter = 0
260 260 for y in range(nrow):
261 261 for x in range(ncol):
262 262 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
263 263
264 264 counter += 1
265 265
266 266 def run(self, dataOut, id, wintitle="", pairsList=None,
267 267 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
268 268 coh_min=None, coh_max=None, phase_min=None, phase_max=None,
269 269 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
270 270 power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
271 271 server=None, folder=None, username=None, password=None,
272 272 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
273 273
274 274 """
275 275
276 276 Input:
277 277 dataOut :
278 278 id :
279 279 wintitle :
280 280 channelList :
281 281 showProfile :
282 282 xmin : None,
283 283 xmax : None,
284 284 ymin : None,
285 285 ymax : None,
286 286 zmin : None,
287 287 zmax : None
288 288 """
289 289
290 290 if pairsList == None:
291 291 pairsIndexList = dataOut.pairsIndexList
292 292 else:
293 293 pairsIndexList = []
294 294 for pair in pairsList:
295 295 if pair not in dataOut.pairsList:
296 296 raise ValueError, "Pair %s is not in dataOut.pairsList" %str(pair)
297 297 pairsIndexList.append(dataOut.pairsList.index(pair))
298 298
299 299 if not pairsIndexList:
300 300 return
301 301
302 302 if len(pairsIndexList) > 4:
303 303 pairsIndexList = pairsIndexList[0:4]
304 304
305 305 factor = dataOut.normFactor
306 306 x = dataOut.getVelRange(1)
307 307 y = dataOut.getHeiRange()
308 308 z = dataOut.data_spc[:,:,:]/factor
309 309 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
310 310
311 311 noise = dataOut.noise/factor
312 312
313 313 zdB = 10*numpy.log10(z)
314 314 noisedB = 10*numpy.log10(noise)
315 315
316 316 if coh_min == None:
317 317 coh_min = 0.0
318 318 if coh_max == None:
319 319 coh_max = 1.0
320 320
321 321 if phase_min == None:
322 322 phase_min = -180
323 323 if phase_max == None:
324 324 phase_max = 180
325 325
326 326 #thisDatetime = dataOut.datatime
327 327 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
328 328 title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
329 329 xlabel = "Velocity (m/s)"
330 330 ylabel = "Range (Km)"
331 331
332 332 if not self.isConfig:
333 333
334 334 nplots = len(pairsIndexList)
335 335
336 336 self.setup(id=id,
337 337 nplots=nplots,
338 338 wintitle=wintitle,
339 339 showprofile=False,
340 340 show=show)
341 341
342 342 avg = numpy.abs(numpy.average(z, axis=1))
343 343 avgdB = 10*numpy.log10(avg)
344 344
345 345 if xmin == None: xmin = numpy.nanmin(x)
346 346 if xmax == None: xmax = numpy.nanmax(x)
347 347 if ymin == None: ymin = numpy.nanmin(y)
348 348 if ymax == None: ymax = numpy.nanmax(y)
349 349 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
350 350 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
351 351
352 352 self.FTP_WEI = ftp_wei
353 353 self.EXP_CODE = exp_code
354 354 self.SUB_EXP_CODE = sub_exp_code
355 355 self.PLOT_POS = plot_pos
356 356
357 357 self.isConfig = True
358 358
359 359 self.setWinTitle(title)
360 360
361 361 for i in range(self.nplots):
362 362 pair = dataOut.pairsList[pairsIndexList[i]]
363 363 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
364 364 title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[pair[0]], str_datetime)
365 365 zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor)
366 366 axes0 = self.axesList[i*self.__nsubplots]
367 367 axes0.pcolor(x, y, zdB,
368 368 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
369 369 xlabel=xlabel, ylabel=ylabel, title=title,
370 370 ticksize=9, colormap=power_cmap, cblabel='')
371 371
372 372 title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[pair[1]], str_datetime)
373 373 zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor)
374 374 axes0 = self.axesList[i*self.__nsubplots+1]
375 375 axes0.pcolor(x, y, zdB,
376 376 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
377 377 xlabel=xlabel, ylabel=ylabel, title=title,
378 378 ticksize=9, colormap=power_cmap, cblabel='')
379 379
380 380 coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
381 381 coherence = numpy.abs(coherenceComplex)
382 382 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
383 383 phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi
384 384
385 title = "Coherence %d%d" %(pair[0], pair[1])
385 title = "Coherence Ch%d * Ch%d" %(pair[0], pair[1])
386 386 axes0 = self.axesList[i*self.__nsubplots+2]
387 387 axes0.pcolor(x, y, coherence,
388 388 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=coh_min, zmax=coh_max,
389 389 xlabel=xlabel, ylabel=ylabel, title=title,
390 390 ticksize=9, colormap=coherence_cmap, cblabel='')
391 391
392 title = "Phase %d%d" %(pair[0], pair[1])
392 title = "Phase Ch%d * Ch%d" %(pair[0], pair[1])
393 393 axes0 = self.axesList[i*self.__nsubplots+3]
394 394 axes0.pcolor(x, y, phase,
395 395 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max,
396 396 xlabel=xlabel, ylabel=ylabel, title=title,
397 397 ticksize=9, colormap=phase_cmap, cblabel='')
398 398
399 399
400 400
401 401 self.draw()
402 402
403 403 self.save(figpath=figpath,
404 404 figfile=figfile,
405 405 save=save,
406 406 ftp=ftp,
407 407 wr_period=wr_period,
408 408 thisDatetime=thisDatetime)
409 409
410 410
411 411 class RTIPlot(Figure):
412 412
413 413 __isConfig = None
414 414 __nsubplots = None
415 415
416 416 WIDTHPROF = None
417 417 HEIGHTPROF = None
418 418 PREFIX = 'rti'
419 419
420 420 def __init__(self):
421 421
422 422 self.timerange = None
423 self.__isConfig = False
423 self.isConfig = False
424 424 self.__nsubplots = 1
425 425
426 426 self.WIDTH = 800
427 427 self.HEIGHT = 180
428 428 self.WIDTHPROF = 120
429 429 self.HEIGHTPROF = 0
430 430 self.counter_imagwr = 0
431 431
432 432 self.PLOT_CODE = RTI_CODE
433 433
434 434 self.FTP_WEI = None
435 435 self.EXP_CODE = None
436 436 self.SUB_EXP_CODE = None
437 437 self.PLOT_POS = None
438 438 self.tmin = None
439 439 self.tmax = None
440 440
441 441 self.xmin = None
442 442 self.xmax = None
443 443
444 444 self.figfile = None
445 445
446 446 def getSubplots(self):
447 447
448 448 ncol = 1
449 449 nrow = self.nplots
450 450
451 451 return nrow, ncol
452 452
453 453 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
454 454
455 455 self.__showprofile = showprofile
456 456 self.nplots = nplots
457 457
458 458 ncolspan = 1
459 459 colspan = 1
460 460 if showprofile:
461 461 ncolspan = 7
462 462 colspan = 6
463 463 self.__nsubplots = 2
464 464
465 465 self.createFigure(id = id,
466 466 wintitle = wintitle,
467 467 widthplot = self.WIDTH + self.WIDTHPROF,
468 468 heightplot = self.HEIGHT + self.HEIGHTPROF,
469 469 show=show)
470 470
471 471 nrow, ncol = self.getSubplots()
472 472
473 473 counter = 0
474 474 for y in range(nrow):
475 475 for x in range(ncol):
476 476
477 477 if counter >= self.nplots:
478 478 break
479 479
480 480 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
481 481
482 482 if showprofile:
483 483 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
484 484
485 485 counter += 1
486 486
487 487 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
488 488 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
489 489 timerange=None,
490 490 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
491 491 server=None, folder=None, username=None, password=None,
492 492 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
493 493
494 494 """
495 495
496 496 Input:
497 497 dataOut :
498 498 id :
499 499 wintitle :
500 500 channelList :
501 501 showProfile :
502 502 xmin : None,
503 503 xmax : None,
504 504 ymin : None,
505 505 ymax : None,
506 506 zmin : None,
507 507 zmax : None
508 508 """
509 509
510 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
511 return
512
510 513 if channelList == None:
511 514 channelIndexList = dataOut.channelIndexList
512 515 else:
513 516 channelIndexList = []
514 517 for channel in channelList:
515 518 if channel not in dataOut.channelList:
516 519 raise ValueError, "Channel %d is not in dataOut.channelList"
517 520 channelIndexList.append(dataOut.channelList.index(channel))
518 521
519 # if timerange != None:
520 # self.timerange = timerange
521
522 #tmin = None
523 #tmax = None
524 522 factor = dataOut.normFactor
525 523 x = dataOut.getTimeRange()
526 524 y = dataOut.getHeiRange()
527 525
528 526 z = dataOut.data_spc/factor
529 527 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
530 528 avg = numpy.average(z, axis=1)
531 529
532 530 avgdB = 10.*numpy.log10(avg)
533
534 531
535 # thisDatetime = dataOut.datatime
536 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
532 thisDatetime = dataOut.datatime
533 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
537 534 title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
538 535 xlabel = ""
539 536 ylabel = "Range (Km)"
540 537
541 if not self.__isConfig:
538 update_figfile = False
539
540 if not self.isConfig:
542 541
543 542 nplots = len(channelIndexList)
544 543
545 544 self.setup(id=id,
546 545 nplots=nplots,
547 546 wintitle=wintitle,
548 547 showprofile=showprofile,
549 548 show=show)
550 549
551 550 if timerange != None:
552 551 self.timerange = timerange
553 552
554 553 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
555 554
556 555 noise = dataOut.noise/factor
557 556 noisedB = 10*numpy.log10(noise)
558 557
559 558 if ymin == None: ymin = numpy.nanmin(y)
560 559 if ymax == None: ymax = numpy.nanmax(y)
561 560 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
562 561 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
563 562
564 563 self.FTP_WEI = ftp_wei
565 564 self.EXP_CODE = exp_code
566 565 self.SUB_EXP_CODE = sub_exp_code
567 566 self.PLOT_POS = plot_pos
568 567
569 568 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
570 self.__isConfig = True
569 self.isConfig = True
571 570 self.figfile = figfile
572
571 update_figfile = True
572
573 573 self.setWinTitle(title)
574 574
575 if ((self.xmax - x[1]) < (x[1]-x[0])):
576 x[1] = self.xmax
577
578 575 for i in range(self.nplots):
579 576 index = channelIndexList[i]
580 577 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
581 578 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
582 579 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
583 580 axes = self.axesList[i*self.__nsubplots]
584 581 zdB = avgdB[index].reshape((1,-1))
585 582 axes.pcolorbuffer(x, y, zdB,
586 583 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
587 584 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
588 585 ticksize=9, cblabel='', cbsize="1%")
589 586
590 587 if self.__showprofile:
591 588 axes = self.axesList[i*self.__nsubplots +1]
592 589 axes.pline(avgdB[index], y,
593 590 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
594 591 xlabel='dB', ylabel='', title='',
595 592 ytick_visible=False,
596 593 grid='x')
597 594
598 self.draw()
599
600 if x[1] >= self.axesList[0].xmax:
595 self.draw()
596
597 if dataOut.ltctime >= self.xmax:
601 598 self.counter_imagwr = wr_period
602 self.__isConfig = False
603 self.figfile = None
599 self.isConfig = False
600 update_figfile = True
604 601
605 602 self.save(figpath=figpath,
606 603 figfile=figfile,
607 604 save=save,
608 605 ftp=ftp,
609 606 wr_period=wr_period,
610 607 thisDatetime=thisDatetime,
611 update_figfile=False)
608 update_figfile=update_figfile)
612 609
613 610 class CoherenceMap(Figure):
614 611 isConfig = None
615 612 __nsubplots = None
616 613
617 614 WIDTHPROF = None
618 615 HEIGHTPROF = None
619 616 PREFIX = 'cmap'
620 617
621 618 def __init__(self):
622 619 self.timerange = 2*60*60
623 620 self.isConfig = False
624 621 self.__nsubplots = 1
625 622
626 623 self.WIDTH = 800
627 624 self.HEIGHT = 180
628 625 self.WIDTHPROF = 120
629 626 self.HEIGHTPROF = 0
630 627 self.counter_imagwr = 0
631 628
632 629 self.PLOT_CODE = COH_CODE
633 630
634 631 self.FTP_WEI = None
635 632 self.EXP_CODE = None
636 633 self.SUB_EXP_CODE = None
637 634 self.PLOT_POS = None
638 635 self.counter_imagwr = 0
639 636
640 637 self.xmin = None
641 638 self.xmax = None
642 639
643 640 def getSubplots(self):
644 641 ncol = 1
645 642 nrow = self.nplots*2
646 643
647 644 return nrow, ncol
648 645
649 646 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
650 647 self.__showprofile = showprofile
651 648 self.nplots = nplots
652 649
653 650 ncolspan = 1
654 651 colspan = 1
655 652 if showprofile:
656 653 ncolspan = 7
657 654 colspan = 6
658 655 self.__nsubplots = 2
659 656
660 657 self.createFigure(id = id,
661 658 wintitle = wintitle,
662 659 widthplot = self.WIDTH + self.WIDTHPROF,
663 660 heightplot = self.HEIGHT + self.HEIGHTPROF,
664 661 show=True)
665 662
666 663 nrow, ncol = self.getSubplots()
667 664
668 665 for y in range(nrow):
669 666 for x in range(ncol):
670 667
671 668 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
672 669
673 670 if showprofile:
674 671 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
675 672
676 673 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
677 674 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
678 675 timerange=None, phase_min=None, phase_max=None,
679 676 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
680 677 coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
681 678 server=None, folder=None, username=None, password=None,
682 679 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
683
680
681 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
682 return
683
684 684 if pairsList == None:
685 685 pairsIndexList = dataOut.pairsIndexList
686 686 else:
687 687 pairsIndexList = []
688 688 for pair in pairsList:
689 689 if pair not in dataOut.pairsList:
690 690 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
691 691 pairsIndexList.append(dataOut.pairsList.index(pair))
692 692
693 693 if pairsIndexList == []:
694 694 return
695 695
696 696 if len(pairsIndexList) > 4:
697 697 pairsIndexList = pairsIndexList[0:4]
698 698
699 699 if phase_min == None:
700 700 phase_min = -180
701 701 if phase_max == None:
702 702 phase_max = 180
703
704 # tmin = None
705 # tmax = None
703
706 704 x = dataOut.getTimeRange()
707 705 y = dataOut.getHeiRange()
708 706
709 #thisDatetime = dataOut.datatime
710 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
707 thisDatetime = dataOut.datatime
708
711 709 title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
712 710 xlabel = ""
713 711 ylabel = "Range (Km)"
712 update_figfile = False
714 713
715 714 if not self.isConfig:
716 715 nplots = len(pairsIndexList)
717 716 self.setup(id=id,
718 717 nplots=nplots,
719 718 wintitle=wintitle,
720 719 showprofile=showprofile,
721 720 show=show)
722 721
723 722 if timerange != None:
724 723 self.timerange = timerange
725 724
726 725 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
727 726
728 727 if ymin == None: ymin = numpy.nanmin(y)
729 728 if ymax == None: ymax = numpy.nanmax(y)
730 729 if zmin == None: zmin = 0.
731 730 if zmax == None: zmax = 1.
732 731
733 732 self.FTP_WEI = ftp_wei
734 733 self.EXP_CODE = exp_code
735 734 self.SUB_EXP_CODE = sub_exp_code
736 735 self.PLOT_POS = plot_pos
737 736
738 737 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
739 738
740 739 self.isConfig = True
740 update_figfile = True
741 741
742 742 self.setWinTitle(title)
743 743
744 if ((self.xmax - x[1]) < (x[1]-x[0])):
745 x[1] = self.xmax
746
747 744 for i in range(self.nplots):
748 745
749 746 pair = dataOut.pairsList[pairsIndexList[i]]
750 747
751 748 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
752 749 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
753 750 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
754 751
755 752
756 753 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
757 754 coherence = numpy.abs(avgcoherenceComplex)
758 755
759 756 z = coherence.reshape((1,-1))
760 757
761 758 counter = 0
762 759
763 title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
760 title = "Coherence Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
764 761 axes = self.axesList[i*self.__nsubplots*2]
765 762 axes.pcolorbuffer(x, y, z,
766 763 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
767 764 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
768 765 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
769 766
770 767 if self.__showprofile:
771 768 counter += 1
772 769 axes = self.axesList[i*self.__nsubplots*2 + counter]
773 770 axes.pline(coherence, y,
774 771 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
775 772 xlabel='', ylabel='', title='', ticksize=7,
776 773 ytick_visible=False, nxticks=5,
777 774 grid='x')
778 775
779 776 counter += 1
780 777
781 778 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
782 779
783 780 z = phase.reshape((1,-1))
784 781
785 title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
782 title = "Phase Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
786 783 axes = self.axesList[i*self.__nsubplots*2 + counter]
787 784 axes.pcolorbuffer(x, y, z,
788 785 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max,
789 786 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
790 787 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
791 788
792 789 if self.__showprofile:
793 790 counter += 1
794 791 axes = self.axesList[i*self.__nsubplots*2 + counter]
795 792 axes.pline(phase, y,
796 793 xmin=phase_min, xmax=phase_max, ymin=ymin, ymax=ymax,
797 794 xlabel='', ylabel='', title='', ticksize=7,
798 795 ytick_visible=False, nxticks=4,
799 796 grid='x')
800 797
801 798 self.draw()
802 799
803 if x[1] >= self.axesList[0].xmax:
800 if dataOut.ltctime >= self.xmax:
804 801 self.counter_imagwr = wr_period
805 self.__isConfig = False
806 self.figfile = None
802 self.isConfig = False
803 update_figfile = True
807 804
808 805 self.save(figpath=figpath,
809 806 figfile=figfile,
810 807 save=save,
811 808 ftp=ftp,
812 809 wr_period=wr_period,
813 810 thisDatetime=thisDatetime,
814 update_figfile=False)
811 update_figfile=update_figfile)
815 812
816 813 class PowerProfilePlot(Figure):
817 814
818 815 isConfig = None
819 816 __nsubplots = None
820 817
821 818 WIDTHPROF = None
822 819 HEIGHTPROF = None
823 820 PREFIX = 'spcprofile'
824 821
825 822 def __init__(self):
826 823 self.isConfig = False
827 824 self.__nsubplots = 1
828 825
829 826 self.PLOT_CODE = POWER_CODE
830 827
831 828 self.WIDTH = 300
832 829 self.HEIGHT = 500
833 830 self.counter_imagwr = 0
834 831
835 832 def getSubplots(self):
836 833 ncol = 1
837 834 nrow = 1
838 835
839 836 return nrow, ncol
840 837
841 838 def setup(self, id, nplots, wintitle, show):
842 839
843 840 self.nplots = nplots
844 841
845 842 ncolspan = 1
846 843 colspan = 1
847 844
848 845 self.createFigure(id = id,
849 846 wintitle = wintitle,
850 847 widthplot = self.WIDTH,
851 848 heightplot = self.HEIGHT,
852 849 show=show)
853 850
854 851 nrow, ncol = self.getSubplots()
855 852
856 853 counter = 0
857 854 for y in range(nrow):
858 855 for x in range(ncol):
859 856 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
860 857
861 858 def run(self, dataOut, id, wintitle="", channelList=None,
862 859 xmin=None, xmax=None, ymin=None, ymax=None,
863 860 save=False, figpath='./', figfile=None, show=True,
864 861 ftp=False, wr_period=1, server=None,
865 862 folder=None, username=None, password=None):
866 863
867 864
868 865 if channelList == None:
869 866 channelIndexList = dataOut.channelIndexList
870 867 channelList = dataOut.channelList
871 868 else:
872 869 channelIndexList = []
873 870 for channel in channelList:
874 871 if channel not in dataOut.channelList:
875 872 raise ValueError, "Channel %d is not in dataOut.channelList"
876 873 channelIndexList.append(dataOut.channelList.index(channel))
877 874
878 875 factor = dataOut.normFactor
879 876
880 877 y = dataOut.getHeiRange()
881 878
882 879 #for voltage
883 880 if dataOut.type == 'Voltage':
884 881 x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
885 882 x = x.real
886 883 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
887 884
888 885 #for spectra
889 886 if dataOut.type == 'Spectra':
890 887 x = dataOut.data_spc[channelIndexList,:,:]/factor
891 888 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
892 889 x = numpy.average(x, axis=1)
893 890
894 891
895 892 xdB = 10*numpy.log10(x)
896 893
897 894 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
898 895 title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y"))
899 896 xlabel = "dB"
900 897 ylabel = "Range (Km)"
901 898
902 899 if not self.isConfig:
903 900
904 901 nplots = 1
905 902
906 903 self.setup(id=id,
907 904 nplots=nplots,
908 905 wintitle=wintitle,
909 906 show=show)
910 907
911 908 if ymin == None: ymin = numpy.nanmin(y)
912 909 if ymax == None: ymax = numpy.nanmax(y)
913 910 if xmin == None: xmin = numpy.nanmin(xdB)*0.9
914 911 if xmax == None: xmax = numpy.nanmax(xdB)*1.1
915 912
916 self.__isConfig = True
913 self.isConfig = True
917 914
918 915 self.setWinTitle(title)
919 916
920 917 title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
921 918 axes = self.axesList[0]
922 919
923 920 legendlabels = ["channel %d"%x for x in channelList]
924 921 axes.pmultiline(xdB, y,
925 922 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
926 923 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
927 924 ytick_visible=True, nxticks=5,
928 925 grid='x')
929 926
930 927 self.draw()
931 928
932 929 self.save(figpath=figpath,
933 930 figfile=figfile,
934 931 save=save,
935 932 ftp=ftp,
936 933 wr_period=wr_period,
937 934 thisDatetime=thisDatetime)
938 935
939 936 class Noise(Figure):
940 937
941 938 isConfig = None
942 939 __nsubplots = None
943 940
944 941 PREFIX = 'noise'
945 942
946 943 def __init__(self):
947 944
948 945 self.timerange = 24*60*60
949 946 self.isConfig = False
950 947 self.__nsubplots = 1
951 948 self.counter_imagwr = 0
952 self.WIDTH = 600
953 self.HEIGHT = 300
949 self.WIDTH = 800
950 self.HEIGHT = 400
954 951 self.WIDTHPROF = 120
955 952 self.HEIGHTPROF = 0
956 953 self.xdata = None
957 954 self.ydata = None
958 955
959 956 self.PLOT_CODE = NOISE_CODE
960 957
961 958 self.FTP_WEI = None
962 959 self.EXP_CODE = None
963 960 self.SUB_EXP_CODE = None
964 961 self.PLOT_POS = None
965 962 self.figfile = None
966 963
967 964 self.xmin = None
968 965 self.xmax = None
969 966
970 967 def getSubplots(self):
971 968
972 969 ncol = 1
973 970 nrow = 1
974 971
975 972 return nrow, ncol
976 973
977 974 def openfile(self, filename):
978 975 dirname = os.path.dirname(filename)
979 976
980 977 if not os.path.exists(dirname):
981 978 os.mkdir(dirname)
982 979
983 980 f = open(filename,'w+')
984 981 f.write('\n\n')
985 982 f.write('JICAMARCA RADIO OBSERVATORY - Noise \n')
986 983 f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' )
987 984 f.close()
988 985
989 986 def save_data(self, filename_phase, data, data_datetime):
990 987
991 988 f=open(filename_phase,'a')
992 989
993 990 timetuple_data = data_datetime.timetuple()
994 991 day = str(timetuple_data.tm_mday)
995 992 month = str(timetuple_data.tm_mon)
996 993 year = str(timetuple_data.tm_year)
997 994 hour = str(timetuple_data.tm_hour)
998 995 minute = str(timetuple_data.tm_min)
999 996 second = str(timetuple_data.tm_sec)
1000 997
1001 998 data_msg = ''
1002 999 for i in range(len(data)):
1003 1000 data_msg += str(data[i]) + ' '
1004 1001
1005 1002 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' ' + data_msg + '\n')
1006 1003 f.close()
1007 1004
1008 1005
1009 1006 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1010 1007
1011 1008 self.__showprofile = showprofile
1012 1009 self.nplots = nplots
1013 1010
1014 1011 ncolspan = 7
1015 1012 colspan = 6
1016 1013 self.__nsubplots = 2
1017 1014
1018 1015 self.createFigure(id = id,
1019 1016 wintitle = wintitle,
1020 1017 widthplot = self.WIDTH+self.WIDTHPROF,
1021 1018 heightplot = self.HEIGHT+self.HEIGHTPROF,
1022 1019 show=show)
1023 1020
1024 1021 nrow, ncol = self.getSubplots()
1025 1022
1026 1023 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1027 1024
1028 1025
1029 1026 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
1030 1027 xmin=None, xmax=None, ymin=None, ymax=None,
1031 1028 timerange=None,
1032 1029 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1033 1030 server=None, folder=None, username=None, password=None,
1034 1031 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1035 1032
1033 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1034 return
1035
1036 1036 if channelList == None:
1037 1037 channelIndexList = dataOut.channelIndexList
1038 1038 channelList = dataOut.channelList
1039 1039 else:
1040 1040 channelIndexList = []
1041 1041 for channel in channelList:
1042 1042 if channel not in dataOut.channelList:
1043 1043 raise ValueError, "Channel %d is not in dataOut.channelList"
1044 1044 channelIndexList.append(dataOut.channelList.index(channel))
1045 1045
1046 1046 x = dataOut.getTimeRange()
1047 1047 #y = dataOut.getHeiRange()
1048 1048 factor = dataOut.normFactor
1049 1049 noise = dataOut.noise[channelIndexList]/factor
1050 1050 noisedB = 10*numpy.log10(noise)
1051 1051
1052 #thisDatetime = dataOut.datatime
1053 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1052 thisDatetime = dataOut.datatime
1053
1054 1054 title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1055 1055 xlabel = ""
1056 1056 ylabel = "Intensity (dB)"
1057 update_figfile = False
1057 1058
1058 1059 if not self.isConfig:
1059 1060
1060 1061 nplots = 1
1061 1062
1062 1063 self.setup(id=id,
1063 1064 nplots=nplots,
1064 1065 wintitle=wintitle,
1065 1066 showprofile=showprofile,
1066 1067 show=show)
1067 1068
1068 1069 if timerange != None:
1069 1070 self.timerange = timerange
1070 1071
1071 1072 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1072 1073
1073 1074 if ymin == None: ymin = numpy.floor(numpy.nanmin(noisedB)) - 10.0
1074 1075 if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0
1075 1076
1076 1077 self.FTP_WEI = ftp_wei
1077 1078 self.EXP_CODE = exp_code
1078 1079 self.SUB_EXP_CODE = sub_exp_code
1079 1080 self.PLOT_POS = plot_pos
1080 1081
1081 1082
1082 1083 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1083 1084 self.isConfig = True
1084 1085 self.figfile = figfile
1085 1086 self.xdata = numpy.array([])
1086 1087 self.ydata = numpy.array([])
1087 1088
1089 update_figfile = True
1090
1088 1091 #open file beacon phase
1089 1092 path = '%s%03d' %(self.PREFIX, self.id)
1090 1093 noise_file = os.path.join(path,'%s.txt'%self.name)
1091 1094 self.filename_noise = os.path.join(figpath,noise_file)
1092 1095
1093 1096 self.setWinTitle(title)
1094
1095 1097
1096 1098 title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1097 1099
1098 1100 legendlabels = ["channel %d"%(idchannel) for idchannel in channelList]
1099 1101 axes = self.axesList[0]
1100 1102
1101 1103 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1102 1104
1103 1105 if len(self.ydata)==0:
1104 1106 self.ydata = noisedB.reshape(-1,1)
1105 1107 else:
1106 1108 self.ydata = numpy.hstack((self.ydata, noisedB.reshape(-1,1)))
1107 1109
1108 1110
1109 1111 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1110 1112 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1111 1113 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1112 1114 XAxisAsTime=True, grid='both'
1113 1115 )
1114 1116
1115 1117 self.draw()
1116 1118
1117 if x[1] >= self.axesList[0].xmax:
1119 if dataOut.ltctime >= self.xmax:
1118 1120 self.counter_imagwr = wr_period
1119 del self.xdata
1120 del self.ydata
1121 self.__isConfig = False
1122 self.figfile = None
1121 self.isConfig = False
1122 update_figfile = True
1123 1123
1124 1124 self.save(figpath=figpath,
1125 1125 figfile=figfile,
1126 1126 save=save,
1127 1127 ftp=ftp,
1128 1128 wr_period=wr_period,
1129 1129 thisDatetime=thisDatetime,
1130 update_figfile=False)
1130 update_figfile=update_figfile)
1131 1131
1132 1132 #store data beacon phase
1133 1133 if save:
1134 1134 self.save_data(self.filename_noise, noisedB, thisDatetime)
1135 1135
1136 1136 class BeaconPhase(Figure):
1137 1137
1138 1138 __isConfig = None
1139 1139 __nsubplots = None
1140 1140
1141 1141 PREFIX = 'beacon_phase'
1142 1142
1143 1143 def __init__(self):
1144 1144
1145 1145 self.timerange = 24*60*60
1146 self.__isConfig = False
1146 self.isConfig = False
1147 1147 self.__nsubplots = 1
1148 1148 self.counter_imagwr = 0
1149 self.WIDTH = 600
1150 self.HEIGHT = 300
1149 self.WIDTH = 800
1150 self.HEIGHT = 400
1151 1151 self.WIDTHPROF = 120
1152 1152 self.HEIGHTPROF = 0
1153 1153 self.xdata = None
1154 1154 self.ydata = None
1155 1155
1156 1156 self.PLOT_CODE = BEACON_CODE
1157 1157
1158 1158 self.FTP_WEI = None
1159 1159 self.EXP_CODE = None
1160 1160 self.SUB_EXP_CODE = None
1161 1161 self.PLOT_POS = None
1162 1162
1163 1163 self.filename_phase = None
1164 1164
1165 1165 self.figfile = None
1166 1166
1167 1167 self.xmin = None
1168 1168 self.xmax = None
1169 1169
1170 1170 def getSubplots(self):
1171 1171
1172 1172 ncol = 1
1173 1173 nrow = 1
1174 1174
1175 1175 return nrow, ncol
1176 1176
1177 1177 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1178 1178
1179 1179 self.__showprofile = showprofile
1180 1180 self.nplots = nplots
1181 1181
1182 1182 ncolspan = 7
1183 1183 colspan = 6
1184 1184 self.__nsubplots = 2
1185 1185
1186 1186 self.createFigure(id = id,
1187 1187 wintitle = wintitle,
1188 1188 widthplot = self.WIDTH+self.WIDTHPROF,
1189 1189 heightplot = self.HEIGHT+self.HEIGHTPROF,
1190 1190 show=show)
1191 1191
1192 1192 nrow, ncol = self.getSubplots()
1193 1193
1194 1194 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1195 1195
1196 1196 def save_phase(self, filename_phase):
1197 1197 f = open(filename_phase,'w+')
1198 1198 f.write('\n\n')
1199 1199 f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n')
1200 1200 f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' )
1201 1201 f.close()
1202 1202
1203 1203 def save_data(self, filename_phase, data, data_datetime):
1204 1204 f=open(filename_phase,'a')
1205 1205 timetuple_data = data_datetime.timetuple()
1206 1206 day = str(timetuple_data.tm_mday)
1207 1207 month = str(timetuple_data.tm_mon)
1208 1208 year = str(timetuple_data.tm_year)
1209 1209 hour = str(timetuple_data.tm_hour)
1210 1210 minute = str(timetuple_data.tm_min)
1211 1211 second = str(timetuple_data.tm_sec)
1212 1212 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n')
1213 1213 f.close()
1214 1214
1215 1215
1216 1216 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1217 xmin=None, xmax=None, ymin=None, ymax=None,
1217 xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None,
1218 1218 timerange=None,
1219 1219 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1220 1220 server=None, folder=None, username=None, password=None,
1221 1221 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1222 1222
1223 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1224 return
1225
1223 1226 if pairsList == None:
1224 pairsIndexList = dataOut.pairsIndexList
1227 pairsIndexList = dataOut.pairsIndexList[:10]
1225 1228 else:
1226 1229 pairsIndexList = []
1227 1230 for pair in pairsList:
1228 1231 if pair not in dataOut.pairsList:
1229 1232 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
1230 1233 pairsIndexList.append(dataOut.pairsList.index(pair))
1231 1234
1232 1235 if pairsIndexList == []:
1233 1236 return
1234 1237
1235 1238 # if len(pairsIndexList) > 4:
1236 1239 # pairsIndexList = pairsIndexList[0:4]
1240
1241 hmin_index = None
1242 hmax_index = None
1237 1243
1244 if hmin != None and hmax != None:
1245 indexes = numpy.arange(dataOut.nHeights)
1246 hmin_list = indexes[dataOut.heightList >= hmin]
1247 hmax_list = indexes[dataOut.heightList <= hmax]
1248
1249 if hmin_list.any():
1250 hmin_index = hmin_list[0]
1251
1252 if hmax_list.any():
1253 hmax_index = hmax_list[-1]+1
1254
1238 1255 x = dataOut.getTimeRange()
1239 1256 #y = dataOut.getHeiRange()
1240 1257
1241 1258
1242 #thisDatetime = dataOut.datatime
1243 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1244 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1259 thisDatetime = dataOut.datatime
1260
1261 title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1245 1262 xlabel = "Local Time"
1246 ylabel = "Phase"
1263 ylabel = "Phase (degrees)"
1264
1265 update_figfile = False
1247 1266
1248 1267 nplots = len(pairsIndexList)
1249 1268 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1250 1269 phase_beacon = numpy.zeros(len(pairsIndexList))
1251 1270 for i in range(nplots):
1252 1271 pair = dataOut.pairsList[pairsIndexList[i]]
1253 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
1254 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
1255 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
1272 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0)
1273 powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0)
1274 powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0)
1256 1275 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
1257 1276 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
1258 1277
1259 1278 #print "Phase %d%d" %(pair[0], pair[1])
1260 1279 #print phase[dataOut.beacon_heiIndexList]
1261 1280
1262 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1281 if dataOut.beacon_heiIndexList:
1282 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1283 else:
1284 phase_beacon[i] = numpy.average(phase)
1263 1285
1264 if not self.__isConfig:
1286 if not self.isConfig:
1265 1287
1266 1288 nplots = len(pairsIndexList)
1267 1289
1268 1290 self.setup(id=id,
1269 1291 nplots=nplots,
1270 1292 wintitle=wintitle,
1271 1293 showprofile=showprofile,
1272 1294 show=show)
1273 1295
1274 1296 if timerange != None:
1275 1297 self.timerange = timerange
1276 1298
1277 1299 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1278 1300
1279 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1280 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1301 if ymin == None: ymin = 0
1302 if ymax == None: ymax = 360
1281 1303
1282 1304 self.FTP_WEI = ftp_wei
1283 1305 self.EXP_CODE = exp_code
1284 1306 self.SUB_EXP_CODE = sub_exp_code
1285 1307 self.PLOT_POS = plot_pos
1286 1308
1287 1309 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1288 self.__isConfig = True
1310 self.isConfig = True
1289 1311 self.figfile = figfile
1290 1312 self.xdata = numpy.array([])
1291 1313 self.ydata = numpy.array([])
1292 1314
1315 update_figfile = True
1316
1293 1317 #open file beacon phase
1294 1318 path = '%s%03d' %(self.PREFIX, self.id)
1295 1319 beacon_file = os.path.join(path,'%s.txt'%self.name)
1296 1320 self.filename_phase = os.path.join(figpath,beacon_file)
1297 1321 #self.save_phase(self.filename_phase)
1298 1322
1299 1323
1300 1324 #store data beacon phase
1301 1325 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1302 1326
1303 1327 self.setWinTitle(title)
1304 1328
1305 1329
1306 title = "Beacon Signal %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1330 title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1307 1331
1308 legendlabels = ["pairs %d%d"%(pair[0], pair[1]) for pair in dataOut.pairsList]
1332 legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList]
1309 1333
1310 1334 axes = self.axesList[0]
1311 1335
1312 1336 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1313 1337
1314 1338 if len(self.ydata)==0:
1315 1339 self.ydata = phase_beacon.reshape(-1,1)
1316 1340 else:
1317 1341 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1318 1342
1319 1343
1320 1344 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1321 1345 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1322 1346 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1323 1347 XAxisAsTime=True, grid='both'
1324 1348 )
1325 1349
1326 1350 self.draw()
1327 1351
1328 if x[1] >= self.axesList[0].xmax:
1352 if dataOut.ltctime >= self.xmax:
1329 1353 self.counter_imagwr = wr_period
1330 del self.xdata
1331 del self.ydata
1332 self.__isConfig = False
1333 self.figfile = None
1354 self.isConfig = False
1355 update_figfile = True
1334 1356
1335 1357 self.save(figpath=figpath,
1336 1358 figfile=figfile,
1337 1359 save=save,
1338 1360 ftp=ftp,
1339 1361 wr_period=wr_period,
1340 1362 thisDatetime=thisDatetime,
1341 update_figfile=False)
1363 update_figfile=update_figfile)
@@ -1,444 +1,448
1 1 import numpy
2 2 import datetime
3 3 import sys
4 4 import matplotlib
5 5
6 6 if 'linux' in sys.platform:
7 7 matplotlib.use("TKAgg")
8 8
9 9 if 'darwin' in sys.platform:
10 10 matplotlib.use('TKAgg')
11 11 #Qt4Agg', 'GTK', 'GTKAgg', 'ps', 'agg', 'cairo', 'MacOSX', 'GTKCairo', 'WXAgg', 'template', 'TkAgg', 'GTK3Cairo', 'GTK3Agg', 'svg', 'WebAgg', 'CocoaAgg', 'emf', 'gdk', 'WX'
12 12 import matplotlib.pyplot
13 13
14 14 from mpl_toolkits.axes_grid1 import make_axes_locatable
15 15 from matplotlib.ticker import FuncFormatter, LinearLocator
16 16
17 17 ###########################################
18 18 #Actualizacion de las funciones del driver
19 19 ###########################################
20 20
21 21 def createFigure(id, wintitle, width, height, facecolor="w", show=True):
22 22
23 23 matplotlib.pyplot.ioff()
24 24 fig = matplotlib.pyplot.figure(num=id, facecolor=facecolor)
25 25 fig.canvas.manager.set_window_title(wintitle)
26 26 fig.canvas.manager.resize(width, height)
27 27 matplotlib.pyplot.ion()
28 28 if show:
29 29 matplotlib.pyplot.show()
30 30
31 31 return fig
32 32
33 33 def closeFigure(show=False, fig=None):
34 34
35 matplotlib.pyplot.ioff()
35 # matplotlib.pyplot.ioff()
36 36 # matplotlib.pyplot.pause(0)
37 37
38 38 if show:
39 39 matplotlib.pyplot.show()
40 40
41 41 if fig != None:
42 42 matplotlib.pyplot.close(fig)
43 43 # matplotlib.pyplot.pause(0)
44 44 # matplotlib.pyplot.ion()
45 45
46 46 return
47 47
48 48 matplotlib.pyplot.close("all")
49 49 # matplotlib.pyplot.pause(0)
50 50 # matplotlib.pyplot.ion()
51 51
52 52 return
53 53
54 54 def saveFigure(fig, filename):
55 55
56 56 # matplotlib.pyplot.ioff()
57 57 fig.savefig(filename)
58 58 # matplotlib.pyplot.ion()
59 59
60 def clearFigure(fig):
61
62 fig.clf()
63
60 64 def setWinTitle(fig, title):
61 65
62 66 fig.canvas.manager.set_window_title(title)
63 67
64 68 def setTitle(fig, title):
65 69
66 70 fig.suptitle(title)
67 71
68 72 def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan, polar=False):
69 73
70 74 matplotlib.pyplot.ioff()
71 75 matplotlib.pyplot.figure(fig.number)
72 76 axes = matplotlib.pyplot.subplot2grid((nrow, ncol),
73 77 (xpos, ypos),
74 78 colspan=colspan,
75 79 rowspan=rowspan,
76 80 polar=polar)
77 81
78 82 matplotlib.pyplot.ion()
79 83 return axes
80 84
81 85 def setAxesText(ax, text):
82 86
83 87 ax.annotate(text,
84 88 xy = (.1, .99),
85 89 xycoords = 'figure fraction',
86 90 horizontalalignment = 'left',
87 91 verticalalignment = 'top',
88 92 fontsize = 10)
89 93
90 94 def printLabels(ax, xlabel, ylabel, title):
91 95
92 96 ax.set_xlabel(xlabel, size=11)
93 97 ax.set_ylabel(ylabel, size=11)
94 98 ax.set_title(title, size=8)
95 99
96 100 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='',
97 101 ticksize=9, xtick_visible=True, ytick_visible=True,
98 102 nxticks=4, nyticks=10,
99 103 grid=None,color='blue'):
100 104
101 105 """
102 106
103 107 Input:
104 108 grid : None, 'both', 'x', 'y'
105 109 """
106 110
107 111 matplotlib.pyplot.ioff()
108 112
109 113 ax.set_xlim([xmin,xmax])
110 114 ax.set_ylim([ymin,ymax])
111 115
112 116 printLabels(ax, xlabel, ylabel, title)
113 117
114 118 ######################################################
115 119 if (xmax-xmin)<=1:
116 120 xtickspos = numpy.linspace(xmin,xmax,nxticks)
117 121 xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos])
118 122 ax.set_xticks(xtickspos)
119 123 else:
120 124 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
121 125 # xtickspos = numpy.arange(nxticks)*float(xmax-xmin)/float(nxticks) + int(xmin)
122 126 ax.set_xticks(xtickspos)
123 127
124 128 for tick in ax.get_xticklabels():
125 129 tick.set_visible(xtick_visible)
126 130
127 131 for tick in ax.xaxis.get_major_ticks():
128 132 tick.label.set_fontsize(ticksize)
129 133
130 134 ######################################################
131 135 for tick in ax.get_yticklabels():
132 136 tick.set_visible(ytick_visible)
133 137
134 138 for tick in ax.yaxis.get_major_ticks():
135 139 tick.label.set_fontsize(ticksize)
136 140
137 141 ax.plot(x, y, color=color)
138 142 iplot = ax.lines[-1]
139 143
140 144 ######################################################
141 145 if '0.' in matplotlib.__version__[0:2]:
142 146 print "The matplotlib version has to be updated to 1.1 or newer"
143 147 return iplot
144 148
145 149 if '1.0.' in matplotlib.__version__[0:4]:
146 150 print "The matplotlib version has to be updated to 1.1 or newer"
147 151 return iplot
148 152
149 153 if grid != None:
150 154 ax.grid(b=True, which='major', axis=grid)
151 155
152 156 matplotlib.pyplot.tight_layout()
153 157
154 158 matplotlib.pyplot.ion()
155 159
156 160 return iplot
157 161
158 162 def set_linedata(ax, x, y, idline):
159 163
160 164 ax.lines[idline].set_data(x,y)
161 165
162 166 def pline(iplot, x, y, xlabel='', ylabel='', title=''):
163 167
164 168 ax = iplot.get_axes()
165 169
166 170 printLabels(ax, xlabel, ylabel, title)
167 171
168 172 set_linedata(ax, x, y, idline=0)
169 173
170 174 def addpline(ax, x, y, color, linestyle, lw):
171 175
172 176 ax.plot(x,y,color=color,linestyle=linestyle,lw=lw)
173 177
174 178
175 179 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax,
176 180 xlabel='', ylabel='', title='', ticksize = 9,
177 181 colormap='jet',cblabel='', cbsize="5%",
178 182 XAxisAsTime=False):
179 183
180 184 matplotlib.pyplot.ioff()
181 185
182 186 divider = make_axes_locatable(ax)
183 187 ax_cb = divider.new_horizontal(size=cbsize, pad=0.05)
184 188 fig = ax.get_figure()
185 189 fig.add_axes(ax_cb)
186 190
187 191 ax.set_xlim([xmin,xmax])
188 192 ax.set_ylim([ymin,ymax])
189 193
190 194 printLabels(ax, xlabel, ylabel, title)
191 195
192 196 imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
193 197 cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb)
194 198 cb.set_label(cblabel)
195 199
196 200 # for tl in ax_cb.get_yticklabels():
197 201 # tl.set_visible(True)
198 202
199 203 for tick in ax.yaxis.get_major_ticks():
200 204 tick.label.set_fontsize(ticksize)
201 205
202 206 for tick in ax.xaxis.get_major_ticks():
203 207 tick.label.set_fontsize(ticksize)
204 208
205 209 for tick in cb.ax.get_yticklabels():
206 210 tick.set_fontsize(ticksize)
207 211
208 212 ax_cb.yaxis.tick_right()
209 213
210 214 if '0.' in matplotlib.__version__[0:2]:
211 215 print "The matplotlib version has to be updated to 1.1 or newer"
212 216 return imesh
213 217
214 218 if '1.0.' in matplotlib.__version__[0:4]:
215 219 print "The matplotlib version has to be updated to 1.1 or newer"
216 220 return imesh
217 221
218 222 matplotlib.pyplot.tight_layout()
219 223
220 224 if XAxisAsTime:
221 225
222 226 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
223 227 ax.xaxis.set_major_formatter(FuncFormatter(func))
224 228 ax.xaxis.set_major_locator(LinearLocator(7))
225 229
226 230 matplotlib.pyplot.ion()
227 231 return imesh
228 232
229 233 def pcolor(imesh, z, xlabel='', ylabel='', title=''):
230 234
231 235 z = z.T
232 236 ax = imesh.get_axes()
233 237 printLabels(ax, xlabel, ylabel, title)
234 238 imesh.set_array(z.ravel())
235 239
236 240 def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
237 241
238 242 printLabels(ax, xlabel, ylabel, title)
239 243
240 244 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
241 245
242 246 def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
243 247
244 248 printLabels(ax, xlabel, ylabel, title)
245 249
246 250 ax.collections.remove(ax.collections[0])
247 251
248 252 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
249 253
250 254 def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
251 255 ticksize=9, xtick_visible=True, ytick_visible=True,
252 256 nxticks=4, nyticks=10,
253 257 grid=None):
254 258
255 259 """
256 260
257 261 Input:
258 262 grid : None, 'both', 'x', 'y'
259 263 """
260 264
261 265 matplotlib.pyplot.ioff()
262 266
263 267 lines = ax.plot(x.T, y)
264 268 leg = ax.legend(lines, legendlabels, loc='upper right')
265 269 leg.get_frame().set_alpha(0.5)
266 270 ax.set_xlim([xmin,xmax])
267 271 ax.set_ylim([ymin,ymax])
268 272 printLabels(ax, xlabel, ylabel, title)
269 273
270 274 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
271 275 ax.set_xticks(xtickspos)
272 276
273 277 for tick in ax.get_xticklabels():
274 278 tick.set_visible(xtick_visible)
275 279
276 280 for tick in ax.xaxis.get_major_ticks():
277 281 tick.label.set_fontsize(ticksize)
278 282
279 283 for tick in ax.get_yticklabels():
280 284 tick.set_visible(ytick_visible)
281 285
282 286 for tick in ax.yaxis.get_major_ticks():
283 287 tick.label.set_fontsize(ticksize)
284 288
285 289 iplot = ax.lines[-1]
286 290
287 291 if '0.' in matplotlib.__version__[0:2]:
288 292 print "The matplotlib version has to be updated to 1.1 or newer"
289 293 return iplot
290 294
291 295 if '1.0.' in matplotlib.__version__[0:4]:
292 296 print "The matplotlib version has to be updated to 1.1 or newer"
293 297 return iplot
294 298
295 299 if grid != None:
296 300 ax.grid(b=True, which='major', axis=grid)
297 301
298 302 matplotlib.pyplot.tight_layout()
299 303
300 304 matplotlib.pyplot.ion()
301 305
302 306 return iplot
303 307
304 308
305 309 def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''):
306 310
307 311 ax = iplot.get_axes()
308 312
309 313 printLabels(ax, xlabel, ylabel, title)
310 314
311 315 for i in range(len(ax.lines)):
312 316 line = ax.lines[i]
313 317 line.set_data(x[i,:],y)
314 318
315 319 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
316 320 ticksize=9, xtick_visible=True, ytick_visible=True,
317 321 nxticks=4, nyticks=10, marker='.', markersize=10, linestyle="None",
318 322 grid=None, XAxisAsTime=False):
319 323
320 324 """
321 325
322 326 Input:
323 327 grid : None, 'both', 'x', 'y'
324 328 """
325 329
326 330 matplotlib.pyplot.ioff()
327 331
328 332 # lines = ax.plot(x, y.T, marker=marker,markersize=markersize,linestyle=linestyle)
329 333 lines = ax.plot(x, y.T, linestyle=linestyle, marker=marker, markersize=markersize)
330 334 leg = ax.legend(lines, legendlabels, loc='upper left', bbox_to_anchor=(1.01, 1.00), numpoints=1, handlelength=1.5, \
331 335 handletextpad=0.5, borderpad=0.5, labelspacing=0.5, borderaxespad=0.)
332 336
333 337 for label in leg.get_texts(): label.set_fontsize(9)
334 338
335 339 ax.set_xlim([xmin,xmax])
336 340 ax.set_ylim([ymin,ymax])
337 341 printLabels(ax, xlabel, ylabel, title)
338 342
339 343 # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
340 344 # ax.set_xticks(xtickspos)
341 345
342 346 for tick in ax.get_xticklabels():
343 347 tick.set_visible(xtick_visible)
344 348
345 349 for tick in ax.xaxis.get_major_ticks():
346 350 tick.label.set_fontsize(ticksize)
347 351
348 352 for tick in ax.get_yticklabels():
349 353 tick.set_visible(ytick_visible)
350 354
351 355 for tick in ax.yaxis.get_major_ticks():
352 356 tick.label.set_fontsize(ticksize)
353 357
354 358 iplot = ax.lines[-1]
355 359
356 360 if '0.' in matplotlib.__version__[0:2]:
357 361 print "The matplotlib version has to be updated to 1.1 or newer"
358 362 return iplot
359 363
360 364 if '1.0.' in matplotlib.__version__[0:4]:
361 365 print "The matplotlib version has to be updated to 1.1 or newer"
362 366 return iplot
363 367
364 368 if grid != None:
365 369 ax.grid(b=True, which='major', axis=grid)
366 370
367 371 matplotlib.pyplot.tight_layout()
368 372
369 373 if XAxisAsTime:
370 374
371 375 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
372 376 ax.xaxis.set_major_formatter(FuncFormatter(func))
373 377 ax.xaxis.set_major_locator(LinearLocator(7))
374 378
375 379 matplotlib.pyplot.ion()
376 380
377 381 return iplot
378 382
379 383 def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''):
380 384
381 385 ax = iplot.get_axes()
382 386
383 387 printLabels(ax, xlabel, ylabel, title)
384 388
385 389 for i in range(len(ax.lines)):
386 390 line = ax.lines[i]
387 391 line.set_data(x,y[i,:])
388 392
389 393 def createPolar(ax, x, y,
390 394 xlabel='', ylabel='', title='', ticksize = 9,
391 395 colormap='jet',cblabel='', cbsize="5%",
392 396 XAxisAsTime=False):
393 397
394 398 matplotlib.pyplot.ioff()
395 399
396 400 ax.plot(x,y,'bo', markersize=5)
397 401 # ax.set_rmax(90)
398 402 ax.set_ylim(0,90)
399 403 ax.set_yticks(numpy.arange(0,90,20))
400 404 # ax.text(0, -110, ylabel, rotation='vertical', va ='center', ha = 'center' ,size='11')
401 405 # ax.text(0, 50, ylabel, rotation='vertical', va ='center', ha = 'left' ,size='11')
402 406 # ax.text(100, 100, 'example', ha='left', va='center', rotation='vertical')
403 407 ax.yaxis.labelpad = 230
404 408 printLabels(ax, xlabel, ylabel, title)
405 409 iplot = ax.lines[-1]
406 410
407 411 if '0.' in matplotlib.__version__[0:2]:
408 412 print "The matplotlib version has to be updated to 1.1 or newer"
409 413 return iplot
410 414
411 415 if '1.0.' in matplotlib.__version__[0:4]:
412 416 print "The matplotlib version has to be updated to 1.1 or newer"
413 417 return iplot
414 418
415 419 # if grid != None:
416 420 # ax.grid(b=True, which='major', axis=grid)
417 421
418 422 matplotlib.pyplot.tight_layout()
419 423
420 424 matplotlib.pyplot.ion()
421 425
422 426
423 427 return iplot
424 428
425 429 def polar(iplot, x, y, xlabel='', ylabel='', title=''):
426 430
427 431 ax = iplot.get_axes()
428 432
429 433 # ax.text(0, -110, ylabel, rotation='vertical', va ='center', ha = 'center',size='11')
430 434 printLabels(ax, xlabel, ylabel, title)
431 435
432 436 set_linedata(ax, x, y, idline=0)
433 437
434 438 def draw(fig):
435 439
436 440 if type(fig) == 'int':
437 441 raise ValueError, "Error drawing: Fig parameter should be a matplotlib figure object figure"
438 442
439 443 fig.canvas.draw()
440 444
441 445 def pause(interval=0.000001):
442 446
443 447 matplotlib.pyplot.pause(interval)
444 448 No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now