##// END OF EJS Templates
Merging remote and local
jespinoza -
r908:2205da7ed447 merge
parent child
Show More
@@ -96,3 +96,7 ENV/
96
96
97 # mkdocs documentation
97 # mkdocs documentation
98 /site
98 /site
99
100 # eclipse
101 .project
102 .pydevproject
@@ -4,4 +4,4 Created on Feb 7, 2012
4 @author $Author$
4 @author $Author$
5 @version $Id$
5 @version $Id$
6 '''
6 '''
7 __version__ = "2.2.5" No newline at end of file
7 __version__ = "2.3" No newline at end of file
@@ -438,7 +438,8 class OperationConf():
438
438
439 def createObject(self, plotter_queue=None):
439 def createObject(self, plotter_queue=None):
440
440
441 if self.type == 'self':
441
442 if self.type == 'self':
442 raise ValueError, "This operation type cannot be created"
443 raise ValueError, "This operation type cannot be created"
443
444
444 if self.type == 'plotter':
445 if self.type == 'plotter':
@@ -449,10 +450,10 class OperationConf():
449 opObj = Plotter(self.name, plotter_queue)
450 opObj = Plotter(self.name, plotter_queue)
450
451
451 if self.type == 'external' or self.type == 'other':
452 if self.type == 'external' or self.type == 'other':
452 print self.name
453
453 className = eval(self.name)
454 className = eval(self.name)
454 kwargs = self.getKwargs()
455 kwargs = self.getKwargs()
455 print kwargs
456
456 opObj = className(**kwargs)
457 opObj = className(**kwargs)
457
458
458 return opObj
459 return opObj
@@ -671,14 +672,18 class ProcUnitConf():
671 kwargs = self.getKwargs()
672 kwargs = self.getKwargs()
672 procUnitObj = className(**kwargs)
673 procUnitObj = className(**kwargs)
673
674
674 for opConfObj in self.opConfObjList:
675 for opConfObj in self.opConfObjList:
675
676
676 if opConfObj.type == 'self':
677 if opConfObj.type=='self' and self.name=='run':
678 continue
679 elif opConfObj.type=='self':
680 procUnitObj.addOperationKwargs(opConfObj.id, **opConfObj.getKwargs())
677 continue
681 continue
678
682
679 opObj = opConfObj.createObject(plotter_queue)
683 opObj = opConfObj.createObject(plotter_queue)
680
684
681 self.opObjDict[opConfObj.id] = opObj
685 self.opObjDict[opConfObj.id] = opObj
686
682 procUnitObj.addOperation(opObj, opConfObj.id)
687 procUnitObj.addOperation(opObj, opConfObj.id)
683
688
684 self.procUnitObj = procUnitObj
689 self.procUnitObj = procUnitObj
@@ -29,8 +29,9 class PlotData(Operation, Process):
29
29
30 def __init__(self, **kwargs):
30 def __init__(self, **kwargs):
31
31
32 Operation.__init__(self, **kwargs)
32 Operation.__init__(self, plot=True, **kwargs)
33 Process.__init__(self)
33 Process.__init__(self)
34 self.kwargs['code'] = self.CODE
34 self.mp = False
35 self.mp = False
35 self.dataOut = None
36 self.dataOut = None
36 self.isConfig = False
37 self.isConfig = False
@@ -35,12 +35,20 class ProcessingUnit(object):
35 self.dataOut = None
35 self.dataOut = None
36
36
37 self.operations2RunDict = {}
37 self.operations2RunDict = {}
38 self.operationKwargs = {}
38
39
39 self.isConfig = False
40 self.isConfig = False
40
41
41 self.args = args
42 self.args = args
42 self.kwargs = kwargs
43 self.kwargs = kwargs
43
44
45 def addOperationKwargs(self, objId, **kwargs):
46 '''
47 '''
48
49 self.operationKwargs[objId] = kwargs
50
51
44 def addOperation(self, opObj, objId):
52 def addOperation(self, opObj, objId):
45
53
46 """
54 """
@@ -80,7 +88,7 class ProcessingUnit(object):
80
88
81 raise NotImplementedError
89 raise NotImplementedError
82
90
83 def callMethod(self, name, **kwargs):
91 def callMethod(self, name, opId):
84
92
85 """
93 """
86 Ejecuta el metodo con el nombre "name" y con argumentos **kwargs de la propia clase.
94 Ejecuta el metodo con el nombre "name" y con argumentos **kwargs de la propia clase.
@@ -100,7 +108,7 class ProcessingUnit(object):
100 return False
108 return False
101 else:
109 else:
102 #Si no es un metodo RUN la entrada es la misma dataOut (interna)
110 #Si no es un metodo RUN la entrada es la misma dataOut (interna)
103 if self.dataOut.isEmpty():
111 if self.dataOut is not None and self.dataOut.isEmpty():
104 return False
112 return False
105
113
106 #Getting the pointer to method
114 #Getting the pointer to method
@@ -109,11 +117,17 class ProcessingUnit(object):
109 #Executing the self method
117 #Executing the self method
110
118
111 if hasattr(self, 'mp'):
119 if hasattr(self, 'mp'):
112 if self.mp is False:
120 if name=='run':
113 self.mp = True
121 if self.mp is False:
114 self.start()
122 self.mp = True
123 self.start()
124 else:
125 methodToCall(**self.operationKwargs[opId])
115 else:
126 else:
116 methodToCall(**kwargs)
127 if name=='run':
128 methodToCall(**self.kwargs)
129 else:
130 methodToCall(**self.operationKwargs[opId])
117
131
118 if self.dataOut is None:
132 if self.dataOut is None:
119 return False
133 return False
@@ -146,10 +160,12 class ProcessingUnit(object):
146
160
147 if hasattr(externalProcObj, 'mp'):
161 if hasattr(externalProcObj, 'mp'):
148 if externalProcObj.mp is False:
162 if externalProcObj.mp is False:
163 self.operationKwargs[objId] = externalProcObj.kwargs
149 externalProcObj.mp = True
164 externalProcObj.mp = True
150 externalProcObj.start()
165 externalProcObj.start()
151 else:
166 else:
152 externalProcObj.run(self.dataOut, **externalProcObj.kwargs)
167 externalProcObj.run(self.dataOut, **externalProcObj.kwargs)
168 self.operationKwargs[objId] = externalProcObj.kwargs
153
169
154 return True
170 return True
155
171
@@ -198,7 +214,7 class ProcessingUnit(object):
198 if not opName:
214 if not opName:
199 raise ValueError, "opName parameter should be defined"
215 raise ValueError, "opName parameter should be defined"
200
216
201 sts = self.callMethod(opName, **self.kwargs)
217 sts = self.callMethod(opName, opId)
202
218
203 elif opType == 'other' or opType == 'external' or opType == 'plotter':
219 elif opType == 'other' or opType == 'external' or opType == 'plotter':
204
220
@@ -518,9 +518,6 class WindProfiler(Operation):
518
518
519 n = None
519 n = None
520
520
521 def __init__(self):
522 Operation.__init__(self)
523
524 def __calculateCosDir(self, elev, azim):
521 def __calculateCosDir(self, elev, azim):
525 zen = (90 - elev)*numpy.pi/180
522 zen = (90 - elev)*numpy.pi/180
526 azim = azim*numpy.pi/180
523 azim = azim*numpy.pi/180
@@ -1204,8 +1201,6 class WindProfiler(Operation):
1204
1201
1205 class EWDriftsEstimation(Operation):
1202 class EWDriftsEstimation(Operation):
1206
1203
1207 def __init__(self):
1208 Operation.__init__(self)
1209
1204
1210 def __correctValues(self, heiRang, phi, velRadial, SNR):
1205 def __correctValues(self, heiRang, phi, velRadial, SNR):
1211 listPhi = phi.tolist()
1206 listPhi = phi.tolist()
@@ -2032,7 +2027,7 class SMDetection(Operation):
2032 timeLag = 45*10**-3
2027 timeLag = 45*10**-3
2033 else:
2028 else:
2034 timeLag = 15*10**-3
2029 timeLag = 15*10**-3
2035 lag = numpy.ceil(timeLag/timeInterval)
2030 lag = int(numpy.ceil(timeLag/timeInterval))
2036
2031
2037 listMeteors1 = []
2032 listMeteors1 = []
2038
2033
@@ -29,6 +29,10 def roundFloats(obj):
29 elif isinstance(obj, float):
29 elif isinstance(obj, float):
30 return round(obj, 2)
30 return round(obj, 2)
31
31
32 def decimate(z):
33 # dx = int(len(self.x)/self.__MAXNUMX) + 1
34 dy = int(len(z[0])/MAXNUMY) + 1
35 return z[::, ::dy]
32
36
33 class throttle(object):
37 class throttle(object):
34 """Decorator that prevents a function from being called more than once every
38 """Decorator that prevents a function from being called more than once every
@@ -258,15 +262,23 class ReceiverData(ProcessingUnit, Process):
258 Process.__init__(self)
262 Process.__init__(self)
259 self.mp = False
263 self.mp = False
260 self.isConfig = False
264 self.isConfig = False
265 self.isWebConfig = False
261 self.plottypes =[]
266 self.plottypes =[]
262 self.connections = 0
267 self.connections = 0
263 server = kwargs.get('server', 'zmq.pipe')
268 server = kwargs.get('server', 'zmq.pipe')
269 plot_server = kwargs.get('plot_server', 'zmq.web')
264 if 'tcp://' in server:
270 if 'tcp://' in server:
265 address = server
271 address = server
266 else:
272 else:
267 address = 'ipc:///tmp/%s' % server
273 address = 'ipc:///tmp/%s' % server
268
274
275 if 'tcp://' in plot_server:
276 plot_address = plot_server
277 else:
278 plot_address = 'ipc:///tmp/%s' % plot_server
279
269 self.address = address
280 self.address = address
281 self.plot_address = plot_address
270 self.plottypes = [s.strip() for s in kwargs.get('plottypes', 'rti').split(',')]
282 self.plottypes = [s.strip() for s in kwargs.get('plottypes', 'rti').split(',')]
271 self.realtime = kwargs.get('realtime', False)
283 self.realtime = kwargs.get('realtime', False)
272 self.throttle_value = kwargs.get('throttle', 10)
284 self.throttle_value = kwargs.get('throttle', 10)
@@ -283,6 +295,7 class ReceiverData(ProcessingUnit, Process):
283 self.data['throttle'] = self.throttle_value
295 self.data['throttle'] = self.throttle_value
284 self.data['ENDED'] = False
296 self.data['ENDED'] = False
285 self.isConfig = True
297 self.isConfig = True
298 self.data_web = {}
286
299
287 def event_monitor(self, monitor):
300 def event_monitor(self, monitor):
288
301
@@ -318,7 +331,7 class ReceiverData(ProcessingUnit, Process):
318 return sendDataThrottled
331 return sendDataThrottled
319
332
320 def send(self, data):
333 def send(self, data):
321 print '[sending] data=%s size=%s' % (data.keys(), len(data['times']))
334 # print '[sending] data=%s size=%s' % (data.keys(), len(data['times']))
322 self.sender.send_pyobj(data)
335 self.sender.send_pyobj(data)
323
336
324 def update(self):
337 def update(self):
@@ -327,7 +340,6 class ReceiverData(ProcessingUnit, Process):
327 self.data['times'].append(t)
340 self.data['times'].append(t)
328 self.data['dataOut'] = self.dataOut
341 self.data['dataOut'] = self.dataOut
329 for plottype in self.plottypes:
342 for plottype in self.plottypes:
330
331 if plottype == 'spc':
343 if plottype == 'spc':
332 z = self.dataOut.data_spc/self.dataOut.normFactor
344 z = self.dataOut.data_spc/self.dataOut.normFactor
333 self.data[plottype] = 10*numpy.log10(z)
345 self.data[plottype] = 10*numpy.log10(z)
@@ -342,7 +354,9 class ReceiverData(ProcessingUnit, Process):
342 self.data[plottype][t] = self.dataOut.getCoherence()
354 self.data[plottype][t] = self.dataOut.getCoherence()
343 if plottype == 'phase':
355 if plottype == 'phase':
344 self.data[plottype][t] = self.dataOut.getCoherence(phase=True)
356 self.data[plottype][t] = self.dataOut.getCoherence(phase=True)
345
357 if self.realtime:
358 self.data_web[plottype] = roundFloats(decimate(self.data[plottype][t]).tolist())
359 self.data_web['time'] = t
346 def run(self):
360 def run(self):
347
361
348 print '[Starting] {} from {}'.format(self.name, self.address)
362 print '[Starting] {} from {}'.format(self.name, self.address)
@@ -352,7 +366,9 class ReceiverData(ProcessingUnit, Process):
352 self.receiver.bind(self.address)
366 self.receiver.bind(self.address)
353 monitor = self.receiver.get_monitor_socket()
367 monitor = self.receiver.get_monitor_socket()
354 self.sender = self.context.socket(zmq.PUB)
368 self.sender = self.context.socket(zmq.PUB)
355
369 if self.realtime:
370 self.sender_web = self.context.socket(zmq.PUB)
371 self.sender_web.bind(self.plot_address)
356 self.sender.bind("ipc:///tmp/zmq.plots")
372 self.sender.bind("ipc:///tmp/zmq.plots")
357
373
358 t = Thread(target=self.event_monitor, args=(monitor,))
374 t = Thread(target=self.event_monitor, args=(monitor,))
@@ -376,8 +392,29 class ReceiverData(ProcessingUnit, Process):
376 else:
392 else:
377 if self.realtime:
393 if self.realtime:
378 self.send(self.data)
394 self.send(self.data)
395 self.sender_web.send_string(json.dumps(self.data_web))
379 else:
396 else:
380 self.sendData(self.send, self.data)
397 self.sendData(self.send, self.data)
381 self.started = True
398 self.started = True
382
399
383 return
400 return
401
402 def sendToWeb(self):
403
404 if not self.isWebConfig:
405 context = zmq.Context()
406 sender_web_config = context.socket(zmq.PUB)
407 if 'tcp://' in self.plot_address:
408 print self.plot_address
409 dum, address, port = self.plot_address.split(':')
410 conf_address = '{}:{}:{}'.format(dum, address, int(port)+1)
411 else:
412 conf_address = self.plot_address + '.config'
413 sender_web_config.bind(conf_address)
414
415 for kwargs in self.operationKwargs.values():
416 if 'plot' in kwargs:
417 sender_web_config.send_string(json.dumps(kwargs))
418 print kwargs
419 self.isWebConfig = True
420
@@ -65,7 +65,7 def fiber(cursor, skip, q, dt):
65 # opObj13.addParameter(name='zeromq', value=1, format='int')
65 # opObj13.addParameter(name='zeromq', value=1, format='int')
66 # opObj13.addParameter(name='server', value="juanca", format='str')
66 # opObj13.addParameter(name='server', value="juanca", format='str')
67
67
68 # opObj12.addParameter(name='delay', value=1, format='int')
68 opObj12.addParameter(name='delay', value=1, format='int')
69
69
70
70
71 # print "Escribiendo el archivo XML"
71 # print "Escribiendo el archivo XML"
@@ -81,6 +81,6 def fiber(cursor, skip, q, dt):
81
81
82 if __name__ == '__main__':
82 if __name__ == '__main__':
83 parser = argparse.ArgumentParser(description='Set number of parallel processes')
83 parser = argparse.ArgumentParser(description='Set number of parallel processes')
84 parser.add_argument('--nProcess', default=2, type=int)
84 parser.add_argument('--nProcess', default=1, type=int)
85 args = parser.parse_args()
85 args = parser.parse_args()
86 multiSchain(fiber, nProcess=args.nProcess, startDate='2015/09/26', endDate='2015/09/26')
86 multiSchain(fiber, nProcess=args.nProcess, startDate='2015/09/26', endDate='2015/09/26')
@@ -15,21 +15,22 if __name__ == '__main__':
15 controllerObj.setup(id='191', name='test01', description=desc)
15 controllerObj.setup(id='191', name='test01', description=desc)
16
16
17 proc1 = controllerObj.addProcUnit(name='ReceiverData')
17 proc1 = controllerObj.addProcUnit(name='ReceiverData')
18 proc1.addParameter(name='realtime', value='0', format='bool')
18 proc1.addParameter(name='realtime', value='1', format='bool')
19 proc1.addParameter(name='plottypes', value='rti,coh,phase', format='str')
19 proc1.addParameter(name='plottypes', value='rti', format='str')
20 proc1.addParameter(name='throttle', value='10', format='int')
20 proc1.addParameter(name='throttle', value='10', format='int')
21 ## TODO Agregar direccion de server de publicacion a graficos como variable
21
22
22 op1 = proc1.addOperation(name='PlotRTIData', optype='other')
23 # op1 = proc1.addOperation(name='PlotRTIData', optype='other')
23 op1.addParameter(name='wintitle', value='Julia 150Km', format='str')
24 # op1.addParameter(name='wintitle', value='Julia 150Km', format='str')
24 op1.addParameter(name='save', value='/home/nanosat/Pictures', format='str')
25 # op1.addParameter(name='save', value='/home/nanosat/Pictures', format='str')
25
26 op2 = proc1.addOperation(name='PlotCOHData', optype='other')
27 op2.addParameter(name='wintitle', value='Julia 150Km', format='str')
28 op2.addParameter(name='save', value='/home/nanosat/Pictures', format='str')
29 #
26 #
30 op6 = proc1.addOperation(name='PlotPHASEData', optype='other')
27 # op2 = proc1.addOperation(name='PlotCOHData', optype='other')
31 op6.addParameter(name='wintitle', value='Julia 150Km', format='str')
28 # op2.addParameter(name='wintitle', value='Julia 150Km', format='str')
32 op6.addParameter(name='save', value='/home/nanosat/Pictures', format='str')
29 # op2.addParameter(name='save', value='/home/nanosat/Pictures', format='str')
30 # #
31 # op6 = proc1.addOperation(name='PlotPHASEData', optype='other')
32 # op6.addParameter(name='wintitle', value='Julia 150Km', format='str')
33 # op6.addParameter(name='save', value='/home/nanosat/Pictures', format='str')
33 #
34 #
34 # proc2 = controllerObj.addProcUnit(name='ReceiverData')
35 # proc2 = controllerObj.addProcUnit(name='ReceiverData')
35 # proc2.addParameter(name='server', value='juanca', format='str')
36 # proc2.addParameter(name='server', value='juanca', format='str')
@@ -1,1 +1,1
1 <Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/home/nanosat/data/hysell_data20/pdata" /><Parameter format="date" id="191113" name="startDate" value="2015/09/26" /><Parameter format="date" id="191114" name="endDate" value="2015/09/26" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="cursor" value="3" /><Parameter format="int" id="191119" name="skip" value="360" /><Parameter format="int" id="191120" name="delay" value="10" /><Parameter format="int" id="191121" name="walk" value="1" /><Parameter format="int" id="191122" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="PublishData" priority="2" type="other"><Parameter format="int" id="191221" name="zeromq" value="1" /></Operation></ProcUnit></Project> No newline at end of file
1 <Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/home/nanosat/data/hysell_data20/pdata" /><Parameter format="date" id="191113" name="startDate" value="2015/09/26" /><Parameter format="date" id="191114" name="endDate" value="2015/09/26" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="cursor" value="2" /><Parameter format="int" id="191119" name="skip" value="720" /><Parameter format="int" id="191120" name="delay" value="10" /><Parameter format="int" id="191121" name="walk" value="1" /><Parameter format="int" id="191122" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="PublishData" priority="2" type="other"><Parameter format="int" id="191221" name="zeromq" value="1" /><Parameter format="int" id="191222" name="delay" value="1" /></Operation></ProcUnit></Project> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now