##// END OF EJS Templates
Signal Chain GUI...
Miguel Valdez -
r600:19c1076f2d8a
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,1166 +1,1194
1 1 '''
2 2 Created on September , 2012
3 3 @author:
4 4 '''
5 5 from xml.etree.ElementTree import Element, SubElement
6 6 from xml.etree import ElementTree as ET
7 7 from xml.dom import minidom
8 8
9 9 #import datetime
10 10 from model import *
11 11
12 12 try:
13 13 from gevent import sleep
14 14 except:
15 15 from time import sleep
16 16
17 17 import ast
18 18
19 19 def prettify(elem):
20 20 """Return a pretty-printed XML string for the Element.
21 21 """
22 22 rough_string = ET.tostring(elem, 'utf-8')
23 23 reparsed = minidom.parseString(rough_string)
24 24 return reparsed.toprettyxml(indent=" ")
25 25
26 26 class ParameterConf():
27 27
28 28 id = None
29 29 name = None
30 30 value = None
31 31 format = None
32 32
33 33 __formated_value = None
34 34
35 35 ELEMENTNAME = 'Parameter'
36 36
37 37 def __init__(self):
38 38
39 39 self.format = 'str'
40 40
41 41 def getElementName(self):
42 42
43 43 return self.ELEMENTNAME
44 44
45 45 def getValue(self):
46 46
47 value = self.value
48 format = self.format
49
47 50 if self.__formated_value != None:
48 51
49 52 return self.__formated_value
50 53
51 value = self.value
52
53 if self.format == 'str':
54 if format == 'str':
54 55 self.__formated_value = str(value)
55 56 return self.__formated_value
56 57
57 58 if value == '':
58 59 raise ValueError, "%s: This parameter value is empty" %self.name
59 60
60 if self.format == 'bool':
61 if format == 'bool':
61 62 value = int(value)
62 63
63 if self.format == 'list':
64 if format == 'list':
64 65 strList = value.split(',')
65 66
66 67 self.__formated_value = strList
67 68
68 69 return self.__formated_value
69 70
70 if self.format == 'intlist':
71 if format == 'intlist':
71 72 """
72 73 Example:
73 74 value = (0,1,2)
74 75 """
75 intList = ast.literal_eval(value)
76 value = value.replace('(', '')
77 value = value.replace(')', '')
78
79 value = value.replace('[', '')
80 value = value.replace(']', '')
81
82 strList = value.split(',')
83 intList = [int(x) for x in strList]
76 84
77 85 self.__formated_value = intList
78 86
79 87 return self.__formated_value
80 88
81 if self.format == 'floatlist':
89 if format == 'floatlist':
82 90 """
83 91 Example:
84 92 value = (0.5, 1.4, 2.7)
85 93 """
86 94
87 floatList = ast.literal_eval(value)
95 value = value.replace('(', '')
96 value = value.replace(')', '')
97
98 value = value.replace('[', '')
99 value = value.replace(']', '')
100
101 strList = value.split(',')
102 floatList = [float(x) for x in strList]
88 103
89 104 self.__formated_value = floatList
90 105
91 106 return self.__formated_value
92 107
93 if self.format == 'date':
108 if format == 'date':
94 109 strList = value.split('/')
95 110 intList = [int(x) for x in strList]
96 111 date = datetime.date(intList[0], intList[1], intList[2])
97 112
98 113 self.__formated_value = date
99 114
100 115 return self.__formated_value
101 116
102 if self.format == 'time':
117 if format == 'time':
103 118 strList = value.split(':')
104 119 intList = [int(x) for x in strList]
105 120 time = datetime.time(intList[0], intList[1], intList[2])
106 121
107 122 self.__formated_value = time
108 123
109 124 return self.__formated_value
110 125
111 if self.format == 'pairslist':
126 if format == 'pairslist':
112 127 """
113 128 Example:
114 129 value = (0,1),(1,2)
115 130 """
116 131
117 pairList = ast.literal_eval(value)
132 value = value.replace('(', '')
133 value = value.replace(')', '')
134
135 value = value.replace('[', '')
136 value = value.replace(']', '')
137
138 strList = value.split(',')
139 intList = [int(item) for item in strList]
140 pairList = []
141 for i in range(len(intList)/2):
142 pairList.append((intList[i*2], intList[i*2 + 1]))
118 143
119 144 self.__formated_value = pairList
120 145
121 146 return self.__formated_value
122 147
123 if self.format == 'multilist':
148 if format == 'multilist':
124 149 """
125 150 Example:
126 151 value = (0,1,2),(3,4,5)
127 152 """
128 153 multiList = ast.literal_eval(value)
129 154
155 if type(multiList[0]) == int:
156 multiList = ast.literal_eval("(" + value + ")")
157
130 158 self.__formated_value = multiList
131 159
132 160 return self.__formated_value
133 161
134 format_func = eval(self.format)
162 format_func = eval(format)
135 163
136 164 self.__formated_value = format_func(value)
137 165
138 166 return self.__formated_value
139 167
140 168 def updateId(self, new_id):
141 169
142 170 self.id = str(new_id)
143 171
144 172 def setup(self, id, name, value, format='str'):
145 173
146 174 self.id = str(id)
147 175 self.name = name
148 176 self.value = str(value)
149 177 self.format = str.lower(format)
150 178
151 179 def update(self, name, value, format='str'):
152 180
153 181 self.name = name
154 182 self.value = str(value)
155 183 self.format = format
156 184
157 185 def makeXml(self, opElement):
158 186
159 187 parmElement = SubElement(opElement, self.ELEMENTNAME)
160 188 parmElement.set('id', str(self.id))
161 189 parmElement.set('name', self.name)
162 190 parmElement.set('value', self.value)
163 191 parmElement.set('format', self.format)
164 192
165 193 def readXml(self, parmElement):
166 194
167 195 self.id = parmElement.get('id')
168 196 self.name = parmElement.get('name')
169 197 self.value = parmElement.get('value')
170 198 self.format = str.lower(parmElement.get('format'))
171 199
172 200 #Compatible with old signal chain version
173 201 if self.format == 'int' and self.name == 'idfigure':
174 202 self.name = 'id'
175 203
176 204 def printattr(self):
177 205
178 206 print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format)
179 207
180 208 class OperationConf():
181 209
182 210 id = None
183 211 name = None
184 212 priority = None
185 213 type = None
186 214
187 215 parmConfObjList = []
188 216
189 217 ELEMENTNAME = 'Operation'
190 218
191 219 def __init__(self):
192 220
193 221 self.id = '0'
194 222 self.name = None
195 223 self.priority = None
196 224 self.type = 'self'
197 225
198 226
199 227 def __getNewId(self):
200 228
201 229 return int(self.id)*10 + len(self.parmConfObjList) + 1
202 230
203 231 def updateId(self, new_id):
204 232
205 233 self.id = str(new_id)
206 234
207 235 n = 1
208 236 for parmObj in self.parmConfObjList:
209 237
210 238 idParm = str(int(new_id)*10 + n)
211 239 parmObj.updateId(idParm)
212 240
213 241 n += 1
214 242
215 243 def getElementName(self):
216 244
217 245 return self.ELEMENTNAME
218 246
219 247 def getParameterObjList(self):
220 248
221 249 return self.parmConfObjList
222 250
223 251 def getParameterObj(self, parameterName):
224 252
225 253 for parmConfObj in self.parmConfObjList:
226 254
227 255 if parmConfObj.name != parameterName:
228 256 continue
229 257
230 258 return parmConfObj
231 259
232 260 return None
233 261
234 262 def getParameterObjfromValue(self,parameterValue):
235 263 for parmConfObj in self.parmConfObjList:
236 264
237 265 if parmConfObj.getValue() != parameterValue:
238 266 continue
239 267
240 268 return parmConfObj.getValue()
241 269
242 270 return None
243 271
244 272 def getParameterValue(self, parameterName):
245 273
246 274 parameterObj = self.getParameterObj(parameterName)
247 275 value = parameterObj.getValue()
248 276
249 277 return value
250 278
251 279 def setup(self, id, name, priority, type):
252 280
253 281 self.id = str(id)
254 282 self.name = name
255 283 self.type = type
256 284 self.priority = priority
257 285
258 286 self.parmConfObjList = []
259 287
260 288 def removeParameters(self):
261 289
262 290 for obj in self.parmConfObjList:
263 291 del obj
264 292
265 293 self.parmConfObjList = []
266 294
267 295 def addParameter(self, name, value, format='str'):
268 296
269 297 id = self.__getNewId()
270 298
271 299 parmConfObj = ParameterConf()
272 300 parmConfObj.setup(id, name, value, format)
273 301
274 302 self.parmConfObjList.append(parmConfObj)
275 303
276 304 return parmConfObj
277 305
278 306 def changeParameter(self, name, value, format='str'):
279 307
280 308 parmConfObj = self.getParameterObj(name)
281 309 parmConfObj.update(name, value, format)
282 310
283 311 return parmConfObj
284 312
285 313 def makeXml(self, upElement):
286 314
287 315 opElement = SubElement(upElement, self.ELEMENTNAME)
288 316 opElement.set('id', str(self.id))
289 317 opElement.set('name', self.name)
290 318 opElement.set('type', self.type)
291 319 opElement.set('priority', str(self.priority))
292 320
293 321 for parmConfObj in self.parmConfObjList:
294 322 parmConfObj.makeXml(opElement)
295 323
296 324 def readXml(self, opElement):
297 325
298 326 self.id = opElement.get('id')
299 327 self.name = opElement.get('name')
300 328 self.type = opElement.get('type')
301 329 self.priority = opElement.get('priority')
302 330
303 331 #Compatible with old signal chain version
304 332 #Use of 'run' method instead 'init'
305 333 if self.type == 'self' and self.name == 'init':
306 334 self.name = 'run'
307 335
308 336 self.parmConfObjList = []
309 337
310 338 parmElementList = opElement.getiterator(ParameterConf().getElementName())
311 339
312 340 for parmElement in parmElementList:
313 341 parmConfObj = ParameterConf()
314 342 parmConfObj.readXml(parmElement)
315 343
316 344 #Compatible with old signal chain version
317 345 #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER
318 346 if self.type != 'self' and self.name == 'Plot':
319 347 if parmConfObj.format == 'str' and parmConfObj.name == 'type':
320 348 self.name = parmConfObj.value
321 349 continue
322 350
323 351 self.parmConfObjList.append(parmConfObj)
324 352
325 353 def printattr(self):
326 354
327 355 print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME,
328 356 self.id,
329 357 self.name,
330 358 self.type,
331 359 self.priority)
332 360
333 361 for parmConfObj in self.parmConfObjList:
334 362 parmConfObj.printattr()
335 363
336 364 def createObject(self):
337 365
338 366 if self.type == 'self':
339 367 raise ValueError, "This operation type cannot be created"
340 368
341 369 if self.type == 'external' or self.type == 'other':
342 370 className = eval(self.name)
343 371 opObj = className()
344 372
345 373 return opObj
346 374
347 375 class ProcUnitConf():
348 376
349 377 id = None
350 378 name = None
351 379 datatype = None
352 380 inputId = None
353 381 parentId = None
354 382
355 383 opConfObjList = []
356 384
357 385 procUnitObj = None
358 386 opObjList = []
359 387
360 388 ELEMENTNAME = 'ProcUnit'
361 389
362 390 def __init__(self):
363 391
364 392 self.id = None
365 393 self.datatype = None
366 394 self.name = None
367 395 self.inputId = None
368 396
369 397 self.opConfObjList = []
370 398
371 399 self.procUnitObj = None
372 400 self.opObjDict = {}
373 401
374 402 def __getPriority(self):
375 403
376 404 return len(self.opConfObjList)+1
377 405
378 406 def __getNewId(self):
379 407
380 408 return int(self.id)*10 + len(self.opConfObjList) + 1
381 409
382 410 def getElementName(self):
383 411
384 412 return self.ELEMENTNAME
385 413
386 414 def getId(self):
387 415
388 416 return self.id
389 417
390 418 def updateId(self, new_id, parentId=parentId):
391 419
392 420
393 421 new_id = int(parentId)*10 + (int(self.id) % 10)
394 422 new_inputId = int(parentId)*10 + (int(self.inputId) % 10)
395 423
396 424 #If this proc unit has not inputs
397 425 if self.inputId == '0':
398 426 new_inputId = 0
399 427
400 428 n = 1
401 429 for opConfObj in self.opConfObjList:
402 430
403 431 idOp = str(int(new_id)*10 + n)
404 432 opConfObj.updateId(idOp)
405 433
406 434 n += 1
407 435
408 436 self.parentId = str(parentId)
409 437 self.id = str(new_id)
410 438 self.inputId = str(new_inputId)
411 439
412 440
413 441 def getInputId(self):
414 442
415 443 return self.inputId
416 444
417 445 def getOperationObjList(self):
418 446
419 447 return self.opConfObjList
420 448
421 449 def getOperationObj(self, name=None):
422 450
423 451 for opConfObj in self.opConfObjList:
424 452
425 453 if opConfObj.name != name:
426 454 continue
427 455
428 456 return opConfObj
429 457
430 458 return None
431 459
432 460 def getOpObjfromParamValue(self,value=None):
433 461
434 462 for opConfObj in self.opConfObjList:
435 463 if opConfObj.getParameterObjfromValue(parameterValue=value) != value:
436 464 continue
437 465 return opConfObj
438 466 return None
439 467
440 468 def getProcUnitObj(self):
441 469
442 470 return self.procUnitObj
443 471
444 472 def setup(self, id, name, datatype, inputId, parentId=None):
445 473
446 474 #Compatible with old signal chain version
447 475 if datatype==None and name==None:
448 476 raise ValueError, "datatype or name should be defined"
449 477
450 478 if name==None:
451 479 if 'Proc' in datatype:
452 480 name = datatype
453 481 else:
454 482 name = '%sProc' %(datatype)
455 483
456 484 if datatype==None:
457 485 datatype = name.replace('Proc','')
458 486
459 487 self.id = str(id)
460 488 self.name = name
461 489 self.datatype = datatype
462 490 self.inputId = inputId
463 491 self.parentId = parentId
464 492
465 493 self.opConfObjList = []
466 494
467 495 self.addOperation(name='run', optype='self')
468 496
469 497 def removeOperations(self):
470 498
471 499 for obj in self.opConfObjList:
472 500 del obj
473 501
474 502 self.opConfObjList = []
475 503 self.addOperation(name='run')
476 504
477 505 def addParameter(self, **kwargs):
478 506 '''
479 507 Add parameters to "run" operation
480 508 '''
481 509 opObj = self.opConfObjList[0]
482 510
483 511 opObj.addParameter(**kwargs)
484 512
485 513 return opObj
486 514
487 515 def addOperation(self, name, optype='self'):
488 516
489 517 id = self.__getNewId()
490 518 priority = self.__getPriority()
491 519
492 520 opConfObj = OperationConf()
493 521 opConfObj.setup(id, name=name, priority=priority, type=optype)
494 522
495 523 self.opConfObjList.append(opConfObj)
496 524
497 525 return opConfObj
498 526
499 527 def makeXml(self, procUnitElement):
500 528
501 529 upElement = SubElement(procUnitElement, self.ELEMENTNAME)
502 530 upElement.set('id', str(self.id))
503 531 upElement.set('name', self.name)
504 532 upElement.set('datatype', self.datatype)
505 533 upElement.set('inputId', str(self.inputId))
506 534
507 535 for opConfObj in self.opConfObjList:
508 536 opConfObj.makeXml(upElement)
509 537
510 538 def readXml(self, upElement):
511 539
512 540 self.id = upElement.get('id')
513 541 self.name = upElement.get('name')
514 542 self.datatype = upElement.get('datatype')
515 543 self.inputId = upElement.get('inputId')
516 544
517 545 if self.ELEMENTNAME == "ReadUnit":
518 546 self.datatype = self.datatype.replace("Reader", "")
519 547
520 548 if self.ELEMENTNAME == "ProcUnit":
521 549 self.datatype = self.datatype.replace("Proc", "")
522 550
523 551 if self.inputId == 'None':
524 552 self.inputId = '0'
525 553
526 554 self.opConfObjList = []
527 555
528 556 opElementList = upElement.getiterator(OperationConf().getElementName())
529 557
530 558 for opElement in opElementList:
531 559 opConfObj = OperationConf()
532 560 opConfObj.readXml(opElement)
533 561 self.opConfObjList.append(opConfObj)
534 562
535 563 def printattr(self):
536 564
537 565 print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME,
538 566 self.id,
539 567 self.name,
540 568 self.datatype,
541 569 self.inputId)
542 570
543 571 for opConfObj in self.opConfObjList:
544 572 opConfObj.printattr()
545 573
546 574 def createObjects(self):
547 575
548 576 className = eval(self.name)
549 577 procUnitObj = className()
550 578
551 579 for opConfObj in self.opConfObjList:
552 580
553 581 if opConfObj.type == 'self':
554 582 continue
555 583
556 584 opObj = opConfObj.createObject()
557 585
558 586 self.opObjDict[opConfObj.id] = opObj
559 587 procUnitObj.addOperation(opObj, opConfObj.id)
560 588
561 589 self.procUnitObj = procUnitObj
562 590
563 591 return procUnitObj
564 592
565 593 def run(self):
566 594
567 595 finalSts = False
568 596
569 597 for opConfObj in self.opConfObjList:
570 598
571 599 kwargs = {}
572 600 for parmConfObj in opConfObj.getParameterObjList():
573 601 if opConfObj.name == 'run' and parmConfObj.name == 'datatype':
574 602 continue
575 603
576 604 kwargs[parmConfObj.name] = parmConfObj.getValue()
577 605
578 606 #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id)
579 607 sts = self.procUnitObj.call(opType = opConfObj.type,
580 608 opName = opConfObj.name,
581 609 opId = opConfObj.id,
582 610 **kwargs)
583 611 finalSts = finalSts or sts
584 612
585 613 return finalSts
586 614
587 615 def close(self):
588 616
589 617 for opConfObj in self.opConfObjList:
590 618 if opConfObj.type == 'self':
591 619 continue
592 620
593 621 opObj = self.procUnitObj.getOperationObj(opConfObj.id)
594 622 opObj.close()
595 623
596 624 self.procUnitObj.close()
597 625
598 626 return
599 627
600 628 class ReadUnitConf(ProcUnitConf):
601 629
602 630 path = None
603 631 startDate = None
604 632 endDate = None
605 633 startTime = None
606 634 endTime = None
607 635
608 636 ELEMENTNAME = 'ReadUnit'
609 637
610 638 def __init__(self):
611 639
612 640 self.id = None
613 641 self.datatype = None
614 642 self.name = None
615 643 self.inputId = None
616 644
617 645 self.parentId = None
618 646
619 647 self.opConfObjList = []
620 648 self.opObjList = []
621 649
622 650 def getElementName(self):
623 651
624 652 return self.ELEMENTNAME
625 653
626 654 def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs):
627 655
628 656 #Compatible with old signal chain version
629 657 if datatype==None and name==None:
630 658 raise ValueError, "datatype or name should be defined"
631 659
632 660 if name==None:
633 661 if 'Reader' in datatype:
634 662 name = datatype
635 663 else:
636 664 name = '%sReader' %(datatype)
637 665
638 666 if datatype==None:
639 667 datatype = name.replace('Reader','')
640 668
641 669 self.id = id
642 670 self.name = name
643 671 self.datatype = datatype
644 672
645 673 self.path = path
646 674 self.startDate = startDate
647 675 self.endDate = endDate
648 676 self.startTime = startTime
649 677 self.endTime = endTime
650 678
651 679 self.inputId = '0'
652 680 self.parentId = parentId
653 681
654 682 self.addRunOperation(**kwargs)
655 683
656 684 def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs):
657 685
658 686 #Compatible with old signal chain version
659 687 if datatype==None and name==None:
660 688 raise ValueError, "datatype or name should be defined"
661 689
662 690 if name==None:
663 691 if 'Reader' in datatype:
664 692 name = datatype
665 693 else:
666 694 name = '%sReader' %(datatype)
667 695
668 696 if datatype==None:
669 697 datatype = name.replace('Reader','')
670 698
671 699 self.datatype = datatype
672 700 self.name = name
673 701 self.path = path
674 702 self.startDate = startDate
675 703 self.endDate = endDate
676 704 self.startTime = startTime
677 705 self.endTime = endTime
678 706
679 707 self.inputId = '0'
680 708 self.parentId = parentId
681 709
682 710 self.updateRunOperation(**kwargs)
683 711
684 712 def addRunOperation(self, **kwargs):
685 713
686 714 opObj = self.addOperation(name = 'run', optype = 'self')
687 715
688 716 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
689 717 opObj.addParameter(name='path' , value=self.path, format='str')
690 718 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
691 719 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
692 720 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
693 721 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
694 722
695 723 for key, value in kwargs.items():
696 724 opObj.addParameter(name=key, value=value, format=type(value).__name__)
697 725
698 726 return opObj
699 727
700 728 def updateRunOperation(self, **kwargs):
701 729
702 730 opObj = self.getOperationObj(name = 'run')
703 731 opObj.removeParameters()
704 732
705 733 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
706 734 opObj.addParameter(name='path' , value=self.path, format='str')
707 735 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
708 736 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
709 737 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
710 738 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
711 739
712 740 for key, value in kwargs.items():
713 741 opObj.addParameter(name=key, value=value, format=type(value).__name__)
714 742
715 743 return opObj
716 744
717 745 class Project():
718 746
719 747 id = None
720 748 name = None
721 749 description = None
722 750 # readUnitConfObjList = None
723 751 procUnitConfObjDict = None
724 752
725 753 ELEMENTNAME = 'Project'
726 754
727 755 def __init__(self, control=None, dataq=None):
728 756
729 757 self.id = None
730 758 self.name = None
731 759 self.description = None
732 760
733 761 self.procUnitConfObjDict = {}
734 762
735 763 #global data_q
736 764 #data_q = dataq
737 765
738 766 if control==None:
739 767 control = {'stop':False,'pause':False}
740 768
741 769 self.control = control
742 770
743 771 def __getNewId(self):
744 772
745 773 id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1
746 774
747 775 return str(id)
748 776
749 777 def getElementName(self):
750 778
751 779 return self.ELEMENTNAME
752 780
753 781 def getId(self):
754 782
755 783 return self.id
756 784
757 785 def updateId(self, new_id):
758 786
759 787 self.id = str(new_id)
760 788
761 789 keyList = self.procUnitConfObjDict.keys()
762 790 keyList.sort()
763 791
764 792 n = 1
765 793 newProcUnitConfObjDict = {}
766 794
767 795 for procKey in keyList:
768 796
769 797 procUnitConfObj = self.procUnitConfObjDict[procKey]
770 798 idProcUnit = str(int(self.id)*10 + n)
771 799 procUnitConfObj.updateId(idProcUnit, parentId = self.id)
772 800
773 801 newProcUnitConfObjDict[idProcUnit] = procUnitConfObj
774 802 n += 1
775 803
776 804 self.procUnitConfObjDict = newProcUnitConfObjDict
777 805
778 806 def setup(self, id, name, description):
779 807
780 808 self.id = str(id)
781 809 self.name = name
782 810 self.description = description
783 811
784 812 def update(self, name, description):
785 813
786 814 self.name = name
787 815 self.description = description
788 816
789 817 def addReadUnit(self, datatype=None, name=None, **kwargs):
790 818
791 819 idReadUnit = self.__getNewId()
792 820
793 821 readUnitConfObj = ReadUnitConf()
794 822 readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs)
795 823
796 824 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
797 825
798 826 return readUnitConfObj
799 827
800 828 def addProcUnit(self, inputId='0', datatype=None, name=None):
801 829
802 830 idProcUnit = self.__getNewId()
803 831
804 832 procUnitConfObj = ProcUnitConf()
805 833 procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id)
806 834
807 835 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
808 836
809 837 return procUnitConfObj
810 838
811 839 def removeProcUnit(self, id):
812 840
813 841 if id in self.procUnitConfObjDict.keys():
814 842 self.procUnitConfObjDict.pop(id)
815 843
816 844 def getReadUnitId(self):
817 845
818 846 readUnitConfObj = self.getReadUnitObj()
819 847
820 848 return readUnitConfObj.id
821 849
822 850 def getReadUnitObj(self):
823 851
824 852 for obj in self.procUnitConfObjDict.values():
825 853 if obj.getElementName() == "ReadUnit":
826 854 return obj
827 855
828 856 return None
829 857
830 858 def getProcUnitObj(self, id):
831 859
832 860 return self.procUnitConfObjDict[id]
833 861
834 862 def getProcUnitObjByName(self, name):
835 863
836 864 for obj in self.procUnitConfObjDict.values():
837 865 if obj.name == name:
838 866 return obj
839 867
840 868 return None
841 869
842 870 def makeXml(self):
843 871
844 872 projectElement = Element('Project')
845 873 projectElement.set('id', str(self.id))
846 874 projectElement.set('name', self.name)
847 875 projectElement.set('description', self.description)
848 876
849 877 # for readUnitConfObj in self.readUnitConfObjList:
850 878 # readUnitConfObj.makeXml(projectElement)
851 879
852 880 for procUnitConfObj in self.procUnitConfObjDict.values():
853 881 procUnitConfObj.makeXml(projectElement)
854 882
855 883 self.projectElement = projectElement
856 884
857 885 def writeXml(self, filename):
858 886
859 887 self.makeXml()
860 888
861 889 #print prettify(self.projectElement)
862 890
863 891 ElementTree(self.projectElement).write(filename, method='xml')
864 892
865 893 def readXml(self, filename):
866 894
867 895 #tree = ET.parse(filename)
868 896 self.projectElement = None
869 897 # self.readUnitConfObjList = []
870 898 self.procUnitConfObjDict = {}
871 899
872 900 self.projectElement = ElementTree().parse(filename)
873 901
874 902 self.project = self.projectElement.tag
875 903
876 904 self.id = self.projectElement.get('id')
877 905 self.name = self.projectElement.get('name')
878 906 self.description = self.projectElement.get('description')
879 907
880 908 readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName())
881 909
882 910 for readUnitElement in readUnitElementList:
883 911 readUnitConfObj = ReadUnitConf()
884 912 readUnitConfObj.readXml(readUnitElement)
885 913
886 914 if readUnitConfObj.parentId == None:
887 915 readUnitConfObj.parentId = self.id
888 916
889 917 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
890 918
891 919 procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName())
892 920
893 921 for procUnitElement in procUnitElementList:
894 922 procUnitConfObj = ProcUnitConf()
895 923 procUnitConfObj.readXml(procUnitElement)
896 924
897 925 if procUnitConfObj.parentId == None:
898 926 procUnitConfObj.parentId = self.id
899 927
900 928 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
901 929
902 930 def printattr(self):
903 931
904 932 print "Project[%s]: name = %s, description = %s" %(self.id,
905 933 self.name,
906 934 self.description)
907 935
908 936 # for readUnitConfObj in self.readUnitConfObjList:
909 937 # readUnitConfObj.printattr()
910 938
911 939 for procUnitConfObj in self.procUnitConfObjDict.values():
912 940 procUnitConfObj.printattr()
913 941
914 942 def createObjects(self):
915 943
916 944 # for readUnitConfObj in self.readUnitConfObjList:
917 945 # readUnitConfObj.createObjects()
918 946
919 947 for procUnitConfObj in self.procUnitConfObjDict.values():
920 948 procUnitConfObj.createObjects()
921 949
922 950 def __connect(self, objIN, thisObj):
923 951
924 952 thisObj.setInput(objIN.getOutputObj())
925 953
926 954 def connectObjects(self):
927 955
928 956 for thisPUConfObj in self.procUnitConfObjDict.values():
929 957
930 958 inputId = thisPUConfObj.getInputId()
931 959
932 960 if int(inputId) == 0:
933 961 continue
934 962
935 963 #Get input object
936 964 puConfINObj = self.procUnitConfObjDict[inputId]
937 965 puObjIN = puConfINObj.getProcUnitObj()
938 966
939 967 #Get current object
940 968 thisPUObj = thisPUConfObj.getProcUnitObj()
941 969
942 970 self.__connect(puObjIN, thisPUObj)
943 971
944 972 def run(self):
945 973
946 974 # for readUnitConfObj in self.readUnitConfObjList:
947 975 # readUnitConfObj.run()
948 976 print
949 977 print "*"*40
950 978 print " Starting SIGNAL CHAIN PROCESSING "
951 979 print "*"*40
952 980 print
953 981
954 982 keyList = self.procUnitConfObjDict.keys()
955 983 keyList.sort()
956 984
957 985 while(True):
958 986
959 987 finalSts = False
960 988
961 989 for procKey in keyList:
962 990 # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id)
963 991
964 992 procUnitConfObj = self.procUnitConfObjDict[procKey]
965 993 sts = procUnitConfObj.run()
966 994 finalSts = finalSts or sts
967 995
968 996 #If every process unit finished so end process
969 997 if not(finalSts):
970 998 print "Every process unit have finished"
971 999 break
972 1000
973 1001 if self.control['pause']:
974 1002 print "Process suspended"
975 1003
976 1004 while True:
977 1005 sleep(0.1)
978 1006
979 1007 if not self.control['pause']:
980 1008 break
981 1009
982 1010 if self.control['stop']:
983 1011 break
984 1012 print "Process reinitialized"
985 1013
986 1014 if self.control['stop']:
987 1015 print "Process stopped"
988 1016 break
989 1017
990 1018 #Closing every process
991 1019 for procKey in keyList:
992 1020 procUnitConfObj = self.procUnitConfObjDict[procKey]
993 1021 procUnitConfObj.close()
994 1022
995 1023 print "Process finished"
996 1024
997 1025 def start(self, filename):
998 1026
999 1027 self.writeXml(filename)
1000 1028 self.readXml(filename)
1001 1029
1002 1030 self.createObjects()
1003 1031 self.connectObjects()
1004 1032 self.run()
1005 1033
1006 1034 class ControllerThread(threading.Thread, Project):
1007 1035
1008 1036 def __init__(self, filename):
1009 1037
1010 1038 threading.Thread.__init__(self)
1011 1039 Project.__init__(self)
1012 1040
1013 1041 self.setDaemon(True)
1014 1042
1015 1043 self.filename = filename
1016 1044 self.control = {'stop':False, 'pause':False}
1017 1045
1018 1046 def stop(self):
1019 1047 self.control['stop'] = True
1020 1048
1021 1049 def pause(self):
1022 1050 self.control['pause'] = not(self.control['pause'])
1023 1051
1024 1052 def run(self):
1025 1053 self.control['stop'] = False
1026 1054 self.control['pause'] = False
1027 1055
1028 1056 self.readXml(self.filename)
1029 1057 self.createObjects()
1030 1058 self.connectObjects()
1031 1059 Project.run(self)
1032 1060
1033 1061 if __name__ == '__main__':
1034 1062
1035 1063 desc = "Segundo Test"
1036 1064 filename = "schain.xml"
1037 1065
1038 1066 controllerObj = Project()
1039 1067
1040 1068 controllerObj.setup(id = '191', name='test01', description=desc)
1041 1069
1042 1070 readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage',
1043 1071 path='data/rawdata/',
1044 1072 startDate='2011/01/01',
1045 1073 endDate='2012/12/31',
1046 1074 startTime='00:00:00',
1047 1075 endTime='23:59:59',
1048 1076 online=1,
1049 1077 walk=1)
1050 1078
1051 1079 # opObj00 = readUnitConfObj.addOperation(name='printInfo')
1052 1080
1053 1081 procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
1054 1082
1055 1083 opObj10 = procUnitConfObj0.addOperation(name='selectChannels')
1056 1084 opObj10.addParameter(name='channelList', value='3,4,5', format='intlist')
1057 1085
1058 1086 opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
1059 1087 opObj10.addParameter(name='minHei', value='90', format='float')
1060 1088 opObj10.addParameter(name='maxHei', value='180', format='float')
1061 1089
1062 1090 opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
1063 1091 opObj12.addParameter(name='n', value='10', format='int')
1064 1092
1065 1093 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId())
1066 1094 procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int')
1067 1095 # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='')
1068 1096
1069 1097
1070 1098 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
1071 1099 opObj11.addParameter(name='idfigure', value='1', format='int')
1072 1100 opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str')
1073 1101 opObj11.addParameter(name='zmin', value='40', format='int')
1074 1102 opObj11.addParameter(name='zmax', value='90', format='int')
1075 1103 opObj11.addParameter(name='showprofile', value='1', format='int')
1076 1104
1077 1105 # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='external')
1078 1106 # opObj11.addParameter(name='idfigure', value='2', format='int')
1079 1107 # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str')
1080 1108 # opObj11.addParameter(name='zmin', value='40', format='int')
1081 1109 # opObj11.addParameter(name='zmax', value='90', format='int')
1082 1110
1083 1111
1084 1112 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Voltage', inputId=procUnitConfObj0.getId())
1085 1113 #
1086 1114 # opObj12 = procUnitConfObj2.addOperation(name='CohInt', optype='external')
1087 1115 # opObj12.addParameter(name='n', value='2', format='int')
1088 1116 # opObj12.addParameter(name='overlapping', value='1', format='int')
1089 1117 #
1090 1118 # procUnitConfObj3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj2.getId())
1091 1119 # procUnitConfObj3.addParameter(name='nFFTPoints', value='32', format='int')
1092 1120 #
1093 1121 # opObj11 = procUnitConfObj3.addOperation(name='SpectraPlot', optype='external')
1094 1122 # opObj11.addParameter(name='idfigure', value='2', format='int')
1095 1123 # opObj11.addParameter(name='wintitle', value='SpectraPlot1', format='str')
1096 1124 # opObj11.addParameter(name='zmin', value='40', format='int')
1097 1125 # opObj11.addParameter(name='zmax', value='90', format='int')
1098 1126 # opObj11.addParameter(name='showprofile', value='1', format='int')
1099 1127
1100 1128 # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='external')
1101 1129 # opObj11.addParameter(name='idfigure', value='10', format='int')
1102 1130 # opObj11.addParameter(name='wintitle', value='RTI', format='str')
1103 1131 ## opObj11.addParameter(name='xmin', value='21', format='float')
1104 1132 ## opObj11.addParameter(name='xmax', value='22', format='float')
1105 1133 # opObj11.addParameter(name='zmin', value='40', format='int')
1106 1134 # opObj11.addParameter(name='zmax', value='90', format='int')
1107 1135 # opObj11.addParameter(name='showprofile', value='1', format='int')
1108 1136 # opObj11.addParameter(name='timerange', value=str(60), format='int')
1109 1137
1110 1138 # opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
1111 1139 # opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist')
1112 1140 #
1113 1141 # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external')
1114 1142 # opObj12.addParameter(name='n', value='2', format='int')
1115 1143 #
1116 1144 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
1117 1145 # opObj11.addParameter(name='idfigure', value='2', format='int')
1118 1146 # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str')
1119 1147 # opObj11.addParameter(name='zmin', value='70', format='int')
1120 1148 # opObj11.addParameter(name='zmax', value='90', format='int')
1121 1149 #
1122 1150 # opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
1123 1151 # opObj10.addParameter(name='channelList', value='2,6', format='intlist')
1124 1152 #
1125 1153 # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external')
1126 1154 # opObj12.addParameter(name='n', value='2', format='int')
1127 1155 #
1128 1156 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
1129 1157 # opObj11.addParameter(name='idfigure', value='3', format='int')
1130 1158 # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str')
1131 1159 # opObj11.addParameter(name='zmin', value='70', format='int')
1132 1160 # opObj11.addParameter(name='zmax', value='90', format='int')
1133 1161
1134 1162
1135 1163 # opObj12 = procUnitConfObj1.addOperation(name='decoder')
1136 1164 # opObj12.addParameter(name='ncode', value='2', format='int')
1137 1165 # opObj12.addParameter(name='nbauds', value='8', format='int')
1138 1166 # opObj12.addParameter(name='code0', value='001110011', format='int')
1139 1167 # opObj12.addParameter(name='code1', value='001110011', format='int')
1140 1168
1141 1169
1142 1170
1143 1171 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId())
1144 1172 #
1145 1173 # opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='external')
1146 1174 # opObj21.addParameter(name='n', value='2', format='int')
1147 1175 #
1148 1176 # opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='external')
1149 1177 # opObj11.addParameter(name='idfigure', value='4', format='int')
1150 1178 # opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str')
1151 1179 # opObj11.addParameter(name='zmin', value='70', format='int')
1152 1180 # opObj11.addParameter(name='zmax', value='90', format='int')
1153 1181
1154 1182 print "Escribiendo el archivo XML"
1155 1183
1156 1184 controllerObj.writeXml(filename)
1157 1185
1158 1186 print "Leyendo el archivo XML"
1159 1187 controllerObj.readXml(filename)
1160 1188 #controllerObj.printattr()
1161 1189
1162 1190 controllerObj.createObjects()
1163 1191 controllerObj.connectObjects()
1164 1192 controllerObj.run()
1165 1193
1166 1194 No newline at end of file
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,415 +1,451
1 1 from PyQt4 import QtCore, QtGui
2 2
3 3 try:
4 4 _fromUtf8 = QtCore.QString.fromUtf8
5 5 except AttributeError:
6 6 def _fromUtf8(s):
7 7 return s
8 8
9 9 try:
10 10 _encoding = QtGui.QApplication.UnicodeUTF8
11 11 def _translate(context, text, disambig):
12 12 return QtGui.QApplication.translate(context, text, disambig, _encoding)
13 13 except AttributeError:
14 14 def _translate(context, text, disambig):
15 15 return QtGui.QApplication.translate(context, text, disambig)
16 16
17 17 class Ui_SpectraTab(object):
18 18
19 19 def setupUi(self):
20 20
21 21 self.tabSpectra = QtGui.QWidget()
22 22 self.tabSpectra.setObjectName(_fromUtf8("tabSpectra"))
23 23 self.gridLayout_7 = QtGui.QGridLayout(self.tabSpectra)
24 24 self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7"))
25 25 self.frame_5 = QtGui.QFrame(self.tabSpectra)
26 26 self.frame_5.setFrameShape(QtGui.QFrame.StyledPanel)
27 27 self.frame_5.setFrameShadow(QtGui.QFrame.Raised)
28 28 self.frame_5.setObjectName(_fromUtf8("frame_5"))
29 29 self.gridLayout_18 = QtGui.QGridLayout(self.frame_5)
30 30 self.gridLayout_18.setObjectName(_fromUtf8("gridLayout_18"))
31 31 self.specOpOk = QtGui.QPushButton(self.frame_5)
32 32 self.specOpOk.setObjectName(_fromUtf8("specOpOk"))
33 33 self.gridLayout_18.addWidget(self.specOpOk, 0, 0, 1, 1)
34 34 self.specGraphClear = QtGui.QPushButton(self.frame_5)
35 35 self.specGraphClear.setObjectName(_fromUtf8("specGraphClear"))
36 36 self.gridLayout_18.addWidget(self.specGraphClear, 0, 1, 1, 1)
37 37 self.gridLayout_7.addWidget(self.frame_5, 1, 1, 1, 1)
38 38 self.tabWidgetSpectra = QtGui.QTabWidget(self.tabSpectra)
39 39 self.tabWidgetSpectra.setObjectName(_fromUtf8("tabWidgetSpectra"))
40 40 self.tabopSpectra = QtGui.QWidget()
41 41 self.tabopSpectra.setObjectName(_fromUtf8("tabopSpectra"))
42 42 self.gridLayout_5 = QtGui.QGridLayout(self.tabopSpectra)
43 43 self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5"))
44 44 self.specOpCebCrossSpectra = QtGui.QCheckBox(self.tabopSpectra)
45 45 self.specOpCebCrossSpectra.setObjectName(_fromUtf8("specOpCebCrossSpectra"))
46 46 self.gridLayout_5.addWidget(self.specOpCebCrossSpectra, 4, 0, 1, 2)
47 47 self.specOpComChannel = QtGui.QComboBox(self.tabopSpectra)
48 48 self.specOpComChannel.setObjectName(_fromUtf8("specOpComChannel"))
49 49 self.specOpComChannel.addItem(_fromUtf8(""))
50 50 self.specOpComChannel.addItem(_fromUtf8(""))
51 51 self.gridLayout_5.addWidget(self.specOpComChannel, 8, 0, 1, 2)
52 52 self.specOpChannel = QtGui.QLineEdit(self.tabopSpectra)
53 53 self.specOpChannel.setObjectName(_fromUtf8("specOpChannel"))
54 54 self.gridLayout_5.addWidget(self.specOpChannel, 8, 3, 1, 2)
55 55 self.specOpComHeights = QtGui.QComboBox(self.tabopSpectra)
56 56 self.specOpComHeights.setObjectName(_fromUtf8("specOpComHeights"))
57 57 self.specOpComHeights.addItem(_fromUtf8(""))
58 58 self.specOpComHeights.addItem(_fromUtf8(""))
59 59 self.gridLayout_5.addWidget(self.specOpComHeights, 11, 0, 1, 2)
60 60 self.specOpHeights = QtGui.QLineEdit(self.tabopSpectra)
61 61 self.specOpHeights.setObjectName(_fromUtf8("specOpHeights"))
62 62 self.gridLayout_5.addWidget(self.specOpHeights, 11, 3, 1, 2)
63 63 self.specOpIncoherent = QtGui.QLineEdit(self.tabopSpectra)
64 64 self.specOpIncoherent.setObjectName(_fromUtf8("specOpIncoherent"))
65 65 self.gridLayout_5.addWidget(self.specOpIncoherent, 13, 3, 1, 2)
66 66 self.specOpCebRemoveDC = QtGui.QCheckBox(self.tabopSpectra)
67 67 self.specOpCebRemoveDC.setObjectName(_fromUtf8("specOpCebRemoveDC"))
68 68 self.gridLayout_5.addWidget(self.specOpCebRemoveDC, 14, 0, 1, 2)
69 69 self.specOpCebHeights = QtGui.QCheckBox(self.tabopSpectra)
70 70 self.specOpCebHeights.setObjectName(_fromUtf8("specOpCebHeights"))
71 71 self.gridLayout_5.addWidget(self.specOpCebHeights, 9, 0, 1, 1)
72 72 self.specOpCebChannel = QtGui.QCheckBox(self.tabopSpectra)
73 73 self.specOpCebChannel.setObjectName(_fromUtf8("specOpCebChannel"))
74 74 self.gridLayout_5.addWidget(self.specOpCebChannel, 7, 0, 1, 1)
75 75 self.specOppairsList = QtGui.QLineEdit(self.tabopSpectra)
76 76 self.specOppairsList.setObjectName(_fromUtf8("specOppairsList"))
77 77 self.gridLayout_5.addWidget(self.specOppairsList, 6, 3, 1, 2)
78 78 self.specOpnFFTpoints = QtGui.QLineEdit(self.tabopSpectra)
79 79 self.specOpnFFTpoints.setObjectName(_fromUtf8("specOpnFFTpoints"))
80 80 self.gridLayout_5.addWidget(self.specOpnFFTpoints, 2, 3, 1, 2)
81 81 self.label_31 = QtGui.QLabel(self.tabopSpectra)
82 82 self.label_31.setObjectName(_fromUtf8("label_31"))
83 83 self.gridLayout_5.addWidget(self.label_31, 6, 0, 1, 2)
84 84 self.label_26 = QtGui.QLabel(self.tabopSpectra)
85 85 self.label_26.setObjectName(_fromUtf8("label_26"))
86 86 self.gridLayout_5.addWidget(self.label_26, 2, 0, 1, 2)
87 87 self.specOpCebIncoherent = QtGui.QCheckBox(self.tabopSpectra)
88 88 self.specOpCebIncoherent.setObjectName(_fromUtf8("specOpCebIncoherent"))
89 89 self.gridLayout_5.addWidget(self.specOpCebIncoherent, 12, 0, 1, 1)
90 90 self.specOpCobIncInt = QtGui.QComboBox(self.tabopSpectra)
91 91 self.specOpCobIncInt.setObjectName(_fromUtf8("specOpCobIncInt"))
92 92 self.specOpCobIncInt.addItem(_fromUtf8(""))
93 93 self.specOpCobIncInt.addItem(_fromUtf8(""))
94 94 self.gridLayout_5.addWidget(self.specOpCobIncInt, 13, 0, 1, 2)
95 95 spacerItem9 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
96 96 self.gridLayout_5.addItem(spacerItem9, 12, 3, 1, 1)
97 97 self.specOpCebRadarfrequency = QtGui.QCheckBox(self.tabopSpectra)
98 98 self.specOpCebRadarfrequency.setObjectName(_fromUtf8("specOpCebRadarfrequency"))
99 99 self.gridLayout_5.addWidget(self.specOpCebRadarfrequency, 0, 0, 1, 2)
100 100 spacerItem10 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
101 101 self.gridLayout_5.addItem(spacerItem10, 9, 3, 1, 1)
102 102 spacerItem11 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
103 103 self.gridLayout_5.addItem(spacerItem11, 7, 3, 1, 1)
104 104 self.specOpRadarfrequency = QtGui.QLineEdit(self.tabopSpectra)
105 105 self.specOpRadarfrequency.setObjectName(_fromUtf8("specOpRadarfrequency"))
106 106 self.gridLayout_5.addWidget(self.specOpRadarfrequency, 0, 3, 1, 2)
107 107 spacerItem12 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
108 108 self.gridLayout_5.addItem(spacerItem12, 4, 3, 1, 1)
109 109 self.label_21 = QtGui.QLabel(self.tabopSpectra)
110 110 self.label_21.setObjectName(_fromUtf8("label_21"))
111 111 self.gridLayout_5.addWidget(self.label_21, 1, 0, 1, 1)
112 112 self.specOpProfiles = QtGui.QLineEdit(self.tabopSpectra)
113 113 self.specOpProfiles.setObjectName(_fromUtf8("specOpProfiles"))
114 114 self.gridLayout_5.addWidget(self.specOpProfiles, 1, 3, 1, 2)
115 115 self.specOpCebRemoveInt = QtGui.QCheckBox(self.tabopSpectra)
116 116 self.specOpCebRemoveInt.setObjectName(_fromUtf8("specOpCebRemoveInt"))
117 117 self.gridLayout_5.addWidget(self.specOpCebRemoveInt, 15, 0, 1, 1)
118 118 spacerItem13 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
119 119 self.gridLayout_5.addItem(spacerItem13, 15, 3, 1, 1)
120 120 self.label_70 = QtGui.QLabel(self.tabopSpectra)
121 121 self.label_70.setObjectName(_fromUtf8("label_70"))
122 122 self.gridLayout_5.addWidget(self.label_70, 3, 0, 1, 1)
123 123 self.specOpCebgetNoise = QtGui.QCheckBox(self.tabopSpectra)
124 124 self.specOpCebgetNoise.setObjectName(_fromUtf8("specOpCebgetNoise"))
125 125 self.gridLayout_5.addWidget(self.specOpCebgetNoise, 16, 0, 1, 1)
126 126 self.specOpippFactor = QtGui.QLineEdit(self.tabopSpectra)
127 127 self.specOpippFactor.setObjectName(_fromUtf8("specOpippFactor"))
128 128 self.gridLayout_5.addWidget(self.specOpippFactor, 3, 3, 1, 2)
129 129 self.specOpComRemoveDC = QtGui.QComboBox(self.tabopSpectra)
130 130 self.specOpComRemoveDC.setObjectName(_fromUtf8("specOpComRemoveDC"))
131 131 self.specOpComRemoveDC.addItem(_fromUtf8(""))
132 132 self.specOpComRemoveDC.addItem(_fromUtf8(""))
133 133 self.gridLayout_5.addWidget(self.specOpComRemoveDC, 14, 3, 1, 2)
134 134 self.specOpgetNoise = QtGui.QLineEdit(self.tabopSpectra)
135 135 self.specOpgetNoise.setObjectName(_fromUtf8("specOpgetNoise"))
136 136 self.gridLayout_5.addWidget(self.specOpgetNoise, 16, 3, 1, 2)
137 137 self.tabWidgetSpectra.addTab(self.tabopSpectra, _fromUtf8(""))
138
139
138 140 self.tabgraphSpectra = QtGui.QWidget()
139 141 self.tabgraphSpectra.setObjectName(_fromUtf8("tabgraphSpectra"))
140 142 self.gridLayout_9 = QtGui.QGridLayout(self.tabgraphSpectra)
141 143 self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9"))
142 self.label_44 = QtGui.QLabel(self.tabgraphSpectra)
143 self.label_44.setObjectName(_fromUtf8("label_44"))
144 self.gridLayout_9.addWidget(self.label_44, 10, 0, 1, 1)
144
145 145 spacerItem14 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
146 146 self.gridLayout_9.addItem(spacerItem14, 14, 2, 1, 1)
147 self.label_20 = QtGui.QLabel(self.tabgraphSpectra)
148 self.label_20.setObjectName(_fromUtf8("label_20"))
149 self.gridLayout_9.addWidget(self.label_20, 21, 0, 1, 1)
150 self.specGraphSaveRTInoise = QtGui.QCheckBox(self.tabgraphSpectra)
151 self.specGraphSaveRTInoise.setText(_fromUtf8(""))
152 self.specGraphSaveRTInoise.setObjectName(_fromUtf8("specGraphSaveRTInoise"))
153 self.gridLayout_9.addWidget(self.specGraphSaveRTInoise, 13, 4, 1, 1)
154 self.specGgraphmagnitud = QtGui.QLineEdit(self.tabgraphSpectra)
155 self.specGgraphmagnitud.setObjectName(_fromUtf8("specGgraphmagnitud"))
156 self.gridLayout_9.addWidget(self.specGgraphmagnitud, 20, 1, 1, 7)
157 self.specGraphSaveSpectra = QtGui.QCheckBox(self.tabgraphSpectra)
158 self.specGraphSaveSpectra.setText(_fromUtf8(""))
159 self.specGraphSaveSpectra.setObjectName(_fromUtf8("specGraphSaveSpectra"))
160 self.gridLayout_9.addWidget(self.specGraphSaveSpectra, 6, 4, 1, 1)
161 self.specGgraphChannelList = QtGui.QLineEdit(self.tabgraphSpectra)
162 self.specGgraphChannelList.setObjectName(_fromUtf8("specGgraphChannelList"))
163 self.gridLayout_9.addWidget(self.specGgraphChannelList, 15, 1, 1, 7)
164 self.label_25 = QtGui.QLabel(self.tabgraphSpectra)
165 self.label_25.setObjectName(_fromUtf8("label_25"))
166 self.gridLayout_9.addWidget(self.label_25, 2, 0, 1, 1)
167 self.specGgraphTminTmax = QtGui.QLineEdit(self.tabgraphSpectra)
168 self.specGgraphTminTmax.setObjectName(_fromUtf8("specGgraphTminTmax"))
169 self.gridLayout_9.addWidget(self.specGgraphTminTmax, 21, 1, 1, 7)
170 spacerItem15 = QtGui.QSpacerItem(28, 15, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
171 self.gridLayout_9.addItem(spacerItem15, 27, 6, 1, 2)
172 spacerItem16 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
173 self.gridLayout_9.addItem(spacerItem16, 3, 5, 1, 1)
174 self.label_42 = QtGui.QLabel(self.tabgraphSpectra)
175 self.label_42.setObjectName(_fromUtf8("label_42"))
176 self.gridLayout_9.addWidget(self.label_42, 9, 0, 1, 1)
177 self.label_16 = QtGui.QLabel(self.tabgraphSpectra)
178 self.label_16.setObjectName(_fromUtf8("label_16"))
179 self.gridLayout_9.addWidget(self.label_16, 18, 0, 1, 1)
180 self.label_17 = QtGui.QLabel(self.tabgraphSpectra)
181 self.label_17.setObjectName(_fromUtf8("label_17"))
182 self.gridLayout_9.addWidget(self.label_17, 19, 0, 1, 1)
183 self.label_18 = QtGui.QLabel(self.tabgraphSpectra)
184 self.label_18.setObjectName(_fromUtf8("label_18"))
185 self.gridLayout_9.addWidget(self.label_18, 20, 0, 1, 1)
186 self.specGgraphFreq = QtGui.QLineEdit(self.tabgraphSpectra)
187 self.specGgraphFreq.setObjectName(_fromUtf8("specGgraphFreq"))
188 self.gridLayout_9.addWidget(self.specGgraphFreq, 16, 1, 1, 7)
189 self.specGgraphHeight = QtGui.QLineEdit(self.tabgraphSpectra)
190 self.specGgraphHeight.setObjectName(_fromUtf8("specGgraphHeight"))
191 self.gridLayout_9.addWidget(self.specGgraphHeight, 18, 1, 1, 7)
192 spacerItem17 = QtGui.QSpacerItem(49, 15, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
193 self.gridLayout_9.addItem(spacerItem17, 27, 0, 1, 1)
147
194 148 self.label_24 = QtGui.QLabel(self.tabgraphSpectra)
195 149 self.label_24.setObjectName(_fromUtf8("label_24"))
196 150 self.gridLayout_9.addWidget(self.label_24, 0, 0, 1, 1)
197 self.specGraphPrefix = QtGui.QLineEdit(self.tabgraphSpectra)
198 self.specGraphPrefix.setObjectName(_fromUtf8("specGraphPrefix"))
199 self.gridLayout_9.addWidget(self.specGraphPrefix, 2, 1, 1, 7)
200 self.specGgraphDbsrange = QtGui.QLineEdit(self.tabgraphSpectra)
201 self.specGgraphDbsrange.setObjectName(_fromUtf8("specGgraphDbsrange"))
202 self.gridLayout_9.addWidget(self.specGgraphDbsrange, 19, 1, 1, 7)
203 self.label_46 = QtGui.QLabel(self.tabgraphSpectra)
204 self.label_46.setObjectName(_fromUtf8("label_46"))
205 self.gridLayout_9.addWidget(self.label_46, 11, 0, 1, 1)
206 self.label_22 = QtGui.QLabel(self.tabgraphSpectra)
207 self.label_22.setObjectName(_fromUtf8("label_22"))
208 self.gridLayout_9.addWidget(self.label_22, 16, 0, 1, 1)
151
209 152 self.specGraphPath = QtGui.QLineEdit(self.tabgraphSpectra)
210 153 self.specGraphPath.setObjectName(_fromUtf8("specGraphPath"))
211 154 self.gridLayout_9.addWidget(self.specGraphPath, 0, 1, 1, 6)
212 self.label_41 = QtGui.QLabel(self.tabgraphSpectra)
213 self.label_41.setObjectName(_fromUtf8("label_41"))
214 self.gridLayout_9.addWidget(self.label_41, 8, 0, 1, 1)
155
215 156 self.specGraphToolPath = QtGui.QToolButton(self.tabgraphSpectra)
216 157 self.specGraphToolPath.setObjectName(_fromUtf8("specGraphToolPath"))
217 158 self.gridLayout_9.addWidget(self.specGraphToolPath, 0, 7, 1, 1)
218 self.label_6 = QtGui.QLabel(self.tabgraphSpectra)
219 self.label_6.setObjectName(_fromUtf8("label_6"))
220 self.gridLayout_9.addWidget(self.label_6, 15, 0, 1, 1)
159
160 self.label_25 = QtGui.QLabel(self.tabgraphSpectra)
161 self.label_25.setObjectName(_fromUtf8("label_25"))
162 self.gridLayout_9.addWidget(self.label_25, 2, 0, 1, 1)
163 self.specGraphPrefix = QtGui.QLineEdit(self.tabgraphSpectra)
164 self.specGraphPrefix.setObjectName(_fromUtf8("specGraphPrefix"))
165 self.gridLayout_9.addWidget(self.specGraphPrefix, 2, 1, 1, 7)
166
167
221 168 self.label_40 = QtGui.QLabel(self.tabgraphSpectra)
222 169 self.label_40.setObjectName(_fromUtf8("label_40"))
223 170 self.gridLayout_9.addWidget(self.label_40, 6, 0, 1, 1)
171 self.label_41 = QtGui.QLabel(self.tabgraphSpectra)
172 self.label_41.setObjectName(_fromUtf8("label_41"))
173 self.gridLayout_9.addWidget(self.label_41, 8, 0, 1, 1)
174 self.label_42 = QtGui.QLabel(self.tabgraphSpectra)
175 self.label_42.setObjectName(_fromUtf8("label_42"))
176 self.gridLayout_9.addWidget(self.label_42, 9, 0, 1, 1)
177 self.label_44 = QtGui.QLabel(self.tabgraphSpectra)
178 self.label_44.setObjectName(_fromUtf8("label_44"))
179 self.gridLayout_9.addWidget(self.label_44, 10, 0, 1, 1)
180 self.label_46 = QtGui.QLabel(self.tabgraphSpectra)
181 self.label_46.setObjectName(_fromUtf8("label_46"))
182 self.gridLayout_9.addWidget(self.label_46, 11, 0, 1, 1)
183 self.label_45 = QtGui.QLabel(self.tabgraphSpectra)
184 self.label_45.setObjectName(_fromUtf8("label_45"))
185 self.gridLayout_9.addWidget(self.label_45, 13, 0, 1, 1)
186
187 self.label_43 = QtGui.QLabel(self.tabgraphSpectra)
188 self.label_43.setObjectName(_fromUtf8("label_43"))
189 self.gridLayout_9.addWidget(self.label_43, 3, 3, 2, 1)
224 190 self.specGraphCebSpectraplot = QtGui.QCheckBox(self.tabgraphSpectra)
225 191 self.specGraphCebSpectraplot.setText(_fromUtf8(""))
226 192 self.specGraphCebSpectraplot.setObjectName(_fromUtf8("specGraphCebSpectraplot"))
227 self.gridLayout_9.addWidget(self.specGraphCebSpectraplot, 6, 2, 1, 1)
193 self.gridLayout_9.addWidget(self.specGraphCebSpectraplot, 6, 3, 1, 1)
228 194 self.specGraphCebCrossSpectraplot = QtGui.QCheckBox(self.tabgraphSpectra)
229 195 self.specGraphCebCrossSpectraplot.setText(_fromUtf8(""))
230 196 self.specGraphCebCrossSpectraplot.setObjectName(_fromUtf8("specGraphCebCrossSpectraplot"))
231 self.gridLayout_9.addWidget(self.specGraphCebCrossSpectraplot, 8, 2, 1, 1)
197 self.gridLayout_9.addWidget(self.specGraphCebCrossSpectraplot, 8, 3, 1, 1)
232 198 self.specGraphCebRTIplot = QtGui.QCheckBox(self.tabgraphSpectra)
233 199 self.specGraphCebRTIplot.setText(_fromUtf8(""))
234 200 self.specGraphCebRTIplot.setObjectName(_fromUtf8("specGraphCebRTIplot"))
235 self.gridLayout_9.addWidget(self.specGraphCebRTIplot, 9, 2, 1, 1)
201 self.gridLayout_9.addWidget(self.specGraphCebRTIplot, 9, 3, 1, 1)
236 202 self.specGraphCebCoherencmap = QtGui.QCheckBox(self.tabgraphSpectra)
237 203 self.specGraphCebCoherencmap.setText(_fromUtf8(""))
238 204 self.specGraphCebCoherencmap.setObjectName(_fromUtf8("specGraphCebCoherencmap"))
239 self.gridLayout_9.addWidget(self.specGraphCebCoherencmap, 10, 2, 1, 1)
205 self.gridLayout_9.addWidget(self.specGraphCebCoherencmap, 10, 3, 1, 1)
240 206 self.specGraphPowerprofile = QtGui.QCheckBox(self.tabgraphSpectra)
241 207 self.specGraphPowerprofile.setText(_fromUtf8(""))
242 208 self.specGraphPowerprofile.setObjectName(_fromUtf8("specGraphPowerprofile"))
243 self.gridLayout_9.addWidget(self.specGraphPowerprofile, 11, 2, 1, 1)
209 self.gridLayout_9.addWidget(self.specGraphPowerprofile, 11, 3, 1, 1)
210 self.specGraphCebRTInoise = QtGui.QCheckBox(self.tabgraphSpectra)
211 self.specGraphCebRTInoise.setText(_fromUtf8(""))
212 self.specGraphCebRTInoise.setObjectName(_fromUtf8("specGraphCebRTInoise"))
213 self.gridLayout_9.addWidget(self.specGraphCebRTInoise, 13, 3, 1, 1)
214
215 # spacerItem18 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
216 # self.gridLayout_9.addItem(spacerItem18, 4, 3, 1, 1)
217
218 self.label_47 = QtGui.QLabel(self.tabgraphSpectra)
219 self.label_47.setObjectName(_fromUtf8("label_47"))
220 self.gridLayout_9.addWidget(self.label_47, 3, 5, 2, 1)
221 self.specGraphSaveSpectra = QtGui.QCheckBox(self.tabgraphSpectra)
222 self.specGraphSaveSpectra.setText(_fromUtf8(""))
223 self.specGraphSaveSpectra.setObjectName(_fromUtf8("specGraphSaveSpectra"))
224 self.gridLayout_9.addWidget(self.specGraphSaveSpectra, 6, 5, 1, 1)
244 225 self.specGraphSaveCross = QtGui.QCheckBox(self.tabgraphSpectra)
245 226 self.specGraphSaveCross.setText(_fromUtf8(""))
246 227 self.specGraphSaveCross.setObjectName(_fromUtf8("specGraphSaveCross"))
247 self.gridLayout_9.addWidget(self.specGraphSaveCross, 8, 4, 1, 1)
248 self.specGraphftpSpectra = QtGui.QCheckBox(self.tabgraphSpectra)
249 self.specGraphftpSpectra.setText(_fromUtf8(""))
250 self.specGraphftpSpectra.setObjectName(_fromUtf8("specGraphftpSpectra"))
251 self.gridLayout_9.addWidget(self.specGraphftpSpectra, 6, 6, 1, 1)
252 spacerItem18 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
253 self.gridLayout_9.addItem(spacerItem18, 4, 3, 1, 1)
254 self.specGraphSavePowerprofile = QtGui.QCheckBox(self.tabgraphSpectra)
255 self.specGraphSavePowerprofile.setText(_fromUtf8(""))
256 self.specGraphSavePowerprofile.setObjectName(_fromUtf8("specGraphSavePowerprofile"))
257 self.gridLayout_9.addWidget(self.specGraphSavePowerprofile, 11, 4, 1, 1)
228 self.gridLayout_9.addWidget(self.specGraphSaveCross, 8, 5, 1, 1)
229 self.specGraphSaveRTIplot = QtGui.QCheckBox(self.tabgraphSpectra)
230 self.specGraphSaveRTIplot.setText(_fromUtf8(""))
231 self.specGraphSaveRTIplot.setObjectName(_fromUtf8("specGraphSaveRTIplot"))
232 self.gridLayout_9.addWidget(self.specGraphSaveRTIplot, 9, 5, 1, 1)
258 233 self.specGraphSaveCoherencemap = QtGui.QCheckBox(self.tabgraphSpectra)
259 234 self.specGraphSaveCoherencemap.setText(_fromUtf8(""))
260 235 self.specGraphSaveCoherencemap.setObjectName(_fromUtf8("specGraphSaveCoherencemap"))
261 self.gridLayout_9.addWidget(self.specGraphSaveCoherencemap, 10, 4, 1, 1)
262 spacerItem19 = QtGui.QSpacerItem(39, 15, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
263 self.gridLayout_9.addItem(spacerItem19, 27, 4, 1, 1)
264 self.specGgraphftpratio = QtGui.QLineEdit(self.tabgraphSpectra)
265 self.specGgraphftpratio.setObjectName(_fromUtf8("specGgraphftpratio"))
266 self.gridLayout_9.addWidget(self.specGgraphftpratio, 23, 1, 1, 7)
267 self.label_43 = QtGui.QLabel(self.tabgraphSpectra)
268 self.label_43.setObjectName(_fromUtf8("label_43"))
269 self.gridLayout_9.addWidget(self.label_43, 3, 2, 2, 1)
236 self.gridLayout_9.addWidget(self.specGraphSaveCoherencemap, 10, 5, 1, 1)
237 self.specGraphSavePowerprofile = QtGui.QCheckBox(self.tabgraphSpectra)
238 self.specGraphSavePowerprofile.setText(_fromUtf8(""))
239 self.specGraphSavePowerprofile.setObjectName(_fromUtf8("specGraphSavePowerprofile"))
240 self.gridLayout_9.addWidget(self.specGraphSavePowerprofile, 11, 5, 1, 1)
241 self.specGraphSaveRTInoise = QtGui.QCheckBox(self.tabgraphSpectra)
242 self.specGraphSaveRTInoise.setText(_fromUtf8(""))
243 self.specGraphSaveRTInoise.setObjectName(_fromUtf8("specGraphSaveRTInoise"))
244 self.gridLayout_9.addWidget(self.specGraphSaveRTInoise, 13, 5, 1, 1)
245
246 self.label_19 = QtGui.QLabel(self.tabgraphSpectra)
247 self.label_19.setObjectName(_fromUtf8("label_19"))
248 self.gridLayout_9.addWidget(self.label_19, 3, 7, 2, 1)
249 self.specGraphftpSpectra = QtGui.QCheckBox(self.tabgraphSpectra)
250 self.specGraphftpSpectra.setText(_fromUtf8(""))
251 self.specGraphftpSpectra.setObjectName(_fromUtf8("specGraphftpSpectra"))
252 self.gridLayout_9.addWidget(self.specGraphftpSpectra, 6, 7, 1, 1)
270 253 self.specGraphftpCross = QtGui.QCheckBox(self.tabgraphSpectra)
271 254 self.specGraphftpCross.setText(_fromUtf8(""))
272 255 self.specGraphftpCross.setObjectName(_fromUtf8("specGraphftpCross"))
273 self.gridLayout_9.addWidget(self.specGraphftpCross, 8, 6, 1, 1)
274 self.label_29 = QtGui.QLabel(self.tabgraphSpectra)
275 self.label_29.setObjectName(_fromUtf8("label_29"))
276 self.gridLayout_9.addWidget(self.label_29, 23, 0, 1, 1)
277 self.label_47 = QtGui.QLabel(self.tabgraphSpectra)
278 self.label_47.setObjectName(_fromUtf8("label_47"))
279 self.gridLayout_9.addWidget(self.label_47, 3, 4, 2, 1)
256 self.gridLayout_9.addWidget(self.specGraphftpCross, 8, 7, 1, 1)
280 257 self.specGraphftpRTIplot = QtGui.QCheckBox(self.tabgraphSpectra)
281 258 self.specGraphftpRTIplot.setText(_fromUtf8(""))
282 259 self.specGraphftpRTIplot.setObjectName(_fromUtf8("specGraphftpRTIplot"))
283 self.gridLayout_9.addWidget(self.specGraphftpRTIplot, 9, 6, 1, 1)
260 self.gridLayout_9.addWidget(self.specGraphftpRTIplot, 9, 7, 1, 1)
284 261 self.specGraphftpCoherencemap = QtGui.QCheckBox(self.tabgraphSpectra)
285 262 self.specGraphftpCoherencemap.setText(_fromUtf8(""))
286 263 self.specGraphftpCoherencemap.setObjectName(_fromUtf8("specGraphftpCoherencemap"))
287 self.gridLayout_9.addWidget(self.specGraphftpCoherencemap, 10, 6, 1, 1)
264 self.gridLayout_9.addWidget(self.specGraphftpCoherencemap, 10, 7, 1, 1)
288 265 self.specGraphftpPowerprofile = QtGui.QCheckBox(self.tabgraphSpectra)
289 266 self.specGraphftpPowerprofile.setText(_fromUtf8(""))
290 267 self.specGraphftpPowerprofile.setObjectName(_fromUtf8("specGraphftpPowerprofile"))
291 self.gridLayout_9.addWidget(self.specGraphftpPowerprofile, 11, 6, 1, 1)
292 self.label_19 = QtGui.QLabel(self.tabgraphSpectra)
293 self.label_19.setObjectName(_fromUtf8("label_19"))
294 self.gridLayout_9.addWidget(self.label_19, 3, 6, 2, 2)
295 self.specGraphSaveRTIplot = QtGui.QCheckBox(self.tabgraphSpectra)
296 self.specGraphSaveRTIplot.setText(_fromUtf8(""))
297 self.specGraphSaveRTIplot.setObjectName(_fromUtf8("specGraphSaveRTIplot"))
298 self.gridLayout_9.addWidget(self.specGraphSaveRTIplot, 9, 4, 1, 1)
299 self.label_45 = QtGui.QLabel(self.tabgraphSpectra)
300 self.label_45.setObjectName(_fromUtf8("label_45"))
301 self.gridLayout_9.addWidget(self.label_45, 13, 0, 1, 1)
268 self.gridLayout_9.addWidget(self.specGraphftpPowerprofile, 11, 7, 1, 1)
302 269 self.specGraphftpRTInoise = QtGui.QCheckBox(self.tabgraphSpectra)
303 270 self.specGraphftpRTInoise.setText(_fromUtf8(""))
304 271 self.specGraphftpRTInoise.setObjectName(_fromUtf8("specGraphftpRTInoise"))
305 self.gridLayout_9.addWidget(self.specGraphftpRTInoise, 13, 6, 1, 1)
306 self.specGraphCebRTInoise = QtGui.QCheckBox(self.tabgraphSpectra)
307 self.specGraphCebRTInoise.setText(_fromUtf8(""))
308 self.specGraphCebRTInoise.setObjectName(_fromUtf8("specGraphCebRTInoise"))
309 self.gridLayout_9.addWidget(self.specGraphCebRTInoise, 13, 2, 1, 1)
272 self.gridLayout_9.addWidget(self.specGraphftpRTInoise, 13, 7, 1, 1)
273
274 spacerItem19 = QtGui.QSpacerItem(39, 15, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
275 self.gridLayout_9.addItem(spacerItem19, 27, 4, 1, 1)
276
277 self.label_22 = QtGui.QLabel(self.tabgraphSpectra)
278 self.label_22.setObjectName(_fromUtf8("label_22"))
279 self.gridLayout_9.addWidget(self.label_22, 16, 0, 1, 1)
280 self.specGgraphFreq = QtGui.QLineEdit(self.tabgraphSpectra)
281 self.specGgraphFreq.setObjectName(_fromUtf8("specGgraphFreq"))
282 self.gridLayout_9.addWidget(self.specGgraphFreq, 16, 2, 1, 2)
283
284 self.label_16 = QtGui.QLabel(self.tabgraphSpectra)
285 self.label_16.setObjectName(_fromUtf8("label_16"))
286 self.gridLayout_9.addWidget(self.label_16, 17, 0, 1, 1)
287 self.specGgraphHeight = QtGui.QLineEdit(self.tabgraphSpectra)
288 self.specGgraphHeight.setObjectName(_fromUtf8("specGgraphHeight"))
289 self.gridLayout_9.addWidget(self.specGgraphHeight, 17, 2, 1, 2)
290
291 self.label_17 = QtGui.QLabel(self.tabgraphSpectra)
292 self.label_17.setObjectName(_fromUtf8("label_17"))
293 self.gridLayout_9.addWidget(self.label_17, 18, 0, 1, 1)
294 self.specGgraphDbsrange = QtGui.QLineEdit(self.tabgraphSpectra)
295 self.specGgraphDbsrange.setObjectName(_fromUtf8("specGgraphDbsrange"))
296 self.gridLayout_9.addWidget(self.specGgraphDbsrange, 18, 2, 1, 2)
297
298 self.specGraphTminTmaxLabel = QtGui.QLabel(self.tabgraphSpectra)
299 self.specGraphTminTmaxLabel.setObjectName(_fromUtf8("specGraphTminTmaxLabel"))
300 self.gridLayout_9.addWidget(self.specGraphTminTmaxLabel, 19, 0, 1, 2)
301 self.specGgraphTminTmax = QtGui.QLineEdit(self.tabgraphSpectra)
302 self.specGgraphTminTmax.setObjectName(_fromUtf8("specGgraphTminTmax"))
303 self.gridLayout_9.addWidget(self.specGgraphTminTmax, 19, 2, 1, 2)
304
305 self.specGraphMagLabel = QtGui.QLabel(self.tabgraphSpectra)
306 self.specGraphMagLabel.setObjectName(_fromUtf8("specGraphMagLabel"))
307 self.gridLayout_9.addWidget(self.specGraphMagLabel, 16, 4, 1, 2)
308 self.specGgraphmagnitud = QtGui.QLineEdit(self.tabgraphSpectra)
309 self.specGgraphmagnitud.setObjectName(_fromUtf8("specGgraphmagnitud"))
310 self.gridLayout_9.addWidget(self.specGgraphmagnitud, 16, 6, 1, 2)
311
312 self.specGraphPhaseLabel = QtGui.QLabel(self.tabgraphSpectra)
313 self.specGraphPhaseLabel.setObjectName(_fromUtf8("specGraphPhaseLabel"))
314 self.gridLayout_9.addWidget(self.specGraphPhaseLabel, 17, 4, 1, 2)
315 self.specGgraphPhase = QtGui.QLineEdit(self.tabgraphSpectra)
316 self.specGgraphPhase.setObjectName(_fromUtf8("specGgraphPhase"))
317 self.gridLayout_9.addWidget(self.specGgraphPhase, 17, 6, 1, 2)
318
319 self.label_6 = QtGui.QLabel(self.tabgraphSpectra)
320 self.label_6.setObjectName(_fromUtf8("label_6"))
321 self.gridLayout_9.addWidget(self.label_6, 18, 4, 1, 1)
322 self.specGgraphChannelList = QtGui.QLineEdit(self.tabgraphSpectra)
323 self.specGgraphChannelList.setObjectName(_fromUtf8("specGgraphChannelList"))
324 self.gridLayout_9.addWidget(self.specGgraphChannelList, 18, 6, 1, 2)
325
326 self.label_29 = QtGui.QLabel(self.tabgraphSpectra)
327 self.label_29.setObjectName(_fromUtf8("label_29"))
328 self.gridLayout_9.addWidget(self.label_29, 19, 4, 1, 2)
329 self.specGgraphftpratio = QtGui.QLineEdit(self.tabgraphSpectra)
330 self.specGgraphftpratio.setObjectName(_fromUtf8("specGgraphftpratio"))
331 self.gridLayout_9.addWidget(self.specGgraphftpratio, 19, 6, 1, 2)
332
310 333 self.label_48 = QtGui.QLabel(self.tabgraphSpectra)
311 334 self.label_48.setObjectName(_fromUtf8("label_48"))
312 self.gridLayout_9.addWidget(self.label_48, 22, 0, 1, 1)
335 self.gridLayout_9.addWidget(self.label_48, 20, 4, 1, 2)
313 336 self.specGgraphTimeRange = QtGui.QLineEdit(self.tabgraphSpectra)
314 337 self.specGgraphTimeRange.setObjectName(_fromUtf8("specGgraphTimeRange"))
315 self.gridLayout_9.addWidget(self.specGgraphTimeRange, 22, 1, 1, 7)
338 self.gridLayout_9.addWidget(self.specGgraphTimeRange, 20, 6, 1, 2)
339
340 spacerItem15 = QtGui.QSpacerItem(28, 15, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
341 self.gridLayout_9.addItem(spacerItem15, 27, 6, 1, 2)
342 spacerItem16 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
343 self.gridLayout_9.addItem(spacerItem16, 3, 5, 1, 1)
344 spacerItem17 = QtGui.QSpacerItem(49, 15, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
345 self.gridLayout_9.addItem(spacerItem17, 27, 0, 1, 1)
346
347
348
316 349 self.tabWidgetSpectra.addTab(self.tabgraphSpectra, _fromUtf8(""))
317 350 self.taboutputSpectra = QtGui.QWidget()
318 351 self.taboutputSpectra.setObjectName(_fromUtf8("taboutputSpectra"))
319 352 self.gridLayout_11 = QtGui.QGridLayout(self.taboutputSpectra)
320 353 self.gridLayout_11.setObjectName(_fromUtf8("gridLayout_11"))
321 354 self.label_39 = QtGui.QLabel(self.taboutputSpectra)
322 355 self.label_39.setObjectName(_fromUtf8("label_39"))
323 356 self.gridLayout_11.addWidget(self.label_39, 0, 0, 1, 1)
324 357 self.specOutputComData = QtGui.QComboBox(self.taboutputSpectra)
325 358 self.specOutputComData.setObjectName(_fromUtf8("specOutputComData"))
326 359 self.specOutputComData.addItem(_fromUtf8(""))
327 360 self.gridLayout_11.addWidget(self.specOutputComData, 0, 2, 1, 2)
328 361 self.label_34 = QtGui.QLabel(self.taboutputSpectra)
329 362 self.label_34.setObjectName(_fromUtf8("label_34"))
330 363 self.gridLayout_11.addWidget(self.label_34, 1, 0, 1, 1)
331 364 self.specOutputPath = QtGui.QLineEdit(self.taboutputSpectra)
332 365 self.specOutputPath.setObjectName(_fromUtf8("specOutputPath"))
333 366 self.gridLayout_11.addWidget(self.specOutputPath, 1, 2, 1, 1)
334 367 spacerItem20 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
335 368 self.gridLayout_11.addItem(spacerItem20, 4, 2, 1, 1)
336 369 self.specOutputToolPath = QtGui.QToolButton(self.taboutputSpectra)
337 370 self.specOutputToolPath.setObjectName(_fromUtf8("specOutputToolPath"))
338 371 self.gridLayout_11.addWidget(self.specOutputToolPath, 1, 3, 1, 1)
339 372 self.specOutputblocksperfile = QtGui.QLineEdit(self.taboutputSpectra)
340 373 self.specOutputblocksperfile.setObjectName(_fromUtf8("specOutputblocksperfile"))
341 374 self.gridLayout_11.addWidget(self.specOutputblocksperfile, 2, 2, 1, 1)
342 375 self.label_9 = QtGui.QLabel(self.taboutputSpectra)
343 376 self.label_9.setObjectName(_fromUtf8("label_9"))
344 377 self.gridLayout_11.addWidget(self.label_9, 2, 0, 1, 2)
345 378 self.label_38 = QtGui.QLabel(self.taboutputSpectra)
346 379 self.label_38.setObjectName(_fromUtf8("label_38"))
347 380 self.gridLayout_11.addWidget(self.label_38, 3, 0, 1, 1)
348 381 self.specOutputprofileperblock = QtGui.QLineEdit(self.taboutputSpectra)
349 382 self.specOutputprofileperblock.setObjectName(_fromUtf8("specOutputprofileperblock"))
350 383 self.gridLayout_11.addWidget(self.specOutputprofileperblock, 3, 2, 1, 1)
351 384 self.tabWidgetSpectra.addTab(self.taboutputSpectra, _fromUtf8(""))
352 385 self.gridLayout_7.addWidget(self.tabWidgetSpectra, 0, 1, 1, 1)
353 386
354 387 self.tabWidgetProject.addTab(self.tabSpectra, _fromUtf8(""))
355 388
356 389 self.tabWidgetSpectra.setCurrentIndex(0)
357 390
358 391 def retranslateUi(self):
359 392
360 393 self.specOpOk.setText(_translate("MainWindow", "Ok", None))
361 394 self.specGraphClear.setText(_translate("MainWindow", "Clear", None))
362 395 self.specOpCebCrossSpectra.setText(_translate("MainWindow", "Select Cross Spectra", None))
363 396 self.specOpComChannel.setItemText(0, _translate("MainWindow", "Value", None))
364 397 self.specOpComChannel.setItemText(1, _translate("MainWindow", "Index", None))
365 398 self.specOpComHeights.setItemText(0, _translate("MainWindow", "Value", None))
366 399 self.specOpComHeights.setItemText(1, _translate("MainWindow", "Index", None))
367 400 self.specOpCebRemoveDC.setText(_translate("MainWindow", "Remove DC", None))
368 401 self.specOpCebHeights.setText(_translate("MainWindow", "Select Heights", None))
369 402 self.specOpCebChannel.setText(_translate("MainWindow", "Select Channel", None))
370 403 self.label_31.setText(_translate("MainWindow", "x-y pairs", None))
371 404 self.label_26.setText(_translate("MainWindow", "nFFTPoints", None))
372 405 self.specOpCebIncoherent.setText(_translate("MainWindow", "Incoherent Integration", None))
373 406 self.specOpCobIncInt.setItemText(0, _translate("MainWindow", "Time Interval", None))
374 407 self.specOpCobIncInt.setItemText(1, _translate("MainWindow", "Profiles", None))
375 408 self.specOpCebRadarfrequency.setText(_translate("MainWindow", "Radar Frequency", None))
376 409 self.label_21.setText(_translate("MainWindow", "Profiles", None))
377 410 self.specOpCebRemoveInt.setText(_translate("MainWindow", "Remove Interference", None))
378 411 self.label_70.setText(_translate("MainWindow", "IppFactor", None))
379 412 self.specOpCebgetNoise.setText(_translate("MainWindow", "Get Noise", None))
380 413 self.specOpComRemoveDC.setItemText(0, _translate("MainWindow", "Mode 1", None))
381 414 self.specOpComRemoveDC.setItemText(1, _translate("MainWindow", "Mode 2", None))
382 415 self.tabWidgetSpectra.setTabText(self.tabWidgetSpectra.indexOf(self.tabopSpectra), _translate("MainWindow", "Operation", None))
383 416
384 417 self.label_44.setText(_translate("MainWindow", "Coherence Map", None))
385 self.label_20.setText(_translate("MainWindow", "Tmin, Tmax:", None))
418 self.specGraphTminTmaxLabel.setText(_translate("MainWindow", "Time range:", None))
386 419 self.label_25.setText(_translate("MainWindow", "Prefix", None))
387 420 self.label_42.setText(_translate("MainWindow", "RTI Plot", None))
388 421 self.label_16.setText(_translate("MainWindow", "Height range", None))
389 422 self.label_17.setText(_translate("MainWindow", "dB range", None))
390 self.label_18.setText(_translate("MainWindow", "Magnitud ", None))
423 self.specGraphMagLabel.setText(_translate("MainWindow", "Coh. Magnitud ", None))
391 424 self.label_24.setText(_translate("MainWindow", "Path", None))
392 425 self.label_46.setText(_translate("MainWindow", "Power Profile", None))
393 self.label_22.setText(_translate("MainWindow", "Freq/Vel:", None))
426 self.label_22.setText(_translate("MainWindow", "Freq/Vel range:", None))
394 427 self.label_41.setText(_translate("MainWindow", "Cross Spectra Plot", None))
395 428 self.specGraphToolPath.setText(_translate("MainWindow", "...", None))
396 429 self.label_6.setText(_translate("MainWindow", "Channel List:", None))
397 430 self.label_40.setText(_translate("MainWindow", "Spectra Plot", None))
398 431 self.label_43.setText(_translate("MainWindow", "Show", None))
399 self.label_29.setText(_translate("MainWindow", "Wr Period:", None))
432 self.label_29.setText(_translate("MainWindow", "Writing Period:", None))
400 433 self.label_47.setText(_translate("MainWindow", "Save", None))
401 self.label_19.setText(_translate("MainWindow", "ftp", None))
434 self.label_19.setText(_translate("MainWindow", "Ftp", None))
402 435 self.label_45.setText(_translate("MainWindow", "Noise", None))
403 436 self.label_48.setText(_translate("MainWindow", "Time Range:", None))
437 self.specGraphPhaseLabel.setText(_translate("MainWindow", "Coh. Phase:", None))
438 self.label_48.hide()
439 self.specGgraphTimeRange.hide()
404 440 self.tabWidgetSpectra.setTabText(self.tabWidgetSpectra.indexOf(self.tabgraphSpectra), _translate("MainWindow", "Graphics", None))
405 441
406 442 self.label_39.setText(_translate("MainWindow", "Type:", None))
407 443 self.specOutputComData.setItemText(0, _translate("MainWindow", ".pdata", None))
408 444 self.label_34.setText(_translate("MainWindow", "Path:", None))
409 445 self.specOutputToolPath.setText(_translate("MainWindow", "...", None))
410 446 self.label_9.setText(_translate("MainWindow", "Blocks per File: ", None))
411 447 self.label_38.setText(_translate("MainWindow", "Profile per Block: ", None))
412 448 self.tabWidgetSpectra.setTabText(self.tabWidgetSpectra.indexOf(self.taboutputSpectra), _translate("MainWindow", "Output", None))
413 449
414 450 self.tabWidgetProject.setTabText(self.tabWidgetProject.indexOf(self.tabSpectra), _translate("MainWindow", "Spectra", None))
415 451 No newline at end of file
@@ -1,610 +1,610
1 1 import os
2 2 import numpy
3 3 import time, datetime
4 4 import mpldriver
5 5
6 6 from schainpy.model.proc.jroproc_base import Operation
7 7
8 8 def isRealtime(utcdatatime):
9 9 utcnow = time.mktime(time.localtime())
10 10 delta = abs(utcnow - utcdatatime) # abs
11 11 if delta >= 30.:
12 12 return False
13 13 return True
14 14
15 15 class Figure(Operation):
16 16
17 17 __driver = mpldriver
18 18 __isConfigThread = False
19 19 fig = None
20 20
21 21 id = None
22 22 wintitle = None
23 23 width = None
24 24 height = None
25 25 nplots = None
26 26 timerange = None
27 27
28 28 axesObjList = []
29 29
30 30 WIDTH = None
31 31 HEIGHT = None
32 32 PREFIX = 'fig'
33 33
34 34 xmin = None
35 35 xmax = None
36 36
37 37 counter_imagwr = 0
38 38
39 39 figfile = None
40 40
41 41 def __init__(self):
42 42
43 43 raise ValueError, "This method is not implemented"
44 44
45 45 def __del__(self):
46 46
47 47 self.__driver.closeFigure()
48 48
49 49 def getFilename(self, name, ext='.png'):
50 50
51 51 path = '%s%03d' %(self.PREFIX, self.id)
52 52 filename = '%s_%s%s' %(self.PREFIX, name, ext)
53 53 return os.path.join(path, filename)
54 54
55 55 def getAxesObjList(self):
56 56
57 57 return self.axesObjList
58 58
59 59 def getSubplots(self):
60 60
61 61 raise ValueError, "Abstract method: This method should be defined"
62 62
63 63 def getScreenDim(self, widthplot, heightplot):
64 64
65 65 nrow, ncol = self.getSubplots()
66 66
67 67 widthscreen = widthplot*ncol
68 68 heightscreen = heightplot*nrow
69 69
70 70 return widthscreen, heightscreen
71 71
72 72 def getTimeLim(self, x, xmin=None, xmax=None, timerange=None):
73 73
74 74 if self.xmin != None and self.xmax != None:
75 75 if timerange == None:
76 76 timerange = self.xmax - self.xmin
77 77 xmin = self.xmin + timerange
78 78 xmax = self.xmax + timerange
79 79
80 80 return xmin, xmax
81 81
82 82 if timerange == None and (xmin==None or xmax==None):
83 83 timerange = 14400 #seconds
84 84 #raise ValueError, "(timerange) or (xmin & xmax) should be defined"
85 85
86 86 if timerange != None:
87 87 txmin = x[0] - x[0] % min(timerange/10, 10*60)
88 88 else:
89 89 txmin = x[0] - x[0] % 10*60
90 90
91 91 thisdatetime = datetime.datetime.utcfromtimestamp(txmin)
92 92 thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0))
93 93
94 94 if timerange != None:
95 95 xmin = (thisdatetime - thisdate).seconds/(60*60.)
96 96 xmax = xmin + timerange/(60*60.)
97 97
98 98 mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone)
99 99 xmin_sec = time.mktime(mindt.timetuple())
100 100
101 101 maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone)
102 102 xmax_sec = time.mktime(maxdt.timetuple())
103 103
104 104 return xmin_sec, xmax_sec
105 105
106 106 def init(self, id, nplots, wintitle):
107 107
108 108 raise ValueError, "This method has been replaced with createFigure"
109 109
110 110 def createFigure(self, id, wintitle, widthplot=None, heightplot=None, show=True):
111 111
112 112 """
113 113 Crea la figura de acuerdo al driver y parametros seleccionados seleccionados.
114 114 Las dimensiones de la pantalla es calculada a partir de los atributos self.WIDTH
115 115 y self.HEIGHT y el numero de subplots (nrow, ncol)
116 116
117 117 Input:
118 118 id : Los parametros necesarios son
119 119 wintitle :
120 120
121 121 """
122 122
123 123 if widthplot == None:
124 124 widthplot = self.WIDTH
125 125
126 126 if heightplot == None:
127 127 heightplot = self.HEIGHT
128 128
129 129 self.id = id
130 130
131 131 self.wintitle = wintitle
132 132
133 133 self.widthscreen, self.heightscreen = self.getScreenDim(widthplot, heightplot)
134 134
135 135 self.fig = self.__driver.createFigure(id=self.id,
136 136 wintitle=self.wintitle,
137 137 width=self.widthscreen,
138 138 height=self.heightscreen,
139 139 show=show)
140 140
141 141 self.axesObjList = []
142 142 self.counter_imagwr = 0
143 143
144 144
145 145 def setDriver(self, driver=mpldriver):
146 146
147 147 self.__driver = driver
148 148
149 149 def setTitle(self, title):
150 150
151 151 self.__driver.setTitle(self.fig, title)
152 152
153 153 def setWinTitle(self, title):
154 154
155 155 self.__driver.setWinTitle(self.fig, title=title)
156 156
157 157 def setTextFromAxes(self, text):
158 158
159 159 raise ValueError, "Este metodo ha sido reemplazaado con el metodo setText de la clase Axes"
160 160
161 161 def makeAxes(self, nrow, ncol, xpos, ypos, colspan, rowspan):
162 162
163 163 raise ValueError, "Este metodo ha sido reemplazaado con el metodo addAxes"
164 164
165 165 def addAxes(self, *args):
166 166 """
167 167
168 168 Input:
169 169 *args : Los parametros necesarios son
170 170 nrow, ncol, xpos, ypos, colspan, rowspan
171 171 """
172 172
173 173 axesObj = Axes(self.fig, *args)
174 174 self.axesObjList.append(axesObj)
175 175
176 176 def saveFigure(self, figpath, figfile, *args):
177 177
178 178 filename = os.path.join(figpath, figfile)
179 179
180 180 fullpath = os.path.split(filename)[0]
181 181
182 182 if not os.path.exists(fullpath):
183 183 subpath = os.path.split(fullpath)[0]
184 184
185 185 if not os.path.exists(subpath):
186 186 os.mkdir(subpath)
187 187
188 188 os.mkdir(fullpath)
189 189
190 190 self.__driver.saveFigure(self.fig, filename, *args)
191 191
192 192 def save(self, figpath, figfile=None, save=True, ftp=False, wr_period=1, thisDatetime=None, update_figfile=True):
193 193
194 194 self.counter_imagwr += 1
195 195 if self.counter_imagwr < wr_period:
196 196 return
197 197
198 198 self.counter_imagwr = 0
199 199
200 200 if save:
201 201
202 if figfile == None:
202 if not figfile:
203 203
204 204 if not thisDatetime:
205 205 raise ValueError, "Saving figure: figfile or thisDatetime should be defined"
206 206 return
207 207
208 208 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
209 209 figfile = self.getFilename(name = str_datetime)
210 210
211 211 if self.figfile == None:
212 212 self.figfile = figfile
213 213
214 214 if update_figfile:
215 215 self.figfile = figfile
216 216
217 217 # store png plot to local folder
218 218 self.saveFigure(figpath, self.figfile)
219 219
220 220
221 221 if not ftp:
222 222 return
223 223
224 224 if not thisDatetime:
225 225 return
226 226
227 227 # store png plot to FTP server according to RT-Web format
228 228 ftp_filename = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
229 229 # ftp_filename = os.path.join(figpath, name)
230 230 self.saveFigure(figpath, ftp_filename)
231 231
232 232 def getNameToFtp(self, thisDatetime, FTP_WEI, EXP_CODE, SUB_EXP_CODE, PLOT_CODE, PLOT_POS):
233 233 YEAR_STR = '%4.4d'%thisDatetime.timetuple().tm_year
234 234 DOY_STR = '%3.3d'%thisDatetime.timetuple().tm_yday
235 235 FTP_WEI = '%2.2d'%FTP_WEI
236 236 EXP_CODE = '%3.3d'%EXP_CODE
237 237 SUB_EXP_CODE = '%2.2d'%SUB_EXP_CODE
238 238 PLOT_CODE = '%2.2d'%PLOT_CODE
239 239 PLOT_POS = '%2.2d'%PLOT_POS
240 240 name = YEAR_STR + DOY_STR + FTP_WEI + EXP_CODE + SUB_EXP_CODE + PLOT_CODE + PLOT_POS
241 241 return name
242 242
243 243 def draw(self):
244 244
245 245 self.__driver.draw(self.fig)
246 246
247 247 def run(self):
248 248
249 249 raise ValueError, "This method is not implemented"
250 250
251 251 def close(self, show=False):
252 252
253 253 self.__driver.closeFigure(show=show, fig=self.fig)
254 254
255 255 axesList = property(getAxesObjList)
256 256
257 257
258 258 class Axes:
259 259
260 260 __driver = mpldriver
261 261 fig = None
262 262 ax = None
263 263 plot = None
264 264 __missing = 1E30
265 265 __firsttime = None
266 266
267 267 __showprofile = False
268 268
269 269 xmin = None
270 270 xmax = None
271 271 ymin = None
272 272 ymax = None
273 273 zmin = None
274 274 zmax = None
275 275
276 276 x_buffer = None
277 277 z_buffer = None
278 278
279 279 decimationx = None
280 280 decimationy = None
281 281
282 282 __MAXNUMX = 300
283 283 __MAXNUMY = 150
284 284
285 285 def __init__(self, *args):
286 286
287 287 """
288 288
289 289 Input:
290 290 *args : Los parametros necesarios son
291 291 fig, nrow, ncol, xpos, ypos, colspan, rowspan
292 292 """
293 293
294 294 ax = self.__driver.createAxes(*args)
295 295 self.fig = args[0]
296 296 self.ax = ax
297 297 self.plot = None
298 298
299 299 self.__firsttime = True
300 300 self.idlineList = []
301 301
302 302 self.x_buffer = numpy.array([])
303 303 self.z_buffer = numpy.array([])
304 304
305 305 def setText(self, text):
306 306
307 307 self.__driver.setAxesText(self.ax, text)
308 308
309 309 def setXAxisAsTime(self):
310 310 pass
311 311
312 312 def pline(self, x, y,
313 313 xmin=None, xmax=None,
314 314 ymin=None, ymax=None,
315 315 xlabel='', ylabel='',
316 316 title='',
317 317 **kwargs):
318 318
319 319 """
320 320
321 321 Input:
322 322 x :
323 323 y :
324 324 xmin :
325 325 xmax :
326 326 ymin :
327 327 ymax :
328 328 xlabel :
329 329 ylabel :
330 330 title :
331 331 **kwargs : Los parametros aceptados son
332 332
333 333 ticksize
334 334 ytick_visible
335 335 """
336 336
337 337 if self.__firsttime:
338 338
339 339 if xmin == None: xmin = numpy.nanmin(x)
340 340 if xmax == None: xmax = numpy.nanmax(x)
341 341 if ymin == None: ymin = numpy.nanmin(y)
342 342 if ymax == None: ymax = numpy.nanmax(y)
343 343
344 344 self.plot = self.__driver.createPline(self.ax, x, y,
345 345 xmin, xmax,
346 346 ymin, ymax,
347 347 xlabel=xlabel,
348 348 ylabel=ylabel,
349 349 title=title,
350 350 **kwargs)
351 351
352 352 self.idlineList.append(0)
353 353 self.__firsttime = False
354 354 return
355 355
356 356 self.__driver.pline(self.plot, x, y, xlabel=xlabel,
357 357 ylabel=ylabel,
358 358 title=title)
359 359
360 360 def addpline(self, x, y, idline, **kwargs):
361 361 lines = self.ax.lines
362 362
363 363 if idline in self.idlineList:
364 364 self.__driver.set_linedata(self.ax, x, y, idline)
365 365
366 366 if idline not in(self.idlineList):
367 367 self.__driver.addpline(self.ax, x, y, **kwargs)
368 368 self.idlineList.append(idline)
369 369
370 370 return
371 371
372 372 def pmultiline(self, x, y,
373 373 xmin=None, xmax=None,
374 374 ymin=None, ymax=None,
375 375 xlabel='', ylabel='',
376 376 title='',
377 377 **kwargs):
378 378
379 379 if self.__firsttime:
380 380
381 381 if xmin == None: xmin = numpy.nanmin(x)
382 382 if xmax == None: xmax = numpy.nanmax(x)
383 383 if ymin == None: ymin = numpy.nanmin(y)
384 384 if ymax == None: ymax = numpy.nanmax(y)
385 385
386 386 self.plot = self.__driver.createPmultiline(self.ax, x, y,
387 387 xmin, xmax,
388 388 ymin, ymax,
389 389 xlabel=xlabel,
390 390 ylabel=ylabel,
391 391 title=title,
392 392 **kwargs)
393 393 self.__firsttime = False
394 394 return
395 395
396 396 self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel,
397 397 ylabel=ylabel,
398 398 title=title)
399 399
400 400 def pmultilineyaxis(self, x, y,
401 401 xmin=None, xmax=None,
402 402 ymin=None, ymax=None,
403 403 xlabel='', ylabel='',
404 404 title='',
405 405 **kwargs):
406 406
407 407 if self.__firsttime:
408 408
409 409 if xmin == None: xmin = numpy.nanmin(x)
410 410 if xmax == None: xmax = numpy.nanmax(x)
411 411 if ymin == None: ymin = numpy.nanmin(y)
412 412 if ymax == None: ymax = numpy.nanmax(y)
413 413
414 414 self.plot = self.__driver.createPmultilineYAxis(self.ax, x, y,
415 415 xmin, xmax,
416 416 ymin, ymax,
417 417 xlabel=xlabel,
418 418 ylabel=ylabel,
419 419 title=title,
420 420 **kwargs)
421 421 if self.xmin == None: self.xmin = xmin
422 422 if self.xmax == None: self.xmax = xmax
423 423 if self.ymin == None: self.ymin = ymin
424 424 if self.ymax == None: self.ymax = ymax
425 425
426 426 self.__firsttime = False
427 427 return
428 428
429 429 self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel,
430 430 ylabel=ylabel,
431 431 title=title)
432 432
433 433 def pcolor(self, x, y, z,
434 434 xmin=None, xmax=None,
435 435 ymin=None, ymax=None,
436 436 zmin=None, zmax=None,
437 437 xlabel='', ylabel='',
438 438 title='', rti = False, colormap='jet',
439 439 **kwargs):
440 440
441 441 """
442 442 Input:
443 443 x :
444 444 y :
445 445 x :
446 446 xmin :
447 447 xmax :
448 448 ymin :
449 449 ymax :
450 450 zmin :
451 451 zmax :
452 452 xlabel :
453 453 ylabel :
454 454 title :
455 455 **kwargs : Los parametros aceptados son
456 456 ticksize=9,
457 457 cblabel=''
458 458 rti = True or False
459 459 """
460 460
461 461 if self.__firsttime:
462 462
463 463 if xmin == None: xmin = numpy.nanmin(x)
464 464 if xmax == None: xmax = numpy.nanmax(x)
465 465 if ymin == None: ymin = numpy.nanmin(y)
466 466 if ymax == None: ymax = numpy.nanmax(y)
467 467 if zmin == None: zmin = numpy.nanmin(z)
468 468 if zmax == None: zmax = numpy.nanmax(z)
469 469
470 470
471 471 self.plot = self.__driver.createPcolor(self.ax, x, y, z,
472 472 xmin, xmax,
473 473 ymin, ymax,
474 474 zmin, zmax,
475 475 xlabel=xlabel,
476 476 ylabel=ylabel,
477 477 title=title,
478 478 colormap=colormap,
479 479 **kwargs)
480 480
481 481 if self.xmin == None: self.xmin = xmin
482 482 if self.xmax == None: self.xmax = xmax
483 483 if self.ymin == None: self.ymin = ymin
484 484 if self.ymax == None: self.ymax = ymax
485 485 if self.zmin == None: self.zmin = zmin
486 486 if self.zmax == None: self.zmax = zmax
487 487
488 488 self.__firsttime = False
489 489 return
490 490
491 491 if rti:
492 492 self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax,
493 493 xlabel=xlabel,
494 494 ylabel=ylabel,
495 495 title=title,
496 496 colormap=colormap)
497 497 return
498 498
499 499 self.__driver.pcolor(self.plot, z,
500 500 xlabel=xlabel,
501 501 ylabel=ylabel,
502 502 title=title)
503 503
504 504 def pcolorbuffer(self, x, y, z,
505 505 xmin=None, xmax=None,
506 506 ymin=None, ymax=None,
507 507 zmin=None, zmax=None,
508 508 xlabel='', ylabel='',
509 509 title='', rti = True, colormap='jet',
510 510 maxNumX = None, maxNumY = None,
511 511 **kwargs):
512 512
513 513 if maxNumX == None:
514 514 maxNumX = self.__MAXNUMX
515 515
516 516 if maxNumY == None:
517 517 maxNumY = self.__MAXNUMY
518 518
519 519 if self.__firsttime:
520 520 self.z_buffer = z
521 521 self.x_buffer = numpy.hstack((self.x_buffer, x))
522 522
523 523 if xmin == None: xmin = numpy.nanmin(x)
524 524 if xmax == None: xmax = numpy.nanmax(x)
525 525 if ymin == None: ymin = numpy.nanmin(y)
526 526 if ymax == None: ymax = numpy.nanmax(y)
527 527 if zmin == None: zmin = numpy.nanmin(z)
528 528 if zmax == None: zmax = numpy.nanmax(z)
529 529
530 530
531 531 self.plot = self.__driver.createPcolor(self.ax, self.x_buffer, y, z,
532 532 xmin, xmax,
533 533 ymin, ymax,
534 534 zmin, zmax,
535 535 xlabel=xlabel,
536 536 ylabel=ylabel,
537 537 title=title,
538 538 colormap=colormap,
539 539 **kwargs)
540 540
541 541 if self.xmin == None: self.xmin = xmin
542 542 if self.xmax == None: self.xmax = xmax
543 543 if self.ymin == None: self.ymin = ymin
544 544 if self.ymax == None: self.ymax = ymax
545 545 if self.zmin == None: self.zmin = zmin
546 546 if self.zmax == None: self.zmax = zmax
547 547
548 548 self.__firsttime = False
549 549 return
550 550
551 551 self.x_buffer = numpy.hstack((self.x_buffer, x[-1]))
552 552 self.z_buffer = numpy.hstack((self.z_buffer, z))
553 553
554 554 if self.decimationx == None:
555 555 deltax = float(self.xmax - self.xmin)/maxNumX
556 556 deltay = float(self.ymax - self.ymin)/maxNumY
557 557
558 558 resolutionx = self.x_buffer[2]-self.x_buffer[0]
559 559 resolutiony = y[1]-y[0]
560 560
561 561 self.decimationx = numpy.ceil(deltax / resolutionx)
562 562 self.decimationy = numpy.ceil(deltay / resolutiony)
563 563
564 564 z_buffer = self.z_buffer.reshape(-1,len(y))
565 565
566 566 x_buffer = self.x_buffer[::self.decimationx]
567 567 y_buffer = y[::self.decimationy]
568 568 z_buffer = z_buffer[::self.decimationx, ::self.decimationy]
569 569 #===================================================
570 570
571 571 x_buffer, y_buffer, z_buffer = self.__fillGaps(x_buffer, y_buffer, z_buffer)
572 572
573 573 self.__driver.addpcolorbuffer(self.ax, x_buffer, y_buffer, z_buffer, self.zmin, self.zmax,
574 574 xlabel=xlabel,
575 575 ylabel=ylabel,
576 576 title=title,
577 577 colormap=colormap)
578 578
579 579 def polar(self, x, y,
580 580 title='', xlabel='',ylabel='',**kwargs):
581 581
582 582 if self.__firsttime:
583 583 self.plot = self.__driver.createPolar(self.ax, x, y, title = title, xlabel = xlabel, ylabel = ylabel)
584 584 self.__firsttime = False
585 585 self.x_buffer = x
586 586 self.y_buffer = y
587 587 return
588 588
589 589 self.x_buffer = numpy.hstack((self.x_buffer,x))
590 590 self.y_buffer = numpy.hstack((self.y_buffer,y))
591 591 self.__driver.polar(self.plot, self.x_buffer, self.y_buffer, xlabel=xlabel,
592 592 ylabel=ylabel,
593 593 title=title)
594 594
595 595 def __fillGaps(self, x_buffer, y_buffer, z_buffer):
596 596
597 597 deltas = x_buffer[1:] - x_buffer[0:-1]
598 598 x_median = numpy.median(deltas)
599 599
600 600 index = numpy.where(deltas >= 2*x_median)
601 601
602 602 if len(index[0]) != 0:
603 603 z_buffer[index[0],::] = self.__missing
604 604 z_buffer = numpy.ma.masked_inside(z_buffer,0.99*self.__missing,1.01*self.__missing)
605 605
606 606 return x_buffer, y_buffer, z_buffer
607 607
608 608
609 609
610 610 No newline at end of file
@@ -1,1327 +1,1337
1 1 '''
2 2 Created on Jul 9, 2014
3 3
4 4 @author: roj-idl71
5 5 '''
6 6 import os
7 7 import datetime
8 8 import numpy
9 9
10 10 from figure import Figure, isRealtime
11 11 from plotting_codes import *
12 12
13 13 class SpectraPlot(Figure):
14 14
15 15 isConfig = None
16 16 __nsubplots = None
17 17
18 18 WIDTHPROF = None
19 19 HEIGHTPROF = None
20 20 PREFIX = 'spc'
21 21
22 22 def __init__(self):
23 23
24 24 self.isConfig = False
25 25 self.__nsubplots = 1
26 26
27 27 self.WIDTH = 280
28 28 self.HEIGHT = 250
29 29 self.WIDTHPROF = 120
30 30 self.HEIGHTPROF = 0
31 31 self.counter_imagwr = 0
32 32
33 33 self.PLOT_CODE = SPEC_CODE
34 34
35 35 self.FTP_WEI = None
36 36 self.EXP_CODE = None
37 37 self.SUB_EXP_CODE = None
38 38 self.PLOT_POS = None
39 39
40 40 self.__xfilter_ena = False
41 41 self.__yfilter_ena = False
42 42
43 43 def getSubplots(self):
44 44
45 45 ncol = int(numpy.sqrt(self.nplots)+0.9)
46 46 nrow = int(self.nplots*1./ncol + 0.9)
47 47
48 48 return nrow, ncol
49 49
50 50 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
51 51
52 52 self.__showprofile = showprofile
53 53 self.nplots = nplots
54 54
55 55 ncolspan = 1
56 56 colspan = 1
57 57 if showprofile:
58 58 ncolspan = 3
59 59 colspan = 2
60 60 self.__nsubplots = 2
61 61
62 62 self.createFigure(id = id,
63 63 wintitle = wintitle,
64 64 widthplot = self.WIDTH + self.WIDTHPROF,
65 65 heightplot = self.HEIGHT + self.HEIGHTPROF,
66 66 show=show)
67 67
68 68 nrow, ncol = self.getSubplots()
69 69
70 70 counter = 0
71 71 for y in range(nrow):
72 72 for x in range(ncol):
73 73
74 74 if counter >= self.nplots:
75 75 break
76 76
77 77 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
78 78
79 79 if showprofile:
80 80 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
81 81
82 82 counter += 1
83 83
84 84 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
85 85 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
86 86 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
87 87 server=None, folder=None, username=None, password=None,
88 88 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
89 89
90 90 """
91 91
92 92 Input:
93 93 dataOut :
94 94 id :
95 95 wintitle :
96 96 channelList :
97 97 showProfile :
98 98 xmin : None,
99 99 xmax : None,
100 100 ymin : None,
101 101 ymax : None,
102 102 zmin : None,
103 103 zmax : None
104 104 """
105 105
106 106 if realtime:
107 107 if not(isRealtime(utcdatatime = dataOut.utctime)):
108 108 print 'Skipping this plot function'
109 109 return
110 110
111 111 if channelList == None:
112 112 channelIndexList = dataOut.channelIndexList
113 113 else:
114 114 channelIndexList = []
115 115 for channel in channelList:
116 116 if channel not in dataOut.channelList:
117 117 raise ValueError, "Channel %d is not in dataOut.channelList"
118 118 channelIndexList.append(dataOut.channelList.index(channel))
119 119
120 120 factor = dataOut.normFactor
121 121
122 122 x = dataOut.getVelRange(1)
123 123 y = dataOut.getHeiRange()
124 124
125 125 z = dataOut.data_spc[channelIndexList,:,:]/factor
126 126 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
127 127 zdB = 10*numpy.log10(z)
128 128
129 129 avg = numpy.average(z, axis=1)
130 130 avgdB = 10*numpy.log10(avg)
131 131
132 132 noise = dataOut.getNoise()/factor
133 133 noisedB = 10*numpy.log10(noise)
134 134
135 135 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
136 136 title = wintitle + " Spectra"
137 137 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
138 138 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
139 139
140 140 xlabel = "Velocity (m/s)"
141 141 ylabel = "Range (Km)"
142 142
143 143 if not self.isConfig:
144 144
145 145 nplots = len(channelIndexList)
146 146
147 147 self.setup(id=id,
148 148 nplots=nplots,
149 149 wintitle=wintitle,
150 150 showprofile=showprofile,
151 151 show=show)
152 152
153 153 if xmin == None: xmin = numpy.nanmin(x)
154 154 if xmax == None: xmax = numpy.nanmax(x)
155 155 if ymin == None: ymin = numpy.nanmin(y)
156 156 if ymax == None: ymax = numpy.nanmax(y)
157 157 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
158 158 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
159 159
160 160 self.FTP_WEI = ftp_wei
161 161 self.EXP_CODE = exp_code
162 162 self.SUB_EXP_CODE = sub_exp_code
163 163 self.PLOT_POS = plot_pos
164 164
165 165 self.isConfig = True
166 166
167 167 self.setWinTitle(title)
168 168
169 169 for i in range(self.nplots):
170 170 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
171 171 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i]+1, noisedB[i], str_datetime)
172 172 if len(dataOut.beam.codeList) != 0:
173 173 title = "Ch%d:%4.2fdB,%2.2f,%2.2f:%s" %(dataOut.channelList[i]+1, noisedB[i], dataOut.beam.azimuthList[i], dataOut.beam.zenithList[i], str_datetime)
174 174
175 175 axes = self.axesList[i*self.__nsubplots]
176 176 axes.pcolor(x, y, zdB[i,:,:],
177 177 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
178 178 xlabel=xlabel, ylabel=ylabel, title=title,
179 179 ticksize=9, cblabel='')
180 180
181 181 if self.__showprofile:
182 182 axes = self.axesList[i*self.__nsubplots +1]
183 183 axes.pline(avgdB[i,:], y,
184 184 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
185 185 xlabel='dB', ylabel='', title='',
186 186 ytick_visible=False,
187 187 grid='x')
188 188
189 189 noiseline = numpy.repeat(noisedB[i], len(y))
190 190 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
191 191
192 192 self.draw()
193 193
194 194 if figfile == None:
195 195 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
196 196 name = str_datetime
197 197 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
198 198 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
199 199 figfile = self.getFilename(name)
200 200
201 201 self.save(figpath=figpath,
202 202 figfile=figfile,
203 203 save=save,
204 204 ftp=ftp,
205 205 wr_period=wr_period,
206 206 thisDatetime=thisDatetime)
207 207
208 208 class CrossSpectraPlot(Figure):
209 209
210 210 isConfig = None
211 211 __nsubplots = None
212 212
213 213 WIDTH = None
214 214 HEIGHT = None
215 215 WIDTHPROF = None
216 216 HEIGHTPROF = None
217 217 PREFIX = 'cspc'
218 218
219 219 def __init__(self):
220 220
221 221 self.isConfig = False
222 222 self.__nsubplots = 4
223 223 self.counter_imagwr = 0
224 224 self.WIDTH = 250
225 225 self.HEIGHT = 250
226 226 self.WIDTHPROF = 0
227 227 self.HEIGHTPROF = 0
228 228
229 229 self.PLOT_CODE = CROSS_CODE
230 230 self.FTP_WEI = None
231 231 self.EXP_CODE = None
232 232 self.SUB_EXP_CODE = None
233 233 self.PLOT_POS = None
234 234
235 235 def getSubplots(self):
236 236
237 237 ncol = 4
238 238 nrow = self.nplots
239 239
240 240 return nrow, ncol
241 241
242 242 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
243 243
244 244 self.__showprofile = showprofile
245 245 self.nplots = nplots
246 246
247 247 ncolspan = 1
248 248 colspan = 1
249 249
250 250 self.createFigure(id = id,
251 251 wintitle = wintitle,
252 252 widthplot = self.WIDTH + self.WIDTHPROF,
253 253 heightplot = self.HEIGHT + self.HEIGHTPROF,
254 254 show=True)
255 255
256 256 nrow, ncol = self.getSubplots()
257 257
258 258 counter = 0
259 259 for y in range(nrow):
260 260 for x in range(ncol):
261 261 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
262 262
263 263 counter += 1
264 264
265 265 def run(self, dataOut, id, wintitle="", pairsList=None,
266 266 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
267 coh_min=None, coh_max=None, phase_min=None, phase_max=None,
267 268 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
268 269 power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
269 270 server=None, folder=None, username=None, password=None,
270 271 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
271 272
272 273 """
273 274
274 275 Input:
275 276 dataOut :
276 277 id :
277 278 wintitle :
278 279 channelList :
279 280 showProfile :
280 281 xmin : None,
281 282 xmax : None,
282 283 ymin : None,
283 284 ymax : None,
284 285 zmin : None,
285 286 zmax : None
286 287 """
287 288
288 289 if pairsList == None:
289 290 pairsIndexList = dataOut.pairsIndexList
290 291 else:
291 292 pairsIndexList = []
292 293 for pair in pairsList:
293 294 if pair not in dataOut.pairsList:
294 295 raise ValueError, "Pair %s is not in dataOut.pairsList" %str(pair)
295 296 pairsIndexList.append(dataOut.pairsList.index(pair))
296 297
297 298 if not pairsIndexList:
298 299 return
299 300
300 301 if len(pairsIndexList) > 4:
301 302 pairsIndexList = pairsIndexList[0:4]
302 303
303 304 factor = dataOut.normFactor
304 305 x = dataOut.getVelRange(1)
305 306 y = dataOut.getHeiRange()
306 307 z = dataOut.data_spc[:,:,:]/factor
307 308 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
308 309
309 310 noise = dataOut.noise/factor
310 311
311 312 zdB = 10*numpy.log10(z)
312 313 noisedB = 10*numpy.log10(noise)
313 314
315 if coh_min == None:
316 coh_min = 0.0
317 if coh_max == None:
318 coh_max = 1.0
319
320 if phase_min == None:
321 phase_min = -180
322 if phase_max == None:
323 phase_max = 180
314 324
315 325 #thisDatetime = dataOut.datatime
316 326 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
317 327 title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
318 328 xlabel = "Velocity (m/s)"
319 329 ylabel = "Range (Km)"
320 330
321 331 if not self.isConfig:
322 332
323 333 nplots = len(pairsIndexList)
324 334
325 335 self.setup(id=id,
326 336 nplots=nplots,
327 337 wintitle=wintitle,
328 338 showprofile=False,
329 339 show=show)
330 340
331 341 avg = numpy.abs(numpy.average(z, axis=1))
332 342 avgdB = 10*numpy.log10(avg)
333 343
334 344 if xmin == None: xmin = numpy.nanmin(x)
335 345 if xmax == None: xmax = numpy.nanmax(x)
336 346 if ymin == None: ymin = numpy.nanmin(y)
337 347 if ymax == None: ymax = numpy.nanmax(y)
338 348 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
339 349 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
340 350
341 351 self.FTP_WEI = ftp_wei
342 352 self.EXP_CODE = exp_code
343 353 self.SUB_EXP_CODE = sub_exp_code
344 354 self.PLOT_POS = plot_pos
345 355
346 356 self.isConfig = True
347 357
348 358 self.setWinTitle(title)
349 359
350 360 for i in range(self.nplots):
351 361 pair = dataOut.pairsList[pairsIndexList[i]]
352 362 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
353 363 title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[pair[0]], str_datetime)
354 364 zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor)
355 365 axes0 = self.axesList[i*self.__nsubplots]
356 366 axes0.pcolor(x, y, zdB,
357 367 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
358 368 xlabel=xlabel, ylabel=ylabel, title=title,
359 369 ticksize=9, colormap=power_cmap, cblabel='')
360 370
361 371 title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[pair[1]], str_datetime)
362 372 zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor)
363 373 axes0 = self.axesList[i*self.__nsubplots+1]
364 374 axes0.pcolor(x, y, zdB,
365 375 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
366 376 xlabel=xlabel, ylabel=ylabel, title=title,
367 377 ticksize=9, colormap=power_cmap, cblabel='')
368 378
369 379 coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
370 380 coherence = numpy.abs(coherenceComplex)
371 381 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
372 382 phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi
373 383
374 384 title = "Coherence %d%d" %(pair[0], pair[1])
375 385 axes0 = self.axesList[i*self.__nsubplots+2]
376 386 axes0.pcolor(x, y, coherence,
377 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1,
387 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=coh_min, zmax=coh_max,
378 388 xlabel=xlabel, ylabel=ylabel, title=title,
379 389 ticksize=9, colormap=coherence_cmap, cblabel='')
380 390
381 391 title = "Phase %d%d" %(pair[0], pair[1])
382 392 axes0 = self.axesList[i*self.__nsubplots+3]
383 393 axes0.pcolor(x, y, phase,
384 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
394 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max,
385 395 xlabel=xlabel, ylabel=ylabel, title=title,
386 396 ticksize=9, colormap=phase_cmap, cblabel='')
387 397
388 398
389 399
390 400 self.draw()
391 401
392 402 self.save(figpath=figpath,
393 403 figfile=figfile,
394 404 save=save,
395 405 ftp=ftp,
396 406 wr_period=wr_period,
397 407 thisDatetime=thisDatetime)
398 408
399 409
400 410 class RTIPlot(Figure):
401 411
402 412 __isConfig = None
403 413 __nsubplots = None
404 414
405 415 WIDTHPROF = None
406 416 HEIGHTPROF = None
407 417 PREFIX = 'rti'
408 418
409 419 def __init__(self):
410 420
411 421 self.timerange = None
412 422 self.__isConfig = False
413 423 self.__nsubplots = 1
414 424
415 425 self.WIDTH = 800
416 426 self.HEIGHT = 150
417 427 self.WIDTHPROF = 120
418 428 self.HEIGHTPROF = 0
419 429 self.counter_imagwr = 0
420 430
421 431 self.PLOT_CODE = RTI_CODE
422 432
423 433 self.FTP_WEI = None
424 434 self.EXP_CODE = None
425 435 self.SUB_EXP_CODE = None
426 436 self.PLOT_POS = None
427 437 self.tmin = None
428 438 self.tmax = None
429 439
430 440 self.xmin = None
431 441 self.xmax = None
432 442
433 443 self.figfile = None
434 444
435 445 def getSubplots(self):
436 446
437 447 ncol = 1
438 448 nrow = self.nplots
439 449
440 450 return nrow, ncol
441 451
442 452 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
443 453
444 454 self.__showprofile = showprofile
445 455 self.nplots = nplots
446 456
447 457 ncolspan = 1
448 458 colspan = 1
449 459 if showprofile:
450 460 ncolspan = 7
451 461 colspan = 6
452 462 self.__nsubplots = 2
453 463
454 464 self.createFigure(id = id,
455 465 wintitle = wintitle,
456 466 widthplot = self.WIDTH + self.WIDTHPROF,
457 467 heightplot = self.HEIGHT + self.HEIGHTPROF,
458 468 show=show)
459 469
460 470 nrow, ncol = self.getSubplots()
461 471
462 472 counter = 0
463 473 for y in range(nrow):
464 474 for x in range(ncol):
465 475
466 476 if counter >= self.nplots:
467 477 break
468 478
469 479 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
470 480
471 481 if showprofile:
472 482 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
473 483
474 484 counter += 1
475 485
476 486 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
477 487 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
478 488 timerange=None,
479 489 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
480 490 server=None, folder=None, username=None, password=None,
481 491 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
482 492
483 493 """
484 494
485 495 Input:
486 496 dataOut :
487 497 id :
488 498 wintitle :
489 499 channelList :
490 500 showProfile :
491 501 xmin : None,
492 502 xmax : None,
493 503 ymin : None,
494 504 ymax : None,
495 505 zmin : None,
496 506 zmax : None
497 507 """
498 508
499 509 if channelList == None:
500 510 channelIndexList = dataOut.channelIndexList
501 511 else:
502 512 channelIndexList = []
503 513 for channel in channelList:
504 514 if channel not in dataOut.channelList:
505 515 raise ValueError, "Channel %d is not in dataOut.channelList"
506 516 channelIndexList.append(dataOut.channelList.index(channel))
507 517
508 518 # if timerange != None:
509 519 # self.timerange = timerange
510 520
511 521 #tmin = None
512 522 #tmax = None
513 523 factor = dataOut.normFactor
514 524 x = dataOut.getTimeRange()
515 525 y = dataOut.getHeiRange()
516 526
517 527 z = dataOut.data_spc[channelIndexList,:,:]/factor
518 528 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
519 529 avg = numpy.average(z, axis=1)
520 530
521 531 avgdB = 10.*numpy.log10(avg)
522 532
523 533
524 534 # thisDatetime = dataOut.datatime
525 535 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
526 536 title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
527 537 xlabel = ""
528 538 ylabel = "Range (Km)"
529 539
530 540 if not self.__isConfig:
531 541
532 542 nplots = len(channelIndexList)
533 543
534 544 self.setup(id=id,
535 545 nplots=nplots,
536 546 wintitle=wintitle,
537 547 showprofile=showprofile,
538 548 show=show)
539 549
540 550 if timerange != None:
541 551 self.timerange = timerange
542 552
543 553 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
544 554
545 555 noise = dataOut.noise/factor
546 556 noisedB = 10*numpy.log10(noise)
547 557
548 558 if ymin == None: ymin = numpy.nanmin(y)
549 559 if ymax == None: ymax = numpy.nanmax(y)
550 560 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
551 561 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
552 562
553 563 self.FTP_WEI = ftp_wei
554 564 self.EXP_CODE = exp_code
555 565 self.SUB_EXP_CODE = sub_exp_code
556 566 self.PLOT_POS = plot_pos
557 567
558 568 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
559 569 self.__isConfig = True
560 570 self.figfile = figfile
561 571
562 572 self.setWinTitle(title)
563 573
564 574 if ((self.xmax - x[1]) < (x[1]-x[0])):
565 575 x[1] = self.xmax
566 576
567 577 for i in range(self.nplots):
568 578 title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
569 579 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
570 580 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
571 581 axes = self.axesList[i*self.__nsubplots]
572 582 zdB = avgdB[i].reshape((1,-1))
573 583 axes.pcolorbuffer(x, y, zdB,
574 584 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
575 585 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
576 586 ticksize=9, cblabel='', cbsize="1%")
577 587
578 588 if self.__showprofile:
579 589 axes = self.axesList[i*self.__nsubplots +1]
580 590 axes.pline(avgdB[i], y,
581 591 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
582 592 xlabel='dB', ylabel='', title='',
583 593 ytick_visible=False,
584 594 grid='x')
585 595
586 596 self.draw()
587 597
588 598 if x[1] >= self.axesList[0].xmax:
589 599 self.counter_imagwr = wr_period
590 600 self.__isConfig = False
591 601 self.figfile = None
592 602
593 603 self.save(figpath=figpath,
594 604 figfile=figfile,
595 605 save=save,
596 606 ftp=ftp,
597 607 wr_period=wr_period,
598 608 thisDatetime=thisDatetime,
599 609 update_figfile=False)
600 610
601 611 class CoherenceMap(Figure):
602 612 isConfig = None
603 613 __nsubplots = None
604 614
605 615 WIDTHPROF = None
606 616 HEIGHTPROF = None
607 617 PREFIX = 'cmap'
608 618
609 619 def __init__(self):
610 620 self.timerange = 2*60*60
611 621 self.isConfig = False
612 622 self.__nsubplots = 1
613 623
614 624 self.WIDTH = 800
615 625 self.HEIGHT = 150
616 626 self.WIDTHPROF = 120
617 627 self.HEIGHTPROF = 0
618 628 self.counter_imagwr = 0
619 629
620 630 self.PLOT_CODE = COH_CODE
621 631
622 632 self.FTP_WEI = None
623 633 self.EXP_CODE = None
624 634 self.SUB_EXP_CODE = None
625 635 self.PLOT_POS = None
626 636 self.counter_imagwr = 0
627 637
628 638 self.xmin = None
629 639 self.xmax = None
630 640
631 641 def getSubplots(self):
632 642 ncol = 1
633 643 nrow = self.nplots*2
634 644
635 645 return nrow, ncol
636 646
637 647 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
638 648 self.__showprofile = showprofile
639 649 self.nplots = nplots
640 650
641 651 ncolspan = 1
642 652 colspan = 1
643 653 if showprofile:
644 654 ncolspan = 7
645 655 colspan = 6
646 656 self.__nsubplots = 2
647 657
648 658 self.createFigure(id = id,
649 659 wintitle = wintitle,
650 660 widthplot = self.WIDTH + self.WIDTHPROF,
651 661 heightplot = self.HEIGHT + self.HEIGHTPROF,
652 662 show=True)
653 663
654 664 nrow, ncol = self.getSubplots()
655 665
656 666 for y in range(nrow):
657 667 for x in range(ncol):
658 668
659 669 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
660 670
661 671 if showprofile:
662 672 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
663 673
664 674 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
665 675 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
666 676 timerange=None,
667 677 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
668 678 coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
669 679 server=None, folder=None, username=None, password=None,
670 680 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
671 681
672 682 if pairsList == None:
673 683 pairsIndexList = dataOut.pairsIndexList
674 684 else:
675 685 pairsIndexList = []
676 686 for pair in pairsList:
677 687 if pair not in dataOut.pairsList:
678 688 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
679 689 pairsIndexList.append(dataOut.pairsList.index(pair))
680 690
681 691 if pairsIndexList == []:
682 692 return
683 693
684 694 if len(pairsIndexList) > 4:
685 695 pairsIndexList = pairsIndexList[0:4]
686 696
687 697 # tmin = None
688 698 # tmax = None
689 699 x = dataOut.getTimeRange()
690 700 y = dataOut.getHeiRange()
691 701
692 702 #thisDatetime = dataOut.datatime
693 703 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
694 704 title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
695 705 xlabel = ""
696 706 ylabel = "Range (Km)"
697 707
698 708 if not self.isConfig:
699 709 nplots = len(pairsIndexList)
700 710 self.setup(id=id,
701 711 nplots=nplots,
702 712 wintitle=wintitle,
703 713 showprofile=showprofile,
704 714 show=show)
705 715
706 716 if timerange != None:
707 717 self.timerange = timerange
708 718
709 719 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
710 720
711 721 if ymin == None: ymin = numpy.nanmin(y)
712 722 if ymax == None: ymax = numpy.nanmax(y)
713 723 if zmin == None: zmin = 0.
714 724 if zmax == None: zmax = 1.
715 725
716 726 self.FTP_WEI = ftp_wei
717 727 self.EXP_CODE = exp_code
718 728 self.SUB_EXP_CODE = sub_exp_code
719 729 self.PLOT_POS = plot_pos
720 730
721 731 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
722 732
723 733 self.isConfig = True
724 734
725 735 self.setWinTitle(title)
726 736
727 737 if ((self.xmax - x[1]) < (x[1]-x[0])):
728 738 x[1] = self.xmax
729 739
730 740 for i in range(self.nplots):
731 741
732 742 pair = dataOut.pairsList[pairsIndexList[i]]
733 743
734 744 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
735 745 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
736 746 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
737 747
738 748
739 749 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
740 750 coherence = numpy.abs(avgcoherenceComplex)
741 751
742 752 z = coherence.reshape((1,-1))
743 753
744 754 counter = 0
745 755
746 756 title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
747 757 axes = self.axesList[i*self.__nsubplots*2]
748 758 axes.pcolorbuffer(x, y, z,
749 759 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
750 760 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
751 761 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
752 762
753 763 if self.__showprofile:
754 764 counter += 1
755 765 axes = self.axesList[i*self.__nsubplots*2 + counter]
756 766 axes.pline(coherence, y,
757 767 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
758 768 xlabel='', ylabel='', title='', ticksize=7,
759 769 ytick_visible=False, nxticks=5,
760 770 grid='x')
761 771
762 772 counter += 1
763 773
764 774 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
765 775
766 776 z = phase.reshape((1,-1))
767 777
768 778 title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
769 779 axes = self.axesList[i*self.__nsubplots*2 + counter]
770 780 axes.pcolorbuffer(x, y, z,
771 781 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
772 782 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
773 783 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
774 784
775 785 if self.__showprofile:
776 786 counter += 1
777 787 axes = self.axesList[i*self.__nsubplots*2 + counter]
778 788 axes.pline(phase, y,
779 789 xmin=-180, xmax=180, ymin=ymin, ymax=ymax,
780 790 xlabel='', ylabel='', title='', ticksize=7,
781 791 ytick_visible=False, nxticks=4,
782 792 grid='x')
783 793
784 794 self.draw()
785 795
786 796 if x[1] >= self.axesList[0].xmax:
787 797 self.counter_imagwr = wr_period
788 798 self.__isConfig = False
789 799 self.figfile = None
790 800
791 801 self.save(figpath=figpath,
792 802 figfile=figfile,
793 803 save=save,
794 804 ftp=ftp,
795 805 wr_period=wr_period,
796 806 thisDatetime=thisDatetime,
797 807 update_figfile=False)
798 808
799 809 class PowerProfilePlot(Figure):
800 810
801 811 isConfig = None
802 812 __nsubplots = None
803 813
804 814 WIDTHPROF = None
805 815 HEIGHTPROF = None
806 816 PREFIX = 'spcprofile'
807 817
808 818 def __init__(self):
809 819 self.isConfig = False
810 820 self.__nsubplots = 1
811 821
812 822 self.PLOT_CODE = POWER_CODE
813 823
814 824 self.WIDTH = 300
815 825 self.HEIGHT = 500
816 826 self.counter_imagwr = 0
817 827
818 828 def getSubplots(self):
819 829 ncol = 1
820 830 nrow = 1
821 831
822 832 return nrow, ncol
823 833
824 834 def setup(self, id, nplots, wintitle, show):
825 835
826 836 self.nplots = nplots
827 837
828 838 ncolspan = 1
829 839 colspan = 1
830 840
831 841 self.createFigure(id = id,
832 842 wintitle = wintitle,
833 843 widthplot = self.WIDTH,
834 844 heightplot = self.HEIGHT,
835 845 show=show)
836 846
837 847 nrow, ncol = self.getSubplots()
838 848
839 849 counter = 0
840 850 for y in range(nrow):
841 851 for x in range(ncol):
842 852 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
843 853
844 854 def run(self, dataOut, id, wintitle="", channelList=None,
845 855 xmin=None, xmax=None, ymin=None, ymax=None,
846 856 save=False, figpath='./', figfile=None, show=True,
847 857 ftp=False, wr_period=1, server=None,
848 858 folder=None, username=None, password=None):
849 859
850 860
851 861 if channelList == None:
852 862 channelIndexList = dataOut.channelIndexList
853 863 channelList = dataOut.channelList
854 864 else:
855 865 channelIndexList = []
856 866 for channel in channelList:
857 867 if channel not in dataOut.channelList:
858 868 raise ValueError, "Channel %d is not in dataOut.channelList"
859 869 channelIndexList.append(dataOut.channelList.index(channel))
860 870
861 871 factor = dataOut.normFactor
862 872
863 873 y = dataOut.getHeiRange()
864 874
865 875 #for voltage
866 876 if dataOut.type == 'Voltage':
867 877 x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
868 878 x = x.real
869 879 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
870 880
871 881 #for spectra
872 882 if dataOut.type == 'Spectra':
873 883 x = dataOut.data_spc[channelIndexList,:,:]/factor
874 884 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
875 885 x = numpy.average(x, axis=1)
876 886
877 887
878 888 xdB = 10*numpy.log10(x)
879 889
880 890 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
881 891 title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y"))
882 892 xlabel = "dB"
883 893 ylabel = "Range (Km)"
884 894
885 895 if not self.isConfig:
886 896
887 897 nplots = 1
888 898
889 899 self.setup(id=id,
890 900 nplots=nplots,
891 901 wintitle=wintitle,
892 902 show=show)
893 903
894 904 if ymin == None: ymin = numpy.nanmin(y)
895 905 if ymax == None: ymax = numpy.nanmax(y)
896 906 if xmin == None: xmin = numpy.nanmin(xdB)*0.9
897 907 if xmax == None: xmax = numpy.nanmax(xdB)*1.1
898 908
899 909 self.__isConfig = True
900 910
901 911 self.setWinTitle(title)
902 912
903 913 title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
904 914 axes = self.axesList[0]
905 915
906 916 legendlabels = ["channel %d"%x for x in channelList]
907 917 axes.pmultiline(xdB, y,
908 918 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
909 919 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
910 920 ytick_visible=True, nxticks=5,
911 921 grid='x')
912 922
913 923 self.draw()
914 924
915 925 self.save(figpath=figpath,
916 926 figfile=figfile,
917 927 save=save,
918 928 ftp=ftp,
919 929 wr_period=wr_period,
920 930 thisDatetime=thisDatetime)
921 931
922 932 class Noise(Figure):
923 933
924 934 isConfig = None
925 935 __nsubplots = None
926 936
927 937 PREFIX = 'noise'
928 938
929 939 def __init__(self):
930 940
931 941 self.timerange = 24*60*60
932 942 self.isConfig = False
933 943 self.__nsubplots = 1
934 944 self.counter_imagwr = 0
935 945 self.WIDTH = 600
936 946 self.HEIGHT = 300
937 947 self.WIDTHPROF = 120
938 948 self.HEIGHTPROF = 0
939 949 self.xdata = None
940 950 self.ydata = None
941 951
942 952 self.PLOT_CODE = NOISE_CODE
943 953
944 954 self.FTP_WEI = None
945 955 self.EXP_CODE = None
946 956 self.SUB_EXP_CODE = None
947 957 self.PLOT_POS = None
948 958 self.figfile = None
949 959
950 960 self.xmin = None
951 961 self.xmax = None
952 962
953 963 def getSubplots(self):
954 964
955 965 ncol = 1
956 966 nrow = 1
957 967
958 968 return nrow, ncol
959 969
960 970 def openfile(self, filename):
961 971 dirname = os.path.dirname(filename)
962 972
963 973 if not os.path.exists(dirname):
964 974 os.mkdir(dirname)
965 975
966 976 f = open(filename,'w+')
967 977 f.write('\n\n')
968 978 f.write('JICAMARCA RADIO OBSERVATORY - Noise \n')
969 979 f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' )
970 980 f.close()
971 981
972 982 def save_data(self, filename_phase, data, data_datetime):
973 983 f=open(filename_phase,'a')
974 984 timetuple_data = data_datetime.timetuple()
975 985 day = str(timetuple_data.tm_mday)
976 986 month = str(timetuple_data.tm_mon)
977 987 year = str(timetuple_data.tm_year)
978 988 hour = str(timetuple_data.tm_hour)
979 989 minute = str(timetuple_data.tm_min)
980 990 second = str(timetuple_data.tm_sec)
981 991
982 992 data_msg = ''
983 993 for i in range(len(data)):
984 994 data_msg += str(data[i]) + ' '
985 995
986 996 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' ' + data_msg + '\n')
987 997 f.close()
988 998
989 999
990 1000 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
991 1001
992 1002 self.__showprofile = showprofile
993 1003 self.nplots = nplots
994 1004
995 1005 ncolspan = 7
996 1006 colspan = 6
997 1007 self.__nsubplots = 2
998 1008
999 1009 self.createFigure(id = id,
1000 1010 wintitle = wintitle,
1001 1011 widthplot = self.WIDTH+self.WIDTHPROF,
1002 1012 heightplot = self.HEIGHT+self.HEIGHTPROF,
1003 1013 show=show)
1004 1014
1005 1015 nrow, ncol = self.getSubplots()
1006 1016
1007 1017 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1008 1018
1009 1019
1010 1020 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
1011 1021 xmin=None, xmax=None, ymin=None, ymax=None,
1012 1022 timerange=None,
1013 1023 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1014 1024 server=None, folder=None, username=None, password=None,
1015 1025 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1016 1026
1017 1027 if channelList == None:
1018 1028 channelIndexList = dataOut.channelIndexList
1019 1029 channelList = dataOut.channelList
1020 1030 else:
1021 1031 channelIndexList = []
1022 1032 for channel in channelList:
1023 1033 if channel not in dataOut.channelList:
1024 1034 raise ValueError, "Channel %d is not in dataOut.channelList"
1025 1035 channelIndexList.append(dataOut.channelList.index(channel))
1026 1036
1027 1037 x = dataOut.getTimeRange()
1028 1038 #y = dataOut.getHeiRange()
1029 1039 factor = dataOut.normFactor
1030 1040 noise = dataOut.noise/factor
1031 1041 noisedB = 10*numpy.log10(noise)
1032 1042
1033 1043 #thisDatetime = dataOut.datatime
1034 1044 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1035 1045 title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1036 1046 xlabel = ""
1037 1047 ylabel = "Intensity (dB)"
1038 1048
1039 1049 if not self.isConfig:
1040 1050
1041 1051 nplots = 1
1042 1052
1043 1053 self.setup(id=id,
1044 1054 nplots=nplots,
1045 1055 wintitle=wintitle,
1046 1056 showprofile=showprofile,
1047 1057 show=show)
1048 1058
1049 1059 if timerange != None:
1050 1060 self.timerange = timerange
1051 1061
1052 1062 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1053 1063
1054 1064 if ymin == None: ymin = numpy.floor(numpy.nanmin(noisedB)) - 10.0
1055 1065 if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0
1056 1066
1057 1067 self.FTP_WEI = ftp_wei
1058 1068 self.EXP_CODE = exp_code
1059 1069 self.SUB_EXP_CODE = sub_exp_code
1060 1070 self.PLOT_POS = plot_pos
1061 1071
1062 1072
1063 1073 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1064 1074 self.isConfig = True
1065 1075 self.figfile = figfile
1066 1076 self.xdata = numpy.array([])
1067 1077 self.ydata = numpy.array([])
1068 1078
1069 1079 #open file beacon phase
1070 1080 path = '%s%03d' %(self.PREFIX, self.id)
1071 1081 noise_file = os.path.join(path,'%s.txt'%self.name)
1072 1082 self.filename_noise = os.path.join(figpath,noise_file)
1073 1083 if save:
1074 1084 self.openfile(self.filename_noise)
1075 1085
1076 1086
1077 1087 #store data beacon phase
1078 1088 if save:
1079 1089 self.save_data(self.filename_noise, noisedB, thisDatetime)
1080 1090
1081 1091
1082 1092 self.setWinTitle(title)
1083 1093
1084 1094
1085 1095 title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1086 1096
1087 1097 legendlabels = ["channel %d"%(idchannel+1) for idchannel in channelList]
1088 1098 axes = self.axesList[0]
1089 1099
1090 1100 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1091 1101
1092 1102 if len(self.ydata)==0:
1093 1103 self.ydata = noisedB[channelIndexList].reshape(-1,1)
1094 1104 else:
1095 1105 self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1)))
1096 1106
1097 1107
1098 1108 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1099 1109 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1100 1110 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1101 1111 XAxisAsTime=True, grid='both'
1102 1112 )
1103 1113
1104 1114 self.draw()
1105 1115
1106 1116 if x[1] >= self.axesList[0].xmax:
1107 1117 self.counter_imagwr = wr_period
1108 1118 del self.xdata
1109 1119 del self.ydata
1110 1120 self.__isConfig = False
1111 1121 self.figfile = None
1112 1122
1113 1123 self.save(figpath=figpath,
1114 1124 figfile=figfile,
1115 1125 save=save,
1116 1126 ftp=ftp,
1117 1127 wr_period=wr_period,
1118 1128 thisDatetime=thisDatetime,
1119 1129 update_figfile=False)
1120 1130
1121 1131
1122 1132 class BeaconPhase(Figure):
1123 1133
1124 1134 __isConfig = None
1125 1135 __nsubplots = None
1126 1136
1127 1137 PREFIX = 'beacon_phase'
1128 1138
1129 1139 def __init__(self):
1130 1140
1131 1141 self.timerange = 24*60*60
1132 1142 self.__isConfig = False
1133 1143 self.__nsubplots = 1
1134 1144 self.counter_imagwr = 0
1135 1145 self.WIDTH = 600
1136 1146 self.HEIGHT = 300
1137 1147 self.WIDTHPROF = 120
1138 1148 self.HEIGHTPROF = 0
1139 1149 self.xdata = None
1140 1150 self.ydata = None
1141 1151
1142 1152 self.PLOT_CODE = BEACON_CODE
1143 1153
1144 1154 self.FTP_WEI = None
1145 1155 self.EXP_CODE = None
1146 1156 self.SUB_EXP_CODE = None
1147 1157 self.PLOT_POS = None
1148 1158
1149 1159 self.filename_phase = None
1150 1160
1151 1161 self.figfile = None
1152 1162
1153 1163 self.xmin = None
1154 1164 self.xmax = None
1155 1165
1156 1166 def getSubplots(self):
1157 1167
1158 1168 ncol = 1
1159 1169 nrow = 1
1160 1170
1161 1171 return nrow, ncol
1162 1172
1163 1173 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1164 1174
1165 1175 self.__showprofile = showprofile
1166 1176 self.nplots = nplots
1167 1177
1168 1178 ncolspan = 7
1169 1179 colspan = 6
1170 1180 self.__nsubplots = 2
1171 1181
1172 1182 self.createFigure(id = id,
1173 1183 wintitle = wintitle,
1174 1184 widthplot = self.WIDTH+self.WIDTHPROF,
1175 1185 heightplot = self.HEIGHT+self.HEIGHTPROF,
1176 1186 show=show)
1177 1187
1178 1188 nrow, ncol = self.getSubplots()
1179 1189
1180 1190 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1181 1191
1182 1192 def save_phase(self, filename_phase):
1183 1193 f = open(filename_phase,'w+')
1184 1194 f.write('\n\n')
1185 1195 f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n')
1186 1196 f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' )
1187 1197 f.close()
1188 1198
1189 1199 def save_data(self, filename_phase, data, data_datetime):
1190 1200 f=open(filename_phase,'a')
1191 1201 timetuple_data = data_datetime.timetuple()
1192 1202 day = str(timetuple_data.tm_mday)
1193 1203 month = str(timetuple_data.tm_mon)
1194 1204 year = str(timetuple_data.tm_year)
1195 1205 hour = str(timetuple_data.tm_hour)
1196 1206 minute = str(timetuple_data.tm_min)
1197 1207 second = str(timetuple_data.tm_sec)
1198 1208 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n')
1199 1209 f.close()
1200 1210
1201 1211
1202 1212 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1203 1213 xmin=None, xmax=None, ymin=None, ymax=None,
1204 1214 timerange=None,
1205 1215 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1206 1216 server=None, folder=None, username=None, password=None,
1207 1217 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1208 1218
1209 1219 if pairsList == None:
1210 1220 pairsIndexList = dataOut.pairsIndexList
1211 1221 else:
1212 1222 pairsIndexList = []
1213 1223 for pair in pairsList:
1214 1224 if pair not in dataOut.pairsList:
1215 1225 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
1216 1226 pairsIndexList.append(dataOut.pairsList.index(pair))
1217 1227
1218 1228 if pairsIndexList == []:
1219 1229 return
1220 1230
1221 1231 # if len(pairsIndexList) > 4:
1222 1232 # pairsIndexList = pairsIndexList[0:4]
1223 1233
1224 1234 x = dataOut.getTimeRange()
1225 1235 #y = dataOut.getHeiRange()
1226 1236
1227 1237
1228 1238 #thisDatetime = dataOut.datatime
1229 1239 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1230 1240 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1231 1241 xlabel = "Local Time"
1232 1242 ylabel = "Phase"
1233 1243
1234 1244 nplots = len(pairsIndexList)
1235 1245 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1236 1246 phase_beacon = numpy.zeros(len(pairsIndexList))
1237 1247 for i in range(nplots):
1238 1248 pair = dataOut.pairsList[pairsIndexList[i]]
1239 1249 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
1240 1250 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
1241 1251 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
1242 1252 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
1243 1253 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
1244 1254
1245 1255 #print "Phase %d%d" %(pair[0], pair[1])
1246 1256 #print phase[dataOut.beacon_heiIndexList]
1247 1257
1248 1258 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1249 1259
1250 1260 if not self.__isConfig:
1251 1261
1252 1262 nplots = len(pairsIndexList)
1253 1263
1254 1264 self.setup(id=id,
1255 1265 nplots=nplots,
1256 1266 wintitle=wintitle,
1257 1267 showprofile=showprofile,
1258 1268 show=show)
1259 1269
1260 1270 if timerange != None:
1261 1271 self.timerange = timerange
1262 1272
1263 1273 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1264 1274
1265 1275 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1266 1276 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1267 1277
1268 1278 self.FTP_WEI = ftp_wei
1269 1279 self.EXP_CODE = exp_code
1270 1280 self.SUB_EXP_CODE = sub_exp_code
1271 1281 self.PLOT_POS = plot_pos
1272 1282
1273 1283 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1274 1284 self.__isConfig = True
1275 1285 self.figfile = figfile
1276 1286 self.xdata = numpy.array([])
1277 1287 self.ydata = numpy.array([])
1278 1288
1279 1289 #open file beacon phase
1280 1290 path = '%s%03d' %(self.PREFIX, self.id)
1281 1291 beacon_file = os.path.join(path,'%s.txt'%self.name)
1282 1292 self.filename_phase = os.path.join(figpath,beacon_file)
1283 1293 #self.save_phase(self.filename_phase)
1284 1294
1285 1295
1286 1296 #store data beacon phase
1287 1297 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1288 1298
1289 1299 self.setWinTitle(title)
1290 1300
1291 1301
1292 1302 title = "Beacon Signal %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1293 1303
1294 1304 legendlabels = ["pairs %d%d"%(pair[0], pair[1]) for pair in dataOut.pairsList]
1295 1305
1296 1306 axes = self.axesList[0]
1297 1307
1298 1308 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1299 1309
1300 1310 if len(self.ydata)==0:
1301 1311 self.ydata = phase_beacon.reshape(-1,1)
1302 1312 else:
1303 1313 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1304 1314
1305 1315
1306 1316 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1307 1317 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1308 1318 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1309 1319 XAxisAsTime=True, grid='both'
1310 1320 )
1311 1321
1312 1322 self.draw()
1313 1323
1314 1324 if x[1] >= self.axesList[0].xmax:
1315 1325 self.counter_imagwr = wr_period
1316 1326 del self.xdata
1317 1327 del self.ydata
1318 1328 self.__isConfig = False
1319 1329 self.figfile = None
1320 1330
1321 1331 self.save(figpath=figpath,
1322 1332 figfile=figfile,
1323 1333 save=save,
1324 1334 ftp=ftp,
1325 1335 wr_period=wr_period,
1326 1336 thisDatetime=thisDatetime,
1327 1337 update_figfile=False)
@@ -1,580 +1,581
1 1 '''
2 2 Created on Jul 3, 2014
3 3
4 4 @author: roj-idl71
5 5 '''
6 6 import datetime
7 7 import numpy
8 8
9 9 try:
10 10 from gevent import sleep
11 11 except:
12 12 from time import sleep
13 13
14 14 from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader
15 15 from schainpy.model.data.jrodata import Voltage
16 16 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
17 17
18 18 try:
19 19 import digital_rf_hdf5
20 20 except:
21 21 print 'You should install "digital_rf_hdf5" module if you want to read USRP data'
22 22
23 23 class USRPReader(ProcessingUnit):
24 24 '''
25 25 classdocs
26 26 '''
27 27
28 28 def __init__(self):
29 29 '''
30 30 Constructor
31 31 '''
32 32
33 33 ProcessingUnit.__init__(self)
34 34
35 35 self.dataOut = Voltage()
36 36 self.__printInfo = True
37 37 self.__flagDiscontinuousBlock = False
38 38 self.__bufferIndex = 9999999
39 39
40 40 self.__ippKm = None
41 41 self.__codeType = 0
42 42 self.__nCode = None
43 43 self.__nBaud = None
44 44 self.__code = None
45 45
46 46 def __getCurrentSecond(self):
47 47
48 48 return self.__thisUnixSample/self.__sample_rate
49 49
50 50 thisSecond = property(__getCurrentSecond, "I'm the 'thisSecond' property.")
51 51
52 52 def __setFileHeader(self):
53 53 '''
54 54 In this method will be initialized every parameter of dataOut object (header, no data)
55 55 '''
56 nProfiles = self.__sample_rate #Number of profiles by second
56 57
57 58 self.dataOut.radarControllerHeaderObj = RadarControllerHeader(ippKm=self.__ippKm,
58 59 txA=0,
59 60 txB=0,
60 61 nWindows=1,
61 62 nHeights=self.__nSamples,
62 63 firstHeight=self.__firstHeigth,
63 64 deltaHeight=self.__deltaHeigth,
64 65 codeType=self.__codeType,
65 66 nCode=self.__nCode, nBaud=self.__nBaud,
66 67 code = self.__code)
67 68
68 69 self.dataOut.systemHeaderObj = SystemHeader(nSamples=self.__nSamples,
69 nProfiles=1024,
70 nProfiles=nProfiles,
70 71 nChannels=len(self.__channelList),
71 72 adcResolution=14)
72 73
73 74 self.dataOut.type = "Voltage"
74 75
75 76 self.dataOut.data = None
76 77
77 78 self.dataOut.dtype = numpy.dtype([('real','<i8'),('imag','<i8')])
78 79
79 80 # self.dataOut.nChannels = 0
80 81
81 82 # self.dataOut.nHeights = 0
82 83
83 self.dataOut.nProfiles = 1
84 self.dataOut.nProfiles = nProfiles
84 85
85 86 self.dataOut.heightList = self.__firstHeigth + numpy.arange(self.__nSamples, dtype = numpy.float)*self.__deltaHeigth
86 87
87 88 self.dataOut.channelList = self.__channelList
88 89
89 90 self.dataOut.blocksize = self.dataOut.getNChannels() * self.dataOut.getNHeights()
90 91
91 92 # self.dataOut.channelIndexList = None
92 93
93 94 self.dataOut.flagNoData = True
94 95
95 96 #Set to TRUE if the data is discontinuous
96 97 self.dataOut.flagDiscontinuousBlock = False
97 98
98 99 self.dataOut.utctime = None
99 100
100 101 self.dataOut.timeZone = self.__timezone/60 #timezone like jroheader, difference in minutes between UTC and localtime
101 102
102 103 self.dataOut.dstFlag = 0
103 104
104 105 self.dataOut.errorCount = 0
105 106
106 107 self.dataOut.nCohInt = 1
107 108
108 109 self.dataOut.flagDecodeData = False #asumo que la data esta decodificada
109 110
110 111 self.dataOut.flagDeflipData = False #asumo que la data esta sin flip
111 112
112 113 self.dataOut.flagShiftFFT = False
113 114
114 115 self.dataOut.ippSeconds = 1.0*self.__nSamples/self.__sample_rate
115 116
116 117 #Time interval between profiles
117 118 #self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt
118 119
119 120 self.dataOut.frequency = self.__frequency
120 121
121 122 self.dataOut.realtime = self.__online
122 123
123 124 def findDatafiles(self, path, startDate=None, endDate=None):
124 125
125 126 try:
126 127 digitalReadObj = digital_rf_hdf5.read_hdf5(path, load_all_metadata=True)
127 128 except:
128 129 digitalReadObj = digital_rf_hdf5.read_hdf5(path)
129 130
130 131 channelNameList = digitalReadObj.get_channels()
131 132
132 133 if not channelNameList:
133 134 return []
134 135
135 136 metadata_dict = digitalReadObj.get_rf_file_metadata(channelNameList[0])
136 137
137 138 sample_rate = metadata_dict['sample_rate'][0]
138 139
139 140 this_metadata_file = digitalReadObj.get_metadata(channelNameList[0])
140 141
141 142 try:
142 143 timezone = this_metadata_file['timezone'].value
143 144 except:
144 145 timezone = 0
145 146
146 147 startUTCSecond, endUTCSecond = digitalReadObj.get_bounds(channelNameList[0])/sample_rate - timezone
147 148
148 149 startDatetime = datetime.datetime.utcfromtimestamp(startUTCSecond)
149 150 endDatatime = datetime.datetime.utcfromtimestamp(endUTCSecond)
150 151
151 152 if not startDate:
152 153 startDate = startDatetime.date()
153 154
154 155 if not endDate:
155 156 endDate = endDatatime.date()
156 157
157 158 dateList = []
158 159
159 160 thisDatetime = startDatetime
160 161
161 162 while(thisDatetime<=endDatatime):
162 163
163 164 thisDate = thisDatetime.date()
164 165
165 166 if thisDate < startDate:
166 167 continue
167 168
168 169 if thisDate > endDate:
169 170 break
170 171
171 172 dateList.append(thisDate)
172 173 thisDatetime += datetime.timedelta(1)
173 174
174 175 return dateList
175 176
176 177 def setup(self, path = None,
177 178 startDate = None,
178 179 endDate = None,
179 180 startTime = datetime.time(0,0,0),
180 181 endTime = datetime.time(23,59,59),
181 182 channelList = None,
182 183 nSamples = None,
183 184 ippKm = 60,
184 185 online = False,
185 186 delay = 60,
186 187 buffer_size = None,
187 188 nbuffer = 1024,
188 189 **kwargs):
189 190 '''
190 191 In this method we should set all initial parameters.
191 192
192 193 Inputs:
193 194 path
194 195 startDate
195 196 endDate
196 197 startTime
197 198 endTime
198 199 set
199 200 expLabel
200 201 ext
201 202 online
202 203 delay
203 204 '''
204 205
205 206 if not buffer_size:
206 207 buffer_size = nbuffer
207 208
208 209 try:
209 210 self.digitalReadObj = digital_rf_hdf5.read_hdf5(path, load_all_metadata=True)
210 211 except:
211 212 self.digitalReadObj = digital_rf_hdf5.read_hdf5(path)
212 213
213 214 channelNameList = self.digitalReadObj.get_channels()
214 215
215 216 if not channelNameList:
216 217 raise IOError, "[Reading] The path doesn,t have any files .. "
217 218
218 219 if not channelList:
219 220 channelList = range(len(channelNameList))
220 221
221 222 ########## Reading metadata ######################
222 223
223 224 metadata_dict = self.digitalReadObj.get_rf_file_metadata(channelNameList[channelList[0]])
224 225
225 226 self.__sample_rate = metadata_dict['sample_rate'][0]
226 227 self.__samples_per_file = metadata_dict['samples_per_file'][0]
227 228 self.__deltaHeigth = 1e6*0.15/self.__sample_rate
228 229
229 230 this_metadata_file = self.digitalReadObj.get_metadata(channelNameList[channelList[0]])
230 231
231 232 self.__frequency = this_metadata_file['center_frequencies'].value
232 233 try:
233 234 self.__timezone = this_metadata_file['timezone'].value
234 235 except:
235 236 self.__timezone = 0
236 237
237 238 self.__firstHeigth = 0
238 239
239 240 try:
240 241 codeType = this_metadata_file['codeType'].value
241 242 except:
242 243 codeType = 0
243 244
244 245 nCode = 0
245 246 nBaud = 0
246 247 code = None
247 248
248 249 if codeType:
249 250 nCode = this_metadata_file['nCode'].value
250 251 nBaud = this_metadata_file['nBaud'].value
251 252 code = this_metadata_file['code'].value
252 253
253 254 if not ippKm:
254 255 try:
255 256 #seconds to km
256 257 ippKm = 1e6*0.15*this_metadata_file['ipp'].value
257 258 except:
258 259 ippKm = None
259 260
260 261 ####################################################
261 262 startUTCSecond = None
262 263 endUTCSecond = None
263 264
264 265 if startDate:
265 266 startDatetime = datetime.datetime.combine(startDate, startTime)
266 267 startUTCSecond = (startDatetime-datetime.datetime(1970,1,1)).total_seconds() + self.__timezone
267 268
268 269 if endDate:
269 270 endDatetime = datetime.datetime.combine(endDate, endTime)
270 271 endUTCSecond = (endDatetime-datetime.datetime(1970,1,1)).total_seconds() + self.__timezone
271 272
272 273 start_index, end_index = self.digitalReadObj.get_bounds(channelNameList[channelList[0]])
273 274
274 275 if not startUTCSecond:
275 276 startUTCSecond = start_index/self.__sample_rate
276 277
277 278 if start_index > startUTCSecond*self.__sample_rate:
278 279 startUTCSecond = start_index/self.__sample_rate
279 280
280 281 if not endUTCSecond:
281 282 endUTCSecond = end_index/self.__sample_rate
282 283
283 284 if end_index < endUTCSecond*self.__sample_rate:
284 285 endUTCSecond = end_index/self.__sample_rate
285 286
286 287 if not nSamples:
287 288 if not ippKm:
288 289 raise ValueError, "[Reading] nSamples or ippKm should be defined"
289 290
290 291 nSamples = ippKm / (1e6*0.15/self.__sample_rate)
291 292
292 293 channelBoundList = []
293 294 channelNameListFiltered = []
294 295
295 296 for thisIndexChannel in channelList:
296 297 thisChannelName = channelNameList[thisIndexChannel]
297 298 start_index, end_index = self.digitalReadObj.get_bounds(thisChannelName)
298 299 channelBoundList.append((start_index, end_index))
299 300 channelNameListFiltered.append(thisChannelName)
300 301
301 302 self.profileIndex = 0
302 303
303 304 self.__delay = delay
304 305 self.__ippKm = ippKm
305 306 self.__codeType = codeType
306 307 self.__nCode = nCode
307 308 self.__nBaud = nBaud
308 309 self.__code = code
309 310
310 311 self.__datapath = path
311 312 self.__online = online
312 313 self.__channelList = channelList
313 314 self.__channelNameList = channelNameListFiltered
314 315 self.__channelBoundList = channelBoundList
315 316 self.__nSamples = nSamples
316 317 self.__samples_to_read = buffer_size*nSamples
317 318 self.__nChannels = len(self.__channelList)
318 319
319 320 self.__startUTCSecond = startUTCSecond
320 321 self.__endUTCSecond = endUTCSecond
321 322
322 323 self.__timeInterval = 1.0 * self.__samples_to_read/self.__sample_rate #Time interval
323 324
324 325 if online:
325 326 # self.__thisUnixSample = int(endUTCSecond*self.__sample_rate - 4*self.__samples_to_read)
326 327 startUTCSecond = numpy.floor(endUTCSecond)
327 328
328 329 self.__thisUnixSample = int(startUTCSecond*self.__sample_rate) - self.__samples_to_read
329 330
330 331 self.__data_buffer = numpy.zeros((self.__nChannels, self.__samples_to_read), dtype = numpy.complex)
331 332
332 333 self.__setFileHeader()
333 334 self.isConfig = True
334 335
335 336 print "[Reading] USRP Data was found from %s to %s " %(
336 337 datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone),
337 338 datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone)
338 339 )
339 340
340 341 print "[Reading] Starting process from ", datetime.datetime.utcfromtimestamp(startUTCSecond - self.__timezone), " to ", datetime.datetime.utcfromtimestamp(endUTCSecond - self.__timezone)
341 342
342 343 def __reload(self):
343 344
344 345 if not self.__online:
345 346 return
346 347
347 348 # print
348 349 # print "%s not in range [%s, %s]" %(
349 350 # datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone),
350 351 # datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone),
351 352 # datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone)
352 353 # )
353 354 print "[Reading] reloading metadata ..."
354 355
355 356 try:
356 357 self.digitalReadObj.reload(complete_update=True)
357 358 except:
358 359 self.digitalReadObj.reload()
359 360
360 361 start_index, end_index = self.digitalReadObj.get_bounds(self.__channelNameList[self.__channelList[0]])
361 362
362 363 if start_index > self.__startUTCSecond*self.__sample_rate:
363 364 self.__startUTCSecond = 1.0*start_index/self.__sample_rate
364 365
365 366 if end_index > self.__endUTCSecond*self.__sample_rate:
366 367 self.__endUTCSecond = 1.0*end_index/self.__sample_rate
367 368 print
368 369 print "[Reading] New timerange found [%s, %s] " %(
369 370 datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone),
370 371 datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone)
371 372 )
372 373
373 374 return True
374 375
375 376 return False
376 377
377 378 def __readNextBlock(self, seconds=30, volt_scale = 218776):
378 379 '''
379 380 '''
380 381
381 382 #Set the next data
382 383 self.__flagDiscontinuousBlock = False
383 384 self.__thisUnixSample += self.__samples_to_read
384 385
385 386 if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate:
386 387 print "[Reading] There are no more data into selected timerange"
387 388
388 389 self.__reload()
389 390
390 391 if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate:
391 392 self.__thisUnixSample -= self.__samples_to_read
392 393 return False
393 394
394 395 indexChannel = 0
395 396
396 397 dataOk = False
397 398
398 399 for thisChannelName in self.__channelNameList:
399 400
400 401 try:
401 402 result = self.digitalReadObj.read_vector_c81d(self.__thisUnixSample,
402 403 self.__samples_to_read,
403 404 thisChannelName)
404 405
405 406 except IOError, e:
406 407 #read next profile
407 408 self.__flagDiscontinuousBlock = True
408 409 print e
409 410 break
410 411
411 412 if result.shape[0] != self.__samples_to_read:
412 413 self.__flagDiscontinuousBlock = True
413 414 print "[Reading] %s: Too few samples were found, just %d samples" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone),
414 415 result.shape[0])
415 416 break
416 417
417 418 self.__data_buffer[indexChannel,:] = result*volt_scale
418 419
419 420 indexChannel += 1
420 421
421 422 dataOk = True
422 423
423 424 self.__utctime = self.__thisUnixSample/self.__sample_rate
424 425
425 426 if not dataOk:
426 427 return False
427 428
428 429 print "[Reading] %s: %d samples <> %f sec" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone),
429 430 self.__samples_to_read,
430 431 self.__timeInterval)
431 432
432 433 self.__bufferIndex = 0
433 434
434 435 return True
435 436
436 437 def __isBufferEmpty(self):
437 438
438 439 if self.__bufferIndex <= self.__samples_to_read - self.__nSamples:
439 440 return False
440 441
441 442 return True
442 443
443 444 def getData(self, seconds=30, nTries=5):
444 445
445 446 '''
446 447 This method gets the data from files and put the data into the dataOut object
447 448
448 449 In addition, increase el the buffer counter in one.
449 450
450 451 Return:
451 452 data : retorna un perfil de voltages (alturas * canales) copiados desde el
452 453 buffer. Si no hay mas archivos a leer retorna None.
453 454
454 455 Affected:
455 456 self.dataOut
456 457 self.profileIndex
457 458 self.flagDiscontinuousBlock
458 459 self.flagIsNewBlock
459 460 '''
460 461
461 462 err_counter = 0
462 463 self.dataOut.flagNoData = True
463 464
464 465 if self.__isBufferEmpty():
465 466
466 467 self.__flagDiscontinuousBlock = False
467 468
468 469 while True:
469 470 if self.__readNextBlock():
470 471 break
471 472
472 473 if self.__thisUnixSample > self.__endUTCSecond*self.__sample_rate:
473 474 return False
474 475
475 476 if self.__flagDiscontinuousBlock:
476 477 print '[Reading] discontinuous block found ... continue with the next block'
477 478 continue
478 479
479 480 if not self.__online:
480 481 return False
481 482
482 483 err_counter += 1
483 484 if err_counter > nTries:
484 485 return False
485 486
486 487 print '[Reading] waiting %d seconds to read a new block' %seconds
487 488 sleep(seconds)
488 489
489 490 self.dataOut.data = self.__data_buffer[:,self.__bufferIndex:self.__bufferIndex+self.__nSamples]
490 491 self.dataOut.utctime = (self.__thisUnixSample + self.__bufferIndex)/self.__sample_rate
491 492 self.dataOut.flagNoData = False
492 493 self.dataOut.flagDiscontinuousBlock = self.__flagDiscontinuousBlock
493 494
494 495 self.__bufferIndex += self.__nSamples
495 496 self.profileIndex += 1
496 497
497 498 return True
498 499
499 500 def printInfo(self):
500 501 '''
501 502 '''
502 503 if self.__printInfo == False:
503 504 return
504 505
505 506 # self.systemHeaderObj.printInfo()
506 507 # self.radarControllerHeaderObj.printInfo()
507 508
508 509 self.__printInfo = False
509 510
510 511 def printNumberOfBlock(self):
511 512 '''
512 513 '''
513 514
514 515 print self.profileIndex
515 516
516 517 def run(self, **kwargs):
517 518 '''
518 519 This method will be called many times so here you should put all your code
519 520 '''
520 521
521 522 if not self.isConfig:
522 523 self.setup(**kwargs)
523 524
524 525 self.getData(seconds=self.__delay)
525 526
526 527 return
527 528
528 529 class USRPWriter(Operation):
529 530 '''
530 531 classdocs
531 532 '''
532 533
533 534 def __init__(self):
534 535 '''
535 536 Constructor
536 537 '''
537 538 self.dataOut = None
538 539
539 540 def setup(self, dataIn, path, blocksPerFile, set=0, ext=None):
540 541 '''
541 542 In this method we should set all initial parameters.
542 543
543 544 Input:
544 545 dataIn : Input data will also be outputa data
545 546
546 547 '''
547 548 self.dataOut = dataIn
548 549
549 550
550 551
551 552
552 553
553 554 self.isConfig = True
554 555
555 556 return
556 557
557 558 def run(self, dataIn, **kwargs):
558 559 '''
559 560 This method will be called many times so here you should put all your code
560 561
561 562 Inputs:
562 563
563 564 dataIn : object with the data
564 565
565 566 '''
566 567
567 568 if not self.isConfig:
568 569 self.setup(dataIn, **kwargs)
569 570
570 571
571 572 if __name__ == '__main__':
572 573
573 574 readObj = USRPReader()
574 575
575 576 while True:
576 577 readObj.run(path='/Volumes/DATA/haystack/passive_radar/')
577 578 # readObj.printInfo()
578 579 readObj.printNumberOfBlock()
579 580
580 581 No newline at end of file
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now