##// END OF EJS Templates
En jroplot.py se cambia el nombre de la clase ProfilePlot por PowerProfilePlot
Daniel Valdez -
r370:ac7ee0d5df8c
parent child
Show More
@@ -1,1354 +1,1354
1 1 import numpy
2 2 import time, datetime, os
3 3 from graphics.figure import *
4 4 def isRealtime(utcdatatime):
5 5 utcnow = time.mktime(datetime.datetime.utcnow().timetuple())
6 6 delta = utcnow - utcdatatime # abs
7 7 if delta >= 5*60.:
8 8 return False
9 9 return True
10 10
11 11 class CrossSpectraPlot(Figure):
12 12
13 13 __isConfig = None
14 14 __nsubplots = None
15 15
16 16 WIDTH = None
17 17 HEIGHT = None
18 18 WIDTHPROF = None
19 19 HEIGHTPROF = None
20 20 PREFIX = 'cspc'
21 21
22 22 def __init__(self):
23 23
24 24 self.__isConfig = False
25 25 self.__nsubplots = 4
26 26
27 27 self.WIDTH = 250
28 28 self.HEIGHT = 250
29 29 self.WIDTHPROF = 0
30 30 self.HEIGHTPROF = 0
31 31
32 32 def getSubplots(self):
33 33
34 34 ncol = 4
35 35 nrow = self.nplots
36 36
37 37 return nrow, ncol
38 38
39 39 def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True):
40 40
41 41 self.__showprofile = showprofile
42 42 self.nplots = nplots
43 43
44 44 ncolspan = 1
45 45 colspan = 1
46 46
47 47 self.createFigure(idfigure = idfigure,
48 48 wintitle = wintitle,
49 49 widthplot = self.WIDTH + self.WIDTHPROF,
50 50 heightplot = self.HEIGHT + self.HEIGHTPROF,
51 51 show=True)
52 52
53 53 nrow, ncol = self.getSubplots()
54 54
55 55 counter = 0
56 56 for y in range(nrow):
57 57 for x in range(ncol):
58 58 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
59 59
60 60 counter += 1
61 61
62 62 def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True',
63 63 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
64 64 save=False, figpath='./', figfile=None,
65 65 power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True):
66 66
67 67 """
68 68
69 69 Input:
70 70 dataOut :
71 71 idfigure :
72 72 wintitle :
73 73 channelList :
74 74 showProfile :
75 75 xmin : None,
76 76 xmax : None,
77 77 ymin : None,
78 78 ymax : None,
79 79 zmin : None,
80 80 zmax : None
81 81 """
82 82
83 83 if pairsList == None:
84 84 pairsIndexList = dataOut.pairsIndexList
85 85 else:
86 86 pairsIndexList = []
87 87 for pair in pairsList:
88 88 if pair not in dataOut.pairsList:
89 89 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
90 90 pairsIndexList.append(dataOut.pairsList.index(pair))
91 91
92 92 if pairsIndexList == []:
93 93 return
94 94
95 95 if len(pairsIndexList) > 4:
96 96 pairsIndexList = pairsIndexList[0:4]
97 97 factor = dataOut.normFactor
98 98 x = dataOut.getVelRange(1)
99 99 y = dataOut.getHeiRange()
100 100 z = dataOut.data_spc[:,:,:]/factor
101 101 # z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
102 102 avg = numpy.abs(numpy.average(z, axis=1))
103 103 noise = dataOut.getNoise()/factor
104 104
105 105 zdB = 10*numpy.log10(z)
106 106 avgdB = 10*numpy.log10(avg)
107 107 noisedB = 10*numpy.log10(noise)
108 108
109 109
110 110 thisDatetime = dataOut.datatime
111 111 title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
112 112 xlabel = "Velocity (m/s)"
113 113 ylabel = "Range (Km)"
114 114
115 115 if not self.__isConfig:
116 116
117 117 nplots = len(pairsIndexList)
118 118
119 119 self.setup(idfigure=idfigure,
120 120 nplots=nplots,
121 121 wintitle=wintitle,
122 122 showprofile=showprofile,
123 123 show=show)
124 124
125 125 if xmin == None: xmin = numpy.nanmin(x)
126 126 if xmax == None: xmax = numpy.nanmax(x)
127 127 if ymin == None: ymin = numpy.nanmin(y)
128 128 if ymax == None: ymax = numpy.nanmax(y)
129 129 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
130 130 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
131 131
132 132 self.__isConfig = True
133 133
134 134 self.setWinTitle(title)
135 135
136 136 for i in range(self.nplots):
137 137 pair = dataOut.pairsList[pairsIndexList[i]]
138 138
139 139 title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]])
140 140 zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor)
141 141 axes0 = self.axesList[i*self.__nsubplots]
142 142 axes0.pcolor(x, y, zdB,
143 143 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
144 144 xlabel=xlabel, ylabel=ylabel, title=title,
145 145 ticksize=9, colormap=power_cmap, cblabel='')
146 146
147 147 title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]])
148 148 zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor)
149 149 axes0 = self.axesList[i*self.__nsubplots+1]
150 150 axes0.pcolor(x, y, zdB,
151 151 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
152 152 xlabel=xlabel, ylabel=ylabel, title=title,
153 153 ticksize=9, colormap=power_cmap, cblabel='')
154 154
155 155 coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
156 156 coherence = numpy.abs(coherenceComplex)
157 157 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
158 158 phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi
159 159
160 160 title = "Coherence %d%d" %(pair[0], pair[1])
161 161 axes0 = self.axesList[i*self.__nsubplots+2]
162 162 axes0.pcolor(x, y, coherence,
163 163 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1,
164 164 xlabel=xlabel, ylabel=ylabel, title=title,
165 165 ticksize=9, colormap=coherence_cmap, cblabel='')
166 166
167 167 title = "Phase %d%d" %(pair[0], pair[1])
168 168 axes0 = self.axesList[i*self.__nsubplots+3]
169 169 axes0.pcolor(x, y, phase,
170 170 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
171 171 xlabel=xlabel, ylabel=ylabel, title=title,
172 172 ticksize=9, colormap=phase_cmap, cblabel='')
173 173
174 174
175 175
176 176 self.draw()
177 177
178 178 if save:
179 179 date = thisDatetime.strftime("%Y%m%d_%H%M%S")
180 180 if figfile == None:
181 181 figfile = self.getFilename(name = date)
182 182
183 183 self.saveFigure(figpath, figfile)
184 184
185 185
186 186 class RTIPlot(Figure):
187 187
188 188 __isConfig = None
189 189 __nsubplots = None
190 190
191 191 WIDTHPROF = None
192 192 HEIGHTPROF = None
193 193 PREFIX = 'rti'
194 194
195 195 def __init__(self):
196 196
197 197 self.timerange = 2*60*60
198 198 self.__isConfig = False
199 199 self.__nsubplots = 1
200 200
201 201 self.WIDTH = 800
202 202 self.HEIGHT = 150
203 203 self.WIDTHPROF = 120
204 204 self.HEIGHTPROF = 0
205 205 self.counterftp = 0
206 206
207 207 def getSubplots(self):
208 208
209 209 ncol = 1
210 210 nrow = self.nplots
211 211
212 212 return nrow, ncol
213 213
214 214 def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True):
215 215
216 216 self.__showprofile = showprofile
217 217 self.nplots = nplots
218 218
219 219 ncolspan = 1
220 220 colspan = 1
221 221 if showprofile:
222 222 ncolspan = 7
223 223 colspan = 6
224 224 self.__nsubplots = 2
225 225
226 226 self.createFigure(idfigure = idfigure,
227 227 wintitle = wintitle,
228 228 widthplot = self.WIDTH + self.WIDTHPROF,
229 229 heightplot = self.HEIGHT + self.HEIGHTPROF,
230 230 show=show)
231 231
232 232 nrow, ncol = self.getSubplots()
233 233
234 234 counter = 0
235 235 for y in range(nrow):
236 236 for x in range(ncol):
237 237
238 238 if counter >= self.nplots:
239 239 break
240 240
241 241 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
242 242
243 243 if showprofile:
244 244 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
245 245
246 246 counter += 1
247 247
248 248 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
249 249 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
250 250 timerange=None,
251 251 save=False, figpath='./', figfile=None, ftp=False, ftpratio=1, show=True):
252 252
253 253 """
254 254
255 255 Input:
256 256 dataOut :
257 257 idfigure :
258 258 wintitle :
259 259 channelList :
260 260 showProfile :
261 261 xmin : None,
262 262 xmax : None,
263 263 ymin : None,
264 264 ymax : None,
265 265 zmin : None,
266 266 zmax : None
267 267 """
268 268
269 269 if channelList == None:
270 270 channelIndexList = dataOut.channelIndexList
271 271 else:
272 272 channelIndexList = []
273 273 for channel in channelList:
274 274 if channel not in dataOut.channelList:
275 275 raise ValueError, "Channel %d is not in dataOut.channelList"
276 276 channelIndexList.append(dataOut.channelList.index(channel))
277 277
278 278 if timerange != None:
279 279 self.timerange = timerange
280 280
281 281 tmin = None
282 282 tmax = None
283 283 factor = dataOut.normFactor
284 284 x = dataOut.getTimeRange()
285 285 y = dataOut.getHeiRange()
286 286
287 287 z = dataOut.data_spc[channelIndexList,:,:]/factor
288 288 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
289 289 avg = numpy.average(z, axis=1)
290 290
291 291 avgdB = 10.*numpy.log10(avg)
292 292
293 293
294 294 thisDatetime = dataOut.datatime
295 295 title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y"))
296 296 xlabel = ""
297 297 ylabel = "Range (Km)"
298 298
299 299 if not self.__isConfig:
300 300
301 301 nplots = len(channelIndexList)
302 302
303 303 self.setup(idfigure=idfigure,
304 304 nplots=nplots,
305 305 wintitle=wintitle,
306 306 showprofile=showprofile,
307 307 show=show)
308 308
309 309 tmin, tmax = self.getTimeLim(x, xmin, xmax)
310 310 if ymin == None: ymin = numpy.nanmin(y)
311 311 if ymax == None: ymax = numpy.nanmax(y)
312 312 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
313 313 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
314 314
315 315 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
316 316 self.__isConfig = True
317 317
318 318
319 319 self.setWinTitle(title)
320 320
321 321 for i in range(self.nplots):
322 322 title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
323 323 axes = self.axesList[i*self.__nsubplots]
324 324 zdB = avgdB[i].reshape((1,-1))
325 325 axes.pcolorbuffer(x, y, zdB,
326 326 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
327 327 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
328 328 ticksize=9, cblabel='', cbsize="1%")
329 329
330 330 if self.__showprofile:
331 331 axes = self.axesList[i*self.__nsubplots +1]
332 332 axes.pline(avgdB[i], y,
333 333 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
334 334 xlabel='dB', ylabel='', title='',
335 335 ytick_visible=False,
336 336 grid='x')
337 337
338 338 self.draw()
339 339
340 340 if save:
341 341
342 342 if figfile == None:
343 343 figfile = self.getFilename(name = self.name)
344 344
345 345 self.saveFigure(figpath, figfile)
346 346
347 347 self.counterftp += 1
348 348 if (ftp and (self.counterftp==ftpratio)):
349 349 figfilename = os.path.join(figpath,figfile)
350 350 self.sendByFTP(figfilename)
351 351 self.counterftp = 0
352 352
353 353 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
354 354 self.__isConfig = False
355 355
356 356 class SpectraPlot(Figure):
357 357
358 358 __isConfig = None
359 359 __nsubplots = None
360 360
361 361 WIDTHPROF = None
362 362 HEIGHTPROF = None
363 363 PREFIX = 'spc'
364 364
365 365 def __init__(self):
366 366
367 367 self.__isConfig = False
368 368 self.__nsubplots = 1
369 369
370 370 self.WIDTH = 230
371 371 self.HEIGHT = 250
372 372 self.WIDTHPROF = 120
373 373 self.HEIGHTPROF = 0
374 374
375 375 def getSubplots(self):
376 376
377 377 ncol = int(numpy.sqrt(self.nplots)+0.9)
378 378 nrow = int(self.nplots*1./ncol + 0.9)
379 379
380 380 return nrow, ncol
381 381
382 382 def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True):
383 383
384 384 self.__showprofile = showprofile
385 385 self.nplots = nplots
386 386
387 387 ncolspan = 1
388 388 colspan = 1
389 389 if showprofile:
390 390 ncolspan = 3
391 391 colspan = 2
392 392 self.__nsubplots = 2
393 393
394 394 self.createFigure(idfigure = idfigure,
395 395 wintitle = wintitle,
396 396 widthplot = self.WIDTH + self.WIDTHPROF,
397 397 heightplot = self.HEIGHT + self.HEIGHTPROF,
398 398 show=show)
399 399
400 400 nrow, ncol = self.getSubplots()
401 401
402 402 counter = 0
403 403 for y in range(nrow):
404 404 for x in range(ncol):
405 405
406 406 if counter >= self.nplots:
407 407 break
408 408
409 409 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
410 410
411 411 if showprofile:
412 412 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
413 413
414 414 counter += 1
415 415
416 416 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
417 417 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
418 418 save=False, figpath='./', figfile=None, show=True):
419 419
420 420 """
421 421
422 422 Input:
423 423 dataOut :
424 424 idfigure :
425 425 wintitle :
426 426 channelList :
427 427 showProfile :
428 428 xmin : None,
429 429 xmax : None,
430 430 ymin : None,
431 431 ymax : None,
432 432 zmin : None,
433 433 zmax : None
434 434 """
435 435
436 436 if channelList == None:
437 437 channelIndexList = dataOut.channelIndexList
438 438 else:
439 439 channelIndexList = []
440 440 for channel in channelList:
441 441 if channel not in dataOut.channelList:
442 442 raise ValueError, "Channel %d is not in dataOut.channelList"
443 443 channelIndexList.append(dataOut.channelList.index(channel))
444 444 factor = dataOut.normFactor
445 445 x = dataOut.getVelRange(1)
446 446 y = dataOut.getHeiRange()
447 447
448 448 z = dataOut.data_spc[channelIndexList,:,:]/factor
449 449 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
450 450 avg = numpy.average(z, axis=1)
451 451 noise = dataOut.getNoise()/factor
452 452
453 453 zdB = 10*numpy.log10(z)
454 454 avgdB = 10*numpy.log10(avg)
455 455 noisedB = 10*numpy.log10(noise)
456 456
457 457 thisDatetime = dataOut.datatime
458 458 title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
459 459 xlabel = "Velocity (m/s)"
460 460 ylabel = "Range (Km)"
461 461
462 462 if not self.__isConfig:
463 463
464 464 nplots = len(channelIndexList)
465 465
466 466 self.setup(idfigure=idfigure,
467 467 nplots=nplots,
468 468 wintitle=wintitle,
469 469 showprofile=showprofile,
470 470 show=show)
471 471
472 472 if xmin == None: xmin = numpy.nanmin(x)
473 473 if xmax == None: xmax = numpy.nanmax(x)
474 474 if ymin == None: ymin = numpy.nanmin(y)
475 475 if ymax == None: ymax = numpy.nanmax(y)
476 476 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
477 477 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
478 478
479 479 self.__isConfig = True
480 480
481 481 self.setWinTitle(title)
482 482
483 483 for i in range(self.nplots):
484 484 title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noisedB[i])
485 485 axes = self.axesList[i*self.__nsubplots]
486 486 axes.pcolor(x, y, zdB[i,:,:],
487 487 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
488 488 xlabel=xlabel, ylabel=ylabel, title=title,
489 489 ticksize=9, cblabel='')
490 490
491 491 if self.__showprofile:
492 492 axes = self.axesList[i*self.__nsubplots +1]
493 493 axes.pline(avgdB[i], y,
494 494 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
495 495 xlabel='dB', ylabel='', title='',
496 496 ytick_visible=False,
497 497 grid='x')
498 498
499 499 noiseline = numpy.repeat(noisedB[i], len(y))
500 500 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
501 501
502 502 self.draw()
503 503
504 504 if save:
505 505 date = thisDatetime.strftime("%Y%m%d_%H%M%S")
506 506 if figfile == None:
507 507 figfile = self.getFilename(name = date)
508 508
509 509 self.saveFigure(figpath, figfile)
510 510
511 511 class Scope(Figure):
512 512
513 513 __isConfig = None
514 514
515 515 def __init__(self):
516 516
517 517 self.__isConfig = False
518 518 self.WIDTH = 600
519 519 self.HEIGHT = 200
520 520
521 521 def getSubplots(self):
522 522
523 523 nrow = self.nplots
524 524 ncol = 3
525 525 return nrow, ncol
526 526
527 527 def setup(self, idfigure, nplots, wintitle, show):
528 528
529 529 self.nplots = nplots
530 530
531 531 self.createFigure(idfigure=idfigure,
532 532 wintitle=wintitle,
533 533 show=show)
534 534
535 535 nrow,ncol = self.getSubplots()
536 536 colspan = 3
537 537 rowspan = 1
538 538
539 539 for i in range(nplots):
540 540 self.addAxes(nrow, ncol, i, 0, colspan, rowspan)
541 541
542 542
543 543
544 544 def run(self, dataOut, idfigure, wintitle="", channelList=None,
545 545 xmin=None, xmax=None, ymin=None, ymax=None, save=False,
546 546 figpath='./', figfile=None, show=True):
547 547
548 548 """
549 549
550 550 Input:
551 551 dataOut :
552 552 idfigure :
553 553 wintitle :
554 554 channelList :
555 555 xmin : None,
556 556 xmax : None,
557 557 ymin : None,
558 558 ymax : None,
559 559 """
560 560
561 561 if channelList == None:
562 562 channelIndexList = dataOut.channelIndexList
563 563 else:
564 564 channelIndexList = []
565 565 for channel in channelList:
566 566 if channel not in dataOut.channelList:
567 567 raise ValueError, "Channel %d is not in dataOut.channelList"
568 568 channelIndexList.append(dataOut.channelList.index(channel))
569 569
570 570 x = dataOut.heightList
571 571 y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
572 572 y = y.real
573 573
574 574 thisDatetime = dataOut.datatime
575 575 title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
576 576 xlabel = "Range (Km)"
577 577 ylabel = "Intensity"
578 578
579 579 if not self.__isConfig:
580 580 nplots = len(channelIndexList)
581 581
582 582 self.setup(idfigure=idfigure,
583 583 nplots=nplots,
584 584 wintitle=wintitle,
585 585 show=show)
586 586
587 587 if xmin == None: xmin = numpy.nanmin(x)
588 588 if xmax == None: xmax = numpy.nanmax(x)
589 589 if ymin == None: ymin = numpy.nanmin(y)
590 590 if ymax == None: ymax = numpy.nanmax(y)
591 591
592 592 self.__isConfig = True
593 593
594 594 self.setWinTitle(title)
595 595
596 596 for i in range(len(self.axesList)):
597 597 title = "Channel %d" %(i)
598 598 axes = self.axesList[i]
599 599 ychannel = y[i,:]
600 600 axes.pline(x, ychannel,
601 601 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
602 602 xlabel=xlabel, ylabel=ylabel, title=title)
603 603
604 604 self.draw()
605 605
606 606 if save:
607 607 date = thisDatetime.strftime("%Y%m%d_%H%M%S")
608 608 if figfile == None:
609 609 figfile = self.getFilename(name = date)
610 610
611 611 self.saveFigure(figpath, figfile)
612 612
613 class ProfilePlot(Figure):
613 class PowerProfilePlot(Figure):
614 614 __isConfig = None
615 615 __nsubplots = None
616 616
617 617 WIDTHPROF = None
618 618 HEIGHTPROF = None
619 619 PREFIX = 'spcprofile'
620 620
621 621 def __init__(self):
622 622 self.__isConfig = False
623 623 self.__nsubplots = 1
624 624
625 625 self.WIDTH = 300
626 626 self.HEIGHT = 500
627 627
628 628 def getSubplots(self):
629 629 ncol = 1
630 630 nrow = 1
631 631
632 632 return nrow, ncol
633 633
634 634 def setup(self, idfigure, nplots, wintitle, show):
635 635
636 636 self.nplots = nplots
637 637
638 638 ncolspan = 1
639 639 colspan = 1
640 640
641 641 self.createFigure(idfigure = idfigure,
642 642 wintitle = wintitle,
643 643 widthplot = self.WIDTH,
644 644 heightplot = self.HEIGHT,
645 645 show=show)
646 646
647 647 nrow, ncol = self.getSubplots()
648 648
649 649 counter = 0
650 650 for y in range(nrow):
651 651 for x in range(ncol):
652 652 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
653 653
654 654 def run(self, dataOut, idfigure, wintitle="", channelList=None,
655 655 xmin=None, xmax=None, ymin=None, ymax=None,
656 656 save=False, figpath='./', figfile=None, show=True):
657 657
658 658 if channelList == None:
659 659 channelIndexList = dataOut.channelIndexList
660 660 channelList = dataOut.channelList
661 661 else:
662 662 channelIndexList = []
663 663 for channel in channelList:
664 664 if channel not in dataOut.channelList:
665 665 raise ValueError, "Channel %d is not in dataOut.channelList"
666 666 channelIndexList.append(dataOut.channelList.index(channel))
667 667
668 668 factor = dataOut.normFactor
669 669 y = dataOut.getHeiRange()
670 670 x = dataOut.data_spc[channelIndexList,:,:]/factor
671 671 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
672 672 avg = numpy.average(x, axis=1)
673 673
674 674 avgdB = 10*numpy.log10(avg)
675 675
676 676 thisDatetime = dataOut.datatime
677 677 title = "Power Profile"
678 678 xlabel = "dB"
679 679 ylabel = "Range (Km)"
680 680
681 681 if not self.__isConfig:
682 682
683 683 nplots = 1
684 684
685 685 self.setup(idfigure=idfigure,
686 686 nplots=nplots,
687 687 wintitle=wintitle,
688 688 show=show)
689 689
690 690 if ymin == None: ymin = numpy.nanmin(y)
691 691 if ymax == None: ymax = numpy.nanmax(y)
692 692 if xmin == None: xmin = numpy.nanmin(avgdB)*0.9
693 693 if xmax == None: xmax = numpy.nanmax(avgdB)*0.9
694 694
695 695 self.__isConfig = True
696 696
697 697 self.setWinTitle(title)
698 698
699 699
700 700 title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
701 701 axes = self.axesList[0]
702 702
703 703 legendlabels = ["channel %d"%x for x in channelList]
704 704 axes.pmultiline(avgdB, y,
705 705 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
706 706 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
707 707 ytick_visible=True, nxticks=5,
708 708 grid='x')
709 709
710 710 self.draw()
711 711
712 712 if save:
713 713 date = thisDatetime.strftime("%Y%m%d")
714 714 if figfile == None:
715 715 figfile = self.getFilename(name = date)
716 716
717 717 self.saveFigure(figpath, figfile)
718 718
719 719 class CoherenceMap(Figure):
720 720 __isConfig = None
721 721 __nsubplots = None
722 722
723 723 WIDTHPROF = None
724 724 HEIGHTPROF = None
725 725 PREFIX = 'cmap'
726 726
727 727 def __init__(self):
728 728 self.timerange = 2*60*60
729 729 self.__isConfig = False
730 730 self.__nsubplots = 1
731 731
732 732 self.WIDTH = 800
733 733 self.HEIGHT = 150
734 734 self.WIDTHPROF = 120
735 735 self.HEIGHTPROF = 0
736 736 self.counterftp = 0
737 737
738 738 def getSubplots(self):
739 739 ncol = 1
740 740 nrow = self.nplots*2
741 741
742 742 return nrow, ncol
743 743
744 744 def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True):
745 745 self.__showprofile = showprofile
746 746 self.nplots = nplots
747 747
748 748 ncolspan = 1
749 749 colspan = 1
750 750 if showprofile:
751 751 ncolspan = 7
752 752 colspan = 6
753 753 self.__nsubplots = 2
754 754
755 755 self.createFigure(idfigure = idfigure,
756 756 wintitle = wintitle,
757 757 widthplot = self.WIDTH + self.WIDTHPROF,
758 758 heightplot = self.HEIGHT + self.HEIGHTPROF,
759 759 show=True)
760 760
761 761 nrow, ncol = self.getSubplots()
762 762
763 763 for y in range(nrow):
764 764 for x in range(ncol):
765 765
766 766 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
767 767
768 768 if showprofile:
769 769 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
770 770
771 771 def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True',
772 772 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
773 773 timerange=None,
774 774 save=False, figpath='./', figfile=None, ftp=False, ftpratio=1,
775 775 coherence_cmap='jet', phase_cmap='RdBu_r', show=True):
776 776
777 777 if pairsList == None:
778 778 pairsIndexList = dataOut.pairsIndexList
779 779 else:
780 780 pairsIndexList = []
781 781 for pair in pairsList:
782 782 if pair not in dataOut.pairsList:
783 783 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
784 784 pairsIndexList.append(dataOut.pairsList.index(pair))
785 785
786 786 if timerange != None:
787 787 self.timerange = timerange
788 788
789 789 if pairsIndexList == []:
790 790 return
791 791
792 792 if len(pairsIndexList) > 4:
793 793 pairsIndexList = pairsIndexList[0:4]
794 794
795 795 tmin = None
796 796 tmax = None
797 797 x = dataOut.getTimeRange()
798 798 y = dataOut.getHeiRange()
799 799
800 800 thisDatetime = dataOut.datatime
801 801 title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y"))
802 802 xlabel = ""
803 803 ylabel = "Range (Km)"
804 804
805 805 if not self.__isConfig:
806 806 nplots = len(pairsIndexList)
807 807 self.setup(idfigure=idfigure,
808 808 nplots=nplots,
809 809 wintitle=wintitle,
810 810 showprofile=showprofile,
811 811 show=show)
812 812
813 813 tmin, tmax = self.getTimeLim(x, xmin, xmax)
814 814 if ymin == None: ymin = numpy.nanmin(y)
815 815 if ymax == None: ymax = numpy.nanmax(y)
816 816
817 817 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
818 818
819 819 self.__isConfig = True
820 820
821 821 self.setWinTitle(title)
822 822
823 823 for i in range(self.nplots):
824 824
825 825 pair = dataOut.pairsList[pairsIndexList[i]]
826 826 coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
827 827 avgcoherenceComplex = numpy.average(coherenceComplex, axis=0)
828 828 coherence = numpy.abs(avgcoherenceComplex)
829 829 # coherence = numpy.abs(coherenceComplex)
830 830 # avg = numpy.average(coherence, axis=0)
831 831
832 832 z = coherence.reshape((1,-1))
833 833
834 834 counter = 0
835 835
836 836 title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
837 837 axes = self.axesList[i*self.__nsubplots*2]
838 838 axes.pcolorbuffer(x, y, z,
839 839 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1,
840 840 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
841 841 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
842 842
843 843 if self.__showprofile:
844 844 counter += 1
845 845 axes = self.axesList[i*self.__nsubplots*2 + counter]
846 846 axes.pline(coherence, y,
847 847 xmin=0, xmax=1, ymin=ymin, ymax=ymax,
848 848 xlabel='', ylabel='', title='', ticksize=7,
849 849 ytick_visible=False, nxticks=5,
850 850 grid='x')
851 851
852 852 counter += 1
853 853 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
854 854 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
855 855 # avg = numpy.average(phase, axis=0)
856 856 z = phase.reshape((1,-1))
857 857
858 858 title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
859 859 axes = self.axesList[i*self.__nsubplots*2 + counter]
860 860 axes.pcolorbuffer(x, y, z,
861 861 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
862 862 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
863 863 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
864 864
865 865 if self.__showprofile:
866 866 counter += 1
867 867 axes = self.axesList[i*self.__nsubplots*2 + counter]
868 868 axes.pline(phase, y,
869 869 xmin=-180, xmax=180, ymin=ymin, ymax=ymax,
870 870 xlabel='', ylabel='', title='', ticksize=7,
871 871 ytick_visible=False, nxticks=4,
872 872 grid='x')
873 873
874 874 self.draw()
875 875
876 876 if save:
877 877
878 878 if figfile == None:
879 879 figfile = self.getFilename(name = self.name)
880 880
881 881 self.saveFigure(figpath, figfile)
882 882
883 883 self.counterftp += 1
884 884 if (ftp and (self.counterftp==ftpratio)):
885 885 figfilename = os.path.join(figpath,figfile)
886 886 self.sendByFTP(figfilename)
887 887 self.counterftp = 0
888 888
889 889 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
890 890 self.__isConfig = False
891 891
892 892 class RTIfromNoise(Figure):
893 893
894 894 __isConfig = None
895 895 __nsubplots = None
896 896
897 897 PREFIX = 'rtinoise'
898 898
899 899 def __init__(self):
900 900
901 901 self.timerange = 24*60*60
902 902 self.__isConfig = False
903 903 self.__nsubplots = 1
904 904
905 905 self.WIDTH = 820
906 906 self.HEIGHT = 200
907 907 self.WIDTHPROF = 120
908 908 self.HEIGHTPROF = 0
909 909 self.xdata = None
910 910 self.ydata = None
911 911
912 912 def getSubplots(self):
913 913
914 914 ncol = 1
915 915 nrow = 1
916 916
917 917 return nrow, ncol
918 918
919 919 def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True):
920 920
921 921 self.__showprofile = showprofile
922 922 self.nplots = nplots
923 923
924 924 ncolspan = 7
925 925 colspan = 6
926 926 self.__nsubplots = 2
927 927
928 928 self.createFigure(idfigure = idfigure,
929 929 wintitle = wintitle,
930 930 widthplot = self.WIDTH+self.WIDTHPROF,
931 931 heightplot = self.HEIGHT+self.HEIGHTPROF,
932 932 show=show)
933 933
934 934 nrow, ncol = self.getSubplots()
935 935
936 936 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
937 937
938 938
939 939 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
940 940 xmin=None, xmax=None, ymin=None, ymax=None,
941 941 timerange=None,
942 942 save=False, figpath='./', figfile=None, show=True):
943 943
944 944 if channelList == None:
945 945 channelIndexList = dataOut.channelIndexList
946 946 channelList = dataOut.channelList
947 947 else:
948 948 channelIndexList = []
949 949 for channel in channelList:
950 950 if channel not in dataOut.channelList:
951 951 raise ValueError, "Channel %d is not in dataOut.channelList"
952 952 channelIndexList.append(dataOut.channelList.index(channel))
953 953
954 954 if timerange != None:
955 955 self.timerange = timerange
956 956
957 957 tmin = None
958 958 tmax = None
959 959 x = dataOut.getTimeRange()
960 960 y = dataOut.getHeiRange()
961 961 factor = dataOut.normFactor
962 962 noise = dataOut.getNoise()/factor
963 963 noisedB = 10*numpy.log10(noise)
964 964
965 965 thisDatetime = dataOut.datatime
966 966 title = "RTI Noise: %s" %(thisDatetime.strftime("%d-%b-%Y"))
967 967 xlabel = ""
968 968 ylabel = "Range (Km)"
969 969
970 970 if not self.__isConfig:
971 971
972 972 nplots = 1
973 973
974 974 self.setup(idfigure=idfigure,
975 975 nplots=nplots,
976 976 wintitle=wintitle,
977 977 showprofile=showprofile,
978 978 show=show)
979 979
980 980 tmin, tmax = self.getTimeLim(x, xmin, xmax)
981 981 if ymin == None: ymin = numpy.nanmin(noisedB)
982 982 if ymax == None: ymax = numpy.nanmax(noisedB)
983 983
984 984 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
985 985 self.__isConfig = True
986 986
987 987 self.xdata = numpy.array([])
988 988 self.ydata = numpy.array([])
989 989
990 990 self.setWinTitle(title)
991 991
992 992
993 993 title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y"))
994 994
995 995 legendlabels = ["channel %d"%idchannel for idchannel in channelList]
996 996 axes = self.axesList[0]
997 997
998 998 self.xdata = numpy.hstack((self.xdata, x[0:1]))
999 999
1000 1000 if len(self.ydata)==0:
1001 1001 self.ydata = noisedB[channelIndexList].reshape(-1,1)
1002 1002 else:
1003 1003 self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1)))
1004 1004
1005 1005
1006 1006 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1007 1007 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
1008 1008 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1009 1009 XAxisAsTime=True
1010 1010 )
1011 1011
1012 1012 self.draw()
1013 1013
1014 1014 if save:
1015 1015
1016 1016 if figfile == None:
1017 1017 figfile = self.getFilename(name = self.name)
1018 1018
1019 1019 self.saveFigure(figpath, figfile)
1020 1020
1021 1021 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1022 1022 self.__isConfig = False
1023 1023 del self.xdata
1024 1024 del self.ydata
1025 1025
1026 1026
1027 1027 class SpectraHeisScope(Figure):
1028 1028
1029 1029
1030 1030 __isConfig = None
1031 1031 __nsubplots = None
1032 1032
1033 1033 WIDTHPROF = None
1034 1034 HEIGHTPROF = None
1035 1035 PREFIX = 'spc'
1036 1036
1037 1037 def __init__(self):
1038 1038
1039 1039 self.__isConfig = False
1040 1040 self.__nsubplots = 1
1041 1041
1042 1042 self.WIDTH = 230
1043 1043 self.HEIGHT = 250
1044 1044 self.WIDTHPROF = 120
1045 1045 self.HEIGHTPROF = 0
1046 1046 self.counterftp = 0
1047 1047
1048 1048 def getSubplots(self):
1049 1049
1050 1050 ncol = int(numpy.sqrt(self.nplots)+0.9)
1051 1051 nrow = int(self.nplots*1./ncol + 0.9)
1052 1052
1053 1053 return nrow, ncol
1054 1054
1055 1055 def setup(self, idfigure, nplots, wintitle, show):
1056 1056
1057 1057 showprofile = False
1058 1058 self.__showprofile = showprofile
1059 1059 self.nplots = nplots
1060 1060
1061 1061 ncolspan = 1
1062 1062 colspan = 1
1063 1063 if showprofile:
1064 1064 ncolspan = 3
1065 1065 colspan = 2
1066 1066 self.__nsubplots = 2
1067 1067
1068 1068 self.createFigure(idfigure = idfigure,
1069 1069 wintitle = wintitle,
1070 1070 widthplot = self.WIDTH + self.WIDTHPROF,
1071 1071 heightplot = self.HEIGHT + self.HEIGHTPROF,
1072 1072 show = show)
1073 1073
1074 1074 nrow, ncol = self.getSubplots()
1075 1075
1076 1076 counter = 0
1077 1077 for y in range(nrow):
1078 1078 for x in range(ncol):
1079 1079
1080 1080 if counter >= self.nplots:
1081 1081 break
1082 1082
1083 1083 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1084 1084
1085 1085 if showprofile:
1086 1086 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1087 1087
1088 1088 counter += 1
1089 1089
1090 1090 # __isConfig = None
1091 1091 # def __init__(self):
1092 1092 #
1093 1093 # self.__isConfig = False
1094 1094 # self.WIDTH = 600
1095 1095 # self.HEIGHT = 200
1096 1096 #
1097 1097 # def getSubplots(self):
1098 1098 #
1099 1099 # nrow = self.nplots
1100 1100 # ncol = 3
1101 1101 # return nrow, ncol
1102 1102 #
1103 1103 # def setup(self, idfigure, nplots, wintitle):
1104 1104 #
1105 1105 # self.nplots = nplots
1106 1106 #
1107 1107 # self.createFigure(idfigure, wintitle)
1108 1108 #
1109 1109 # nrow,ncol = self.getSubplots()
1110 1110 # colspan = 3
1111 1111 # rowspan = 1
1112 1112 #
1113 1113 # for i in range(nplots):
1114 1114 # self.addAxes(nrow, ncol, i, 0, colspan, rowspan)
1115 1115
1116 1116 def run(self, dataOut, idfigure, wintitle="", channelList=None,
1117 1117 xmin=None, xmax=None, ymin=None, ymax=None, save=False,
1118 1118 figpath='./', figfile=None, ftp=False, ftpratio=1, show=True):
1119 1119
1120 1120 """
1121 1121
1122 1122 Input:
1123 1123 dataOut :
1124 1124 idfigure :
1125 1125 wintitle :
1126 1126 channelList :
1127 1127 xmin : None,
1128 1128 xmax : None,
1129 1129 ymin : None,
1130 1130 ymax : None,
1131 1131 """
1132 1132
1133 1133 if dataOut.realtime:
1134 1134 if not(isRealtime(utcdatatime = dataOut.utctime)):
1135 1135 print 'Skipping this plot function'
1136 1136 return
1137 1137
1138 1138 if channelList == None:
1139 1139 channelIndexList = dataOut.channelIndexList
1140 1140 else:
1141 1141 channelIndexList = []
1142 1142 for channel in channelList:
1143 1143 if channel not in dataOut.channelList:
1144 1144 raise ValueError, "Channel %d is not in dataOut.channelList"
1145 1145 channelIndexList.append(dataOut.channelList.index(channel))
1146 1146
1147 1147 # x = dataOut.heightList
1148 1148 c = 3E8
1149 1149 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1150 1150 #deberia cambiar para el caso de 1Mhz y 100KHz
1151 1151 x = numpy.arange(-1*dataOut.nHeights/2.,dataOut.nHeights/2.)*(c/(2*deltaHeight*dataOut.nHeights*1000))
1152 1152 x= x/(10000.0)
1153 1153 # y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
1154 1154 # y = y.real
1155 1155 datadB = 10.*numpy.log10(dataOut.data_spc)
1156 1156 y = datadB
1157 1157
1158 1158 thisDatetime = dataOut.datatime
1159 1159 title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1160 1160 xlabel = "Frequency x 10000"
1161 1161 ylabel = "Intensity (dB)"
1162 1162
1163 1163 if not self.__isConfig:
1164 1164 nplots = len(channelIndexList)
1165 1165
1166 1166 self.setup(idfigure=idfigure,
1167 1167 nplots=nplots,
1168 1168 wintitle=wintitle,
1169 1169 show=show)
1170 1170
1171 1171 if xmin == None: xmin = numpy.nanmin(x)
1172 1172 if xmax == None: xmax = numpy.nanmax(x)
1173 1173 if ymin == None: ymin = numpy.nanmin(y)
1174 1174 if ymax == None: ymax = numpy.nanmax(y)
1175 1175
1176 1176 self.__isConfig = True
1177 1177
1178 1178 self.setWinTitle(title)
1179 1179
1180 1180 for i in range(len(self.axesList)):
1181 1181 ychannel = y[i,:]
1182 1182 title = "Channel %d - peak:%.2f" %(i,numpy.max(ychannel))
1183 1183 axes = self.axesList[i]
1184 1184 axes.pline(x, ychannel,
1185 1185 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1186 1186 xlabel=xlabel, ylabel=ylabel, title=title, grid='both')
1187 1187
1188 1188
1189 1189 self.draw()
1190 1190
1191 1191 if save:
1192 1192 date = thisDatetime.strftime("%Y%m%d_%H%M%S")
1193 1193 if figfile == None:
1194 1194 figfile = self.getFilename(name = date)
1195 1195
1196 1196 self.saveFigure(figpath, figfile)
1197 1197
1198 1198 self.counterftp += 1
1199 1199 if (ftp and (self.counterftp==ftpratio)):
1200 1200 figfilename = os.path.join(figpath,figfile)
1201 1201 self.sendByFTP(figfilename)
1202 1202 self.counterftp = 0
1203 1203
1204 1204
1205 1205 class RTIfromSpectraHeis(Figure):
1206 1206
1207 1207 __isConfig = None
1208 1208 __nsubplots = None
1209 1209
1210 1210 PREFIX = 'rtinoise'
1211 1211
1212 1212 def __init__(self):
1213 1213
1214 1214 self.timerange = 24*60*60
1215 1215 self.__isConfig = False
1216 1216 self.__nsubplots = 1
1217 1217
1218 1218 self.WIDTH = 820
1219 1219 self.HEIGHT = 200
1220 1220 self.WIDTHPROF = 120
1221 1221 self.HEIGHTPROF = 0
1222 1222 self.counterftp = 0
1223 1223 self.xdata = None
1224 1224 self.ydata = None
1225 1225
1226 1226 def getSubplots(self):
1227 1227
1228 1228 ncol = 1
1229 1229 nrow = 1
1230 1230
1231 1231 return nrow, ncol
1232 1232
1233 1233 def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True):
1234 1234
1235 1235 self.__showprofile = showprofile
1236 1236 self.nplots = nplots
1237 1237
1238 1238 ncolspan = 7
1239 1239 colspan = 6
1240 1240 self.__nsubplots = 2
1241 1241
1242 1242 self.createFigure(idfigure = idfigure,
1243 1243 wintitle = wintitle,
1244 1244 widthplot = self.WIDTH+self.WIDTHPROF,
1245 1245 heightplot = self.HEIGHT+self.HEIGHTPROF,
1246 1246 show = show)
1247 1247
1248 1248 nrow, ncol = self.getSubplots()
1249 1249
1250 1250 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1251 1251
1252 1252
1253 1253 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
1254 1254 xmin=None, xmax=None, ymin=None, ymax=None,
1255 1255 timerange=None,
1256 1256 save=False, figpath='./', figfile=None, ftp=False, ftpratio=1, show=True):
1257 1257
1258 1258 if channelList == None:
1259 1259 channelIndexList = dataOut.channelIndexList
1260 1260 channelList = dataOut.channelList
1261 1261 else:
1262 1262 channelIndexList = []
1263 1263 for channel in channelList:
1264 1264 if channel not in dataOut.channelList:
1265 1265 raise ValueError, "Channel %d is not in dataOut.channelList"
1266 1266 channelIndexList.append(dataOut.channelList.index(channel))
1267 1267
1268 1268 if timerange != None:
1269 1269 self.timerange = timerange
1270 1270
1271 1271 tmin = None
1272 1272 tmax = None
1273 1273 x = dataOut.getTimeRange()
1274 1274 y = dataOut.getHeiRange()
1275 1275
1276 1276 factor = 1
1277 1277 data = dataOut.data_spc/factor
1278 1278 data = numpy.average(data,axis=1)
1279 1279 datadB = 10*numpy.log10(data)
1280 1280
1281 1281 # factor = dataOut.normFactor
1282 1282 # noise = dataOut.getNoise()/factor
1283 1283 # noisedB = 10*numpy.log10(noise)
1284 1284
1285 1285 thisDatetime = dataOut.datatime
1286 1286 title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y"))
1287 1287 xlabel = "Local Time"
1288 1288 ylabel = "Intensity (dB)"
1289 1289
1290 1290 if not self.__isConfig:
1291 1291
1292 1292 nplots = 1
1293 1293
1294 1294 self.setup(idfigure=idfigure,
1295 1295 nplots=nplots,
1296 1296 wintitle=wintitle,
1297 1297 showprofile=showprofile,
1298 1298 show=show)
1299 1299
1300 1300 tmin, tmax = self.getTimeLim(x, xmin, xmax)
1301 1301 if ymin == None: ymin = numpy.nanmin(datadB)
1302 1302 if ymax == None: ymax = numpy.nanmax(datadB)
1303 1303
1304 1304 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1305 1305 self.__isConfig = True
1306 1306
1307 1307 self.xdata = numpy.array([])
1308 1308 self.ydata = numpy.array([])
1309 1309
1310 1310 self.setWinTitle(title)
1311 1311
1312 1312
1313 1313 # title = "RTI %s" %(thisDatetime.strftime("%d-%b-%Y"))
1314 1314 title = "RTI-Noise - %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1315 1315
1316 1316 legendlabels = ["channel %d"%idchannel for idchannel in channelList]
1317 1317 axes = self.axesList[0]
1318 1318
1319 1319 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1320 1320
1321 1321 if len(self.ydata)==0:
1322 1322 self.ydata = datadB[channelIndexList].reshape(-1,1)
1323 1323 else:
1324 1324 self.ydata = numpy.hstack((self.ydata, datadB[channelIndexList].reshape(-1,1)))
1325 1325
1326 1326
1327 1327 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1328 1328 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
1329 1329 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='.', markersize=8, linestyle="solid", grid='both',
1330 1330 XAxisAsTime=True
1331 1331 )
1332 1332
1333 1333 self.draw()
1334 1334
1335 1335 if save:
1336 1336
1337 1337 if figfile == None:
1338 1338 figfile = self.getFilename(name = self.name)
1339 1339
1340 1340 self.saveFigure(figpath, figfile)
1341 1341
1342 1342 self.counterftp += 1
1343 1343 if (ftp and (self.counterftp==ftpratio)):
1344 1344 figfilename = os.path.join(figpath,figfile)
1345 1345 self.sendByFTP(figfilename)
1346 1346 self.counterftp = 0
1347 1347
1348 1348 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1349 1349 self.__isConfig = False
1350 1350 del self.xdata
1351 1351 del self.ydata
1352 1352
1353 1353
1354 1354 No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now