##// END OF EJS Templates
reading AMISR data from different Beams, other considerations to do RTI Plots, timezone is fixed to 300 minutes, x-axis in localtime.
Daniel Valdez -
r476:29575f70eb4a
parent child
Show More
@@ -1,690 +1,690
1 1 '''
2 2
3 3 $Author: murco $
4 4 $Id: JROData.py 173 2012-11-20 15:06:21Z murco $
5 5 '''
6 6
7 7 import os, sys
8 8 import copy
9 9 import numpy
10 10 import datetime
11
11 import time
12 12 from jroheaderIO import SystemHeader, RadarControllerHeader
13 13
14 14
15 15 def hildebrand_sekhon(data, navg):
16 16
17 17 data = data.copy()
18 18
19 19 sortdata = numpy.sort(data,axis=None)
20 20 lenOfData = len(sortdata)
21 21 nums_min = lenOfData/10
22 22
23 23 if (lenOfData/10) > 2:
24 24 nums_min = lenOfData/10
25 25 else:
26 26 nums_min = 2
27 27
28 28 sump = 0.
29 29
30 30 sumq = 0.
31 31
32 32 j = 0
33 33
34 34 cont = 1
35 35
36 36 while((cont==1)and(j<lenOfData)):
37 37
38 38 sump += sortdata[j]
39 39
40 40 sumq += sortdata[j]**2
41 41
42 42 j += 1
43 43
44 44 if j > nums_min:
45 45 rtest = float(j)/(j-1) + 1.0/navg
46 46 if ((sumq*j) > (rtest*sump**2)):
47 47 j = j - 1
48 48 sump = sump - sortdata[j]
49 49 sumq = sumq - sortdata[j]**2
50 50 cont = 0
51 51
52 52 lnoise = sump /j
53 53 stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1))
54 54 return lnoise
55 55
56 56 class JROData:
57 57
58 58 # m_BasicHeader = BasicHeader()
59 59 # m_ProcessingHeader = ProcessingHeader()
60 60
61 61 systemHeaderObj = SystemHeader()
62 62
63 63 radarControllerHeaderObj = RadarControllerHeader()
64 64
65 65 # data = None
66 66
67 67 type = None
68 68
69 69 dtype = None
70 70
71 71 # nChannels = None
72 72
73 73 # nHeights = None
74 74
75 75 nProfiles = None
76 76
77 77 heightList = None
78 78
79 79 channelList = None
80 80
81 81 flagNoData = True
82 82
83 83 flagTimeBlock = False
84 84
85 85 useLocalTime = False
86 86
87 87 utctime = None
88 88
89 89 timeZone = None
90 90
91 91 dstFlag = None
92 92
93 93 errorCount = None
94 94
95 95 blocksize = None
96 96
97 97 nCode = None
98 98
99 99 nBaud = None
100 100
101 101 code = None
102 102
103 103 flagDecodeData = False #asumo q la data no esta decodificada
104 104
105 105 flagDeflipData = False #asumo q la data no esta sin flip
106 106
107 107 flagShiftFFT = False
108 108
109 109 ippSeconds = None
110 110
111 111 timeInterval = None
112 112
113 113 nCohInt = None
114 114
115 115 noise = None
116 116
117 117 windowOfFilter = 1
118 118
119 119 #Speed of ligth
120 120 C = 3e8
121 121
122 122 frequency = 49.92e6
123 123
124 124 realtime = False
125 125
126 126 beacon_heiIndexList = None
127 127
128 128 last_block = None
129 129
130 130 blocknow = None
131 131
132 132 def __init__(self):
133 133
134 134 raise ValueError, "This class has not been implemented"
135 135
136 136 def copy(self, inputObj=None):
137 137
138 138 if inputObj == None:
139 139 return copy.deepcopy(self)
140 140
141 141 for key in inputObj.__dict__.keys():
142 142 self.__dict__[key] = inputObj.__dict__[key]
143 143
144 144 def deepcopy(self):
145 145
146 146 return copy.deepcopy(self)
147 147
148 148 def isEmpty(self):
149 149
150 150 return self.flagNoData
151 151
152 152 def getNoise(self):
153 153
154 154 raise ValueError, "Not implemented"
155 155
156 156 def getNChannels(self):
157 157
158 158 return len(self.channelList)
159 159
160 160 def getChannelIndexList(self):
161 161
162 162 return range(self.nChannels)
163 163
164 164 def getNHeights(self):
165 165
166 166 return len(self.heightList)
167 167
168 168 def getHeiRange(self, extrapoints=0):
169 169
170 170 heis = self.heightList
171 171 # deltah = self.heightList[1] - self.heightList[0]
172 172 #
173 173 # heis.append(self.heightList[-1])
174 174
175 175 return heis
176 176
177 177 def getltctime(self):
178 178
179 179 if self.useLocalTime:
180 180 return self.utctime - self.timeZone*60
181 181
182 182 return self.utctime
183 183
184 184 def getDatatime(self):
185 185
186 186 datatime = datetime.datetime.utcfromtimestamp(self.ltctime)
187 187 return datatime
188 188
189 189 def getTimeRange(self):
190 190
191 191 datatime = []
192 192
193 193 datatime.append(self.ltctime)
194 194 datatime.append(self.ltctime + self.timeInterval)
195 195
196 196 datatime = numpy.array(datatime)
197 197
198 198 return datatime
199 199
200 200 def getFmax(self):
201 201
202 202 PRF = 1./(self.ippSeconds * self.nCohInt)
203 203
204 204 fmax = PRF/2.
205 205
206 206 return fmax
207 207
208 208 def getVmax(self):
209 209
210 210 _lambda = self.C/self.frequency
211 211
212 212 vmax = self.getFmax() * _lambda
213 213
214 214 return vmax
215 215
216 216 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
217 217 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
218 218 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
219 219 noise = property(getNoise, "I'm the 'nHeights' property.")
220 220 datatime = property(getDatatime, "I'm the 'datatime' property")
221 221 ltctime = property(getltctime, "I'm the 'ltctime' property")
222 222
223 223 class Voltage(JROData):
224 224
225 225 #data es un numpy array de 2 dmensiones (canales, alturas)
226 226 data = None
227 227
228 228 def __init__(self):
229 229 '''
230 230 Constructor
231 231 '''
232 232
233 233 self.radarControllerHeaderObj = RadarControllerHeader()
234 234
235 235 self.systemHeaderObj = SystemHeader()
236 236
237 237 self.type = "Voltage"
238 238
239 239 self.data = None
240 240
241 241 self.dtype = None
242 242
243 243 # self.nChannels = 0
244 244
245 245 # self.nHeights = 0
246 246
247 247 self.nProfiles = None
248 248
249 249 self.heightList = None
250 250
251 251 self.channelList = None
252 252
253 253 # self.channelIndexList = None
254 254
255 255 self.flagNoData = True
256 256
257 257 self.flagTimeBlock = False
258 258
259 259 self.utctime = None
260 260
261 261 self.timeZone = None
262 262
263 263 self.dstFlag = None
264 264
265 265 self.errorCount = None
266 266
267 267 self.nCohInt = None
268 268
269 269 self.blocksize = None
270 270
271 271 self.flagDecodeData = False #asumo q la data no esta decodificada
272 272
273 273 self.flagDeflipData = False #asumo q la data no esta sin flip
274 274
275 275 self.flagShiftFFT = False
276 276
277 277
278 278 def getNoisebyHildebrand(self):
279 279 """
280 280 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
281 281
282 282 Return:
283 283 noiselevel
284 284 """
285 285
286 286 for channel in range(self.nChannels):
287 287 daux = self.data_spc[channel,:,:]
288 288 self.noise[channel] = hildebrand_sekhon(daux, self.nCohInt)
289 289
290 290 return self.noise
291 291
292 292 def getNoise(self, type = 1):
293 293
294 294 self.noise = numpy.zeros(self.nChannels)
295 295
296 296 if type == 1:
297 297 noise = self.getNoisebyHildebrand()
298 298
299 299 return 10*numpy.log10(noise)
300 300
301 301 class Spectra(JROData):
302 302
303 303 #data es un numpy array de 2 dmensiones (canales, perfiles, alturas)
304 304 data_spc = None
305 305
306 306 #data es un numpy array de 2 dmensiones (canales, pares, alturas)
307 307 data_cspc = None
308 308
309 309 #data es un numpy array de 2 dmensiones (canales, alturas)
310 310 data_dc = None
311 311
312 312 nFFTPoints = None
313 313
314 314 nPairs = None
315 315
316 316 pairsList = None
317 317
318 318 nIncohInt = None
319 319
320 320 wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia
321 321
322 322 nCohInt = None #se requiere para determinar el valor de timeInterval
323 323
324 324 ippFactor = None
325 325
326 326 def __init__(self):
327 327 '''
328 328 Constructor
329 329 '''
330 330
331 331 self.radarControllerHeaderObj = RadarControllerHeader()
332 332
333 333 self.systemHeaderObj = SystemHeader()
334 334
335 335 self.type = "Spectra"
336 336
337 337 # self.data = None
338 338
339 339 self.dtype = None
340 340
341 341 # self.nChannels = 0
342 342
343 343 # self.nHeights = 0
344 344
345 345 self.nProfiles = None
346 346
347 347 self.heightList = None
348 348
349 349 self.channelList = None
350 350
351 351 # self.channelIndexList = None
352 352
353 353 self.flagNoData = True
354 354
355 355 self.flagTimeBlock = False
356 356
357 357 self.utctime = None
358 358
359 359 self.nCohInt = None
360 360
361 361 self.nIncohInt = None
362 362
363 363 self.blocksize = None
364 364
365 365 self.nFFTPoints = None
366 366
367 367 self.wavelength = None
368 368
369 369 self.flagDecodeData = False #asumo q la data no esta decodificada
370 370
371 371 self.flagDeflipData = False #asumo q la data no esta sin flip
372 372
373 373 self.flagShiftFFT = False
374 374
375 375 self.ippFactor = 1
376 376
377 377 self.noise = None
378 378
379 379 self.beacon_heiIndexList = []
380 380
381 381
382 382 def getNoisebyHildebrand(self):
383 383 """
384 384 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
385 385
386 386 Return:
387 387 noiselevel
388 388 """
389 389 noise = numpy.zeros(self.nChannels)
390 390 for channel in range(self.nChannels):
391 391 daux = self.data_spc[channel,:,:]
392 392 noise[channel] = hildebrand_sekhon(daux, self.nIncohInt)
393 393
394 394 return noise
395 395
396 396 def getNoise(self):
397 397 if self.noise != None:
398 398 return self.noise
399 399 else:
400 400 noise = self.getNoisebyHildebrand()
401 401 return noise
402 402
403 403
404 404 def getFreqRange(self, extrapoints=0):
405 405
406 406 deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor)
407 407 freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
408 408
409 409 return freqrange
410 410
411 411 def getVelRange(self, extrapoints=0):
412 412
413 413 deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor)
414 414 velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2
415 415
416 416 return velrange
417 417
418 418 def getNPairs(self):
419 419
420 420 return len(self.pairsList)
421 421
422 422 def getPairsIndexList(self):
423 423
424 424 return range(self.nPairs)
425 425
426 426 def getNormFactor(self):
427 427 pwcode = 1
428 428 if self.flagDecodeData:
429 429 pwcode = numpy.sum(self.code[0]**2)
430 430 #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter
431 431 normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter
432 432
433 433 return normFactor
434 434
435 435 def getFlagCspc(self):
436 436
437 437 if self.data_cspc == None:
438 438 return True
439 439
440 440 return False
441 441
442 442 def getFlagDc(self):
443 443
444 444 if self.data_dc == None:
445 445 return True
446 446
447 447 return False
448 448
449 449 nPairs = property(getNPairs, "I'm the 'nPairs' property.")
450 450 pairsIndexList = property(getPairsIndexList, "I'm the 'pairsIndexList' property.")
451 451 normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.")
452 452 flag_cspc = property(getFlagCspc)
453 453 flag_dc = property(getFlagDc)
454 454
455 455 class SpectraHeis(JROData):
456 456
457 457 data_spc = None
458 458
459 459 data_cspc = None
460 460
461 461 data_dc = None
462 462
463 463 nFFTPoints = None
464 464
465 465 nPairs = None
466 466
467 467 pairsList = None
468 468
469 469 nIncohInt = None
470 470
471 471 def __init__(self):
472 472
473 473 self.radarControllerHeaderObj = RadarControllerHeader()
474 474
475 475 self.systemHeaderObj = SystemHeader()
476 476
477 477 self.type = "SpectraHeis"
478 478
479 479 self.dtype = None
480 480
481 481 # self.nChannels = 0
482 482
483 483 # self.nHeights = 0
484 484
485 485 self.nProfiles = None
486 486
487 487 self.heightList = None
488 488
489 489 self.channelList = None
490 490
491 491 # self.channelIndexList = None
492 492
493 493 self.flagNoData = True
494 494
495 495 self.flagTimeBlock = False
496 496
497 497 self.nPairs = 0
498 498
499 499 self.utctime = None
500 500
501 501 self.blocksize = None
502 502
503 503 class Fits:
504 504
505 505 heightList = None
506 506
507 507 channelList = None
508 508
509 509 flagNoData = True
510 510
511 511 flagTimeBlock = False
512 512
513 513 useLocalTime = False
514 514
515 515 utctime = None
516 516
517 517 timeZone = None
518 518
519 519 ippSeconds = None
520 520
521 521 timeInterval = None
522 522
523 523 nCohInt = None
524 524
525 525 nIncohInt = None
526 526
527 527 noise = None
528 528
529 529 windowOfFilter = 1
530 530
531 531 #Speed of ligth
532 532 C = 3e8
533 533
534 534 frequency = 49.92e6
535 535
536 536 realtime = False
537 537
538 538
539 539 def __init__(self):
540 540
541 541 self.type = "Fits"
542 542
543 543 self.nProfiles = None
544 544
545 545 self.heightList = None
546 546
547 547 self.channelList = None
548 548
549 549 # self.channelIndexList = None
550 550
551 551 self.flagNoData = True
552 552
553 553 self.utctime = None
554 554
555 555 self.nCohInt = None
556 556
557 557 self.nIncohInt = None
558 558
559 559 self.useLocalTime = True
560 560
561 561 # self.utctime = None
562 562 # self.timeZone = None
563 563 # self.ltctime = None
564 564 # self.timeInterval = None
565 565 # self.header = None
566 566 # self.data_header = None
567 567 # self.data = None
568 568 # self.datatime = None
569 569 # self.flagNoData = False
570 570 # self.expName = ''
571 571 # self.nChannels = None
572 572 # self.nSamples = None
573 573 # self.dataBlocksPerFile = None
574 574 # self.comments = ''
575 575 #
576 576
577 577
578 578 def getltctime(self):
579 579
580 580 if self.useLocalTime:
581 581 return self.utctime - self.timeZone*60
582 582
583 583 return self.utctime
584 584
585 585 def getDatatime(self):
586 586
587 587 datatime = datetime.datetime.utcfromtimestamp(self.ltctime)
588 588 return datatime
589 589
590 590 def getTimeRange(self):
591 591
592 592 datatime = []
593 593
594 594 datatime.append(self.ltctime)
595 595 datatime.append(self.ltctime + self.timeInterval)
596 596
597 597 datatime = numpy.array(datatime)
598 598
599 599 return datatime
600 600
601 601 def getHeiRange(self):
602 602
603 603 heis = self.heightList
604 604
605 605 return heis
606 606
607 607 def isEmpty(self):
608 608
609 609 return self.flagNoData
610 610
611 611 def getNHeights(self):
612 612
613 613 return len(self.heightList)
614 614
615 615 def getNChannels(self):
616 616
617 617 return len(self.channelList)
618 618
619 619 def getChannelIndexList(self):
620 620
621 621 return range(self.nChannels)
622 622
623 623 def getNoise(self, type = 1):
624 624
625 625 self.noise = numpy.zeros(self.nChannels)
626 626
627 627 if type == 1:
628 628 noise = self.getNoisebyHildebrand()
629 629
630 630 if type == 2:
631 631 noise = self.getNoisebySort()
632 632
633 633 if type == 3:
634 634 noise = self.getNoisebyWindow()
635 635
636 636 return noise
637 637
638 638 datatime = property(getDatatime, "I'm the 'datatime' property")
639 639 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
640 640 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
641 641 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
642 642 noise = property(getNoise, "I'm the 'nHeights' property.")
643 643 datatime = property(getDatatime, "I'm the 'datatime' property")
644 644 ltctime = property(getltctime, "I'm the 'ltctime' property")
645 645
646 646 ltctime = property(getltctime, "I'm the 'ltctime' property")
647 647
648 648 class AMISR:
649 649 def __init__(self):
650 650 self.flagNoData = True
651 651 self.data = None
652 652 self.utctime = None
653 653 self.type = "AMISR"
654 654
655 655 #propiedades para compatibilidad con Voltages
656 self.timeZone = 0#self.dataIn.timeZone
656 self.timeZone = 300#timezone like jroheader, difference in minutes between UTC and localtime
657 657 self.dstFlag = 0#self.dataIn.dstFlag
658 658 self.errorCount = 0#self.dataIn.errorCount
659 659 self.useLocalTime = True#self.dataIn.useLocalTime
660 660
661 661 self.radarControllerHeaderObj = None#self.dataIn.radarControllerHeaderObj.copy()
662 662 self.systemHeaderObj = None#self.dataIn.systemHeaderObj.copy()
663 self.channelList = [1]#self.dataIn.channelList esto solo aplica para el caso de AMISR
663 self.channelList = [0]#self.dataIn.channelList esto solo aplica para el caso de AMISR
664 664 self.dtype = numpy.dtype([('real','<f4'),('imag','<f4')])
665 665
666 666 self.flagTimeBlock = None#self.dataIn.flagTimeBlock
667 667 #self.utctime = #self.firstdatatime
668 668 self.flagDecodeData = None#self.dataIn.flagDecodeData #asumo q la data esta decodificada
669 669 self.flagDeflipData = None#self.dataIn.flagDeflipData #asumo q la data esta sin flip
670 670
671 671 self.nCohInt = 1#self.dataIn.nCohInt
672 672 self.nIncohInt = 1
673 673 self.ippSeconds = 0.004#self.dataIn.ippSeconds, segun el filename/Setup/Tufile
674 674 self.windowOfFilter = None#self.dataIn.windowOfFilter
675 675
676 676 self.timeInterval = None#self.dataIn.timeInterval*self.dataOut.nFFTPoints*self.dataOut.nIncohInt
677 677 self.frequency = 20000000#self.dataIn.frequency
678 678 self.realtime = 0#self.dataIn.realtime
679 679
680 680 #actualizar en la lectura de datos
681 681 self.heightList = None#self.dataIn.heightList
682 682 self.nProfiles = None#self.dataOut.nFFTPoints
683 683 self.nBaud = None#self.dataIn.nBaud
684 684 self.nCode = None#self.dataIn.nCode
685 685 self.code = None#self.dataIn.code
686 686
687 687
688 688 def isEmpty(self):
689 689
690 690 return self.flagNoData No newline at end of file
@@ -1,2118 +1,2119
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(time.localtime())
6 6 delta = abs(utcnow - utcdatatime) # abs
7 7 if delta >= 30.:
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 self.counter_imagwr = 0
27 27 self.WIDTH = 250
28 28 self.HEIGHT = 250
29 29 self.WIDTHPROF = 0
30 30 self.HEIGHTPROF = 0
31 31
32 32 self.PLOT_CODE = 1
33 33 self.FTP_WEI = None
34 34 self.EXP_CODE = None
35 35 self.SUB_EXP_CODE = None
36 36 self.PLOT_POS = None
37 37
38 38 def getSubplots(self):
39 39
40 40 ncol = 4
41 41 nrow = self.nplots
42 42
43 43 return nrow, ncol
44 44
45 45 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
46 46
47 47 self.__showprofile = showprofile
48 48 self.nplots = nplots
49 49
50 50 ncolspan = 1
51 51 colspan = 1
52 52
53 53 self.createFigure(id = id,
54 54 wintitle = wintitle,
55 55 widthplot = self.WIDTH + self.WIDTHPROF,
56 56 heightplot = self.HEIGHT + self.HEIGHTPROF,
57 57 show=True)
58 58
59 59 nrow, ncol = self.getSubplots()
60 60
61 61 counter = 0
62 62 for y in range(nrow):
63 63 for x in range(ncol):
64 64 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
65 65
66 66 counter += 1
67 67
68 68 def run(self, dataOut, id, wintitle="", pairsList=None,
69 69 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
70 70 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
71 71 power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
72 72 server=None, folder=None, username=None, password=None,
73 73 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
74 74
75 75 """
76 76
77 77 Input:
78 78 dataOut :
79 79 id :
80 80 wintitle :
81 81 channelList :
82 82 showProfile :
83 83 xmin : None,
84 84 xmax : None,
85 85 ymin : None,
86 86 ymax : None,
87 87 zmin : None,
88 88 zmax : None
89 89 """
90 90
91 91 if pairsList == None:
92 92 pairsIndexList = dataOut.pairsIndexList
93 93 else:
94 94 pairsIndexList = []
95 95 for pair in pairsList:
96 96 if pair not in dataOut.pairsList:
97 97 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
98 98 pairsIndexList.append(dataOut.pairsList.index(pair))
99 99
100 100 if pairsIndexList == []:
101 101 return
102 102
103 103 if len(pairsIndexList) > 4:
104 104 pairsIndexList = pairsIndexList[0:4]
105 105 factor = dataOut.normFactor
106 106 x = dataOut.getVelRange(1)
107 107 y = dataOut.getHeiRange()
108 108 z = dataOut.data_spc[:,:,:]/factor
109 109 # z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
110 110 avg = numpy.abs(numpy.average(z, axis=1))
111 111 noise = dataOut.getNoise()/factor
112 112
113 113 zdB = 10*numpy.log10(z)
114 114 avgdB = 10*numpy.log10(avg)
115 115 noisedB = 10*numpy.log10(noise)
116 116
117 117
118 118 #thisDatetime = dataOut.datatime
119 119 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
120 120 title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
121 121 xlabel = "Velocity (m/s)"
122 122 ylabel = "Range (Km)"
123 123
124 124 if not self.__isConfig:
125 125
126 126 nplots = len(pairsIndexList)
127 127
128 128 self.setup(id=id,
129 129 nplots=nplots,
130 130 wintitle=wintitle,
131 131 showprofile=False,
132 132 show=show)
133 133
134 134 if xmin == None: xmin = numpy.nanmin(x)
135 135 if xmax == None: xmax = numpy.nanmax(x)
136 136 if ymin == None: ymin = numpy.nanmin(y)
137 137 if ymax == None: ymax = numpy.nanmax(y)
138 138 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
139 139 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
140 140
141 141 self.FTP_WEI = ftp_wei
142 142 self.EXP_CODE = exp_code
143 143 self.SUB_EXP_CODE = sub_exp_code
144 144 self.PLOT_POS = plot_pos
145 145
146 146 self.__isConfig = True
147 147
148 148 self.setWinTitle(title)
149 149
150 150 for i in range(self.nplots):
151 151 pair = dataOut.pairsList[pairsIndexList[i]]
152 152 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
153 153 title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[pair[0]], str_datetime)
154 154 zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:])
155 155 axes0 = self.axesList[i*self.__nsubplots]
156 156 axes0.pcolor(x, y, zdB,
157 157 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
158 158 xlabel=xlabel, ylabel=ylabel, title=title,
159 159 ticksize=9, colormap=power_cmap, cblabel='')
160 160
161 161 title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[pair[1]], str_datetime)
162 162 zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:])
163 163 axes0 = self.axesList[i*self.__nsubplots+1]
164 164 axes0.pcolor(x, y, zdB,
165 165 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
166 166 xlabel=xlabel, ylabel=ylabel, title=title,
167 167 ticksize=9, colormap=power_cmap, cblabel='')
168 168
169 169 coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
170 170 coherence = numpy.abs(coherenceComplex)
171 171 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
172 172 phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi
173 173
174 174 title = "Coherence %d%d" %(pair[0], pair[1])
175 175 axes0 = self.axesList[i*self.__nsubplots+2]
176 176 axes0.pcolor(x, y, coherence,
177 177 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1,
178 178 xlabel=xlabel, ylabel=ylabel, title=title,
179 179 ticksize=9, colormap=coherence_cmap, cblabel='')
180 180
181 181 title = "Phase %d%d" %(pair[0], pair[1])
182 182 axes0 = self.axesList[i*self.__nsubplots+3]
183 183 axes0.pcolor(x, y, phase,
184 184 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
185 185 xlabel=xlabel, ylabel=ylabel, title=title,
186 186 ticksize=9, colormap=phase_cmap, cblabel='')
187 187
188 188
189 189
190 190 self.draw()
191 191
192 192 if save:
193 193
194 194 self.counter_imagwr += 1
195 195 if (self.counter_imagwr==wr_period):
196 196 if figfile == None:
197 197 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
198 198 figfile = self.getFilename(name = str_datetime)
199 199
200 200 self.saveFigure(figpath, figfile)
201 201
202 202 if ftp:
203 203 #provisionalmente envia archivos en el formato de la web en tiempo real
204 204 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
205 205 path = '%s%03d' %(self.PREFIX, self.id)
206 206 ftp_file = os.path.join(path,'ftp','%s.png'%name)
207 207 self.saveFigure(figpath, ftp_file)
208 208 ftp_filename = os.path.join(figpath,ftp_file)
209 209
210 210 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
211 211 self.counter_imagwr = 0
212 212
213 213 self.counter_imagwr = 0
214 214
215 215 class SNRPlot(Figure):
216 216
217 217 __isConfig = None
218 218 __nsubplots = None
219 219
220 220 WIDTHPROF = None
221 221 HEIGHTPROF = None
222 222 PREFIX = 'snr'
223 223
224 224 def __init__(self):
225 225
226 226 self.timerange = 2*60*60
227 227 self.__isConfig = False
228 228 self.__nsubplots = 1
229 229
230 230 self.WIDTH = 800
231 231 self.HEIGHT = 150
232 232 self.WIDTHPROF = 120
233 233 self.HEIGHTPROF = 0
234 234 self.counter_imagwr = 0
235 235
236 236 self.PLOT_CODE = 0
237 237 self.FTP_WEI = None
238 238 self.EXP_CODE = None
239 239 self.SUB_EXP_CODE = None
240 240 self.PLOT_POS = None
241 241
242 242 def getSubplots(self):
243 243
244 244 ncol = 1
245 245 nrow = self.nplots
246 246
247 247 return nrow, ncol
248 248
249 249 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
250 250
251 251 self.__showprofile = showprofile
252 252 self.nplots = nplots
253 253
254 254 ncolspan = 1
255 255 colspan = 1
256 256 if showprofile:
257 257 ncolspan = 7
258 258 colspan = 6
259 259 self.__nsubplots = 2
260 260
261 261 self.createFigure(id = id,
262 262 wintitle = wintitle,
263 263 widthplot = self.WIDTH + self.WIDTHPROF,
264 264 heightplot = self.HEIGHT + self.HEIGHTPROF,
265 265 show=show)
266 266
267 267 nrow, ncol = self.getSubplots()
268 268
269 269 counter = 0
270 270 for y in range(nrow):
271 271 for x in range(ncol):
272 272
273 273 if counter >= self.nplots:
274 274 break
275 275
276 276 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
277 277
278 278 if showprofile:
279 279 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
280 280
281 281 counter += 1
282 282
283 283 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
284 284 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
285 285 timerange=None,
286 286 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
287 287 server=None, folder=None, username=None, password=None,
288 288 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
289 289
290 290 """
291 291
292 292 Input:
293 293 dataOut :
294 294 id :
295 295 wintitle :
296 296 channelList :
297 297 showProfile :
298 298 xmin : None,
299 299 xmax : None,
300 300 ymin : None,
301 301 ymax : None,
302 302 zmin : None,
303 303 zmax : None
304 304 """
305 305
306 306 if channelList == None:
307 307 channelIndexList = dataOut.channelIndexList
308 308 else:
309 309 channelIndexList = []
310 310 for channel in channelList:
311 311 if channel not in dataOut.channelList:
312 312 raise ValueError, "Channel %d is not in dataOut.channelList"
313 313 channelIndexList.append(dataOut.channelList.index(channel))
314 314
315 315 if timerange != None:
316 316 self.timerange = timerange
317 317
318 318 tmin = None
319 319 tmax = None
320 320 factor = dataOut.normFactor
321 321 x = dataOut.getTimeRange()
322 322 y = dataOut.getHeiRange()
323 323
324 324 z = dataOut.data_spc[channelIndexList,:,:]/factor
325 325 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
326 326 avg = numpy.average(z, axis=1)
327 327
328 328 avgdB = 10.*numpy.log10(avg)
329 329
330 330 noise = dataOut.getNoise()/factor
331 331 noisedB = 10.*numpy.log10(noise)
332 332
333 333 SNR = numpy.transpose(numpy.divide(avg.T,noise))
334 334
335 335 SNR_dB = 10.*numpy.log10(SNR)
336 336
337 337 #SNR_dB = numpy.transpose(numpy.subtract(avgdB.T, noisedB))
338 338
339 339 # thisDatetime = dataOut.datatime
340 340 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
341 341 title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
342 342 xlabel = ""
343 343 ylabel = "Range (Km)"
344 344
345 345 if not self.__isConfig:
346 346
347 347 nplots = len(channelIndexList)
348 348
349 349 self.setup(id=id,
350 350 nplots=nplots,
351 351 wintitle=wintitle,
352 352 showprofile=showprofile,
353 353 show=show)
354 354
355 355 tmin, tmax = self.getTimeLim(x, xmin, xmax)
356 356 if ymin == None: ymin = numpy.nanmin(y)
357 357 if ymax == None: ymax = numpy.nanmax(y)
358 358 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
359 359 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
360 360
361 361 self.FTP_WEI = ftp_wei
362 362 self.EXP_CODE = exp_code
363 363 self.SUB_EXP_CODE = sub_exp_code
364 364 self.PLOT_POS = plot_pos
365 365
366 366 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
367 367 self.__isConfig = True
368 368
369 369
370 370 self.setWinTitle(title)
371 371
372 372 for i in range(self.nplots):
373 373 title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
374 374 axes = self.axesList[i*self.__nsubplots]
375 375 zdB = SNR_dB[i].reshape((1,-1))
376 376 axes.pcolorbuffer(x, y, zdB,
377 377 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
378 378 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
379 379 ticksize=9, cblabel='', cbsize="1%")
380 380
381 381 # if self.__showprofile:
382 382 # axes = self.axesList[i*self.__nsubplots +1]
383 383 # axes.pline(avgdB[i], y,
384 384 # xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
385 385 # xlabel='dB', ylabel='', title='',
386 386 # ytick_visible=False,
387 387 # grid='x')
388 388 #
389 389 self.draw()
390 390
391 391 if lastone:
392 392 if dataOut.blocknow >= dataOut.last_block:
393 393 if figfile == None:
394 394 figfile = self.getFilename(name = self.name)
395 395 self.saveFigure(figpath, figfile)
396 396
397 397 if (save and not(lastone)):
398 398
399 399 self.counter_imagwr += 1
400 400 if (self.counter_imagwr==wr_period):
401 401 if figfile == None:
402 402 figfile = self.getFilename(name = self.name)
403 403 self.saveFigure(figpath, figfile)
404 404
405 405 if ftp:
406 406 #provisionalmente envia archivos en el formato de la web en tiempo real
407 407 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
408 408 path = '%s%03d' %(self.PREFIX, self.id)
409 409 ftp_file = os.path.join(path,'ftp','%s.png'%name)
410 410 self.saveFigure(figpath, ftp_file)
411 411 ftp_filename = os.path.join(figpath,ftp_file)
412 412 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
413 413 self.counter_imagwr = 0
414 414
415 415 self.counter_imagwr = 0
416 416
417 417 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
418 418
419 419 self.__isConfig = False
420 420
421 421 if lastone:
422 422 if figfile == None:
423 423 figfile = self.getFilename(name = self.name)
424 424 self.saveFigure(figpath, figfile)
425 425
426 426 if ftp:
427 427 #provisionalmente envia archivos en el formato de la web en tiempo real
428 428 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
429 429 path = '%s%03d' %(self.PREFIX, self.id)
430 430 ftp_file = os.path.join(path,'ftp','%s.png'%name)
431 431 self.saveFigure(figpath, ftp_file)
432 432 ftp_filename = os.path.join(figpath,ftp_file)
433 433 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
434 434
435 435
436 436 class RTIPlot(Figure):
437 437
438 438 __isConfig = None
439 439 __nsubplots = None
440 440
441 441 WIDTHPROF = None
442 442 HEIGHTPROF = None
443 443 PREFIX = 'rti'
444 444
445 445 def __init__(self):
446 446
447 447 self.timerange = 2*60*60
448 448 self.__isConfig = False
449 449 self.__nsubplots = 1
450 450
451 451 self.WIDTH = 800
452 452 self.HEIGHT = 150
453 453 self.WIDTHPROF = 120
454 454 self.HEIGHTPROF = 0
455 455 self.counter_imagwr = 0
456 456
457 457 self.PLOT_CODE = 0
458 458 self.FTP_WEI = None
459 459 self.EXP_CODE = None
460 460 self.SUB_EXP_CODE = None
461 461 self.PLOT_POS = None
462 462 self.tmin = None
463 463 self.tmax = None
464 464
465 465 self.xmin = None
466 466 self.xmax = None
467 467
468 468 def getSubplots(self):
469 469
470 470 ncol = 1
471 471 nrow = self.nplots
472 472
473 473 return nrow, ncol
474 474
475 475 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
476 476
477 477 self.__showprofile = showprofile
478 478 self.nplots = nplots
479 479
480 480 ncolspan = 1
481 481 colspan = 1
482 482 if showprofile:
483 483 ncolspan = 7
484 484 colspan = 6
485 485 self.__nsubplots = 2
486 486
487 487 self.createFigure(id = id,
488 488 wintitle = wintitle,
489 489 widthplot = self.WIDTH + self.WIDTHPROF,
490 490 heightplot = self.HEIGHT + self.HEIGHTPROF,
491 491 show=show)
492 492
493 493 nrow, ncol = self.getSubplots()
494 494
495 495 counter = 0
496 496 for y in range(nrow):
497 497 for x in range(ncol):
498 498
499 499 if counter >= self.nplots:
500 500 break
501 501
502 502 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
503 503
504 504 if showprofile:
505 505 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
506 506
507 507 counter += 1
508 508
509 509 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
510 510 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
511 511 timerange=None,
512 512 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
513 513 server=None, folder=None, username=None, password=None,
514 514 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
515 515
516 516 """
517 517
518 518 Input:
519 519 dataOut :
520 520 id :
521 521 wintitle :
522 522 channelList :
523 523 showProfile :
524 524 xmin : None,
525 525 xmax : None,
526 526 ymin : None,
527 527 ymax : None,
528 528 zmin : None,
529 529 zmax : None
530 530 """
531 531
532 532 if channelList == None:
533 533 channelIndexList = dataOut.channelIndexList
534 534 else:
535 535 channelIndexList = []
536 536 for channel in channelList:
537 537 if channel not in dataOut.channelList:
538 538 raise ValueError, "Channel %d is not in dataOut.channelList"
539 539 channelIndexList.append(dataOut.channelList.index(channel))
540 540
541 541 if timerange != None:
542 542 self.timerange = timerange
543 543
544 544 #tmin = None
545 545 #tmax = None
546 546 factor = dataOut.normFactor
547 547 x = dataOut.getTimeRange()
548 548 y = dataOut.getHeiRange()
549 549
550 550 z = dataOut.data_spc[channelIndexList,:,:]/factor
551 551 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
552 552 avg = numpy.average(z, axis=1)
553 553
554 554 avgdB = 10.*numpy.log10(avg)
555 555
556 556
557 557 # thisDatetime = dataOut.datatime
558 558 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
559 559 title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
560 560 xlabel = ""
561 561 ylabel = "Range (Km)"
562 562
563 563 if not self.__isConfig:
564 564
565 565 nplots = len(channelIndexList)
566 566
567 567 self.setup(id=id,
568 568 nplots=nplots,
569 569 wintitle=wintitle,
570 570 showprofile=showprofile,
571 571 show=show)
572 572
573 573 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
574 574
575 575 # if timerange != None:
576 576 # self.timerange = timerange
577 577 # self.xmin, self.tmax = self.getTimeLim(x, xmin, xmax, timerange)
578 578
579 579
580 580
581 581 if ymin == None: ymin = numpy.nanmin(y)
582 582 if ymax == None: ymax = numpy.nanmax(y)
583 583 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
584 584 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
585 585
586 586 self.FTP_WEI = ftp_wei
587 587 self.EXP_CODE = exp_code
588 588 self.SUB_EXP_CODE = sub_exp_code
589 589 self.PLOT_POS = plot_pos
590 590
591 591 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
592 592 self.__isConfig = True
593 593
594 594
595 595 self.setWinTitle(title)
596 596
597 597 if ((self.xmax - x[1]) < (x[1]-x[0])):
598 598 x[1] = self.xmax
599 599
600 600 for i in range(self.nplots):
601 601 title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
602 602 axes = self.axesList[i*self.__nsubplots]
603 603 zdB = avgdB[i].reshape((1,-1))
604 604 axes.pcolorbuffer(x, y, zdB,
605 605 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
606 606 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
607 607 ticksize=9, cblabel='', cbsize="1%")
608 608
609 609 if self.__showprofile:
610 610 axes = self.axesList[i*self.__nsubplots +1]
611 611 axes.pline(avgdB[i], y,
612 612 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
613 613 xlabel='dB', ylabel='', title='',
614 614 ytick_visible=False,
615 615 grid='x')
616 616
617 617 self.draw()
618 618
619 619 # if lastone:
620 620 # if dataOut.blocknow >= dataOut.last_block:
621 621 # if figfile == None:
622 622 # figfile = self.getFilename(name = self.name)
623 623 # self.saveFigure(figpath, figfile)
624 624 #
625 625 # if (save and not(lastone)):
626 626 #
627 627 # self.counter_imagwr += 1
628 628 # if (self.counter_imagwr==wr_period):
629 629 # if figfile == None:
630 630 # figfile = self.getFilename(name = self.name)
631 631 # self.saveFigure(figpath, figfile)
632 632 #
633 633 # if ftp:
634 634 # #provisionalmente envia archivos en el formato de la web en tiempo real
635 635 # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
636 636 # path = '%s%03d' %(self.PREFIX, self.id)
637 637 # ftp_file = os.path.join(path,'ftp','%s.png'%name)
638 638 # self.saveFigure(figpath, ftp_file)
639 639 # ftp_filename = os.path.join(figpath,ftp_file)
640 640 # self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
641 641 # self.counter_imagwr = 0
642 642 #
643 643 # self.counter_imagwr = 0
644 644
645 645 #if ((dataOut.utctime-time.timezone) >= self.axesList[0].xmax):
646 self.saveFigure(figpath, figfile)
646 647 if x[1] >= self.axesList[0].xmax:
647 #self.saveFigure(figpath, figfile)
648 self.saveFigure(figpath, figfile)
648 649 self.__isConfig = False
649 650
650 651 # if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
651 652 #
652 653 # self.__isConfig = False
653 654
654 655 # if lastone:
655 656 # if figfile == None:
656 657 # figfile = self.getFilename(name = self.name)
657 658 # self.saveFigure(figpath, figfile)
658 659 #
659 660 # if ftp:
660 661 # #provisionalmente envia archivos en el formato de la web en tiempo real
661 662 # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
662 663 # path = '%s%03d' %(self.PREFIX, self.id)
663 664 # ftp_file = os.path.join(path,'ftp','%s.png'%name)
664 665 # self.saveFigure(figpath, ftp_file)
665 666 # ftp_filename = os.path.join(figpath,ftp_file)
666 667 # self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
667 668
668 669
669 670 class SpectraPlot(Figure):
670 671
671 672 __isConfig = None
672 673 __nsubplots = None
673 674
674 675 WIDTHPROF = None
675 676 HEIGHTPROF = None
676 677 PREFIX = 'spc'
677 678
678 679 def __init__(self):
679 680
680 681 self.__isConfig = False
681 682 self.__nsubplots = 1
682 683
683 684 self.WIDTH = 280
684 685 self.HEIGHT = 250
685 686 self.WIDTHPROF = 120
686 687 self.HEIGHTPROF = 0
687 688 self.counter_imagwr = 0
688 689
689 690 self.PLOT_CODE = 1
690 691 self.FTP_WEI = None
691 692 self.EXP_CODE = None
692 693 self.SUB_EXP_CODE = None
693 694 self.PLOT_POS = None
694 695
695 696 def getSubplots(self):
696 697
697 698 ncol = int(numpy.sqrt(self.nplots)+0.9)
698 699 nrow = int(self.nplots*1./ncol + 0.9)
699 700
700 701 return nrow, ncol
701 702
702 703 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
703 704
704 705 self.__showprofile = showprofile
705 706 self.nplots = nplots
706 707
707 708 ncolspan = 1
708 709 colspan = 1
709 710 if showprofile:
710 711 ncolspan = 3
711 712 colspan = 2
712 713 self.__nsubplots = 2
713 714
714 715 self.createFigure(id = id,
715 716 wintitle = wintitle,
716 717 widthplot = self.WIDTH + self.WIDTHPROF,
717 718 heightplot = self.HEIGHT + self.HEIGHTPROF,
718 719 show=show)
719 720
720 721 nrow, ncol = self.getSubplots()
721 722
722 723 counter = 0
723 724 for y in range(nrow):
724 725 for x in range(ncol):
725 726
726 727 if counter >= self.nplots:
727 728 break
728 729
729 730 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
730 731
731 732 if showprofile:
732 733 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
733 734
734 735 counter += 1
735 736
736 737 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
737 738 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
738 739 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
739 740 server=None, folder=None, username=None, password=None,
740 741 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
741 742
742 743 """
743 744
744 745 Input:
745 746 dataOut :
746 747 id :
747 748 wintitle :
748 749 channelList :
749 750 showProfile :
750 751 xmin : None,
751 752 xmax : None,
752 753 ymin : None,
753 754 ymax : None,
754 755 zmin : None,
755 756 zmax : None
756 757 """
757 758
758 759 if dataOut.flagNoData:
759 760 return None
760 761
761 762 if realtime:
762 763 if not(isRealtime(utcdatatime = dataOut.utctime)):
763 764 print 'Skipping this plot function'
764 765 return
765 766
766 767 if channelList == None:
767 768 channelIndexList = dataOut.channelIndexList
768 769 else:
769 770 channelIndexList = []
770 771 for channel in channelList:
771 772 if channel not in dataOut.channelList:
772 773 raise ValueError, "Channel %d is not in dataOut.channelList"
773 774 channelIndexList.append(dataOut.channelList.index(channel))
774 775 factor = dataOut.normFactor
775 776 x = dataOut.getVelRange(1)
776 777 y = dataOut.getHeiRange()
777 778
778 779 z = dataOut.data_spc[channelIndexList,:,:]/factor
779 780 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
780 781 avg = numpy.average(z, axis=1)
781 782 noise = dataOut.getNoise()/factor
782 783
783 784 zdB = 10*numpy.log10(z)
784 785 avgdB = 10*numpy.log10(avg)
785 786 noisedB = 10*numpy.log10(noise)
786 787
787 788 #thisDatetime = dataOut.datatime
788 789 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
789 790 title = wintitle + " Spectra"
790 791 xlabel = "Velocity (m/s)"
791 792 ylabel = "Range (Km)"
792 793
793 794 if not self.__isConfig:
794 795
795 796 nplots = len(channelIndexList)
796 797
797 798 self.setup(id=id,
798 799 nplots=nplots,
799 800 wintitle=wintitle,
800 801 showprofile=showprofile,
801 802 show=show)
802 803
803 804 if xmin == None: xmin = numpy.nanmin(x)
804 805 if xmax == None: xmax = numpy.nanmax(x)
805 806 if ymin == None: ymin = numpy.nanmin(y)
806 807 if ymax == None: ymax = numpy.nanmax(y)
807 808 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
808 809 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
809 810
810 811 self.FTP_WEI = ftp_wei
811 812 self.EXP_CODE = exp_code
812 813 self.SUB_EXP_CODE = sub_exp_code
813 814 self.PLOT_POS = plot_pos
814 815
815 816 self.__isConfig = True
816 817
817 818 self.setWinTitle(title)
818 819
819 820 for i in range(self.nplots):
820 821 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
821 822 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i]+1, noisedB[i], str_datetime)
822 823 axes = self.axesList[i*self.__nsubplots]
823 824 axes.pcolor(x, y, zdB[i,:,:],
824 825 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
825 826 xlabel=xlabel, ylabel=ylabel, title=title,
826 827 ticksize=9, cblabel='')
827 828
828 829 if self.__showprofile:
829 830 axes = self.axesList[i*self.__nsubplots +1]
830 831 axes.pline(avgdB[i], y,
831 832 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
832 833 xlabel='dB', ylabel='', title='',
833 834 ytick_visible=False,
834 835 grid='x')
835 836
836 837 noiseline = numpy.repeat(noisedB[i], len(y))
837 838 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
838 839
839 840 self.draw()
840 841
841 842 if save:
842 843
843 844 self.counter_imagwr += 1
844 845 if (self.counter_imagwr==wr_period):
845 846 if figfile == None:
846 847 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
847 848 figfile = self.getFilename(name = str_datetime)
848 849
849 850 self.saveFigure(figpath, figfile)
850 851
851 852 if ftp:
852 853 #provisionalmente envia archivos en el formato de la web en tiempo real
853 854 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
854 855 path = '%s%03d' %(self.PREFIX, self.id)
855 856 ftp_file = os.path.join(path,'ftp','%s.png'%name)
856 857 self.saveFigure(figpath, ftp_file)
857 858 ftp_filename = os.path.join(figpath,ftp_file)
858 859 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
859 860 self.counter_imagwr = 0
860 861
861 862
862 863 self.counter_imagwr = 0
863 864
864 865
865 866 class Scope(Figure):
866 867
867 868 __isConfig = None
868 869
869 870 def __init__(self):
870 871
871 872 self.__isConfig = False
872 873 self.WIDTH = 300
873 874 self.HEIGHT = 200
874 875 self.counter_imagwr = 0
875 876
876 877 def getSubplots(self):
877 878
878 879 nrow = self.nplots
879 880 ncol = 3
880 881 return nrow, ncol
881 882
882 883 def setup(self, id, nplots, wintitle, show):
883 884
884 885 self.nplots = nplots
885 886
886 887 self.createFigure(id=id,
887 888 wintitle=wintitle,
888 889 show=show)
889 890
890 891 nrow,ncol = self.getSubplots()
891 892 colspan = 3
892 893 rowspan = 1
893 894
894 895 for i in range(nplots):
895 896 self.addAxes(nrow, ncol, i, 0, colspan, rowspan)
896 897
897 898 def plot_iq(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax):
898 899 yreal = y[channelIndexList,:].real
899 900 yimag = y[channelIndexList,:].imag
900 901
901 902 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
902 903 xlabel = "Range (Km)"
903 904 ylabel = "Intensity - IQ"
904 905
905 906 if not self.__isConfig:
906 907 nplots = len(channelIndexList)
907 908
908 909 self.setup(id=id,
909 910 nplots=nplots,
910 911 wintitle='',
911 912 show=show)
912 913
913 914 if xmin == None: xmin = numpy.nanmin(x)
914 915 if xmax == None: xmax = numpy.nanmax(x)
915 916 if ymin == None: ymin = min(numpy.nanmin(yreal),numpy.nanmin(yimag))
916 917 if ymax == None: ymax = max(numpy.nanmax(yreal),numpy.nanmax(yimag))
917 918
918 919 self.__isConfig = True
919 920
920 921 self.setWinTitle(title)
921 922
922 923 for i in range(len(self.axesList)):
923 924 title = "Channel %d" %(i)
924 925 axes = self.axesList[i]
925 926
926 927 axes.pline(x, yreal[i,:],
927 928 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
928 929 xlabel=xlabel, ylabel=ylabel, title=title)
929 930
930 931 axes.addpline(x, yimag[i,:], idline=1, color="red", linestyle="solid", lw=2)
931 932
932 933 def plot_power(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax):
933 934 y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:])
934 935 yreal = y.real
935 936
936 937 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
937 938 xlabel = "Range (Km)"
938 939 ylabel = "Intensity"
939 940
940 941 if not self.__isConfig:
941 942 nplots = len(channelIndexList)
942 943
943 944 self.setup(id=id,
944 945 nplots=nplots,
945 946 wintitle='',
946 947 show=show)
947 948
948 949 if xmin == None: xmin = numpy.nanmin(x)
949 950 if xmax == None: xmax = numpy.nanmax(x)
950 951 if ymin == None: ymin = numpy.nanmin(yreal)
951 952 if ymax == None: ymax = numpy.nanmax(yreal)
952 953
953 954 self.__isConfig = True
954 955
955 956 self.setWinTitle(title)
956 957
957 958 for i in range(len(self.axesList)):
958 959 title = "Channel %d" %(i)
959 960 axes = self.axesList[i]
960 961 ychannel = yreal[i,:]
961 962 axes.pline(x, ychannel,
962 963 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
963 964 xlabel=xlabel, ylabel=ylabel, title=title)
964 965
965 966
966 967 def run(self, dataOut, id, wintitle="", channelList=None,
967 968 xmin=None, xmax=None, ymin=None, ymax=None, save=False,
968 969 figpath='./', figfile=None, show=True, wr_period=1,
969 970 server=None, folder=None, username=None, password=None, type='power'):
970 971
971 972 """
972 973
973 974 Input:
974 975 dataOut :
975 976 id :
976 977 wintitle :
977 978 channelList :
978 979 xmin : None,
979 980 xmax : None,
980 981 ymin : None,
981 982 ymax : None,
982 983 """
983 984 if dataOut.flagNoData:
984 985 return None
985 986
986 987 if channelList == None:
987 988 channelIndexList = dataOut.channelIndexList
988 989 else:
989 990 channelIndexList = []
990 991 for channel in channelList:
991 992 if channel not in dataOut.channelList:
992 993 raise ValueError, "Channel %d is not in dataOut.channelList"
993 994 channelIndexList.append(dataOut.channelList.index(channel))
994 995
995 996 x = dataOut.heightList
996 997 y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
997 998 y = y.real
998 999
999 1000 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1000 1001
1001 1002 if type == "power":
1002 1003 self.plot_power(dataOut.heightList,
1003 1004 dataOut.data,
1004 1005 id,
1005 1006 channelIndexList,
1006 1007 thisDatetime,
1007 1008 wintitle,
1008 1009 show,
1009 1010 xmin,
1010 1011 xmax,
1011 1012 ymin,
1012 1013 ymax)
1013 1014
1014 1015 if type == "iq":
1015 1016 self.plot_iq(dataOut.heightList,
1016 1017 dataOut.data,
1017 1018 id,
1018 1019 channelIndexList,
1019 1020 thisDatetime,
1020 1021 wintitle,
1021 1022 show,
1022 1023 xmin,
1023 1024 xmax,
1024 1025 ymin,
1025 1026 ymax)
1026 1027
1027 1028
1028 1029 self.draw()
1029 1030
1030 1031 if save:
1031 1032 date = thisDatetime.strftime("%Y%m%d_%H%M%S")
1032 1033 if figfile == None:
1033 1034 figfile = self.getFilename(name = date)
1034 1035
1035 1036 self.saveFigure(figpath, figfile)
1036 1037
1037 1038 self.counter_imagwr += 1
1038 1039 if (ftp and (self.counter_imagwr==wr_period)):
1039 1040 ftp_filename = os.path.join(figpath,figfile)
1040 1041 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1041 1042 self.counter_imagwr = 0
1042 1043
1043 1044 class PowerProfile(Figure):
1044 1045 __isConfig = None
1045 1046 __nsubplots = None
1046 1047
1047 1048 WIDTHPROF = None
1048 1049 HEIGHTPROF = None
1049 1050 PREFIX = 'spcprofile'
1050 1051
1051 1052 def __init__(self):
1052 1053 self.__isConfig = False
1053 1054 self.__nsubplots = 1
1054 1055
1055 1056 self.WIDTH = 300
1056 1057 self.HEIGHT = 500
1057 1058 self.counter_imagwr = 0
1058 1059
1059 1060 def getSubplots(self):
1060 1061 ncol = 1
1061 1062 nrow = 1
1062 1063
1063 1064 return nrow, ncol
1064 1065
1065 1066 def setup(self, id, nplots, wintitle, show):
1066 1067
1067 1068 self.nplots = nplots
1068 1069
1069 1070 ncolspan = 1
1070 1071 colspan = 1
1071 1072
1072 1073 self.createFigure(id = id,
1073 1074 wintitle = wintitle,
1074 1075 widthplot = self.WIDTH,
1075 1076 heightplot = self.HEIGHT,
1076 1077 show=show)
1077 1078
1078 1079 nrow, ncol = self.getSubplots()
1079 1080
1080 1081 counter = 0
1081 1082 for y in range(nrow):
1082 1083 for x in range(ncol):
1083 1084 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1084 1085
1085 1086 def run(self, dataOut, id, wintitle="", channelList=None,
1086 1087 xmin=None, xmax=None, ymin=None, ymax=None,
1087 1088 save=False, figpath='./', figfile=None, show=True, wr_period=1,
1088 1089 server=None, folder=None, username=None, password=None,):
1089 1090
1090 1091 if dataOut.flagNoData:
1091 1092 return None
1092 1093
1093 1094 if channelList == None:
1094 1095 channelIndexList = dataOut.channelIndexList
1095 1096 channelList = dataOut.channelList
1096 1097 else:
1097 1098 channelIndexList = []
1098 1099 for channel in channelList:
1099 1100 if channel not in dataOut.channelList:
1100 1101 raise ValueError, "Channel %d is not in dataOut.channelList"
1101 1102 channelIndexList.append(dataOut.channelList.index(channel))
1102 1103
1103 1104 try:
1104 1105 factor = dataOut.normFactor
1105 1106 except:
1106 1107 factor = 1
1107 1108
1108 1109 y = dataOut.getHeiRange()
1109 1110
1110 1111 #for voltage
1111 1112 if dataOut.type == 'Voltage':
1112 1113 x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
1113 1114 x = x.real
1114 1115 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
1115 1116
1116 1117 #for spectra
1117 1118 if dataOut.type == 'Spectra':
1118 1119 x = dataOut.data_spc[channelIndexList,:,:]/factor
1119 1120 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
1120 1121 x = numpy.average(x, axis=1)
1121 1122
1122 1123
1123 1124 xdB = 10*numpy.log10(x)
1124 1125
1125 1126 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1126 1127 title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y"))
1127 1128 xlabel = "dB"
1128 1129 ylabel = "Range (Km)"
1129 1130
1130 1131 if not self.__isConfig:
1131 1132
1132 1133 nplots = 1
1133 1134
1134 1135 self.setup(id=id,
1135 1136 nplots=nplots,
1136 1137 wintitle=wintitle,
1137 1138 show=show)
1138 1139
1139 1140 if ymin == None: ymin = numpy.nanmin(y)
1140 1141 if ymax == None: ymax = numpy.nanmax(y)
1141 1142 if xmin == None: xmin = numpy.nanmin(xdB)*0.9
1142 1143 if xmax == None: xmax = numpy.nanmax(xdB)*0.9
1143 1144
1144 1145 self.__isConfig = True
1145 1146
1146 1147 self.setWinTitle(title)
1147 1148
1148 1149 title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1149 1150 axes = self.axesList[0]
1150 1151
1151 1152 legendlabels = ["channel %d"%x for x in channelList]
1152 1153 axes.pmultiline(xdB, y,
1153 1154 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1154 1155 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
1155 1156 ytick_visible=True, nxticks=5,
1156 1157 grid='x')
1157 1158
1158 1159 self.draw()
1159 1160
1160 1161 if save:
1161 1162 date = thisDatetime.strftime("%Y%m%d")
1162 1163 if figfile == None:
1163 1164 figfile = self.getFilename(name = date)
1164 1165
1165 1166 self.saveFigure(figpath, figfile)
1166 1167
1167 1168 self.counter_imagwr += 1
1168 1169 if (ftp and (self.counter_imagwr==wr_period)):
1169 1170 ftp_filename = os.path.join(figpath,figfile)
1170 1171 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1171 1172 self.counter_imagwr = 0
1172 1173
1173 1174 class CoherenceMap(Figure):
1174 1175 __isConfig = None
1175 1176 __nsubplots = None
1176 1177
1177 1178 WIDTHPROF = None
1178 1179 HEIGHTPROF = None
1179 1180 PREFIX = 'cmap'
1180 1181
1181 1182 def __init__(self):
1182 1183 self.timerange = 2*60*60
1183 1184 self.__isConfig = False
1184 1185 self.__nsubplots = 1
1185 1186
1186 1187 self.WIDTH = 800
1187 1188 self.HEIGHT = 150
1188 1189 self.WIDTHPROF = 120
1189 1190 self.HEIGHTPROF = 0
1190 1191 self.counter_imagwr = 0
1191 1192
1192 1193 self.PLOT_CODE = 3
1193 1194 self.FTP_WEI = None
1194 1195 self.EXP_CODE = None
1195 1196 self.SUB_EXP_CODE = None
1196 1197 self.PLOT_POS = None
1197 1198 self.counter_imagwr = 0
1198 1199
1199 1200 self.xmin = None
1200 1201 self.xmax = None
1201 1202
1202 1203 def getSubplots(self):
1203 1204 ncol = 1
1204 1205 nrow = self.nplots*2
1205 1206
1206 1207 return nrow, ncol
1207 1208
1208 1209 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1209 1210 self.__showprofile = showprofile
1210 1211 self.nplots = nplots
1211 1212
1212 1213 ncolspan = 1
1213 1214 colspan = 1
1214 1215 if showprofile:
1215 1216 ncolspan = 7
1216 1217 colspan = 6
1217 1218 self.__nsubplots = 2
1218 1219
1219 1220 self.createFigure(id = id,
1220 1221 wintitle = wintitle,
1221 1222 widthplot = self.WIDTH + self.WIDTHPROF,
1222 1223 heightplot = self.HEIGHT + self.HEIGHTPROF,
1223 1224 show=True)
1224 1225
1225 1226 nrow, ncol = self.getSubplots()
1226 1227
1227 1228 for y in range(nrow):
1228 1229 for x in range(ncol):
1229 1230
1230 1231 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1231 1232
1232 1233 if showprofile:
1233 1234 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1234 1235
1235 1236 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1236 1237 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1237 1238 timerange=None,
1238 1239 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
1239 1240 coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
1240 1241 server=None, folder=None, username=None, password=None,
1241 1242 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1242 1243
1243 1244 if pairsList == None:
1244 1245 pairsIndexList = dataOut.pairsIndexList
1245 1246 else:
1246 1247 pairsIndexList = []
1247 1248 for pair in pairsList:
1248 1249 if pair not in dataOut.pairsList:
1249 1250 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
1250 1251 pairsIndexList.append(dataOut.pairsList.index(pair))
1251 1252
1252 1253 if timerange != None:
1253 1254 self.timerange = timerange
1254 1255
1255 1256 if pairsIndexList == []:
1256 1257 return
1257 1258
1258 1259 if len(pairsIndexList) > 4:
1259 1260 pairsIndexList = pairsIndexList[0:4]
1260 1261
1261 1262 # tmin = None
1262 1263 # tmax = None
1263 1264 x = dataOut.getTimeRange()
1264 1265 y = dataOut.getHeiRange()
1265 1266
1266 1267 #thisDatetime = dataOut.datatime
1267 1268 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1268 1269 title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
1269 1270 xlabel = ""
1270 1271 ylabel = "Range (Km)"
1271 1272
1272 1273 if not self.__isConfig:
1273 1274 nplots = len(pairsIndexList)
1274 1275 self.setup(id=id,
1275 1276 nplots=nplots,
1276 1277 wintitle=wintitle,
1277 1278 showprofile=showprofile,
1278 1279 show=show)
1279 1280
1280 1281 #tmin, tmax = self.getTimeLim(x, xmin, xmax)
1281 1282
1282 1283 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1283 1284
1284 1285 if ymin == None: ymin = numpy.nanmin(y)
1285 1286 if ymax == None: ymax = numpy.nanmax(y)
1286 1287 if zmin == None: zmin = 0.
1287 1288 if zmax == None: zmax = 1.
1288 1289
1289 1290 self.FTP_WEI = ftp_wei
1290 1291 self.EXP_CODE = exp_code
1291 1292 self.SUB_EXP_CODE = sub_exp_code
1292 1293 self.PLOT_POS = plot_pos
1293 1294
1294 1295 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1295 1296
1296 1297 self.__isConfig = True
1297 1298
1298 1299 self.setWinTitle(title)
1299 1300
1300 1301 if ((self.xmax - x[1]) < (x[1]-x[0])):
1301 1302 x[1] = self.xmax
1302 1303
1303 1304 for i in range(self.nplots):
1304 1305
1305 1306 pair = dataOut.pairsList[pairsIndexList[i]]
1306 1307 # coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
1307 1308 # avgcoherenceComplex = numpy.average(coherenceComplex, axis=0)
1308 1309 # coherence = numpy.abs(avgcoherenceComplex)
1309 1310
1310 1311 ## coherence = numpy.abs(coherenceComplex)
1311 1312 ## avg = numpy.average(coherence, axis=0)
1312 1313
1313 1314 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
1314 1315 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
1315 1316 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
1316 1317
1317 1318
1318 1319 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
1319 1320 coherence = numpy.abs(avgcoherenceComplex)
1320 1321
1321 1322 z = coherence.reshape((1,-1))
1322 1323
1323 1324 counter = 0
1324 1325
1325 1326 title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1326 1327 axes = self.axesList[i*self.__nsubplots*2]
1327 1328 axes.pcolorbuffer(x, y, z,
1328 1329 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1329 1330 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1330 1331 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
1331 1332
1332 1333 if self.__showprofile:
1333 1334 counter += 1
1334 1335 axes = self.axesList[i*self.__nsubplots*2 + counter]
1335 1336 axes.pline(coherence, y,
1336 1337 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
1337 1338 xlabel='', ylabel='', title='', ticksize=7,
1338 1339 ytick_visible=False, nxticks=5,
1339 1340 grid='x')
1340 1341
1341 1342 counter += 1
1342 1343 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
1343 1344 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
1344 1345 # avg = numpy.average(phase, axis=0)
1345 1346 z = phase.reshape((1,-1))
1346 1347
1347 1348 title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1348 1349 axes = self.axesList[i*self.__nsubplots*2 + counter]
1349 1350 axes.pcolorbuffer(x, y, z,
1350 1351 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
1351 1352 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1352 1353 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
1353 1354
1354 1355 if self.__showprofile:
1355 1356 counter += 1
1356 1357 axes = self.axesList[i*self.__nsubplots*2 + counter]
1357 1358 axes.pline(phase, y,
1358 1359 xmin=-180, xmax=180, ymin=ymin, ymax=ymax,
1359 1360 xlabel='', ylabel='', title='', ticksize=7,
1360 1361 ytick_visible=False, nxticks=4,
1361 1362 grid='x')
1362 1363
1363 1364 self.draw()
1364 1365
1365 1366 if x[1] >= self.axesList[0].xmax:
1366 1367 self.saveFigure(figpath, figfile)
1367 1368 self.__isConfig = False
1368 1369
1369 1370 # if save:
1370 1371 #
1371 1372 # self.counter_imagwr += 1
1372 1373 # if (self.counter_imagwr==wr_period):
1373 1374 # if figfile == None:
1374 1375 # figfile = self.getFilename(name = self.name)
1375 1376 # self.saveFigure(figpath, figfile)
1376 1377 #
1377 1378 # if ftp:
1378 1379 # #provisionalmente envia archivos en el formato de la web en tiempo real
1379 1380 # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
1380 1381 # path = '%s%03d' %(self.PREFIX, self.id)
1381 1382 # ftp_file = os.path.join(path,'ftp','%s.png'%name)
1382 1383 # self.saveFigure(figpath, ftp_file)
1383 1384 # ftp_filename = os.path.join(figpath,ftp_file)
1384 1385 # self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1385 1386 # self.counter_imagwr = 0
1386 1387 #
1387 1388 # self.counter_imagwr = 0
1388 1389 #
1389 1390 #
1390 1391 # if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1391 1392 # self.__isConfig = False
1392 1393
1393 1394 class BeaconPhase(Figure):
1394 1395
1395 1396 __isConfig = None
1396 1397 __nsubplots = None
1397 1398
1398 1399 PREFIX = 'beacon_phase'
1399 1400
1400 1401 def __init__(self):
1401 1402
1402 1403 self.timerange = 24*60*60
1403 1404 self.__isConfig = False
1404 1405 self.__nsubplots = 1
1405 1406 self.counter_imagwr = 0
1406 1407 self.WIDTH = 600
1407 1408 self.HEIGHT = 300
1408 1409 self.WIDTHPROF = 120
1409 1410 self.HEIGHTPROF = 0
1410 1411 self.xdata = None
1411 1412 self.ydata = None
1412 1413
1413 1414 self.PLOT_CODE = 18
1414 1415 self.FTP_WEI = None
1415 1416 self.EXP_CODE = None
1416 1417 self.SUB_EXP_CODE = None
1417 1418 self.PLOT_POS = None
1418 1419
1419 1420 self.filename_phase = None
1420 1421
1421 1422 def getSubplots(self):
1422 1423
1423 1424 ncol = 1
1424 1425 nrow = 1
1425 1426
1426 1427 return nrow, ncol
1427 1428
1428 1429 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1429 1430
1430 1431 self.__showprofile = showprofile
1431 1432 self.nplots = nplots
1432 1433
1433 1434 ncolspan = 7
1434 1435 colspan = 6
1435 1436 self.__nsubplots = 2
1436 1437
1437 1438 self.createFigure(id = id,
1438 1439 wintitle = wintitle,
1439 1440 widthplot = self.WIDTH+self.WIDTHPROF,
1440 1441 heightplot = self.HEIGHT+self.HEIGHTPROF,
1441 1442 show=show)
1442 1443
1443 1444 nrow, ncol = self.getSubplots()
1444 1445
1445 1446 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1446 1447
1447 1448 def save_phase(self, filename_phase):
1448 1449 f = open(filename_phase,'w+')
1449 1450 f.write('\n\n')
1450 1451 f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n')
1451 1452 f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' )
1452 1453 f.close()
1453 1454
1454 1455 def save_data(self, filename_phase, data, data_datetime):
1455 1456 f=open(filename_phase,'a')
1456 1457 timetuple_data = data_datetime.timetuple()
1457 1458 day = str(timetuple_data.tm_mday)
1458 1459 month = str(timetuple_data.tm_mon)
1459 1460 year = str(timetuple_data.tm_year)
1460 1461 hour = str(timetuple_data.tm_hour)
1461 1462 minute = str(timetuple_data.tm_min)
1462 1463 second = str(timetuple_data.tm_sec)
1463 1464 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n')
1464 1465 f.close()
1465 1466
1466 1467
1467 1468 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1468 1469 xmin=None, xmax=None, ymin=None, ymax=None,
1469 1470 timerange=None,
1470 1471 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1471 1472 server=None, folder=None, username=None, password=None,
1472 1473 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1473 1474
1474 1475 if pairsList == None:
1475 1476 pairsIndexList = dataOut.pairsIndexList
1476 1477 else:
1477 1478 pairsIndexList = []
1478 1479 for pair in pairsList:
1479 1480 if pair not in dataOut.pairsList:
1480 1481 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
1481 1482 pairsIndexList.append(dataOut.pairsList.index(pair))
1482 1483
1483 1484 if pairsIndexList == []:
1484 1485 return
1485 1486
1486 1487 # if len(pairsIndexList) > 4:
1487 1488 # pairsIndexList = pairsIndexList[0:4]
1488 1489
1489 1490 if timerange != None:
1490 1491 self.timerange = timerange
1491 1492
1492 1493 tmin = None
1493 1494 tmax = None
1494 1495 x = dataOut.getTimeRange()
1495 1496 y = dataOut.getHeiRange()
1496 1497
1497 1498
1498 1499 #thisDatetime = dataOut.datatime
1499 1500 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1500 1501 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1501 1502 xlabel = "Local Time"
1502 1503 ylabel = "Phase"
1503 1504
1504 1505 nplots = len(pairsIndexList)
1505 1506 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1506 1507 phase_beacon = numpy.zeros(len(pairsIndexList))
1507 1508 for i in range(nplots):
1508 1509 pair = dataOut.pairsList[pairsIndexList[i]]
1509 1510 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
1510 1511 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
1511 1512 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
1512 1513 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
1513 1514 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
1514 1515
1515 1516 #print "Phase %d%d" %(pair[0], pair[1])
1516 1517 #print phase[dataOut.beacon_heiIndexList]
1517 1518
1518 1519 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1519 1520
1520 1521 if not self.__isConfig:
1521 1522
1522 1523 nplots = len(pairsIndexList)
1523 1524
1524 1525 self.setup(id=id,
1525 1526 nplots=nplots,
1526 1527 wintitle=wintitle,
1527 1528 showprofile=showprofile,
1528 1529 show=show)
1529 1530
1530 1531 tmin, tmax = self.getTimeLim(x, xmin, xmax)
1531 1532 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1532 1533 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1533 1534
1534 1535 self.FTP_WEI = ftp_wei
1535 1536 self.EXP_CODE = exp_code
1536 1537 self.SUB_EXP_CODE = sub_exp_code
1537 1538 self.PLOT_POS = plot_pos
1538 1539
1539 1540 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1540 1541 self.__isConfig = True
1541 1542
1542 1543 self.xdata = numpy.array([])
1543 1544 self.ydata = numpy.array([])
1544 1545
1545 1546 #open file beacon phase
1546 1547 path = '%s%03d' %(self.PREFIX, self.id)
1547 1548 beacon_file = os.path.join(path,'%s.txt'%self.name)
1548 1549 self.filename_phase = os.path.join(figpath,beacon_file)
1549 1550 #self.save_phase(self.filename_phase)
1550 1551
1551 1552
1552 1553 #store data beacon phase
1553 1554 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1554 1555
1555 1556 self.setWinTitle(title)
1556 1557
1557 1558
1558 1559 title = "Beacon Signal %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1559 1560
1560 1561 legendlabels = ["pairs %d%d"%(pair[0], pair[1]) for pair in dataOut.pairsList]
1561 1562
1562 1563 axes = self.axesList[0]
1563 1564
1564 1565 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1565 1566
1566 1567 if len(self.ydata)==0:
1567 1568 self.ydata = phase_beacon.reshape(-1,1)
1568 1569 else:
1569 1570 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1570 1571
1571 1572
1572 1573 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1573 1574 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
1574 1575 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1575 1576 XAxisAsTime=True, grid='both'
1576 1577 )
1577 1578
1578 1579 self.draw()
1579 1580
1580 1581 if save:
1581 1582
1582 1583 self.counter_imagwr += 1
1583 1584 if (self.counter_imagwr==wr_period):
1584 1585 if figfile == None:
1585 1586 figfile = self.getFilename(name = self.name)
1586 1587 self.saveFigure(figpath, figfile)
1587 1588
1588 1589 if ftp:
1589 1590 #provisionalmente envia archivos en el formato de la web en tiempo real
1590 1591 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
1591 1592 path = '%s%03d' %(self.PREFIX, self.id)
1592 1593 ftp_file = os.path.join(path,'ftp','%s.png'%name)
1593 1594 self.saveFigure(figpath, ftp_file)
1594 1595 ftp_filename = os.path.join(figpath,ftp_file)
1595 1596 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1596 1597
1597 1598 self.counter_imagwr = 0
1598 1599
1599 1600 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1600 1601 self.__isConfig = False
1601 1602 del self.xdata
1602 1603 del self.ydata
1603 1604
1604 1605
1605 1606
1606 1607
1607 1608 class Noise(Figure):
1608 1609
1609 1610 __isConfig = None
1610 1611 __nsubplots = None
1611 1612
1612 1613 PREFIX = 'noise'
1613 1614
1614 1615 def __init__(self):
1615 1616
1616 1617 self.timerange = 24*60*60
1617 1618 self.__isConfig = False
1618 1619 self.__nsubplots = 1
1619 1620 self.counter_imagwr = 0
1620 1621 self.WIDTH = 600
1621 1622 self.HEIGHT = 300
1622 1623 self.WIDTHPROF = 120
1623 1624 self.HEIGHTPROF = 0
1624 1625 self.xdata = None
1625 1626 self.ydata = None
1626 1627
1627 1628 self.PLOT_CODE = 77
1628 1629 self.FTP_WEI = None
1629 1630 self.EXP_CODE = None
1630 1631 self.SUB_EXP_CODE = None
1631 1632 self.PLOT_POS = None
1632 1633
1633 1634 def getSubplots(self):
1634 1635
1635 1636 ncol = 1
1636 1637 nrow = 1
1637 1638
1638 1639 return nrow, ncol
1639 1640
1640 1641 def openfile(self, filename):
1641 1642 f = open(filename,'w+')
1642 1643 f.write('\n\n')
1643 1644 f.write('JICAMARCA RADIO OBSERVATORY - Noise \n')
1644 1645 f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' )
1645 1646 f.close()
1646 1647
1647 1648 def save_data(self, filename_phase, data, data_datetime):
1648 1649 f=open(filename_phase,'a')
1649 1650 timetuple_data = data_datetime.timetuple()
1650 1651 day = str(timetuple_data.tm_mday)
1651 1652 month = str(timetuple_data.tm_mon)
1652 1653 year = str(timetuple_data.tm_year)
1653 1654 hour = str(timetuple_data.tm_hour)
1654 1655 minute = str(timetuple_data.tm_min)
1655 1656 second = str(timetuple_data.tm_sec)
1656 1657 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n')
1657 1658 f.close()
1658 1659
1659 1660
1660 1661 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1661 1662
1662 1663 self.__showprofile = showprofile
1663 1664 self.nplots = nplots
1664 1665
1665 1666 ncolspan = 7
1666 1667 colspan = 6
1667 1668 self.__nsubplots = 2
1668 1669
1669 1670 self.createFigure(id = id,
1670 1671 wintitle = wintitle,
1671 1672 widthplot = self.WIDTH+self.WIDTHPROF,
1672 1673 heightplot = self.HEIGHT+self.HEIGHTPROF,
1673 1674 show=show)
1674 1675
1675 1676 nrow, ncol = self.getSubplots()
1676 1677
1677 1678 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1678 1679
1679 1680
1680 1681 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
1681 1682 xmin=None, xmax=None, ymin=None, ymax=None,
1682 1683 timerange=None,
1683 1684 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1684 1685 server=None, folder=None, username=None, password=None,
1685 1686 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1686 1687
1687 1688 if channelList == None:
1688 1689 channelIndexList = dataOut.channelIndexList
1689 1690 channelList = dataOut.channelList
1690 1691 else:
1691 1692 channelIndexList = []
1692 1693 for channel in channelList:
1693 1694 if channel not in dataOut.channelList:
1694 1695 raise ValueError, "Channel %d is not in dataOut.channelList"
1695 1696 channelIndexList.append(dataOut.channelList.index(channel))
1696 1697
1697 1698 if timerange != None:
1698 1699 self.timerange = timerange
1699 1700
1700 1701 tmin = None
1701 1702 tmax = None
1702 1703 x = dataOut.getTimeRange()
1703 1704 y = dataOut.getHeiRange()
1704 1705 factor = dataOut.normFactor
1705 1706 noise = dataOut.getNoise()/factor
1706 1707 noisedB = 10*numpy.log10(noise)
1707 1708
1708 1709 #thisDatetime = dataOut.datatime
1709 1710 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1710 1711 title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1711 1712 xlabel = ""
1712 1713 ylabel = "Intensity (dB)"
1713 1714
1714 1715 if not self.__isConfig:
1715 1716
1716 1717 nplots = 1
1717 1718
1718 1719 self.setup(id=id,
1719 1720 nplots=nplots,
1720 1721 wintitle=wintitle,
1721 1722 showprofile=showprofile,
1722 1723 show=show)
1723 1724
1724 1725 tmin, tmax = self.getTimeLim(x, xmin, xmax)
1725 1726 if ymin == None: ymin = numpy.nanmin(noisedB) - 10.0
1726 1727 if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0
1727 1728
1728 1729 self.FTP_WEI = ftp_wei
1729 1730 self.EXP_CODE = exp_code
1730 1731 self.SUB_EXP_CODE = sub_exp_code
1731 1732 self.PLOT_POS = plot_pos
1732 1733
1733 1734
1734 1735 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1735 1736 self.__isConfig = True
1736 1737
1737 1738 self.xdata = numpy.array([])
1738 1739 self.ydata = numpy.array([])
1739 1740
1740 1741 #open file beacon phase
1741 1742 path = '%s%03d' %(self.PREFIX, self.id)
1742 1743 noise_file = os.path.join(path,'%s.txt'%self.name)
1743 1744 self.filename_noise = os.path.join(figpath,noise_file)
1744 1745 self.openfile(self.filename_noise)
1745 1746
1746 1747
1747 1748 #store data beacon phase
1748 1749 self.save_data(self.filename_noise, noisedB, thisDatetime)
1749 1750
1750 1751
1751 1752 self.setWinTitle(title)
1752 1753
1753 1754
1754 1755 title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1755 1756
1756 1757 legendlabels = ["channel %d"%(idchannel+1) for idchannel in channelList]
1757 1758 axes = self.axesList[0]
1758 1759
1759 1760 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1760 1761
1761 1762 if len(self.ydata)==0:
1762 1763 self.ydata = noisedB[channelIndexList].reshape(-1,1)
1763 1764 else:
1764 1765 self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1)))
1765 1766
1766 1767
1767 1768 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1768 1769 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
1769 1770 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1770 1771 XAxisAsTime=True, grid='both'
1771 1772 )
1772 1773
1773 1774 self.draw()
1774 1775
1775 1776 # if save:
1776 1777 #
1777 1778 # if figfile == None:
1778 1779 # figfile = self.getFilename(name = self.name)
1779 1780 #
1780 1781 # self.saveFigure(figpath, figfile)
1781 1782
1782 1783 if save:
1783 1784
1784 1785 self.counter_imagwr += 1
1785 1786 if (self.counter_imagwr==wr_period):
1786 1787 if figfile == None:
1787 1788 figfile = self.getFilename(name = self.name)
1788 1789 self.saveFigure(figpath, figfile)
1789 1790
1790 1791 if ftp:
1791 1792 #provisionalmente envia archivos en el formato de la web en tiempo real
1792 1793 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
1793 1794 path = '%s%03d' %(self.PREFIX, self.id)
1794 1795 ftp_file = os.path.join(path,'ftp','%s.png'%name)
1795 1796 self.saveFigure(figpath, ftp_file)
1796 1797 ftp_filename = os.path.join(figpath,ftp_file)
1797 1798 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1798 1799 self.counter_imagwr = 0
1799 1800
1800 1801 self.counter_imagwr = 0
1801 1802
1802 1803 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1803 1804 self.__isConfig = False
1804 1805 del self.xdata
1805 1806 del self.ydata
1806 1807
1807 1808
1808 1809 class SpectraHeisScope(Figure):
1809 1810
1810 1811
1811 1812 __isConfig = None
1812 1813 __nsubplots = None
1813 1814
1814 1815 WIDTHPROF = None
1815 1816 HEIGHTPROF = None
1816 1817 PREFIX = 'spc'
1817 1818
1818 1819 def __init__(self):
1819 1820
1820 1821 self.__isConfig = False
1821 1822 self.__nsubplots = 1
1822 1823
1823 1824 self.WIDTH = 230
1824 1825 self.HEIGHT = 250
1825 1826 self.WIDTHPROF = 120
1826 1827 self.HEIGHTPROF = 0
1827 1828 self.counter_imagwr = 0
1828 1829
1829 1830 def getSubplots(self):
1830 1831
1831 1832 ncol = int(numpy.sqrt(self.nplots)+0.9)
1832 1833 nrow = int(self.nplots*1./ncol + 0.9)
1833 1834
1834 1835 return nrow, ncol
1835 1836
1836 1837 def setup(self, id, nplots, wintitle, show):
1837 1838
1838 1839 showprofile = False
1839 1840 self.__showprofile = showprofile
1840 1841 self.nplots = nplots
1841 1842
1842 1843 ncolspan = 1
1843 1844 colspan = 1
1844 1845 if showprofile:
1845 1846 ncolspan = 3
1846 1847 colspan = 2
1847 1848 self.__nsubplots = 2
1848 1849
1849 1850 self.createFigure(id = id,
1850 1851 wintitle = wintitle,
1851 1852 widthplot = self.WIDTH + self.WIDTHPROF,
1852 1853 heightplot = self.HEIGHT + self.HEIGHTPROF,
1853 1854 show = show)
1854 1855
1855 1856 nrow, ncol = self.getSubplots()
1856 1857
1857 1858 counter = 0
1858 1859 for y in range(nrow):
1859 1860 for x in range(ncol):
1860 1861
1861 1862 if counter >= self.nplots:
1862 1863 break
1863 1864
1864 1865 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1865 1866
1866 1867 if showprofile:
1867 1868 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1868 1869
1869 1870 counter += 1
1870 1871
1871 1872
1872 1873 def run(self, dataOut, id, wintitle="", channelList=None,
1873 1874 xmin=None, xmax=None, ymin=None, ymax=None, save=False,
1874 1875 figpath='./', figfile=None, ftp=False, wr_period=1, show=True,
1875 1876 server=None, folder=None, username=None, password=None):
1876 1877
1877 1878 """
1878 1879
1879 1880 Input:
1880 1881 dataOut :
1881 1882 id :
1882 1883 wintitle :
1883 1884 channelList :
1884 1885 xmin : None,
1885 1886 xmax : None,
1886 1887 ymin : None,
1887 1888 ymax : None,
1888 1889 """
1889 1890
1890 1891 if dataOut.realtime:
1891 1892 if not(isRealtime(utcdatatime = dataOut.utctime)):
1892 1893 print 'Skipping this plot function'
1893 1894 return
1894 1895
1895 1896 if channelList == None:
1896 1897 channelIndexList = dataOut.channelIndexList
1897 1898 else:
1898 1899 channelIndexList = []
1899 1900 for channel in channelList:
1900 1901 if channel not in dataOut.channelList:
1901 1902 raise ValueError, "Channel %d is not in dataOut.channelList"
1902 1903 channelIndexList.append(dataOut.channelList.index(channel))
1903 1904
1904 1905 # x = dataOut.heightList
1905 1906 c = 3E8
1906 1907 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1907 1908 #deberia cambiar para el caso de 1Mhz y 100KHz
1908 1909 x = numpy.arange(-1*dataOut.nHeights/2.,dataOut.nHeights/2.)*(c/(2*deltaHeight*dataOut.nHeights*1000))
1909 1910 #para 1Mhz descomentar la siguiente linea
1910 1911 #x= x/(10000.0)
1911 1912 # y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
1912 1913 # y = y.real
1913 1914 datadB = 10.*numpy.log10(dataOut.data_spc)
1914 1915 y = datadB
1915 1916
1916 1917 #thisDatetime = dataOut.datatime
1917 1918 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1918 1919 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1919 1920 xlabel = ""
1920 1921 #para 1Mhz descomentar la siguiente linea
1921 1922 #xlabel = "Frequency x 10000"
1922 1923 ylabel = "Intensity (dB)"
1923 1924
1924 1925 if not self.__isConfig:
1925 1926 nplots = len(channelIndexList)
1926 1927
1927 1928 self.setup(id=id,
1928 1929 nplots=nplots,
1929 1930 wintitle=wintitle,
1930 1931 show=show)
1931 1932
1932 1933 if xmin == None: xmin = numpy.nanmin(x)
1933 1934 if xmax == None: xmax = numpy.nanmax(x)
1934 1935 if ymin == None: ymin = numpy.nanmin(y)
1935 1936 if ymax == None: ymax = numpy.nanmax(y)
1936 1937
1937 1938 self.__isConfig = True
1938 1939
1939 1940 self.setWinTitle(title)
1940 1941
1941 1942 for i in range(len(self.axesList)):
1942 1943 ychannel = y[i,:]
1943 1944 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1944 1945 title = "Channel %d: %4.2fdB: %s" %(i, numpy.max(ychannel), str_datetime)
1945 1946 axes = self.axesList[i]
1946 1947 axes.pline(x, ychannel,
1947 1948 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1948 1949 xlabel=xlabel, ylabel=ylabel, title=title, grid='both')
1949 1950
1950 1951
1951 1952 self.draw()
1952 1953
1953 1954 if save:
1954 1955 date = thisDatetime.strftime("%Y%m%d_%H%M%S")
1955 1956 if figfile == None:
1956 1957 figfile = self.getFilename(name = date)
1957 1958
1958 1959 self.saveFigure(figpath, figfile)
1959 1960
1960 1961 self.counter_imagwr += 1
1961 1962 if (ftp and (self.counter_imagwr==wr_period)):
1962 1963 ftp_filename = os.path.join(figpath,figfile)
1963 1964 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1964 1965 self.counter_imagwr = 0
1965 1966
1966 1967
1967 1968 class RTIfromSpectraHeis(Figure):
1968 1969
1969 1970 __isConfig = None
1970 1971 __nsubplots = None
1971 1972
1972 1973 PREFIX = 'rtinoise'
1973 1974
1974 1975 def __init__(self):
1975 1976
1976 1977 self.timerange = 24*60*60
1977 1978 self.__isConfig = False
1978 1979 self.__nsubplots = 1
1979 1980
1980 1981 self.WIDTH = 820
1981 1982 self.HEIGHT = 200
1982 1983 self.WIDTHPROF = 120
1983 1984 self.HEIGHTPROF = 0
1984 1985 self.counter_imagwr = 0
1985 1986 self.xdata = None
1986 1987 self.ydata = None
1987 1988
1988 1989 def getSubplots(self):
1989 1990
1990 1991 ncol = 1
1991 1992 nrow = 1
1992 1993
1993 1994 return nrow, ncol
1994 1995
1995 1996 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1996 1997
1997 1998 self.__showprofile = showprofile
1998 1999 self.nplots = nplots
1999 2000
2000 2001 ncolspan = 7
2001 2002 colspan = 6
2002 2003 self.__nsubplots = 2
2003 2004
2004 2005 self.createFigure(id = id,
2005 2006 wintitle = wintitle,
2006 2007 widthplot = self.WIDTH+self.WIDTHPROF,
2007 2008 heightplot = self.HEIGHT+self.HEIGHTPROF,
2008 2009 show = show)
2009 2010
2010 2011 nrow, ncol = self.getSubplots()
2011 2012
2012 2013 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
2013 2014
2014 2015
2015 2016 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
2016 2017 xmin=None, xmax=None, ymin=None, ymax=None,
2017 2018 timerange=None,
2018 2019 save=False, figpath='./', figfile=None, ftp=False, wr_period=1, show=True,
2019 2020 server=None, folder=None, username=None, password=None):
2020 2021
2021 2022 if channelList == None:
2022 2023 channelIndexList = dataOut.channelIndexList
2023 2024 channelList = dataOut.channelList
2024 2025 else:
2025 2026 channelIndexList = []
2026 2027 for channel in channelList:
2027 2028 if channel not in dataOut.channelList:
2028 2029 raise ValueError, "Channel %d is not in dataOut.channelList"
2029 2030 channelIndexList.append(dataOut.channelList.index(channel))
2030 2031
2031 2032 if timerange != None:
2032 2033 self.timerange = timerange
2033 2034
2034 2035 tmin = None
2035 2036 tmax = None
2036 2037 x = dataOut.getTimeRange()
2037 2038 y = dataOut.getHeiRange()
2038 2039
2039 2040 #factor = 1
2040 2041 data = dataOut.data_spc#/factor
2041 2042 data = numpy.average(data,axis=1)
2042 2043 datadB = 10*numpy.log10(data)
2043 2044
2044 2045 # factor = dataOut.normFactor
2045 2046 # noise = dataOut.getNoise()/factor
2046 2047 # noisedB = 10*numpy.log10(noise)
2047 2048
2048 2049 #thisDatetime = dataOut.datatime
2049 2050 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
2050 2051 title = wintitle + " RTI: %s" %(thisDatetime.strftime("%d-%b-%Y"))
2051 2052 xlabel = "Local Time"
2052 2053 ylabel = "Intensity (dB)"
2053 2054
2054 2055 if not self.__isConfig:
2055 2056
2056 2057 nplots = 1
2057 2058
2058 2059 self.setup(id=id,
2059 2060 nplots=nplots,
2060 2061 wintitle=wintitle,
2061 2062 showprofile=showprofile,
2062 2063 show=show)
2063 2064
2064 2065 tmin, tmax = self.getTimeLim(x, xmin, xmax)
2065 2066 if ymin == None: ymin = numpy.nanmin(datadB)
2066 2067 if ymax == None: ymax = numpy.nanmax(datadB)
2067 2068
2068 2069 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
2069 2070 self.__isConfig = True
2070 2071
2071 2072 self.xdata = numpy.array([])
2072 2073 self.ydata = numpy.array([])
2073 2074
2074 2075 self.setWinTitle(title)
2075 2076
2076 2077
2077 2078 # title = "RTI %s" %(thisDatetime.strftime("%d-%b-%Y"))
2078 2079 title = "RTI - %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
2079 2080
2080 2081 legendlabels = ["channel %d"%idchannel for idchannel in channelList]
2081 2082 axes = self.axesList[0]
2082 2083
2083 2084 self.xdata = numpy.hstack((self.xdata, x[0:1]))
2084 2085
2085 2086 if len(self.ydata)==0:
2086 2087 self.ydata = datadB[channelIndexList].reshape(-1,1)
2087 2088 else:
2088 2089 self.ydata = numpy.hstack((self.ydata, datadB[channelIndexList].reshape(-1,1)))
2089 2090
2090 2091
2091 2092 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
2092 2093 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
2093 2094 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='.', markersize=8, linestyle="solid", grid='both',
2094 2095 XAxisAsTime=True
2095 2096 )
2096 2097
2097 2098 self.draw()
2098 2099
2099 2100 if save:
2100 2101
2101 2102 if figfile == None:
2102 2103 figfile = self.getFilename(name = self.name)
2103 2104
2104 2105 self.saveFigure(figpath, figfile)
2105 2106
2106 2107 self.counter_imagwr += 1
2107 2108 if (ftp and (self.counter_imagwr==wr_period)):
2108 2109 ftp_filename = os.path.join(figpath,figfile)
2109 2110 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
2110 2111 self.counter_imagwr = 0
2111 2112
2112 2113 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
2113 2114 self.__isConfig = False
2114 2115 del self.xdata
2115 2116 del self.ydata
2116 2117
2117 2118
2118 2119 No newline at end of file
@@ -1,93 +1,287
1 1 import os, sys
2 2
3 3 path = os.path.split(os.getcwd())[0]
4 4 sys.path.append(path)
5 5
6 6 from controller import *
7 7
8 8 desc = "AMISR Experiment Test"
9 9 filename = "amisr.xml"
10 10
11 11 controllerObj = Project()
12 12
13 13 controllerObj.setup(id = '191', name='test01', description=desc)
14 14
15 15 path = '/home/administrator/Documents/amisr'
16 path = '/media/administrator/New Volume/amisr'
17
18 figpath = '/home/administrator/Pictures/amisr'
19
20 figfile0 = 'amisr_rti_beam0.png'
21 figfile1 = 'amisr_rti_beam1.png'
22 figfile2 = 'amisr_rti_beam2.png'
23 figfile3 = 'amisr_rti_beam3.png'
24 figfile4 = 'amisr_rti_beam4.png'
25 figfile5 = 'amisr_rti_beam5.png'
26 figfile6 = 'amisr_rti_beam6.png'
27
28 title0 = 'RTI AMISR Beam 0'
29 title1 = 'RTI AMISR Beam 1'
30 title2 = 'RTI AMISR Beam 2'
31 title3 = 'RTI AMISR Beam 3'
32 title4 = 'RTI AMISR Beam 4'
33 title5 = 'RTI AMISR Beam 5'
34 title6 = 'RTI AMISR Beam 6'
16 35
17 36 readUnitConfObj = controllerObj.addReadUnit(datatype='AMISR',
18 37 path=path,
19 startDate='2014/08/18',
20 endDate='2014/08/18',
38 startDate='2014/08/19',
39 endDate='2014/08/19',
21 40 startTime='00:00:00',
22 41 endTime='23:59:59',
23 42 walk=1)
24 43
25 44 procUnitConfObjBeam0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
26 45 procUnitConfObjBeam1 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
27 46 procUnitConfObjBeam2 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
28 47 procUnitConfObjBeam3 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
29 48 procUnitConfObjBeam4 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
30 49 procUnitConfObjBeam5 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
31 50 procUnitConfObjBeam6 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
32 51
33 # Beam0
52
53
54
55 ############################# Beam0 #############################
34 56 opObj11 = procUnitConfObjBeam0.addOperation(name='ProfileSelector', optype='other')
35 57 opObj11.addParameter(name='profileRangeList', value='0,81', format='intlist')
58
59 opObj11 = procUnitConfObjBeam0.addOperation(name='CohInt', optype='other')
60 opObj11.addParameter(name='n', value='82', format='int')
61
62 procUnitConfObjSpectraBeam0 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam0.getId())
63 procUnitConfObjSpectraBeam0.addParameter(name='nFFTPoints', value='32', format='int')
64 procUnitConfObjSpectraBeam0.addParameter(name='nProfiles', value='32', format='int')
65
66 opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='getNoise')
67 opObj11.addParameter(name='minHei', value='100', format='float')
68 opObj11.addParameter(name='maxHei', value='450', format='float')
69
70 opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='RTIPlot', optype='other')
71 opObj11.addParameter(name='id', value='200', format='int')
72 opObj11.addParameter(name='wintitle', value=title0, format='str')
73 opObj11.addParameter(name='xmin', value='0', format='int')
74 opObj11.addParameter(name='xmax', value='18', format='int')
75 opObj11.addParameter(name='zmin', value='45', format='int')
76 opObj11.addParameter(name='zmax', value='70', format='int')
77 #opObj11.addParameter(name='timerange', value='7200', format='int')
78 opObj11.addParameter(name='showprofile', value='0', format='int')
79 opObj11.addParameter(name='figpath', value=figpath, format='str')
80 opObj11.addParameter(name='figfile', value=figfile0, format='str')
81
82
36 83
37 opObj11 = procUnitConfObjBeam0.addOperation(name='PowerProfile', optype='other')
38 opObj11.addParameter(name='id', value='10', format='int')
39 opObj11.addParameter(name='wintitle', value='AMISR Beam0 - Power Profile', format='str')
40 84
41 # Beam1
85
86 #
87 ############################# Beam1 #############################
42 88 opObj11 = procUnitConfObjBeam1.addOperation(name='ProfileSelector', optype='other')
43 opObj11.addParameter(name='profileRangeList', value='82,209', format='intlist')
44 opObj11 = procUnitConfObjBeam1.addOperation(name='PowerProfile', optype='other')
45 opObj11.addParameter(name='id', value='11', format='int')
46 opObj11.addParameter(name='wintitle', value='AMISR Beam1 - Power Profile', format='str')
47
48 # # Beam2
89 opObj11.addParameter(name='profileRangeList', value='82,209', format='intlist')
90
91 opObj11 = procUnitConfObjBeam1.addOperation(name='CohInt', optype='other')
92 opObj11.addParameter(name='n', value='128', format='int')
93
94 procUnitConfObjSpectraBeam1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam1.getId())
95 procUnitConfObjSpectraBeam1.addParameter(name='nFFTPoints', value='32', format='int')
96 procUnitConfObjSpectraBeam1.addParameter(name='nProfiles', value='32', format='int')
97
98 opObj11 = procUnitConfObjSpectraBeam1.addOperation(name='getNoise')
99 opObj11.addParameter(name='minHei', value='100', format='float')
100 opObj11.addParameter(name='maxHei', value='450', format='float')
101
102 #opObj11 = procUnitConfObjSpectraBeam1.addOperation(name='SpectraPlot', optype='other')
103 #opObj11.addParameter(name='id', value='100', format='int')
104 #opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
105 # opObj11.addParameter(name='zmin', value='45', format='int')
106 # opObj11.addParameter(name='zmax', value='70', format='int')
107 # opObj11.addParameter(name='save', value='1', format='bool')
108 # opObj11.addParameter(name='figpath', value='/Users/administrator/Pictures/amisr', format='str')
109
110 opObj11 = procUnitConfObjSpectraBeam1.addOperation(name='RTIPlot', optype='other')
111 opObj11.addParameter(name='id', value='201', format='int')
112 opObj11.addParameter(name='wintitle', value=title1, format='str')
113 #opObj11.addParameter(name='timerange', value='36000', format='int')
114 opObj11.addParameter(name='xmin', value='0', format='int')
115 opObj11.addParameter(name='xmax', value='18', format='int')
116 opObj11.addParameter(name='zmin', value='45', format='int')
117 opObj11.addParameter(name='zmax', value='70', format='int')
118 opObj11.addParameter(name='showprofile', value='0', format='int')
119 opObj11.addParameter(name='figpath', value=figpath, format='str')
120 opObj11.addParameter(name='figfile', value=figfile1, format='str')
121 #
122 #
123 #
124 #
125 #
126 ############################## Beam2 #############################
49 127 opObj11 = procUnitConfObjBeam2.addOperation(name='ProfileSelector', optype='other')
50 128 opObj11.addParameter(name='profileRangeList', value='210,337', format='intlist')
51 opObj11 = procUnitConfObjBeam2.addOperation(name='PowerProfile', optype='other')
52 opObj11.addParameter(name='id', value='12', format='int')
53 opObj11.addParameter(name='wintitle', value='AMISR Beam2 - Power Profile', format='str')
54 #
55 # # Beam3
129
130 opObj11 = procUnitConfObjBeam2.addOperation(name='CohInt', optype='other')
131 opObj11.addParameter(name='n', value='128', format='int')
132
133 procUnitConfObjSpectraBeam2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam2.getId())
134 procUnitConfObjSpectraBeam2.addParameter(name='nFFTPoints', value='32', format='int')
135 procUnitConfObjSpectraBeam2.addParameter(name='nProfiles', value='32', format='int')
136
137 opObj11 = procUnitConfObjSpectraBeam2.addOperation(name='getNoise')
138 opObj11.addParameter(name='minHei', value='100', format='float')
139 opObj11.addParameter(name='maxHei', value='450', format='float')
140
141 opObj11 = procUnitConfObjSpectraBeam2.addOperation(name='RTIPlot', optype='other')
142 opObj11.addParameter(name='id', value='202', format='int')
143 opObj11.addParameter(name='wintitle', value=title2, format='str')
144 #opObj11.addParameter(name='timerange', value='18000', format='int')
145 opObj11.addParameter(name='xmin', value='0', format='int')
146 opObj11.addParameter(name='xmax', value='18', format='int')
147 opObj11.addParameter(name='zmin', value='45', format='int')
148 opObj11.addParameter(name='zmax', value='70', format='int')
149 opObj11.addParameter(name='showprofile', value='0', format='int')
150 opObj11.addParameter(name='figpath', value=figpath, format='str')
151 opObj11.addParameter(name='figfile', value=figfile2, format='str')
152 # #
153 # #
154 # #
155 # #
156 # #
157 # #
158 ############################## Beam3 #############################
56 159 opObj11 = procUnitConfObjBeam3.addOperation(name='ProfileSelector', optype='other')
57 160 opObj11.addParameter(name='profileRangeList', value='338,465', format='intlist')
58 opObj11 = procUnitConfObjBeam3.addOperation(name='PowerProfile', optype='other')
59 opObj11.addParameter(name='id', value='13', format='int')
60 opObj11.addParameter(name='wintitle', value='AMISR Beam3 - Power Profile', format='str')
61
62 # # Beam4
161
162 opObj11 = procUnitConfObjBeam3.addOperation(name='CohInt', optype='other')
163 opObj11.addParameter(name='n', value='128', format='int')
164
165 procUnitConfObjSpectraBeam3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam3.getId())
166 procUnitConfObjSpectraBeam3.addParameter(name='nFFTPoints', value='32', format='int')
167 procUnitConfObjSpectraBeam3.addParameter(name='nProfiles', value='32', format='int')
168
169 opObj11 = procUnitConfObjSpectraBeam3.addOperation(name='getNoise')
170 opObj11.addParameter(name='minHei', value='100', format='float')
171 opObj11.addParameter(name='maxHei', value='450', format='float')
172
173 opObj11 = procUnitConfObjSpectraBeam3.addOperation(name='RTIPlot', optype='other')
174 opObj11.addParameter(name='id', value='203', format='int')
175 opObj11.addParameter(name='wintitle', value=title3, format='str')
176 #opObj11.addParameter(name='timerange', value='18000', format='int')
177 opObj11.addParameter(name='xmin', value='0', format='int')
178 opObj11.addParameter(name='xmax', value='18', format='int')
179 opObj11.addParameter(name='zmin', value='45', format='int')
180 opObj11.addParameter(name='zmax', value='70', format='int')
181 opObj11.addParameter(name='showprofile', value='0', format='int')
182 opObj11.addParameter(name='figpath', value=figpath, format='str')
183 opObj11.addParameter(name='figfile', value=figfile3, format='str')
184 # #
185 # #
186 # #
187 # #
188 # #
189 # #
190 ############################## Beam4 #############################
63 191 opObj11 = procUnitConfObjBeam4.addOperation(name='ProfileSelector', optype='other')
64 192 opObj11.addParameter(name='profileRangeList', value='466,593', format='intlist')
65 opObj11 = procUnitConfObjBeam4.addOperation(name='PowerProfile', optype='other')
66 opObj11.addParameter(name='id', value='14', format='int')
67 opObj11.addParameter(name='wintitle', value='AMISR Beam4 - Power Profile', format='str')
68 #
69 # # Beam5
70 # opObj11 = procUnitConfObjBeam5.addOperation(name='ProfileSelector', optype='other')
71 # opObj11.addParameter(name='profileRangeList', value='594,721', format='intlist')
72 # opObj11 = procUnitConfObjBeam5.addOperation(name='PowerProfile', optype='other')
73 # opObj11.addParameter(name='id', value='15', format='int')
74 # opObj11.addParameter(name='wintitle', value='AMISR Beam5 - Power Profile', format='str')
75 #
76 # # Beam6
77 # opObj11 = procUnitConfObjBeam6.addOperation(name='ProfileSelector', optype='other')
78 # opObj11.addParameter(name='profileRangeList', value='722,849', format='intlist')
79 # opObj11 = procUnitConfObjBeam6.addOperation(name='PowerProfile', optype='other')
80 # opObj11.addParameter(name='id', value='16', format='int')
81 # opObj11.addParameter(name='wintitle', value='AMISR Beam6 - Power Profile', format='str')
82
83
193
194 opObj11 = procUnitConfObjBeam4.addOperation(name='CohInt', optype='other')
195 opObj11.addParameter(name='n', value='128', format='int')
196
197 procUnitConfObjSpectraBeam4 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam4.getId())
198 procUnitConfObjSpectraBeam4.addParameter(name='nFFTPoints', value='32', format='int')
199 procUnitConfObjSpectraBeam4.addParameter(name='nProfiles', value='32', format='int')
200
201 opObj11 = procUnitConfObjSpectraBeam4.addOperation(name='getNoise')
202 opObj11.addParameter(name='minHei', value='100', format='float')
203 opObj11.addParameter(name='maxHei', value='450', format='float')
204
205 opObj11 = procUnitConfObjSpectraBeam4.addOperation(name='RTIPlot', optype='other')
206 opObj11.addParameter(name='id', value='204', format='int')
207 opObj11.addParameter(name='wintitle', value=title4, format='str')
208 #opObj11.addParameter(name='timerange', value='18000', format='int')
209 opObj11.addParameter(name='xmin', value='0', format='int')
210 opObj11.addParameter(name='xmax', value='18', format='int')
211 opObj11.addParameter(name='zmin', value='45', format='int')
212 opObj11.addParameter(name='zmax', value='70', format='int')
213 opObj11.addParameter(name='showprofile', value='0', format='int')
214 opObj11.addParameter(name='figpath', value=figpath, format='str')
215 opObj11.addParameter(name='figfile', value=figfile4, format='str')
216 # #
217 # #
218 # #
219 # #
220 # #
221 ############################## Beam5 #############################
222 opObj11 = procUnitConfObjBeam5.addOperation(name='ProfileSelector', optype='other')
223 opObj11.addParameter(name='profileRangeList', value='594,721', format='intlist')
224
225 opObj11 = procUnitConfObjBeam5.addOperation(name='CohInt', optype='other')
226 opObj11.addParameter(name='n', value='128', format='int')
227
228 procUnitConfObjSpectraBeam5 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam5.getId())
229 procUnitConfObjSpectraBeam5.addParameter(name='nFFTPoints', value='32', format='int')
230 procUnitConfObjSpectraBeam5.addParameter(name='nProfiles', value='32', format='int')
231
232 opObj11 = procUnitConfObjSpectraBeam5.addOperation(name='getNoise')
233 opObj11.addParameter(name='minHei', value='100', format='float')
234 opObj11.addParameter(name='maxHei', value='450', format='float')
235
236 opObj11 = procUnitConfObjSpectraBeam5.addOperation(name='RTIPlot', optype='other')
237 opObj11.addParameter(name='id', value='205', format='int')
238 opObj11.addParameter(name='wintitle', value=title5, format='str')
239 #opObj11.addParameter(name='timerange', value='18000', format='int')
240 opObj11.addParameter(name='xmin', value='0', format='int')
241 opObj11.addParameter(name='xmax', value='18', format='int')
242 opObj11.addParameter(name='zmin', value='45', format='int')
243 opObj11.addParameter(name='zmax', value='70', format='int')
244 opObj11.addParameter(name='showprofile', value='0', format='int')
245 opObj11.addParameter(name='figpath', value=figpath, format='str')
246 opObj11.addParameter(name='figfile', value=figfile5, format='str')
247 # #
248 # #
249 # #
250 # #
251 # #
252 ############################## Beam6 #############################
253 opObj11 = procUnitConfObjBeam6.addOperation(name='ProfileSelector', optype='other')
254 opObj11.addParameter(name='profileRangeList', value='722,849', format='intlist')
255
256 opObj11 = procUnitConfObjBeam6.addOperation(name='CohInt', optype='other')
257 opObj11.addParameter(name='n', value='128', format='int')
258
259 procUnitConfObjSpectraBeam6 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam6.getId())
260 procUnitConfObjSpectraBeam6.addParameter(name='nFFTPoints', value='32', format='int')
261 procUnitConfObjSpectraBeam6.addParameter(name='nProfiles', value='32', format='int')
262
263 opObj11 = procUnitConfObjSpectraBeam6.addOperation(name='getNoise')
264 opObj11.addParameter(name='minHei', value='100', format='float')
265 opObj11.addParameter(name='maxHei', value='450', format='float')
266
267 opObj11 = procUnitConfObjSpectraBeam6.addOperation(name='RTIPlot', optype='other')
268 opObj11.addParameter(name='id', value='206', format='int')
269 opObj11.addParameter(name='wintitle', value=title6, format='str')
270 #opObj11.addParameter(name='timerange', value='18000', format='int')
271 opObj11.addParameter(name='xmin', value='0', format='int')
272 opObj11.addParameter(name='xmax', value='18', format='int')
273 opObj11.addParameter(name='zmin', value='45', format='int')
274 opObj11.addParameter(name='zmax', value='70', format='int')
275 opObj11.addParameter(name='showprofile', value='0', format='int')
276 opObj11.addParameter(name='figpath', value=figpath, format='str')
277 opObj11.addParameter(name='figfile', value=figfile6, format='str')
84 278
85 279
86 280 print "Escribiendo el archivo XML"
87 281 controllerObj.writeXml(filename)
88 282 print "Leyendo el archivo XML"
89 283 controllerObj.readXml(filename)
90 284
91 285 controllerObj.createObjects()
92 286 controllerObj.connectObjects()
93 287 controllerObj.run()
General Comments 0
You need to be logged in to leave comments. Login now