##// END OF EJS Templates
cambio para xmin
José Chávez -
r1008:3346b2da492e merge
parent child
Show More
@@ -1,131 +1,132
1 1 # Signal Chain
2 2
3 3 ## Introduction
4 4
5 5 Signal Chain (SCh) is a radar data processing library developed using [Python](www.python.org) at JRO. SCh provides modules to read, write, process and plot data.
6 6
7 7 ## Installation
8 8
9 Install system dependencies, download the latest stable release from [svn](http://jro-dev.igp.gob.pe/svn/jro_soft/schain/Releases/) e.g. schainpy-2.2.5.tar.gz. and install it as a normal python package.
9 Install system dependencies, clone the latest version from [git](http://jro-dev.igp.gob.pe/rhodecode/schain/) and install it as a normal python package.
10 10
11 11 ```
12 12 $ sudo apt-get install python-pip python-dev gfortran libpng-dev freetype* libblas-dev liblapack-dev libatlas-base-dev python-qt4 python-tk libssl-dev libhdf5-dev
13 $ tar xvzf schainpy-2.2.5.tar.gz
14 $ cd schainpy-2.2.5
13 $ sudo pip install numpy
14 $ git clone http://jro-dev.igp.gob.pe/rhodecode/schain/
15 $ cd schain
15 16 $ sudo pip install ./
16 17 ```
17 18
18 19 **Its recommended to install schain in a virtual environment**
19 20
20 21 ```
21 22 $ sudo pip install virtualenv
22 23 $ virtualenv /path/to/virtual --system-site-packages
23 24 $ source /path/to/virtual/bin/activate
24 (virtual) $ cd schainpy-2.2.5
25 (virtual) $ cd schain
25 26 (virtual) $ pip install ./
26 27 ```
27 28
28 29 ## First Script
29 30
30 31 Read Spectra data (.pdata) - remove dc - plot spectra & RTI
31 32
32 33 Import SCh and creating a project
33 34
34 35 ```python
35 36 #!/usr/bin/python
36 37
37 38 from schainpy.controller import Project
38 39
39 40 controller = Project()
40 41 controller.setup(id = '100',
41 42 name='test',
42 43 description='Basic experiment')
43 44
44 45
45 46 ```
46 47
47 48 Adding read unit and operations
48 49
49 50 ```python
50 51 read_unit = controller.addReadUnit(datatype='Spectra',
51 52 path='/path/to/pdata/',
52 53 startDate='2014/01/31',
53 54 endDate='2014/03/31',
54 55 startTime='00:00:00',
55 56 endTime='23:59:59',
56 57 online=0,
57 58 walk=0)
58 59
59 60 proc_unit = controller.addProcUnit(datatype='Spectra',
60 61 inputId=read_unit.getId())
61 62
62 63 op = proc_unit.addOperation(name='selectChannels')
63 64 op.addParameter(name='channelList', value='0,1', format='intlist')
64 65
65 66 op = proc_unit.addOperation(name='selectHeights')
66 67 op.addParameter(name='minHei', value='80', format='float')
67 68 op.addParameter(name='maxHei', value='200', format='float')
68 69
69 70 op = proc_unit.addOperation(name='removeDC')
70 71
71 72 ```
72 73
73 74 Plotting data & start project
74 75
75 76 ```python
76 77 op = proc_unit.addOperation(name='SpectraPlot', optype='other')
77 78 op.addParameter(name='id', value='1', format='int')
78 79 op.addParameter(name='wintitle', value='Spectra', format='str')
79 80
80 81 op = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
81 82 op.addParameter(name='id', value='2', format='int')
82 83 op.addParameter(name='wintitle', value='RTI', format='str')
83 84
84 85 controller.start()
85 86
86 87 ```
87 88
88 89 Full script
89 90
90 91
91 92 ```python
92 93 #!/usr/bin/python
93 94
94 95 from schainpy.controller import Project
95 96
96 97 controller = Project()
97 98 controller.setup(id = '100',
98 99 name='test',
99 100 description='Basic experiment')
100 101 read_unit = controller.addReadUnit(datatype='Spectra',
101 102 path='/path/to/pdata/',
102 103 startDate='2014/01/31',
103 104 endDate='2014/03/31',
104 105 startTime='00:00:00',
105 106 endTime='23:59:59',
106 107 online=0,
107 108 walk=0)
108 109
109 110 proc_unit = controller.addProcUnit(datatype='Spectra',
110 111 inputId=read_unit.getId())
111 112
112 113 op = proc_unit.addOperation(name='selectChannels')
113 114 op.addParameter(name='channelList', value='0,1', format='intlist')
114 115
115 116 op = proc_unit.addOperation(name='selectHeights')
116 117 op.addParameter(name='minHei', value='80', format='float')
117 118 op.addParameter(name='maxHei', value='200', format='float')
118 119
119 120 op = proc_unit.addOperation(name='removeDC')
120 121
121 122 op = proc_unit.addOperation(name='SpectraPlot', optype='other')
122 123 op.addParameter(name='id', value='6', format='int')
123 124 op.addParameter(name='wintitle', value='Spectra', format='str')
124 125
125 126 op = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
126 127 op.addParameter(name='id', value='2', format='int')
127 128 op.addParameter(name='wintitle', value='RTI', format='str')
128 129
129 130 controller.start()
130 131
131 132 ```
@@ -1,1329 +1,1333
1 1 '''
2 2 Created on September , 2012
3 3 @author:
4 4 '''
5 5
6 6 import sys
7 7 import ast
8 8 import datetime
9 9 import traceback
10 10 import math
11 11 import time
12 12 from multiprocessing import Process, Queue, cpu_count
13 13 from profilehooks import profile, coverage
14 14
15 15 import schainpy
16 16 import schainpy.admin
17 17
18 18 from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring
19 19 from xml.dom import minidom
20 20
21 21 from schainpy.model import *
22 22 from time import sleep
23 23
24 24
25 25
26 26 def prettify(elem):
27 27 """Return a pretty-printed XML string for the Element.
28 28 """
29 29 rough_string = tostring(elem, 'utf-8')
30 30 reparsed = minidom.parseString(rough_string)
31 31 return reparsed.toprettyxml(indent=" ")
32 32
33 33 def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, by_day=False):
34 34 skip = 0
35 35 cursor = 0
36 36 nFiles = None
37 37 processes = []
38 38 dt1 = datetime.datetime.strptime(startDate, '%Y/%m/%d')
39 39 dt2 = datetime.datetime.strptime(endDate, '%Y/%m/%d')
40 40 days = (dt2 - dt1).days
41 41
42 42 for day in range(days+1):
43 43 skip = 0
44 44 cursor = 0
45 45 q = Queue()
46 46 processes = []
47 47 dt = (dt1 + datetime.timedelta(day)).strftime('%Y/%m/%d')
48 48 firstProcess = Process(target=child, args=(cursor, skip, q, dt))
49 49 firstProcess.start()
50 50 if by_day:
51 51 continue
52 52 nFiles = q.get()
53 if nFiles==0:
54 continue
53 55 firstProcess.terminate()
54 56 skip = int(math.ceil(nFiles/nProcess))
55 57 while True:
56 58 processes.append(Process(target=child, args=(cursor, skip, q, dt)))
57 59 processes[cursor].start()
58 60 if nFiles < cursor*skip:
59 61 break
60 62 cursor += 1
61 63
62 64 def beforeExit(exctype, value, trace):
63 65 for process in processes:
64 66 process.terminate()
65 67 process.join()
66 68 print traceback.print_tb(trace)
67 69
68 70 sys.excepthook = beforeExit
69 71
70 72 for process in processes:
71 73 process.join()
72 74 process.terminate()
75
73 76 time.sleep(3)
74 77
78
75 79 class ParameterConf():
76 80
77 81 id = None
78 82 name = None
79 83 value = None
80 84 format = None
81 85
82 86 __formated_value = None
83 87
84 88 ELEMENTNAME = 'Parameter'
85 89
86 90 def __init__(self):
87 91
88 92 self.format = 'str'
89 93
90 94 def getElementName(self):
91 95
92 96 return self.ELEMENTNAME
93 97
94 98 def getValue(self):
95 99
96 100 value = self.value
97 101 format = self.format
98 102
99 103 if self.__formated_value != None:
100 104
101 105 return self.__formated_value
102 106
103 107 if format == 'obj':
104 108 return value
105 109
106 110 if format == 'str':
107 111 self.__formated_value = str(value)
108 112 return self.__formated_value
109 113
110 114 if value == '':
111 115 raise ValueError, "%s: This parameter value is empty" %self.name
112 116
113 117 if format == 'list':
114 118 strList = value.split(',')
115 119
116 120 self.__formated_value = strList
117 121
118 122 return self.__formated_value
119 123
120 124 if format == 'intlist':
121 125 """
122 126 Example:
123 127 value = (0,1,2)
124 128 """
125 129
126 130 new_value = ast.literal_eval(value)
127 131
128 132 if type(new_value) not in (tuple, list):
129 133 new_value = [int(new_value)]
130 134
131 135 self.__formated_value = new_value
132 136
133 137 return self.__formated_value
134 138
135 139 if format == 'floatlist':
136 140 """
137 141 Example:
138 142 value = (0.5, 1.4, 2.7)
139 143 """
140 144
141 145 new_value = ast.literal_eval(value)
142 146
143 147 if type(new_value) not in (tuple, list):
144 148 new_value = [float(new_value)]
145 149
146 150 self.__formated_value = new_value
147 151
148 152 return self.__formated_value
149 153
150 154 if format == 'date':
151 155 strList = value.split('/')
152 156 intList = [int(x) for x in strList]
153 157 date = datetime.date(intList[0], intList[1], intList[2])
154 158
155 159 self.__formated_value = date
156 160
157 161 return self.__formated_value
158 162
159 163 if format == 'time':
160 164 strList = value.split(':')
161 165 intList = [int(x) for x in strList]
162 166 time = datetime.time(intList[0], intList[1], intList[2])
163 167
164 168 self.__formated_value = time
165 169
166 170 return self.__formated_value
167 171
168 172 if format == 'pairslist':
169 173 """
170 174 Example:
171 175 value = (0,1),(1,2)
172 176 """
173 177
174 178 new_value = ast.literal_eval(value)
175 179
176 180 if type(new_value) not in (tuple, list):
177 181 raise ValueError, "%s has to be a tuple or list of pairs" %value
178 182
179 183 if type(new_value[0]) not in (tuple, list):
180 184 if len(new_value) != 2:
181 185 raise ValueError, "%s has to be a tuple or list of pairs" %value
182 186 new_value = [new_value]
183 187
184 188 for thisPair in new_value:
185 189 if len(thisPair) != 2:
186 190 raise ValueError, "%s has to be a tuple or list of pairs" %value
187 191
188 192 self.__formated_value = new_value
189 193
190 194 return self.__formated_value
191 195
192 196 if format == 'multilist':
193 197 """
194 198 Example:
195 199 value = (0,1,2),(3,4,5)
196 200 """
197 201 multiList = ast.literal_eval(value)
198 202
199 203 if type(multiList[0]) == int:
200 204 multiList = ast.literal_eval("(" + value + ")")
201 205
202 206 self.__formated_value = multiList
203 207
204 208 return self.__formated_value
205 209
206 210 if format == 'bool':
207 211 value = int(value)
208 212
209 213 if format == 'int':
210 214 value = float(value)
211 215
212 216 format_func = eval(format)
213 217
214 218 self.__formated_value = format_func(value)
215 219
216 220 return self.__formated_value
217 221
218 222 def updateId(self, new_id):
219 223
220 224 self.id = str(new_id)
221 225
222 226 def setup(self, id, name, value, format='str'):
223 227 self.id = str(id)
224 228 self.name = name
225 229 if format == 'obj':
226 230 self.value = value
227 231 else:
228 232 self.value = str(value)
229 233 self.format = str.lower(format)
230 234
231 235 self.getValue()
232 236
233 237 return 1
234 238
235 239 def update(self, name, value, format='str'):
236 240
237 241 self.name = name
238 242 self.value = str(value)
239 243 self.format = format
240 244
241 245 def makeXml(self, opElement):
242 246 if self.name not in ('queue',):
243 247 parmElement = SubElement(opElement, self.ELEMENTNAME)
244 248 parmElement.set('id', str(self.id))
245 249 parmElement.set('name', self.name)
246 250 parmElement.set('value', self.value)
247 251 parmElement.set('format', self.format)
248 252
249 253 def readXml(self, parmElement):
250 254
251 255 self.id = parmElement.get('id')
252 256 self.name = parmElement.get('name')
253 257 self.value = parmElement.get('value')
254 258 self.format = str.lower(parmElement.get('format'))
255 259
256 260 #Compatible with old signal chain version
257 261 if self.format == 'int' and self.name == 'idfigure':
258 262 self.name = 'id'
259 263
260 264 def printattr(self):
261 265
262 266 print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format)
263 267
264 268 class OperationConf():
265 269
266 270 id = None
267 271 name = None
268 272 priority = None
269 273 type = None
270 274
271 275 parmConfObjList = []
272 276
273 277 ELEMENTNAME = 'Operation'
274 278
275 279 def __init__(self):
276 280
277 281 self.id = '0'
278 282 self.name = None
279 283 self.priority = None
280 284 self.type = 'self'
281 285
282 286
283 287 def __getNewId(self):
284 288
285 289 return int(self.id)*10 + len(self.parmConfObjList) + 1
286 290
287 291 def updateId(self, new_id):
288 292
289 293 self.id = str(new_id)
290 294
291 295 n = 1
292 296 for parmObj in self.parmConfObjList:
293 297
294 298 idParm = str(int(new_id)*10 + n)
295 299 parmObj.updateId(idParm)
296 300
297 301 n += 1
298 302
299 303 def getElementName(self):
300 304
301 305 return self.ELEMENTNAME
302 306
303 307 def getParameterObjList(self):
304 308
305 309 return self.parmConfObjList
306 310
307 311 def getParameterObj(self, parameterName):
308 312
309 313 for parmConfObj in self.parmConfObjList:
310 314
311 315 if parmConfObj.name != parameterName:
312 316 continue
313 317
314 318 return parmConfObj
315 319
316 320 return None
317 321
318 322 def getParameterObjfromValue(self, parameterValue):
319 323
320 324 for parmConfObj in self.parmConfObjList:
321 325
322 326 if parmConfObj.getValue() != parameterValue:
323 327 continue
324 328
325 329 return parmConfObj.getValue()
326 330
327 331 return None
328 332
329 333 def getParameterValue(self, parameterName):
330 334
331 335 parameterObj = self.getParameterObj(parameterName)
332 336
333 337 # if not parameterObj:
334 338 # return None
335 339
336 340 value = parameterObj.getValue()
337 341
338 342 return value
339 343
340 344
341 345 def getKwargs(self):
342 346
343 347 kwargs = {}
344 348
345 349 for parmConfObj in self.parmConfObjList:
346 350 if self.name == 'run' and parmConfObj.name == 'datatype':
347 351 continue
348 352
349 353 kwargs[parmConfObj.name] = parmConfObj.getValue()
350 354
351 355 return kwargs
352 356
353 357 def setup(self, id, name, priority, type):
354 358
355 359 self.id = str(id)
356 360 self.name = name
357 361 self.type = type
358 362 self.priority = priority
359 363
360 364 self.parmConfObjList = []
361 365
362 366 def removeParameters(self):
363 367
364 368 for obj in self.parmConfObjList:
365 369 del obj
366 370
367 371 self.parmConfObjList = []
368 372
369 373 def addParameter(self, name, value, format='str'):
370 374
371 375 id = self.__getNewId()
372 376
373 377 parmConfObj = ParameterConf()
374 378 if not parmConfObj.setup(id, name, value, format):
375 379 return None
376 380
377 381 self.parmConfObjList.append(parmConfObj)
378 382
379 383 return parmConfObj
380 384
381 385 def changeParameter(self, name, value, format='str'):
382 386
383 387 parmConfObj = self.getParameterObj(name)
384 388 parmConfObj.update(name, value, format)
385 389
386 390 return parmConfObj
387 391
388 392 def makeXml(self, procUnitElement):
389 393
390 394 opElement = SubElement(procUnitElement, self.ELEMENTNAME)
391 395 opElement.set('id', str(self.id))
392 396 opElement.set('name', self.name)
393 397 opElement.set('type', self.type)
394 398 opElement.set('priority', str(self.priority))
395 399
396 400 for parmConfObj in self.parmConfObjList:
397 401 parmConfObj.makeXml(opElement)
398 402
399 403 def readXml(self, opElement):
400 404
401 405 self.id = opElement.get('id')
402 406 self.name = opElement.get('name')
403 407 self.type = opElement.get('type')
404 408 self.priority = opElement.get('priority')
405 409
406 410 #Compatible with old signal chain version
407 411 #Use of 'run' method instead 'init'
408 412 if self.type == 'self' and self.name == 'init':
409 413 self.name = 'run'
410 414
411 415 self.parmConfObjList = []
412 416
413 417 parmElementList = opElement.iter(ParameterConf().getElementName())
414 418
415 419 for parmElement in parmElementList:
416 420 parmConfObj = ParameterConf()
417 421 parmConfObj.readXml(parmElement)
418 422
419 423 #Compatible with old signal chain version
420 424 #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER
421 425 if self.type != 'self' and self.name == 'Plot':
422 426 if parmConfObj.format == 'str' and parmConfObj.name == 'type':
423 427 self.name = parmConfObj.value
424 428 continue
425 429
426 430 self.parmConfObjList.append(parmConfObj)
427 431
428 432 def printattr(self):
429 433
430 434 print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME,
431 435 self.id,
432 436 self.name,
433 437 self.type,
434 438 self.priority)
435 439
436 440 for parmConfObj in self.parmConfObjList:
437 441 parmConfObj.printattr()
438 442
439 443 def createObject(self, plotter_queue=None):
440 444
441 445
442 446 if self.type == 'self':
443 447 raise ValueError, "This operation type cannot be created"
444 448
445 449 if self.type == 'plotter':
446 450 #Plotter(plotter_name)
447 451 if not plotter_queue:
448 452 raise ValueError, "plotter_queue is not defined. Use:\nmyProject = Project()\nmyProject.setPlotterQueue(plotter_queue)"
449 453
450 454 opObj = Plotter(self.name, plotter_queue)
451 455
452 456 if self.type == 'external' or self.type == 'other':
453 457
454 458 className = eval(self.name)
455 459 kwargs = self.getKwargs()
456 460
457 461 opObj = className(**kwargs)
458 462
459 463 return opObj
460 464
461 465
462 466 class ProcUnitConf():
463 467
464 468 id = None
465 469 name = None
466 470 datatype = None
467 471 inputId = None
468 472 parentId = None
469 473
470 474 opConfObjList = []
471 475
472 476 procUnitObj = None
473 477 opObjList = []
474 478
475 479 ELEMENTNAME = 'ProcUnit'
476 480
477 481 def __init__(self):
478 482
479 483 self.id = None
480 484 self.datatype = None
481 485 self.name = None
482 486 self.inputId = None
483 487
484 488 self.opConfObjList = []
485 489
486 490 self.procUnitObj = None
487 491 self.opObjDict = {}
488 492
489 493 def __getPriority(self):
490 494
491 495 return len(self.opConfObjList)+1
492 496
493 497 def __getNewId(self):
494 498
495 499 return int(self.id)*10 + len(self.opConfObjList) + 1
496 500
497 501 def getElementName(self):
498 502
499 503 return self.ELEMENTNAME
500 504
501 505 def getId(self):
502 506
503 507 return self.id
504 508
505 509 def updateId(self, new_id, parentId=parentId):
506 510
507 511
508 512 new_id = int(parentId)*10 + (int(self.id) % 10)
509 513 new_inputId = int(parentId)*10 + (int(self.inputId) % 10)
510 514
511 515 #If this proc unit has not inputs
512 516 if self.inputId == '0':
513 517 new_inputId = 0
514 518
515 519 n = 1
516 520 for opConfObj in self.opConfObjList:
517 521
518 522 idOp = str(int(new_id)*10 + n)
519 523 opConfObj.updateId(idOp)
520 524
521 525 n += 1
522 526
523 527 self.parentId = str(parentId)
524 528 self.id = str(new_id)
525 529 self.inputId = str(new_inputId)
526 530
527 531
528 532 def getInputId(self):
529 533
530 534 return self.inputId
531 535
532 536 def getOperationObjList(self):
533 537
534 538 return self.opConfObjList
535 539
536 540 def getOperationObj(self, name=None):
537 541
538 542 for opConfObj in self.opConfObjList:
539 543
540 544 if opConfObj.name != name:
541 545 continue
542 546
543 547 return opConfObj
544 548
545 549 return None
546 550
547 551 def getOpObjfromParamValue(self, value=None):
548 552
549 553 for opConfObj in self.opConfObjList:
550 554 if opConfObj.getParameterObjfromValue(parameterValue=value) != value:
551 555 continue
552 556 return opConfObj
553 557 return None
554 558
555 559 def getProcUnitObj(self):
556 560
557 561 return self.procUnitObj
558 562
559 563 def setup(self, id, name, datatype, inputId, parentId=None):
560 564
561 565 #Compatible with old signal chain version
562 566 if datatype==None and name==None:
563 567 raise ValueError, "datatype or name should be defined"
564 568
565 569 if name==None:
566 570 if 'Proc' in datatype:
567 571 name = datatype
568 572 else:
569 573 name = '%sProc' %(datatype)
570 574
571 575 if datatype==None:
572 576 datatype = name.replace('Proc','')
573 577
574 578 self.id = str(id)
575 579 self.name = name
576 580 self.datatype = datatype
577 581 self.inputId = inputId
578 582 self.parentId = parentId
579 583
580 584 self.opConfObjList = []
581 585
582 586 self.addOperation(name='run', optype='self')
583 587
584 588 def removeOperations(self):
585 589
586 590 for obj in self.opConfObjList:
587 591 del obj
588 592
589 593 self.opConfObjList = []
590 594 self.addOperation(name='run')
591 595
592 596 def addParameter(self, **kwargs):
593 597 '''
594 598 Add parameters to "run" operation
595 599 '''
596 600 opObj = self.opConfObjList[0]
597 601
598 602 opObj.addParameter(**kwargs)
599 603
600 604 return opObj
601 605
602 606 def addOperation(self, name, optype='self'):
603 607
604 608 id = self.__getNewId()
605 609 priority = self.__getPriority()
606 610
607 611 opConfObj = OperationConf()
608 612 opConfObj.setup(id, name=name, priority=priority, type=optype)
609 613
610 614 self.opConfObjList.append(opConfObj)
611 615
612 616 return opConfObj
613 617
614 618 def makeXml(self, projectElement):
615 619
616 620 procUnitElement = SubElement(projectElement, self.ELEMENTNAME)
617 621 procUnitElement.set('id', str(self.id))
618 622 procUnitElement.set('name', self.name)
619 623 procUnitElement.set('datatype', self.datatype)
620 624 procUnitElement.set('inputId', str(self.inputId))
621 625
622 626 for opConfObj in self.opConfObjList:
623 627 opConfObj.makeXml(procUnitElement)
624 628
625 629 def readXml(self, upElement):
626 630
627 631 self.id = upElement.get('id')
628 632 self.name = upElement.get('name')
629 633 self.datatype = upElement.get('datatype')
630 634 self.inputId = upElement.get('inputId')
631 635
632 636 if self.ELEMENTNAME == "ReadUnit":
633 637 self.datatype = self.datatype.replace("Reader", "")
634 638
635 639 if self.ELEMENTNAME == "ProcUnit":
636 640 self.datatype = self.datatype.replace("Proc", "")
637 641
638 642 if self.inputId == 'None':
639 643 self.inputId = '0'
640 644
641 645 self.opConfObjList = []
642 646
643 647 opElementList = upElement.iter(OperationConf().getElementName())
644 648
645 649 for opElement in opElementList:
646 650 opConfObj = OperationConf()
647 651 opConfObj.readXml(opElement)
648 652 self.opConfObjList.append(opConfObj)
649 653
650 654 def printattr(self):
651 655
652 656 print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME,
653 657 self.id,
654 658 self.name,
655 659 self.datatype,
656 660 self.inputId)
657 661
658 662 for opConfObj in self.opConfObjList:
659 663 opConfObj.printattr()
660 664
661 665
662 666 def getKwargs(self):
663 667
664 668 opObj = self.opConfObjList[0]
665 669 kwargs = opObj.getKwargs()
666 670
667 671 return kwargs
668 672
669 673 def createObjects(self, plotter_queue=None):
670 674
671 675 className = eval(self.name)
672 676 kwargs = self.getKwargs()
673 677 procUnitObj = className(**kwargs)
674 678
675 679 for opConfObj in self.opConfObjList:
676 680
677 681 if opConfObj.type=='self' and self.name=='run':
678 682 continue
679 683 elif opConfObj.type=='self':
680 684 procUnitObj.addOperationKwargs(opConfObj.id, **opConfObj.getKwargs())
681 685 continue
682 686
683 687 opObj = opConfObj.createObject(plotter_queue)
684 688
685 689 self.opObjDict[opConfObj.id] = opObj
686 690
687 691 procUnitObj.addOperation(opObj, opConfObj.id)
688 692
689 693 self.procUnitObj = procUnitObj
690 694
691 695 return procUnitObj
692 696
693 697 ## @profile
694 698 def run(self):
695 699
696 700 is_ok = False
697 701
698 702 for opConfObj in self.opConfObjList:
699 703
700 704 kwargs = {}
701 705 for parmConfObj in opConfObj.getParameterObjList():
702 706 if opConfObj.name == 'run' and parmConfObj.name == 'datatype':
703 707 continue
704 708
705 709 kwargs[parmConfObj.name] = parmConfObj.getValue()
706 710
707 711 #ini = time.time()
708 712
709 713 #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id)
710 714 sts = self.procUnitObj.call(opType = opConfObj.type,
711 715 opName = opConfObj.name,
712 716 opId = opConfObj.id,
713 717 )
714 718
715 719 # total_time = time.time() - ini
716 720 #
717 721 # if total_time > 0.002:
718 722 # print "%s::%s took %f seconds" %(self.name, opConfObj.name, total_time)
719 723
720 724 is_ok = is_ok or sts
721 725
722 726 return is_ok
723 727
724 728 def close(self):
725 729
726 730 for opConfObj in self.opConfObjList:
727 731 if opConfObj.type == 'self':
728 732 continue
729 733
730 734 opObj = self.procUnitObj.getOperationObj(opConfObj.id)
731 735 opObj.close()
732 736
733 737 self.procUnitObj.close()
734 738
735 739 return
736 740
737 741 class ReadUnitConf(ProcUnitConf):
738 742
739 743 path = None
740 744 startDate = None
741 745 endDate = None
742 746 startTime = None
743 747 endTime = None
744 748
745 749 ELEMENTNAME = 'ReadUnit'
746 750
747 751 def __init__(self):
748 752
749 753 self.id = None
750 754 self.datatype = None
751 755 self.name = None
752 756 self.inputId = None
753 757
754 758 self.parentId = None
755 759
756 760 self.opConfObjList = []
757 761 self.opObjList = []
758 762
759 763 def getElementName(self):
760 764
761 765 return self.ELEMENTNAME
762 766
763 767 def setup(self, id, name, datatype, path='', startDate="", endDate="", startTime="",
764 768 endTime="", parentId=None, queue=None, server=None, **kwargs):
765 769
766 770 #Compatible with old signal chain version
767 771 if datatype==None and name==None:
768 772 raise ValueError, "datatype or name should be defined"
769 773
770 774 if name==None:
771 775 if 'Reader' in datatype:
772 776 name = datatype
773 777 else:
774 778 name = '%sReader' %(datatype)
775 779 if datatype==None:
776 780 datatype = name.replace('Reader','')
777 781
778 782 self.id = id
779 783 self.name = name
780 784 self.datatype = datatype
781 785 if path != '':
782 786 self.path = os.path.abspath(path)
783 787 self.startDate = startDate
784 788 self.endDate = endDate
785 789 self.startTime = startTime
786 790 self.endTime = endTime
787 791
788 792 self.inputId = '0'
789 793 self.parentId = parentId
790 794 self.queue = queue
791 795 self.server = server
792 796 self.addRunOperation(**kwargs)
793 797
794 798 def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs):
795 799
796 800 #Compatible with old signal chain version
797 801 if datatype==None and name==None:
798 802 raise ValueError, "datatype or name should be defined"
799 803
800 804 if name==None:
801 805 if 'Reader' in datatype:
802 806 name = datatype
803 807 else:
804 808 name = '%sReader' %(datatype)
805 809
806 810 if datatype==None:
807 811 datatype = name.replace('Reader','')
808 812
809 813 self.datatype = datatype
810 814 self.name = name
811 815 self.path = path
812 816 self.startDate = startDate
813 817 self.endDate = endDate
814 818 self.startTime = startTime
815 819 self.endTime = endTime
816 820
817 821 self.inputId = '0'
818 822 self.parentId = parentId
819 823
820 824 self.updateRunOperation(**kwargs)
821 825
822 826 def removeOperations(self):
823 827
824 828 for obj in self.opConfObjList:
825 829 del obj
826 830
827 831 self.opConfObjList = []
828 832
829 833 def addRunOperation(self, **kwargs):
830 834
831 835 opObj = self.addOperation(name = 'run', optype = 'self')
832 836
833 837 if self.server is None:
834 838 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
835 839 opObj.addParameter(name='path' , value=self.path, format='str')
836 840 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
837 841 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
838 842 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
839 843 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
840 844 opObj.addParameter(name='queue' , value=self.queue, format='obj')
841 845 for key, value in kwargs.items():
842 846 opObj.addParameter(name=key, value=value, format=type(value).__name__)
843 847 else:
844 848 opObj.addParameter(name='server' , value=self.server, format='str')
845 849
846 850
847 851 return opObj
848 852
849 853 def updateRunOperation(self, **kwargs):
850 854
851 855 opObj = self.getOperationObj(name = 'run')
852 856 opObj.removeParameters()
853 857
854 858 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
855 859 opObj.addParameter(name='path' , value=self.path, format='str')
856 860 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
857 861 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
858 862 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
859 863 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
860 864
861 865 for key, value in kwargs.items():
862 866 opObj.addParameter(name=key, value=value, format=type(value).__name__)
863 867
864 868 return opObj
865 869
866 870 # def makeXml(self, projectElement):
867 871 #
868 872 # procUnitElement = SubElement(projectElement, self.ELEMENTNAME)
869 873 # procUnitElement.set('id', str(self.id))
870 874 # procUnitElement.set('name', self.name)
871 875 # procUnitElement.set('datatype', self.datatype)
872 876 # procUnitElement.set('inputId', str(self.inputId))
873 877 #
874 878 # for opConfObj in self.opConfObjList:
875 879 # opConfObj.makeXml(procUnitElement)
876 880
877 881 def readXml(self, upElement):
878 882
879 883 self.id = upElement.get('id')
880 884 self.name = upElement.get('name')
881 885 self.datatype = upElement.get('datatype')
882 886 self.inputId = upElement.get('inputId')
883 887
884 888 if self.ELEMENTNAME == "ReadUnit":
885 889 self.datatype = self.datatype.replace("Reader", "")
886 890
887 891 if self.inputId == 'None':
888 892 self.inputId = '0'
889 893
890 894 self.opConfObjList = []
891 895
892 896 opElementList = upElement.iter(OperationConf().getElementName())
893 897
894 898 for opElement in opElementList:
895 899 opConfObj = OperationConf()
896 900 opConfObj.readXml(opElement)
897 901 self.opConfObjList.append(opConfObj)
898 902
899 903 if opConfObj.name == 'run':
900 904 self.path = opConfObj.getParameterValue('path')
901 905 self.startDate = opConfObj.getParameterValue('startDate')
902 906 self.endDate = opConfObj.getParameterValue('endDate')
903 907 self.startTime = opConfObj.getParameterValue('startTime')
904 908 self.endTime = opConfObj.getParameterValue('endTime')
905 909
906 910 class Project():
907 911
908 912 id = None
909 913 name = None
910 914 description = None
911 915 filename = None
912 916
913 917 procUnitConfObjDict = None
914 918
915 919 ELEMENTNAME = 'Project'
916 920
917 921 plotterQueue = None
918 922
919 923 def __init__(self, plotter_queue=None):
920 924
921 925 self.id = None
922 926 self.name = None
923 927 self.description = None
924 928
925 929 self.plotterQueue = plotter_queue
926 930
927 931 self.procUnitConfObjDict = {}
928 932
929 933 def __getNewId(self):
930 934
931 935 idList = self.procUnitConfObjDict.keys()
932 936
933 937 id = int(self.id)*10
934 938
935 939 while True:
936 940 id += 1
937 941
938 942 if str(id) in idList:
939 943 continue
940 944
941 945 break
942 946
943 947 return str(id)
944 948
945 949 def getElementName(self):
946 950
947 951 return self.ELEMENTNAME
948 952
949 953 def getId(self):
950 954
951 955 return self.id
952 956
953 957 def updateId(self, new_id):
954 958
955 959 self.id = str(new_id)
956 960
957 961 keyList = self.procUnitConfObjDict.keys()
958 962 keyList.sort()
959 963
960 964 n = 1
961 965 newProcUnitConfObjDict = {}
962 966
963 967 for procKey in keyList:
964 968
965 969 procUnitConfObj = self.procUnitConfObjDict[procKey]
966 970 idProcUnit = str(int(self.id)*10 + n)
967 971 procUnitConfObj.updateId(idProcUnit, parentId = self.id)
968 972
969 973 newProcUnitConfObjDict[idProcUnit] = procUnitConfObj
970 974 n += 1
971 975
972 976 self.procUnitConfObjDict = newProcUnitConfObjDict
973 977
974 978 def setup(self, id, name, description):
975 979
976 980 self.id = str(id)
977 981 self.name = name
978 982 self.description = description
979 983
980 984 def update(self, name, description):
981 985
982 986 self.name = name
983 987 self.description = description
984 988
985 989 def addReadUnit(self, id=None, datatype=None, name=None, **kwargs):
986 990
987 991 if id is None:
988 992 idReadUnit = self.__getNewId()
989 993 else:
990 994 idReadUnit = str(id)
991 995
992 996 readUnitConfObj = ReadUnitConf()
993 997 readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs)
994 998
995 999 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
996 1000
997 1001 return readUnitConfObj
998 1002
999 1003 def addProcUnit(self, inputId='0', datatype=None, name=None):
1000 1004
1001 1005 idProcUnit = self.__getNewId()
1002 1006
1003 1007 procUnitConfObj = ProcUnitConf()
1004 1008 procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id)
1005 1009
1006 1010 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
1007 1011
1008 1012 return procUnitConfObj
1009 1013
1010 1014 def removeProcUnit(self, id):
1011 1015
1012 1016 if id in self.procUnitConfObjDict.keys():
1013 1017 self.procUnitConfObjDict.pop(id)
1014 1018
1015 1019 def getReadUnitId(self):
1016 1020
1017 1021 readUnitConfObj = self.getReadUnitObj()
1018 1022
1019 1023 return readUnitConfObj.id
1020 1024
1021 1025 def getReadUnitObj(self):
1022 1026
1023 1027 for obj in self.procUnitConfObjDict.values():
1024 1028 if obj.getElementName() == "ReadUnit":
1025 1029 return obj
1026 1030
1027 1031 return None
1028 1032
1029 1033 def getProcUnitObj(self, id=None, name=None):
1030 1034
1031 1035 if id != None:
1032 1036 return self.procUnitConfObjDict[id]
1033 1037
1034 1038 if name != None:
1035 1039 return self.getProcUnitObjByName(name)
1036 1040
1037 1041 return None
1038 1042
1039 1043 def getProcUnitObjByName(self, name):
1040 1044
1041 1045 for obj in self.procUnitConfObjDict.values():
1042 1046 if obj.name == name:
1043 1047 return obj
1044 1048
1045 1049 return None
1046 1050
1047 1051 def procUnitItems(self):
1048 1052
1049 1053 return self.procUnitConfObjDict.items()
1050 1054
1051 1055 def makeXml(self):
1052 1056
1053 1057 projectElement = Element('Project')
1054 1058 projectElement.set('id', str(self.id))
1055 1059 projectElement.set('name', self.name)
1056 1060 projectElement.set('description', self.description)
1057 1061
1058 1062 for procUnitConfObj in self.procUnitConfObjDict.values():
1059 1063 procUnitConfObj.makeXml(projectElement)
1060 1064
1061 1065 self.projectElement = projectElement
1062 1066
1063 1067 def writeXml(self, filename=None):
1064 1068
1065 1069 if filename == None:
1066 1070 if self.filename:
1067 1071 filename = self.filename
1068 1072 else:
1069 1073 filename = "schain.xml"
1070 1074
1071 1075 if not filename:
1072 1076 print "filename has not been defined. Use setFilename(filename) for do it."
1073 1077 return 0
1074 1078
1075 1079 abs_file = os.path.abspath(filename)
1076 1080
1077 1081 if not os.access(os.path.dirname(abs_file), os.W_OK):
1078 1082 print "No write permission on %s" %os.path.dirname(abs_file)
1079 1083 return 0
1080 1084
1081 1085 if os.path.isfile(abs_file) and not(os.access(abs_file, os.W_OK)):
1082 1086 print "File %s already exists and it could not be overwriten" %abs_file
1083 1087 return 0
1084 1088
1085 1089 self.makeXml()
1086 1090
1087 1091 ElementTree(self.projectElement).write(abs_file, method='xml')
1088 1092
1089 1093 self.filename = abs_file
1090 1094
1091 1095 return 1
1092 1096
1093 1097 def readXml(self, filename = None):
1094 1098
1095 1099 if not filename:
1096 1100 print "filename is not defined"
1097 1101 return 0
1098 1102
1099 1103 abs_file = os.path.abspath(filename)
1100 1104
1101 1105 if not os.path.isfile(abs_file):
1102 1106 print "%s file does not exist" %abs_file
1103 1107 return 0
1104 1108
1105 1109 self.projectElement = None
1106 1110 self.procUnitConfObjDict = {}
1107 1111
1108 1112 try:
1109 1113 self.projectElement = ElementTree().parse(abs_file)
1110 1114 except:
1111 1115 print "Error reading %s, verify file format" %filename
1112 1116 return 0
1113 1117
1114 1118 self.project = self.projectElement.tag
1115 1119
1116 1120 self.id = self.projectElement.get('id')
1117 1121 self.name = self.projectElement.get('name')
1118 1122 self.description = self.projectElement.get('description')
1119 1123
1120 1124 readUnitElementList = self.projectElement.iter(ReadUnitConf().getElementName())
1121 1125
1122 1126 for readUnitElement in readUnitElementList:
1123 1127 readUnitConfObj = ReadUnitConf()
1124 1128 readUnitConfObj.readXml(readUnitElement)
1125 1129
1126 1130 if readUnitConfObj.parentId == None:
1127 1131 readUnitConfObj.parentId = self.id
1128 1132
1129 1133 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
1130 1134
1131 1135 procUnitElementList = self.projectElement.iter(ProcUnitConf().getElementName())
1132 1136
1133 1137 for procUnitElement in procUnitElementList:
1134 1138 procUnitConfObj = ProcUnitConf()
1135 1139 procUnitConfObj.readXml(procUnitElement)
1136 1140
1137 1141 if procUnitConfObj.parentId == None:
1138 1142 procUnitConfObj.parentId = self.id
1139 1143
1140 1144 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
1141 1145
1142 1146 self.filename = abs_file
1143 1147
1144 1148 return 1
1145 1149
1146 1150 def printattr(self):
1147 1151
1148 1152 print "Project[%s]: name = %s, description = %s" %(self.id,
1149 1153 self.name,
1150 1154 self.description)
1151 1155
1152 1156 for procUnitConfObj in self.procUnitConfObjDict.values():
1153 1157 procUnitConfObj.printattr()
1154 1158
1155 1159 def createObjects(self):
1156 1160
1157 1161 for procUnitConfObj in self.procUnitConfObjDict.values():
1158 1162 procUnitConfObj.createObjects(self.plotterQueue)
1159 1163
1160 1164 def __connect(self, objIN, thisObj):
1161 1165
1162 1166 thisObj.setInput(objIN.getOutputObj())
1163 1167
1164 1168 def connectObjects(self):
1165 1169
1166 1170 for thisPUConfObj in self.procUnitConfObjDict.values():
1167 1171
1168 1172 inputId = thisPUConfObj.getInputId()
1169 1173
1170 1174 if int(inputId) == 0:
1171 1175 continue
1172 1176
1173 1177 #Get input object
1174 1178 puConfINObj = self.procUnitConfObjDict[inputId]
1175 1179 puObjIN = puConfINObj.getProcUnitObj()
1176 1180
1177 1181 #Get current object
1178 1182 thisPUObj = thisPUConfObj.getProcUnitObj()
1179 1183
1180 1184 self.__connect(puObjIN, thisPUObj)
1181 1185
1182 1186 def __handleError(self, procUnitConfObj, send_email=True):
1183 1187
1184 1188 import socket
1185 1189
1186 1190 err = traceback.format_exception(sys.exc_info()[0],
1187 1191 sys.exc_info()[1],
1188 1192 sys.exc_info()[2])
1189 1193
1190 1194 print "***** Error occurred in %s *****" %(procUnitConfObj.name)
1191 1195 print "***** %s" %err[-1]
1192 1196
1193 1197 message = "".join(err)
1194 1198
1195 1199 sys.stderr.write(message)
1196 1200
1197 1201 if not send_email:
1198 1202 return
1199 1203
1200 1204 subject = "SChain v%s: Error running %s\n" %(schainpy.__version__, procUnitConfObj.name)
1201 1205
1202 1206 subtitle = "%s: %s\n" %(procUnitConfObj.getElementName() ,procUnitConfObj.name)
1203 1207 subtitle += "Hostname: %s\n" %socket.gethostbyname(socket.gethostname())
1204 1208 subtitle += "Working directory: %s\n" %os.path.abspath("./")
1205 1209 subtitle += "Configuration file: %s\n" %self.filename
1206 1210 subtitle += "Time: %s\n" %str(datetime.datetime.now())
1207 1211
1208 1212 readUnitConfObj = self.getReadUnitObj()
1209 1213 if readUnitConfObj:
1210 1214 subtitle += "\nInput parameters:\n"
1211 1215 subtitle += "[Data path = %s]\n" %readUnitConfObj.path
1212 1216 subtitle += "[Data type = %s]\n" %readUnitConfObj.datatype
1213 1217 subtitle += "[Start date = %s]\n" %readUnitConfObj.startDate
1214 1218 subtitle += "[End date = %s]\n" %readUnitConfObj.endDate
1215 1219 subtitle += "[Start time = %s]\n" %readUnitConfObj.startTime
1216 1220 subtitle += "[End time = %s]\n" %readUnitConfObj.endTime
1217 1221
1218 1222 adminObj = schainpy.admin.SchainNotify()
1219 1223 adminObj.sendAlert(message=message,
1220 1224 subject=subject,
1221 1225 subtitle=subtitle,
1222 1226 filename=self.filename)
1223 1227
1224 1228 def isPaused(self):
1225 1229 return 0
1226 1230
1227 1231 def isStopped(self):
1228 1232 return 0
1229 1233
1230 1234 def runController(self):
1231 1235 """
1232 1236 returns 0 when this process has been stopped, 1 otherwise
1233 1237 """
1234 1238
1235 1239 if self.isPaused():
1236 1240 print "Process suspended"
1237 1241
1238 1242 while True:
1239 1243 sleep(0.1)
1240 1244
1241 1245 if not self.isPaused():
1242 1246 break
1243 1247
1244 1248 if self.isStopped():
1245 1249 break
1246 1250
1247 1251 print "Process reinitialized"
1248 1252
1249 1253 if self.isStopped():
1250 1254 print "Process stopped"
1251 1255 return 0
1252 1256
1253 1257 return 1
1254 1258
1255 1259 def setFilename(self, filename):
1256 1260
1257 1261 self.filename = filename
1258 1262
1259 1263 def setPlotterQueue(self, plotter_queue):
1260 1264
1261 1265 raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class"
1262 1266
1263 1267 def getPlotterQueue(self):
1264 1268
1265 1269 raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class"
1266 1270
1267 1271 def useExternalPlotter(self):
1268 1272
1269 1273 raise NotImplementedError, "Use schainpy.controller_api.ControllerThread instead Project class"
1270 1274
1271 1275
1272 1276 def run(self):
1273 1277
1274 1278 print
1275 1279 print "*"*60
1276 1280 print " Starting SIGNAL CHAIN PROCESSING v%s " %schainpy.__version__
1277 1281 print "*"*60
1278 1282 print
1279 1283
1280 1284 keyList = self.procUnitConfObjDict.keys()
1281 1285 keyList.sort()
1282 1286
1283 1287 while(True):
1284 1288
1285 1289 is_ok = False
1286 1290
1287 1291 for procKey in keyList:
1288 1292 # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id)
1289 1293
1290 1294 procUnitConfObj = self.procUnitConfObjDict[procKey]
1291 1295
1292 1296 try:
1293 1297 sts = procUnitConfObj.run()
1294 1298 is_ok = is_ok or sts
1295 1299 except KeyboardInterrupt:
1296 1300 is_ok = False
1297 1301 break
1298 1302 except ValueError, e:
1299 1303 sleep(0.5)
1300 1304 self.__handleError(procUnitConfObj, send_email=True)
1301 1305 is_ok = False
1302 1306 break
1303 1307 except:
1304 1308 sleep(0.5)
1305 1309 self.__handleError(procUnitConfObj)
1306 1310 is_ok = False
1307 1311 break
1308 1312
1309 1313 #If every process unit finished so end process
1310 1314 if not(is_ok):
1311 1315 # print "Every process unit have finished"
1312 1316 break
1313 1317
1314 1318 if not self.runController():
1315 1319 break
1316 1320
1317 1321 #Closing every process
1318 1322 for procKey in keyList:
1319 1323 procUnitConfObj = self.procUnitConfObjDict[procKey]
1320 1324 procUnitConfObj.close()
1321 1325
1322 1326 print "Process finished"
1323 1327
1324 1328 def start(self, filename=None):
1325 1329
1326 1330 self.writeXml(filename)
1327 1331 self.createObjects()
1328 1332 self.connectObjects()
1329 1333 self.run()
@@ -1,12 +1,12
1 1 #from schainpy.model.data.jrodata import *
2 2 # from schainpy.model.io.jrodataIO import *
3 3 # from schainpy.model.proc.jroprocessing import *
4 4 # from schainpy.model.graphics.jroplot import *
5 5 # from schainpy.model.utils.jroutils import *
6 6 # from schainpy.serializer import *
7 7
8 8 from data import *
9 9 from io import *
10 10 from proc import *
11 #from graphics import *
11 from graphics import *
12 12 from utils import *
@@ -1,783 +1,964
1 1
2 2 import os
3 3 import zmq
4 4 import time
5 5 import numpy
6 6 import datetime
7 7 import numpy as np
8 8 import matplotlib
9 import glob
9 10 matplotlib.use('TkAgg')
10 11 import matplotlib.pyplot as plt
11 12 from mpl_toolkits.axes_grid1 import make_axes_locatable
12 13 from matplotlib.ticker import FuncFormatter, LinearLocator
13 14 from multiprocessing import Process
14 15
15 16 from schainpy.model.proc.jroproc_base import Operation
16 17
17 18 plt.ion()
18 19
19 20 func = lambda x, pos: ('%s') %(datetime.datetime.fromtimestamp(x).strftime('%H:%M'))
20 21 fromtimestamp = lambda x, mintime : (datetime.datetime.utcfromtimestamp(mintime).replace(hour=(x + 5), minute=0) - d1970).total_seconds()
21 22
22 23
23 24 d1970 = datetime.datetime(1970,1,1)
24 25
25 26 class PlotData(Operation, Process):
26 27
27 28 CODE = 'Figure'
28 29 colormap = 'jro'
29 30 CONFLATE = False
30 31 __MAXNUMX = 80
31 32 __missing = 1E30
32 33
33 34 def __init__(self, **kwargs):
34 35
35 36 Operation.__init__(self, plot=True, **kwargs)
36 37 Process.__init__(self)
37 38 self.kwargs['code'] = self.CODE
38 39 self.mp = False
39 40 self.dataOut = None
40 41 self.isConfig = False
41 42 self.figure = None
42 43 self.axes = []
43 44 self.localtime = kwargs.pop('localtime', True)
44 45 self.show = kwargs.get('show', True)
45 46 self.save = kwargs.get('save', False)
46 47 self.colormap = kwargs.get('colormap', self.colormap)
47 48 self.colormap_coh = kwargs.get('colormap_coh', 'jet')
48 49 self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r')
49 50 self.showprofile = kwargs.get('showprofile', True)
50 51 self.title = kwargs.get('wintitle', '')
51 52 self.xaxis = kwargs.get('xaxis', 'frequency')
52 53 self.zmin = kwargs.get('zmin', None)
53 54 self.zmax = kwargs.get('zmax', None)
54 55 self.xmin = kwargs.get('xmin', None)
55 56 self.xmax = kwargs.get('xmax', None)
56 57 self.xrange = kwargs.get('xrange', 24)
57 58 self.ymin = kwargs.get('ymin', None)
58 59 self.ymax = kwargs.get('ymax', None)
59 60 self.__MAXNUMY = kwargs.get('decimation', 5000)
60 61 self.throttle_value = 5
61 62 self.times = []
62 63 #self.interactive = self.kwargs['parent']
63 64
65 '''
66 this new parameter is created to plot data from varius channels at different figures
67 1. crear una lista de figuras donde se puedan plotear las figuras,
68 2. dar las opciones de configuracion a cada figura, estas opciones son iguales para ambas figuras
69 3. probar?
70 '''
71 self.ind_plt_ch = kwargs.get('ind_plt_ch', False)
72 self.figurelist = None
73
64 74
65 75 def fill_gaps(self, x_buffer, y_buffer, z_buffer):
66 76
67 77 if x_buffer.shape[0] < 2:
68 78 return x_buffer, y_buffer, z_buffer
69 79
70 80 deltas = x_buffer[1:] - x_buffer[0:-1]
71 81 x_median = np.median(deltas)
72 82
73 83 index = np.where(deltas > 5*x_median)
74 84
75 85 if len(index[0]) != 0:
76 86 z_buffer[::, index[0], ::] = self.__missing
77 87 z_buffer = np.ma.masked_inside(z_buffer,
78 88 0.99*self.__missing,
79 89 1.01*self.__missing)
80 90
81 91 return x_buffer, y_buffer, z_buffer
82 92
83 93 def decimate(self):
84 94
85 95 # dx = int(len(self.x)/self.__MAXNUMX) + 1
86 96 dy = int(len(self.y)/self.__MAXNUMY) + 1
87 97
88 98 # x = self.x[::dx]
89 99 x = self.x
90 100 y = self.y[::dy]
91 101 z = self.z[::, ::, ::dy]
92 102
93 103 return x, y, z
94 104
105 '''
106 JM:
107 elimana las otras imagenes generadas debido a que lso workers no llegan en orden y le pueden
108 poner otro tiempo a la figura q no necesariamente es el ultimo.
109 Solo se realiza cuando termina la imagen.
110 Problemas:
111
112 File "/home/ci-81/workspace/schainv2.3/schainpy/model/graphics/jroplot_data.py", line 145, in __plot
113 for n, eachfigure in enumerate(self.figurelist):
114 TypeError: 'NoneType' object is not iterable
115
116 '''
117 def deleteanotherfiles(self):
118 figurenames=[]
119 if self.figurelist != None:
120 for n, eachfigure in enumerate(self.figurelist):
121 #add specific name for each channel in channelList
122 ghostfigname = os.path.join(self.save, '{}_{}_{}'.format(self.titles[n].replace(' ',''),self.CODE,
123 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d')))
124 figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n].replace(' ',''),self.CODE,
125 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
126
127 for ghostfigure in glob.glob(ghostfigname+'*'): #ghostfigure will adopt all posible names of figures
128 if ghostfigure != figname:
129 os.remove(ghostfigure)
130 print 'Removing GhostFigures:' , figname
131 else :
132 '''Erasing ghost images for just on******************'''
133 ghostfigname = os.path.join(self.save, '{}_{}'.format(self.CODE,datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d')))
134 figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
135 for ghostfigure in glob.glob(ghostfigname+'*'): #ghostfigure will adopt all posible names of figures
136 if ghostfigure != figname:
137 os.remove(ghostfigure)
138 print 'Removing GhostFigures:' , figname
139
95 140 def __plot(self):
96 141
97 142 print 'plotting...{}'.format(self.CODE)
98
99 if self.show:
100 self.figure.show()
101
102 self.plot()
103 plt.tight_layout()
104 self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(),
143 if self.ind_plt_ch is False : #standard
144 if self.show:
145 self.figure.show()
146 self.plot()
147 plt.tight_layout()
148 self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(),
105 149 datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d')))
150 else :
151 print 'len(self.figurelist): ',len(self.figurelist)
152 for n, eachfigure in enumerate(self.figurelist):
153 if self.show:
154 eachfigure.show()
155
156 self.plot()
157 eachfigure.tight_layout() # ajuste de cada subplot
158 eachfigure.canvas.manager.set_window_title('{} {} - {}'.format(self.title[n], self.CODE.upper(),
159 datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d')))
160
161 # if self.save:
162 # if self.ind_plt_ch is False : #standard
163 # figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,
164 # datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
165 # print 'Saving figure: {}'.format(figname)
166 # self.figure.savefig(figname)
167 # else :
168 # for n, eachfigure in enumerate(self.figurelist):
169 # #add specific name for each channel in channelList
170 # figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n],self.CODE,
171 # datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
172 #
173 # print 'Saving figure: {}'.format(figname)
174 # eachfigure.savefig(figname)
175
176 if self.ind_plt_ch is False :
177 self.figure.canvas.draw()
178 else :
179 for eachfigure in self.figurelist:
180 eachfigure.canvas.draw()
106 181
107 182 if self.save:
108 figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,
109 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
110 print 'Saving figure: {}'.format(figname)
111 self.figure.savefig(figname)
183 if self.ind_plt_ch is False : #standard
184 figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,
185 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
186 print 'Saving figure: {}'.format(figname)
187 self.figure.savefig(figname)
188 else :
189 for n, eachfigure in enumerate(self.figurelist):
190 #add specific name for each channel in channelList
191 figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n].replace(' ',''),self.CODE,
192 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
193
194 print 'Saving figure: {}'.format(figname)
195 eachfigure.savefig(figname)
112 196
113 self.figure.canvas.draw()
114 197
115 198 def plot(self):
116 199
117 200 print 'plotting...{}'.format(self.CODE.upper())
118 201 return
119 202
120 203 def run(self):
121 204
122 205 print '[Starting] {}'.format(self.name)
123 206
124 207 context = zmq.Context()
125 208 receiver = context.socket(zmq.SUB)
126 209 receiver.setsockopt(zmq.SUBSCRIBE, '')
127 210 receiver.setsockopt(zmq.CONFLATE, self.CONFLATE)
128
211
129 212 if 'server' in self.kwargs['parent']:
130 213 receiver.connect('ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server']))
131 214 else:
132 215 receiver.connect("ipc:///tmp/zmq.plots")
133 216
134 217 seconds_passed = 0
135 218
136 219 while True:
137 220 try:
138 221 self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK)#flags=zmq.NOBLOCK
139 222 self.started = self.data['STARTED']
140 223 self.dataOut = self.data['dataOut']
141 224
142 225 if (len(self.times) < len(self.data['times']) and not self.started and self.data['ENDED']):
143 226 continue
144 227
145 228 self.times = self.data['times']
146 229 self.times.sort()
147 230 self.throttle_value = self.data['throttle']
148 231 self.min_time = self.times[0]
149 232 self.max_time = self.times[-1]
150 233
151 234 if self.isConfig is False:
152 235 print 'setting up'
153 236 self.setup()
154 237 self.isConfig = True
155 238 self.__plot()
156 239
157 240 if self.data['ENDED'] is True:
158 241 print '********GRAPHIC ENDED********'
159 242 self.ended = True
160 243 self.isConfig = False
161 244 self.__plot()
245 self.deleteanotherfiles() #CLPDG
162 246 elif seconds_passed >= self.data['throttle']:
163 247 print 'passed', seconds_passed
164 248 self.__plot()
165 249 seconds_passed = 0
166 250
167 251 except zmq.Again as e:
168 252 print 'Waiting for data...'
169 253 plt.pause(2)
170 254 seconds_passed += 2
171 255
172 256 def close(self):
173 257 if self.dataOut:
174 258 self.__plot()
175 259
176 260
177 261 class PlotSpectraData(PlotData):
178 262
179 263 CODE = 'spc'
180 264 colormap = 'jro'
181 265 CONFLATE = False
182 266
183 267 def setup(self):
184 268
185 269 ncolspan = 1
186 270 colspan = 1
187 271 self.ncols = int(numpy.sqrt(self.dataOut.nChannels)+0.9)
188 272 self.nrows = int(self.dataOut.nChannels*1./self.ncols + 0.9)
189 273 self.width = 3.6*self.ncols
190 274 self.height = 3.2*self.nrows
191 275 if self.showprofile:
192 276 ncolspan = 3
193 277 colspan = 2
194 278 self.width += 1.2*self.ncols
195 279
196 280 self.ylabel = 'Range [Km]'
197 281 self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList]
198 282
199 283 if self.figure is None:
200 284 self.figure = plt.figure(figsize=(self.width, self.height),
201 285 edgecolor='k',
202 286 facecolor='w')
203 287 else:
204 288 self.figure.clf()
205 289
206 290 n = 0
207 291 for y in range(self.nrows):
208 292 for x in range(self.ncols):
209 293 if n >= self.dataOut.nChannels:
210 294 break
211 295 ax = plt.subplot2grid((self.nrows, self.ncols*ncolspan), (y, x*ncolspan), 1, colspan)
212 296 if self.showprofile:
213 297 ax.ax_profile = plt.subplot2grid((self.nrows, self.ncols*ncolspan), (y, x*ncolspan+colspan), 1, 1)
214 298
215 299 ax.firsttime = True
216 300 self.axes.append(ax)
217 301 n += 1
218 302
219 303 def plot(self):
220 304
221 305 if self.xaxis == "frequency":
222 306 x = self.dataOut.getFreqRange(1)/1000.
223 307 xlabel = "Frequency (kHz)"
224 308 elif self.xaxis == "time":
225 309 x = self.dataOut.getAcfRange(1)
226 310 xlabel = "Time (ms)"
227 311 else:
228 312 x = self.dataOut.getVelRange(1)
229 313 xlabel = "Velocity (m/s)"
230 314
231 315 y = self.dataOut.getHeiRange()
232 316 z = self.data[self.CODE]
233 317
234 318 for n, ax in enumerate(self.axes):
235
236 319 if ax.firsttime:
237 320 self.xmax = self.xmax if self.xmax else np.nanmax(x)
238 321 self.xmin = self.xmin if self.xmin else -self.xmax
239 322 self.ymin = self.ymin if self.ymin else np.nanmin(y)
240 323 self.ymax = self.ymax if self.ymax else np.nanmax(y)
241 324 self.zmin = self.zmin if self.zmin else np.nanmin(z)
242 325 self.zmax = self.zmax if self.zmax else np.nanmax(z)
243 326 ax.plot = ax.pcolormesh(x, y, z[n].T,
244 327 vmin=self.zmin,
245 328 vmax=self.zmax,
246 329 cmap=plt.get_cmap(self.colormap)
247 330 )
248 331 divider = make_axes_locatable(ax)
249 332 cax = divider.new_horizontal(size='3%', pad=0.05)
250 333 self.figure.add_axes(cax)
251 334 plt.colorbar(ax.plot, cax)
252 335
253 336 ax.set_xlim(self.xmin, self.xmax)
254 337 ax.set_ylim(self.ymin, self.ymax)
255 338
256 339 ax.set_ylabel(self.ylabel)
257 340 ax.set_xlabel(xlabel)
258 341
259 342 ax.firsttime = False
260 343
261 344 if self.showprofile:
262 345 ax.plot_profile= ax.ax_profile.plot(self.data['rti'][self.max_time][n], y)[0]
263 346 ax.ax_profile.set_xlim(self.zmin, self.zmax)
264 347 ax.ax_profile.set_ylim(self.ymin, self.ymax)
265 348 ax.ax_profile.set_xlabel('dB')
266 349 ax.ax_profile.grid(b=True, axis='x')
267 350 ax.plot_noise = ax.ax_profile.plot(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y,
268 351 color="k", linestyle="dashed", lw=2)[0]
269 352 [tick.set_visible(False) for tick in ax.ax_profile.get_yticklabels()]
270 353 else:
271 354 ax.plot.set_array(z[n].T.ravel())
272 355 if self.showprofile:
273 356 ax.plot_profile.set_data(self.data['rti'][self.max_time][n], y)
274 357 ax.plot_noise.set_data(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y)
275 358
276 359 ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]),
277 360 size=8)
278 361 self.saveTime = self.max_time
279 362
280 363
281 364 class PlotCrossSpectraData(PlotData):
282 365
283 366 CODE = 'cspc'
284 367 zmin_coh = None
285 368 zmax_coh = None
286 369 zmin_phase = None
287 370 zmax_phase = None
288 371 CONFLATE = False
289 372
290 373 def setup(self):
291 374
292 375 ncolspan = 1
293 376 colspan = 1
294 377 self.ncols = 2
295 378 self.nrows = self.dataOut.nPairs
296 379 self.width = 3.6*self.ncols
297 380 self.height = 3.2*self.nrows
298 381
299 382 self.ylabel = 'Range [Km]'
300 383 self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList]
301 384
302 385 if self.figure is None:
303 386 self.figure = plt.figure(figsize=(self.width, self.height),
304 387 edgecolor='k',
305 388 facecolor='w')
306 389 else:
307 390 self.figure.clf()
308 391
309 392 for y in range(self.nrows):
310 393 for x in range(self.ncols):
311 394 ax = plt.subplot2grid((self.nrows, self.ncols), (y, x), 1, 1)
312 395 ax.firsttime = True
313 396 self.axes.append(ax)
314 397
315 398 def plot(self):
316 399
317 400 if self.xaxis == "frequency":
318 401 x = self.dataOut.getFreqRange(1)/1000.
319 402 xlabel = "Frequency (kHz)"
320 403 elif self.xaxis == "time":
321 404 x = self.dataOut.getAcfRange(1)
322 405 xlabel = "Time (ms)"
323 406 else:
324 407 x = self.dataOut.getVelRange(1)
325 408 xlabel = "Velocity (m/s)"
326 409
327 410 y = self.dataOut.getHeiRange()
328 411 z_coh = self.data['cspc_coh']
329 412 z_phase = self.data['cspc_phase']
330 413
331 414 for n in range(self.nrows):
332 415 ax = self.axes[2*n]
333 416 ax1 = self.axes[2*n+1]
334 417 if ax.firsttime:
335 418 self.xmax = self.xmax if self.xmax else np.nanmax(x)
336 419 self.xmin = self.xmin if self.xmin else -self.xmax
337 420 self.ymin = self.ymin if self.ymin else np.nanmin(y)
338 421 self.ymax = self.ymax if self.ymax else np.nanmax(y)
339 422 self.zmin_coh = self.zmin_coh if self.zmin_coh else 0.0
340 423 self.zmax_coh = self.zmax_coh if self.zmax_coh else 1.0
341 424 self.zmin_phase = self.zmin_phase if self.zmin_phase else -180
342 425 self.zmax_phase = self.zmax_phase if self.zmax_phase else 180
343 426
344 427 ax.plot = ax.pcolormesh(x, y, z_coh[n].T,
345 428 vmin=self.zmin_coh,
346 429 vmax=self.zmax_coh,
347 430 cmap=plt.get_cmap(self.colormap_coh)
348 431 )
349 432 divider = make_axes_locatable(ax)
350 433 cax = divider.new_horizontal(size='3%', pad=0.05)
351 434 self.figure.add_axes(cax)
352 435 plt.colorbar(ax.plot, cax)
353 436
354 437 ax.set_xlim(self.xmin, self.xmax)
355 438 ax.set_ylim(self.ymin, self.ymax)
356 439
357 440 ax.set_ylabel(self.ylabel)
358 441 ax.set_xlabel(xlabel)
359 442 ax.firsttime = False
360 443
361 444 ax1.plot = ax1.pcolormesh(x, y, z_phase[n].T,
362 445 vmin=self.zmin_phase,
363 446 vmax=self.zmax_phase,
364 447 cmap=plt.get_cmap(self.colormap_phase)
365 448 )
366 449 divider = make_axes_locatable(ax1)
367 450 cax = divider.new_horizontal(size='3%', pad=0.05)
368 451 self.figure.add_axes(cax)
369 452 plt.colorbar(ax1.plot, cax)
370 453
371 454 ax1.set_xlim(self.xmin, self.xmax)
372 455 ax1.set_ylim(self.ymin, self.ymax)
373 456
374 457 ax1.set_ylabel(self.ylabel)
375 458 ax1.set_xlabel(xlabel)
376 459 ax1.firsttime = False
377 460 else:
378 461 ax.plot.set_array(z_coh[n].T.ravel())
379 462 ax1.plot.set_array(z_phase[n].T.ravel())
380 463
381 464 ax.set_title('Coherence Ch{} * Ch{}'.format(self.dataOut.pairsList[n][0], self.dataOut.pairsList[n][1]), size=8)
382 465 ax1.set_title('Phase Ch{} * Ch{}'.format(self.dataOut.pairsList[n][0], self.dataOut.pairsList[n][1]), size=8)
383 466 self.saveTime = self.max_time
384 467
385 468
386 469 class PlotSpectraMeanData(PlotSpectraData):
387 470
388 471 CODE = 'spc_mean'
389 472 colormap = 'jet'
390 473
391 474 def plot(self):
392 475
393 476 if self.xaxis == "frequency":
394 477 x = self.dataOut.getFreqRange(1)/1000.
395 478 xlabel = "Frequency (kHz)"
396 479 elif self.xaxis == "time":
397 480 x = self.dataOut.getAcfRange(1)
398 481 xlabel = "Time (ms)"
399 482 else:
400 483 x = self.dataOut.getVelRange(1)
401 484 xlabel = "Velocity (m/s)"
402 485
403 486 y = self.dataOut.getHeiRange()
404 487 z = self.data['spc']
405 488 mean = self.data['mean'][self.max_time]
406 489
407 490 for n, ax in enumerate(self.axes):
408 491
409 492 if ax.firsttime:
410 493 self.xmax = self.xmax if self.xmax else np.nanmax(x)
411 494 self.xmin = self.xmin if self.xmin else -self.xmax
412 495 self.ymin = self.ymin if self.ymin else np.nanmin(y)
413 496 self.ymax = self.ymax if self.ymax else np.nanmax(y)
414 497 self.zmin = self.zmin if self.zmin else np.nanmin(z)
415 498 self.zmax = self.zmax if self.zmax else np.nanmax(z)
416 499 ax.plt = ax.pcolormesh(x, y, z[n].T,
417 500 vmin=self.zmin,
418 501 vmax=self.zmax,
419 502 cmap=plt.get_cmap(self.colormap)
420 503 )
421 504 ax.plt_dop = ax.plot(mean[n], y,
422 505 color='k')[0]
423 506
424 507 divider = make_axes_locatable(ax)
425 508 cax = divider.new_horizontal(size='3%', pad=0.05)
426 509 self.figure.add_axes(cax)
427 510 plt.colorbar(ax.plt, cax)
428 511
429 512 ax.set_xlim(self.xmin, self.xmax)
430 513 ax.set_ylim(self.ymin, self.ymax)
431 514
432 515 ax.set_ylabel(self.ylabel)
433 516 ax.set_xlabel(xlabel)
434 517
435 518 ax.firsttime = False
436 519
437 520 if self.showprofile:
438 521 ax.plt_profile= ax.ax_profile.plot(self.data['rti'][self.max_time][n], y)[0]
439 522 ax.ax_profile.set_xlim(self.zmin, self.zmax)
440 523 ax.ax_profile.set_ylim(self.ymin, self.ymax)
441 524 ax.ax_profile.set_xlabel('dB')
442 525 ax.ax_profile.grid(b=True, axis='x')
443 526 ax.plt_noise = ax.ax_profile.plot(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y,
444 527 color="k", linestyle="dashed", lw=2)[0]
445 528 [tick.set_visible(False) for tick in ax.ax_profile.get_yticklabels()]
446 529 else:
447 530 ax.plt.set_array(z[n].T.ravel())
448 531 ax.plt_dop.set_data(mean[n], y)
449 532 if self.showprofile:
450 533 ax.plt_profile.set_data(self.data['rti'][self.max_time][n], y)
451 534 ax.plt_noise.set_data(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y)
452 535
453 536 ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]),
454 537 size=8)
455 538 self.saveTime = self.max_time
456 539
457 540
458 541 class PlotRTIData(PlotData):
459 542
460 543 CODE = 'rti'
461 544 colormap = 'jro'
462 545
463 546 def setup(self):
464 547 self.ncols = 1
465 548 self.nrows = self.dataOut.nChannels
466 549 self.width = 10
467 self.height = 2.2*self.nrows if self.nrows<6 else 12
550 #TODO : arreglar la altura de la figura, esta hardcodeada.
551 #Se arreglo, testear!
552 if self.ind_plt_ch:
553 self.height = 3.2#*self.nrows if self.nrows<6 else 12
554 else:
555 self.height = 2.2*self.nrows if self.nrows<6 else 12
556
557 '''
468 558 if self.nrows==1:
469 559 self.height += 1
560 '''
470 561 self.ylabel = 'Range [Km]'
471 562 self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList]
472 563
473 if self.figure is None:
474 self.figure = plt.figure(figsize=(self.width, self.height),
475 edgecolor='k',
476 facecolor='w')
477 else:
478 self.figure.clf()
479 self.axes = []
480
481 for n in range(self.nrows):
482 ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
483 ax.firsttime = True
484 self.axes.append(ax)
485
486 def plot(self):
487
488 self.x = np.array(self.times)
489 self.y = self.dataOut.getHeiRange()
490 self.z = []
491
492 for ch in range(self.nrows):
493 self.z.append([self.data[self.CODE][t][ch] for t in self.times])
494
495 self.z = np.array(self.z)
496 for n, ax in enumerate(self.axes):
497 x, y, z = self.fill_gaps(*self.decimate())
498 if self.xmin is None:
499 xmin = self.min_time
500 else:
501 xmin = fromtimestamp(int(self.xmin), self.min_time)
502 if self.xmax is None:
503 xmax = xmin + self.xrange*60*60
564 '''
565 Logica:
566 1) Si la variable ind_plt_ch es True, va a crear mas de 1 figura
567 2) guardamos "Figures" en una lista y "axes" en otra, quizas se deberia guardar el
568 axis dentro de "Figures" como un diccionario.
569 '''
570 if self.ind_plt_ch is False: #standard mode
571
572 if self.figure is None: #solo para la priemra vez
573 self.figure = plt.figure(figsize=(self.width, self.height),
574 edgecolor='k',
575 facecolor='w')
504 576 else:
505 xmax = xmin + (self.xmax - self.xmin) * 60 * 60
506 self.zmin = self.zmin if self.zmin else np.min(self.z)
507 self.zmax = self.zmax if self.zmax else np.max(self.z)
508 if ax.firsttime:
509 self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
510 self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
511 plot = ax.pcolormesh(x, y, z[n].T,
512 vmin=self.zmin,
513 vmax=self.zmax,
514 cmap=plt.get_cmap(self.colormap)
515 )
516 divider = make_axes_locatable(ax)
517 cax = divider.new_horizontal(size='2%', pad=0.05)
518 self.figure.add_axes(cax)
519 plt.colorbar(plot, cax)
520 ax.set_ylim(self.ymin, self.ymax)
577 self.figure.clf()
578 self.axes = []
521 579
522 ax.xaxis.set_major_formatter(FuncFormatter(func))
523 ax.xaxis.set_major_locator(LinearLocator(6))
524 580
525 ax.set_ylabel(self.ylabel)
581 for n in range(self.nrows):
582 ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
583 #ax = self.figure(n+1)
584 ax.firsttime = True
585 self.axes.append(ax)
586
587 else : #append one figure foreach channel in channelList
588 if self.figurelist == None:
589 self.figurelist = []
590 for n in range(self.nrows):
591 self.figure = plt.figure(figsize=(self.width, self.height),
592 edgecolor='k',
593 facecolor='w')
594 #add always one subplot
595 self.figurelist.append(self.figure)
596
597 else : # cada dia nuevo limpia el axes, pero mantiene el figure
598 for eachfigure in self.figurelist:
599 eachfigure.clf() # eliminaria todas las figuras de la lista?
600 self.axes = []
601
602 for eachfigure in self.figurelist:
603 ax = eachfigure.add_subplot(1,1,1) #solo 1 axis por figura
604 #ax = self.figure(n+1)
605 ax.firsttime = True
606 #Cada figura tiene un distinto puntero
607 self.axes.append(ax)
608 #plt.close(eachfigure)
526 609
527 # if self.xmin is None:
528 # xmin = self.min_time
529 # else:
530 # xmin = (datetime.datetime.combine(self.dataOut.datatime.date(),
531 # datetime.time(self.xmin, 0, 0))-d1970).total_seconds()
532 610
533 ax.set_xlim(xmin, xmax)
534 ax.firsttime = False
535 else:
536 ax.collections.remove(ax.collections[0])
537 ax.set_xlim(xmin, xmax)
538 plot = ax.pcolormesh(x, y, z[n].T,
539 vmin=self.zmin,
540 vmax=self.zmax,
541 cmap=plt.get_cmap(self.colormap)
542 )
543 ax.set_title('{} {}'.format(self.titles[n],
544 datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
545 size=8)
611 def plot(self):
546 612
547 self.saveTime = self.min_time
613 if self.ind_plt_ch is False: #standard mode
614 self.x = np.array(self.times)
615 self.y = self.dataOut.getHeiRange()
616 self.z = []
617
618 for ch in range(self.nrows):
619 self.z.append([self.data[self.CODE][t][ch] for t in self.times])
620
621 self.z = np.array(self.z)
622 for n, ax in enumerate(self.axes):
623 x, y, z = self.fill_gaps(*self.decimate())
624 if self.xmin is None:
625 xmin = self.min_time
626 else:
627 xmin = fromtimestamp(int(self.xmin), self.min_time)
628 if self.xmax is None:
629 xmax = xmin + self.xrange*60*60
630 else:
631 xmax = xmin + (self.xmax - self.xmin) * 60 * 60
632 self.zmin = self.zmin if self.zmin else np.min(self.z)
633 self.zmax = self.zmax if self.zmax else np.max(self.z)
634 if ax.firsttime:
635 self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
636 self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
637 plot = ax.pcolormesh(x, y, z[n].T,
638 vmin=self.zmin,
639 vmax=self.zmax,
640 cmap=plt.get_cmap(self.colormap)
641 )
642 divider = make_axes_locatable(ax)
643 cax = divider.new_horizontal(size='2%', pad=0.05)
644 self.figure.add_axes(cax)
645 plt.colorbar(plot, cax)
646 ax.set_ylim(self.ymin, self.ymax)
647 ax.xaxis.set_major_formatter(FuncFormatter(func))
648 ax.xaxis.set_major_locator(LinearLocator(6))
649 ax.set_ylabel(self.ylabel)
650 # if self.xmin is None:
651 # xmin = self.min_time
652 # else:
653 # xmin = (datetime.datetime.combine(self.dataOut.datatime.date(),
654 # datetime.time(self.xmin, 0, 0))-d1970).total_seconds()
655
656 ax.set_xlim(xmin, xmax)
657 ax.firsttime = False
658 else:
659 ax.collections.remove(ax.collections[0])
660 ax.set_xlim(xmin, xmax)
661 plot = ax.pcolormesh(x, y, z[n].T,
662 vmin=self.zmin,
663 vmax=self.zmax,
664 cmap=plt.get_cmap(self.colormap)
665 )
666 ax.set_title('{} {}'.format(self.titles[n],
667 datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
668 size=8)
669
670 self.saveTime = self.min_time
671 else :
672 self.x = np.array(self.times)
673 self.y = self.dataOut.getHeiRange()
674 self.z = []
675
676 for ch in range(self.nrows):
677 self.z.append([self.data[self.CODE][t][ch] for t in self.times])
678
679 self.z = np.array(self.z)
680 for n, eachfigure in enumerate(self.figurelist): #estaba ax in axes
681
682 x, y, z = self.fill_gaps(*self.decimate())
683 xmin = self.min_time
684 xmax = xmin+self.xrange*60*60
685 self.zmin = self.zmin if self.zmin else np.min(self.z)
686 self.zmax = self.zmax if self.zmax else np.max(self.z)
687 if self.axes[n].firsttime:
688 self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
689 self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
690 plot = self.axes[n].pcolormesh(x, y, z[n].T,
691 vmin=self.zmin,
692 vmax=self.zmax,
693 cmap=plt.get_cmap(self.colormap)
694 )
695 divider = make_axes_locatable(self.axes[n])
696 cax = divider.new_horizontal(size='2%', pad=0.05)
697 eachfigure.add_axes(cax)
698 #self.figure2.add_axes(cax)
699 plt.colorbar(plot, cax)
700 self.axes[n].set_ylim(self.ymin, self.ymax)
701
702 self.axes[n].xaxis.set_major_formatter(FuncFormatter(func))
703 self.axes[n].xaxis.set_major_locator(LinearLocator(6))
704
705 self.axes[n].set_ylabel(self.ylabel)
706
707 if self.xmin is None:
708 xmin = self.min_time
709 else:
710 xmin = (datetime.datetime.combine(self.dataOut.datatime.date(),
711 datetime.time(self.xmin, 0, 0))-d1970).total_seconds()
712
713 self.axes[n].set_xlim(xmin, xmax)
714 self.axes[n].firsttime = False
715 else:
716 self.axes[n].collections.remove(self.axes[n].collections[0])
717 self.axes[n].set_xlim(xmin, xmax)
718 plot = self.axes[n].pcolormesh(x, y, z[n].T,
719 vmin=self.zmin,
720 vmax=self.zmax,
721 cmap=plt.get_cmap(self.colormap)
722 )
723 self.axes[n].set_title('{} {}'.format(self.titles[n],
724 datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
725 size=8)
726
727 self.saveTime = self.min_time
548 728
549 729
550 730 class PlotCOHData(PlotRTIData):
551 731
552 732 CODE = 'coh'
553 733
554 734 def setup(self):
555 735
556 736 self.ncols = 1
557 737 self.nrows = self.dataOut.nPairs
558 738 self.width = 10
559 739 self.height = 2.2*self.nrows if self.nrows<6 else 12
740 self.ind_plt_ch = False #just for coherence and phase
560 741 if self.nrows==1:
561 742 self.height += 1
562 743 self.ylabel = 'Range [Km]'
563 744 self.titles = ['{} Ch{} * Ch{}'.format(self.CODE.upper(), x[0], x[1]) for x in self.dataOut.pairsList]
564 745
565 746 if self.figure is None:
566 747 self.figure = plt.figure(figsize=(self.width, self.height),
567 748 edgecolor='k',
568 749 facecolor='w')
569 750 else:
570 751 self.figure.clf()
571 752 self.axes = []
572 753
573 754 for n in range(self.nrows):
574 755 ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
575 756 ax.firsttime = True
576 757 self.axes.append(ax)
577 758
578 759
579 760 class PlotNoiseData(PlotData):
580 761 CODE = 'noise'
581 762
582 763 def setup(self):
583 764
584 765 self.ncols = 1
585 766 self.nrows = 1
586 767 self.width = 10
587 768 self.height = 3.2
588 769 self.ylabel = 'Intensity [dB]'
589 770 self.titles = ['Noise']
590 771
591 772 if self.figure is None:
592 773 self.figure = plt.figure(figsize=(self.width, self.height),
593 774 edgecolor='k',
594 775 facecolor='w')
595 776 else:
596 777 self.figure.clf()
597 778 self.axes = []
598 779
599 780 self.ax = self.figure.add_subplot(self.nrows, self.ncols, 1)
600 781 self.ax.firsttime = True
601 782
602 783 def plot(self):
603 784
604 785 x = self.times
605 786 xmin = self.min_time
606 787 xmax = xmin+self.xrange*60*60
607 788 if self.ax.firsttime:
608 789 for ch in self.dataOut.channelList:
609 790 y = [self.data[self.CODE][t][ch] for t in self.times]
610 791 self.ax.plot(x, y, lw=1, label='Ch{}'.format(ch))
611 792 self.ax.firsttime = False
612 793 self.ax.xaxis.set_major_formatter(FuncFormatter(func))
613 794 self.ax.xaxis.set_major_locator(LinearLocator(6))
614 795 self.ax.set_ylabel(self.ylabel)
615 796 plt.legend()
616 797 else:
617 798 for ch in self.dataOut.channelList:
618 799 y = [self.data[self.CODE][t][ch] for t in self.times]
619 800 self.ax.lines[ch].set_data(x, y)
620 801
621 802 self.ax.set_xlim(xmin, xmax)
622 803 self.ax.set_ylim(min(y)-5, max(y)+5)
623 804 self.saveTime = self.min_time
624 805
625 806
626 807 class PlotWindProfilerData(PlotRTIData):
627 808
628 809 CODE = 'wind'
629 810 colormap = 'seismic'
630 811
631 812 def setup(self):
632 813 self.ncols = 1
633 814 self.nrows = self.dataOut.data_output.shape[0]
634 815 self.width = 10
635 816 self.height = 2.2*self.nrows
636 817 self.ylabel = 'Height [Km]'
637 818 self.titles = ['Zonal Wind' ,'Meridional Wind', 'Vertical Wind']
638 819 self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
639 820 self.windFactor = [1, 1, 100]
640 821
641 822 if self.figure is None:
642 823 self.figure = plt.figure(figsize=(self.width, self.height),
643 824 edgecolor='k',
644 825 facecolor='w')
645 826 else:
646 827 self.figure.clf()
647 828 self.axes = []
648 829
649 830 for n in range(self.nrows):
650 831 ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
651 832 ax.firsttime = True
652 833 self.axes.append(ax)
653 834
654 835 def plot(self):
655 836
656 837 self.x = np.array(self.times)
657 838 self.y = self.dataOut.heightList
658 839 self.z = []
659 840
660 841 for ch in range(self.nrows):
661 842 self.z.append([self.data['output'][t][ch] for t in self.times])
662 843
663 844 self.z = np.array(self.z)
664 845 self.z = numpy.ma.masked_invalid(self.z)
665 846
666 847 cmap=plt.get_cmap(self.colormap)
667 848 cmap.set_bad('black', 1.)
668 849
669 850 for n, ax in enumerate(self.axes):
670 851 x, y, z = self.fill_gaps(*self.decimate())
671 852 xmin = self.min_time
672 853 xmax = xmin+self.xrange*60*60
673 854 if ax.firsttime:
674 855 self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
675 856 self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
676 857 self.zmax = self.zmax if self.zmax else numpy.nanmax(abs(self.z[:-1, :]))
677 858 self.zmin = self.zmin if self.zmin else -self.zmax
678 859
679 860 plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n],
680 861 vmin=self.zmin,
681 862 vmax=self.zmax,
682 863 cmap=cmap
683 864 )
684 865 divider = make_axes_locatable(ax)
685 866 cax = divider.new_horizontal(size='2%', pad=0.05)
686 867 self.figure.add_axes(cax)
687 868 cb = plt.colorbar(plot, cax)
688 869 cb.set_label(self.clabels[n])
689 870 ax.set_ylim(self.ymin, self.ymax)
690 871
691 872 ax.xaxis.set_major_formatter(FuncFormatter(func))
692 873 ax.xaxis.set_major_locator(LinearLocator(6))
693 874
694 875 ax.set_ylabel(self.ylabel)
695 876
696 877 ax.set_xlim(xmin, xmax)
697 878 ax.firsttime = False
698 879 else:
699 880 ax.collections.remove(ax.collections[0])
700 881 ax.set_xlim(xmin, xmax)
701 882 plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n],
702 883 vmin=self.zmin,
703 884 vmax=self.zmax,
704 885 cmap=plt.get_cmap(self.colormap)
705 886 )
706 887 ax.set_title('{} {}'.format(self.titles[n],
707 888 datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
708 889 size=8)
709 890
710 891 self.saveTime = self.min_time
711 892
712 893
713 894 class PlotSNRData(PlotRTIData):
714 895 CODE = 'snr'
715 896 colormap = 'jet'
716 897
717 898 class PlotDOPData(PlotRTIData):
718 899 CODE = 'dop'
719 900 colormap = 'jet'
720 901
721 902
722 903 class PlotPHASEData(PlotCOHData):
723 904 CODE = 'phase'
724 905 colormap = 'seismic'
725 906
726 907
727 908 class PlotSkyMapData(PlotData):
728 909
729 910 CODE = 'met'
730 911
731 912 def setup(self):
732 913
733 914 self.ncols = 1
734 915 self.nrows = 1
735 916 self.width = 7.2
736 917 self.height = 7.2
737 918
738 919 self.xlabel = 'Zonal Zenith Angle (deg)'
739 920 self.ylabel = 'Meridional Zenith Angle (deg)'
740 921
741 922 if self.figure is None:
742 923 self.figure = plt.figure(figsize=(self.width, self.height),
743 924 edgecolor='k',
744 925 facecolor='w')
745 926 else:
746 927 self.figure.clf()
747 928
748 929 self.ax = plt.subplot2grid((self.nrows, self.ncols), (0, 0), 1, 1, polar=True)
749 930 self.ax.firsttime = True
750 931
751 932
752 933 def plot(self):
753 934
754 935 arrayParameters = np.concatenate([self.data['param'][t] for t in self.times])
755 936 error = arrayParameters[:,-1]
756 937 indValid = numpy.where(error == 0)[0]
757 938 finalMeteor = arrayParameters[indValid,:]
758 939 finalAzimuth = finalMeteor[:,3]
759 940 finalZenith = finalMeteor[:,4]
760 941
761 942 x = finalAzimuth*numpy.pi/180
762 943 y = finalZenith
763 944
764 945 if self.ax.firsttime:
765 946 self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0]
766 947 self.ax.set_ylim(0,90)
767 948 self.ax.set_yticks(numpy.arange(0,90,20))
768 949 self.ax.set_xlabel(self.xlabel)
769 950 self.ax.set_ylabel(self.ylabel)
770 951 self.ax.yaxis.labelpad = 40
771 952 self.ax.firsttime = False
772 953 else:
773 954 self.ax.plot.set_data(x, y)
774 955
775 956
776 957 dt1 = datetime.datetime.fromtimestamp(self.min_time).strftime('%y/%m/%d %H:%M:%S')
777 958 dt2 = datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')
778 959 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
779 960 dt2,
780 961 len(x))
781 962 self.ax.set_title(title, size=8)
782 963
783 964 self.saveTime = self.max_time
@@ -1,1 +1,1
1 <Project description="JASMET Meteor Detection" id="002" name="script02"><ReadUnit datatype="VoltageReader" id="21" inputId="0" name="VoltageReader"><Operation id="211" name="run" priority="1" type="self"><Parameter format="str" id="2111" name="datatype" value="VoltageReader" /><Parameter format="str" id="2112" name="path" value="/home/nanosat/data/jasmet" /><Parameter format="date" id="2113" name="startDate" value="2010/08/29" /><Parameter format="date" id="2114" name="endDate" value="2017/09/11" /><Parameter format="time" id="2115" name="startTime" value="00:00:00" /><Parameter format="time" id="2116" name="endTime" value="23:59:59" /><Parameter format="int" id="2118" name="delay" value="30" /><Parameter format="int" id="2119" name="blocktime" value="100" /><Parameter format="int" id="2120" name="getblock" value="1" /><Parameter format="int" id="2121" name="walk" value="1" /><Parameter format="int" id="2122" name="online" value="0" /></Operation><Operation id="212" name="printNumberOfBlock" priority="2" type="self" /></ReadUnit><ProcUnit datatype="VoltageProc" id="22" inputId="21" name="VoltageProc"><Operation id="221" name="run" priority="1" type="self" /><Operation id="222" name="selectChannels" priority="2" type="self"><Parameter format="intlist" id="2221" name="channelList" value="0,1,2,3,4" /></Operation><Operation id="223" name="setRadarFrequency" priority="3" type="self"><Parameter format="float" id="2231" name="frequency" value="30.e6" /></Operation><Operation id="224" name="interpolateHeights" priority="4" type="self"><Parameter format="int" id="2241" name="topLim" value="73" /><Parameter format="int" id="2242" name="botLim" value="71" /></Operation><Operation id="225" name="Decoder" priority="5" type="other" /><Operation id="226" name="CohInt" priority="6" type="other"><Parameter format="int" id="2261" name="n" value="2" /></Operation></ProcUnit><ProcUnit datatype="ParametersProc" id="23" inputId="22" name="ParametersProc"><Operation id="231" name="run" priority="1" type="self" /><Operation id="232" name="SMDetection" priority="2" type="other"><Parameter format="float" id="2321" name="azimuth" value="45" /><Parameter format="float" id="2322" name="hmin" value="60" /><Parameter format="float" id="2323" name="hmax" value="120" /></Operation><Operation id="233" name="ParamWriter" priority="3" type="other"><Parameter format="str" id="2331" name="path" value="/home/nanosat/Pictures/JASMET30/201608/meteor" /><Parameter format="int" id="2332" name="blocksPerFile" value="1000" /><Parameter format="list" id="2333" name="metadataList" value="type,heightList,paramInterval,timeZone" /><Parameter format="list" id="2334" name="dataList" value="data_param,utctime" /><Parameter format="int" id="2335" name="mode" value="2" /></Operation></ProcUnit></Project> No newline at end of file
1 <Project description="Claire" id="002" name="script02"><ReadUnit datatype="VoltageReader" id="21" inputId="0" name="VoltageReader"><Operation id="211" name="run" priority="1" type="self"><Parameter format="str" id="2111" name="datatype" value="VoltageReader" /><Parameter format="str" id="2112" name="path" value="/media/nanosat/0BDE10E00BDE10E0/CLAIRE" /><Parameter format="date" id="2113" name="startDate" value="2017/07/26" /><Parameter format="date" id="2114" name="endDate" value="2017/07/26" /><Parameter format="time" id="2115" name="startTime" value="9:30:0" /><Parameter format="time" id="2116" name="endTime" value="23:59:59" /><Parameter format="int" id="2118" name="online" value="0" /><Parameter format="int" id="2119" name="walk" value="1" /></Operation><Operation id="212" name="printNumberOfBlock" priority="2" type="self" /></ReadUnit><ProcUnit datatype="VoltageProc" id="22" inputId="21" name="VoltageProc"><Operation id="221" name="run" priority="1" type="self" /></ProcUnit><ProcUnit datatype="SpectraProc" id="23" inputId="22" name="SpectraProc"><Operation id="231" name="run" priority="1" type="self"><Parameter format="int" id="2311" name="nFFTPoints" value="128" /><Parameter format="int" id="2312" name="nProfiles" value="128" /><Parameter format="pairslist" id="2313" name="pairsList" value="(0,1),(0,2),(1,2)" /></Operation><Operation id="232" name="setRadarFrequency" priority="2" type="self"><Parameter format="float" id="2321" name="frequency" value="445000000.0" /></Operation><Operation id="233" name="IncohInt" priority="3" type="other"><Parameter format="float" id="2331" name="timeInterval" value="2" /></Operation><Operation id="234" name="removeDC" priority="4" type="self"><Parameter format="int" id="2341" name="mode" value="2" /></Operation><Operation id="235" name="PublishData" priority="5" type="other"><Parameter format="int" id="2351" name="zeromq" value="1" /><Parameter format="bool" id="2352" name="verbose" value="0" /></Operation></ProcUnit></Project> No newline at end of file
@@ -1,65 +1,64
1 1 """.
2 2
3 3 Created on Jul 16, 2014
4 4
5 5 @author: Miguel Urco
6 6 """
7 7
8 from schainpy import __version__
8 import numpy
9 9 from setuptools import setup, Extension
10 10 import numpy
11 11
12 12 setup(name="schainpy",
13 13 version=__version__,
14 14 description="Python tools to read, write and process Jicamarca data",
15 15 author="Miguel Urco",
16 16 author_email="miguel.urco@jro.igp.gob.pe",
17 17 url="http://jro.igp.gob.pe",
18 18 packages={'schainpy',
19 19 'schainpy.model',
20 20 'schainpy.model.data',
21 21 'schainpy.model.graphics',
22 22 'schainpy.model.io',
23 23 'schainpy.model.proc',
24 24 'schainpy.model.serializer',
25 25 'schainpy.model.utils',
26 26 'schainpy.gui',
27 27 'schainpy.gui.figures',
28 28 'schainpy.gui.viewcontroller',
29 29 'schainpy.gui.viewer',
30 30 'schainpy.gui.viewer.windows'},
31 31 ext_package='schainpy',
32 32 py_modules=[''],
33 33 package_data={'': ['schain.conf.template'],
34 34 'schainpy.gui.figures': ['*.png', '*.jpg'],
35 35 },
36 36 include_package_data=False,
37 37 entry_points={
38 38 'console_scripts': [
39 39 'schain = schaincli.cli:main',
40 40 ],
41 41 },
42 42 scripts=['schainpy/gui/schainGUI'],
43 43 ext_modules=[
44 44 Extension("cSchain",
45 45 ["schainpy/model/proc/extensions.c"],
46 46 include_dirs=[numpy.get_include()],
47 47 #extra_compile_args=['-Werror'],
48 48 )
49 49 ],
50 50 install_requires=[
51 51 "scipy >= 0.14.0",
52 52 "h5py >= 2.2.1",
53 53 "matplotlib >= 1.4.2",
54 "pyfits >= 3.4",
55 "numpy >= 1.11.2",
54 "pyfits >= 3.4",
56 55 "paramiko >= 2.1.2",
57 56 "paho-mqtt >= 1.2",
58 57 "zmq",
59 58 "fuzzywuzzy",
60 59 "click",
61 60 "colorama",
62 61 "python-Levenshtein"
63 62 ],
64 63 )
65 64
General Comments 0
You need to be logged in to leave comments. Login now