@@ -1,347 +1,346 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author: murco $ |
|
3 | $Author: murco $ | |
4 | $Id: jroproc_base.py 1 2012-11-12 18:56:07Z murco $ |
|
4 | $Id: jroproc_base.py 1 2012-11-12 18:56:07Z murco $ | |
5 | ''' |
|
5 | ''' | |
6 | import inspect |
|
6 | import inspect | |
7 | from fuzzywuzzy import process |
|
7 | from fuzzywuzzy import process | |
8 |
|
8 | |||
9 | def checkKwargs(method, kwargs): |
|
9 | def checkKwargs(method, kwargs): | |
10 | currentKwargs = kwargs |
|
10 | currentKwargs = kwargs | |
11 | choices = inspect.getargspec(method).args |
|
11 | choices = inspect.getargspec(method).args | |
12 | try: |
|
12 | try: | |
13 | choices.remove('self') |
|
13 | choices.remove('self') | |
14 | except Exception as e: |
|
14 | except Exception as e: | |
15 | pass |
|
15 | pass | |
16 |
|
16 | |||
17 | try: |
|
17 | try: | |
18 | choices.remove('dataOut') |
|
18 | choices.remove('dataOut') | |
19 | except Exception as e: |
|
19 | except Exception as e: | |
20 | pass |
|
20 | pass | |
21 |
|
21 | |||
22 | for kwarg in kwargs: |
|
22 | for kwarg in kwargs: | |
23 | fuzz = process.extractOne(kwarg, choices) |
|
23 | fuzz = process.extractOne(kwarg, choices) | |
24 | print fuzz |
|
|||
25 | if fuzz is None: |
|
24 | if fuzz is None: | |
26 | continue |
|
25 | continue | |
27 | if fuzz[1] < 100: |
|
26 | if fuzz[1] < 100: | |
28 | raise Exception('\x1b[2;30;43mDid you mean {} instead of {} in {}? \x1b[0m'. |
|
27 | raise Exception('\x1b[2;30;43mDid you mean {} instead of {} in {}? \x1b[0m'. | |
29 | format(fuzz[0], kwarg, method.__self__.__class__.__name__)) |
|
28 | format(fuzz[0], kwarg, method.__self__.__class__.__name__)) | |
30 |
|
29 | |||
31 | class ProcessingUnit(object): |
|
30 | class ProcessingUnit(object): | |
32 |
|
31 | |||
33 | """ |
|
32 | """ | |
34 | Esta es la clase base para el procesamiento de datos. |
|
33 | Esta es la clase base para el procesamiento de datos. | |
35 |
|
34 | |||
36 | Contiene el metodo "call" para llamar operaciones. Las operaciones pueden ser: |
|
35 | Contiene el metodo "call" para llamar operaciones. Las operaciones pueden ser: | |
37 | - Metodos internos (callMethod) |
|
36 | - Metodos internos (callMethod) | |
38 | - Objetos del tipo Operation (callObject). Antes de ser llamados, estos objetos |
|
37 | - Objetos del tipo Operation (callObject). Antes de ser llamados, estos objetos | |
39 | tienen que ser agreagados con el metodo "add". |
|
38 | tienen que ser agreagados con el metodo "add". | |
40 |
|
39 | |||
41 | """ |
|
40 | """ | |
42 | # objeto de datos de entrada (Voltage, Spectra o Correlation) |
|
41 | # objeto de datos de entrada (Voltage, Spectra o Correlation) | |
43 | dataIn = None |
|
42 | dataIn = None | |
44 | dataInList = [] |
|
43 | dataInList = [] | |
45 |
|
44 | |||
46 | # objeto de datos de entrada (Voltage, Spectra o Correlation) |
|
45 | # objeto de datos de entrada (Voltage, Spectra o Correlation) | |
47 | dataOut = None |
|
46 | dataOut = None | |
48 |
|
47 | |||
49 | operations2RunDict = None |
|
48 | operations2RunDict = None | |
50 |
|
49 | |||
51 | isConfig = False |
|
50 | isConfig = False | |
52 |
|
51 | |||
53 |
|
52 | |||
54 | def __init__(self, *args, **kwargs): |
|
53 | def __init__(self, *args, **kwargs): | |
55 |
|
54 | |||
56 | self.dataIn = None |
|
55 | self.dataIn = None | |
57 | self.dataInList = [] |
|
56 | self.dataInList = [] | |
58 |
|
57 | |||
59 | self.dataOut = None |
|
58 | self.dataOut = None | |
60 |
|
59 | |||
61 | self.operations2RunDict = {} |
|
60 | self.operations2RunDict = {} | |
62 | self.operationKwargs = {} |
|
61 | self.operationKwargs = {} | |
63 |
|
62 | |||
64 | self.isConfig = False |
|
63 | self.isConfig = False | |
65 |
|
64 | |||
66 | self.args = args |
|
65 | self.args = args | |
67 | self.kwargs = kwargs |
|
66 | self.kwargs = kwargs | |
68 | checkKwargs(self.run, kwargs) |
|
67 | checkKwargs(self.run, kwargs) | |
69 |
|
68 | |||
70 | def getAllowedArgs(self): |
|
69 | def getAllowedArgs(self): | |
71 | return inspect.getargspec(self.run).args |
|
70 | return inspect.getargspec(self.run).args | |
72 |
|
71 | |||
73 | def addOperationKwargs(self, objId, **kwargs): |
|
72 | def addOperationKwargs(self, objId, **kwargs): | |
74 | ''' |
|
73 | ''' | |
75 | ''' |
|
74 | ''' | |
76 |
|
75 | |||
77 | self.operationKwargs[objId] = kwargs |
|
76 | self.operationKwargs[objId] = kwargs | |
78 |
|
77 | |||
79 |
|
78 | |||
80 | def addOperation(self, opObj, objId): |
|
79 | def addOperation(self, opObj, objId): | |
81 |
|
80 | |||
82 | """ |
|
81 | """ | |
83 | Agrega un objeto del tipo "Operation" (opObj) a la lista de objetos "self.objectList" y retorna el |
|
82 | Agrega un objeto del tipo "Operation" (opObj) a la lista de objetos "self.objectList" y retorna el | |
84 | identificador asociado a este objeto. |
|
83 | identificador asociado a este objeto. | |
85 |
|
84 | |||
86 | Input: |
|
85 | Input: | |
87 |
|
86 | |||
88 | object : objeto de la clase "Operation" |
|
87 | object : objeto de la clase "Operation" | |
89 |
|
88 | |||
90 | Return: |
|
89 | Return: | |
91 |
|
90 | |||
92 | objId : identificador del objeto, necesario para ejecutar la operacion |
|
91 | objId : identificador del objeto, necesario para ejecutar la operacion | |
93 | """ |
|
92 | """ | |
94 |
|
93 | |||
95 | self.operations2RunDict[objId] = opObj |
|
94 | self.operations2RunDict[objId] = opObj | |
96 |
|
95 | |||
97 | return objId |
|
96 | return objId | |
98 |
|
97 | |||
99 | def getOperationObj(self, objId): |
|
98 | def getOperationObj(self, objId): | |
100 |
|
99 | |||
101 | if objId not in self.operations2RunDict.keys(): |
|
100 | if objId not in self.operations2RunDict.keys(): | |
102 | return None |
|
101 | return None | |
103 |
|
102 | |||
104 | return self.operations2RunDict[objId] |
|
103 | return self.operations2RunDict[objId] | |
105 |
|
104 | |||
106 | def operation(self, **kwargs): |
|
105 | def operation(self, **kwargs): | |
107 |
|
106 | |||
108 | """ |
|
107 | """ | |
109 | Operacion directa sobre la data (dataOut.data). Es necesario actualizar los valores de los |
|
108 | Operacion directa sobre la data (dataOut.data). Es necesario actualizar los valores de los | |
110 | atributos del objeto dataOut |
|
109 | atributos del objeto dataOut | |
111 |
|
110 | |||
112 | Input: |
|
111 | Input: | |
113 |
|
112 | |||
114 | **kwargs : Diccionario de argumentos de la funcion a ejecutar |
|
113 | **kwargs : Diccionario de argumentos de la funcion a ejecutar | |
115 | """ |
|
114 | """ | |
116 |
|
115 | |||
117 | raise NotImplementedError |
|
116 | raise NotImplementedError | |
118 |
|
117 | |||
119 | def callMethod(self, name, opId): |
|
118 | def callMethod(self, name, opId): | |
120 |
|
119 | |||
121 | """ |
|
120 | """ | |
122 | Ejecuta el metodo con el nombre "name" y con argumentos **kwargs de la propia clase. |
|
121 | Ejecuta el metodo con el nombre "name" y con argumentos **kwargs de la propia clase. | |
123 |
|
122 | |||
124 | Input: |
|
123 | Input: | |
125 | name : nombre del metodo a ejecutar |
|
124 | name : nombre del metodo a ejecutar | |
126 |
|
125 | |||
127 | **kwargs : diccionario con los nombres y valores de la funcion a ejecutar. |
|
126 | **kwargs : diccionario con los nombres y valores de la funcion a ejecutar. | |
128 |
|
127 | |||
129 | """ |
|
128 | """ | |
130 |
|
129 | |||
131 | #Checking the inputs |
|
130 | #Checking the inputs | |
132 | if name == 'run': |
|
131 | if name == 'run': | |
133 |
|
132 | |||
134 | if not self.checkInputs(): |
|
133 | if not self.checkInputs(): | |
135 | self.dataOut.flagNoData = True |
|
134 | self.dataOut.flagNoData = True | |
136 | return False |
|
135 | return False | |
137 | else: |
|
136 | else: | |
138 | #Si no es un metodo RUN la entrada es la misma dataOut (interna) |
|
137 | #Si no es un metodo RUN la entrada es la misma dataOut (interna) | |
139 | if self.dataOut is not None and self.dataOut.isEmpty(): |
|
138 | if self.dataOut is not None and self.dataOut.isEmpty(): | |
140 | return False |
|
139 | return False | |
141 |
|
140 | |||
142 | #Getting the pointer to method |
|
141 | #Getting the pointer to method | |
143 | methodToCall = getattr(self, name) |
|
142 | methodToCall = getattr(self, name) | |
144 |
|
143 | |||
145 | #Executing the self method |
|
144 | #Executing the self method | |
146 |
|
145 | |||
147 | if hasattr(self, 'mp'): |
|
146 | if hasattr(self, 'mp'): | |
148 | if name=='run': |
|
147 | if name=='run': | |
149 | if self.mp is False: |
|
148 | if self.mp is False: | |
150 | self.mp = True |
|
149 | self.mp = True | |
151 | self.start() |
|
150 | self.start() | |
152 | else: |
|
151 | else: | |
153 | methodToCall(**self.operationKwargs[opId]) |
|
152 | methodToCall(**self.operationKwargs[opId]) | |
154 | else: |
|
153 | else: | |
155 | if name=='run': |
|
154 | if name=='run': | |
156 | methodToCall(**self.kwargs) |
|
155 | methodToCall(**self.kwargs) | |
157 | else: |
|
156 | else: | |
158 | methodToCall(**self.operationKwargs[opId]) |
|
157 | methodToCall(**self.operationKwargs[opId]) | |
159 |
|
158 | |||
160 | if self.dataOut is None: |
|
159 | if self.dataOut is None: | |
161 | return False |
|
160 | return False | |
162 |
|
161 | |||
163 | if self.dataOut.isEmpty(): |
|
162 | if self.dataOut.isEmpty(): | |
164 | return False |
|
163 | return False | |
165 |
|
164 | |||
166 | return True |
|
165 | return True | |
167 |
|
166 | |||
168 | def callObject(self, objId): |
|
167 | def callObject(self, objId): | |
169 |
|
168 | |||
170 | """ |
|
169 | """ | |
171 | Ejecuta la operacion asociada al identificador del objeto "objId" |
|
170 | Ejecuta la operacion asociada al identificador del objeto "objId" | |
172 |
|
171 | |||
173 | Input: |
|
172 | Input: | |
174 |
|
173 | |||
175 | objId : identificador del objeto a ejecutar |
|
174 | objId : identificador del objeto a ejecutar | |
176 |
|
175 | |||
177 | **kwargs : diccionario con los nombres y valores de la funcion a ejecutar. |
|
176 | **kwargs : diccionario con los nombres y valores de la funcion a ejecutar. | |
178 |
|
177 | |||
179 | Return: |
|
178 | Return: | |
180 |
|
179 | |||
181 | None |
|
180 | None | |
182 | """ |
|
181 | """ | |
183 |
|
182 | |||
184 | if self.dataOut is not None and self.dataOut.isEmpty(): |
|
183 | if self.dataOut is not None and self.dataOut.isEmpty(): | |
185 | return False |
|
184 | return False | |
186 |
|
185 | |||
187 | externalProcObj = self.operations2RunDict[objId] |
|
186 | externalProcObj = self.operations2RunDict[objId] | |
188 |
|
187 | |||
189 | if hasattr(externalProcObj, 'mp'): |
|
188 | if hasattr(externalProcObj, 'mp'): | |
190 | if externalProcObj.mp is False: |
|
189 | if externalProcObj.mp is False: | |
191 | self.operationKwargs[objId] = externalProcObj.kwargs |
|
190 | self.operationKwargs[objId] = externalProcObj.kwargs | |
192 | externalProcObj.mp = True |
|
191 | externalProcObj.mp = True | |
193 | externalProcObj.start() |
|
192 | externalProcObj.start() | |
194 | else: |
|
193 | else: | |
195 | externalProcObj.run(self.dataOut, **externalProcObj.kwargs) |
|
194 | externalProcObj.run(self.dataOut, **externalProcObj.kwargs) | |
196 | self.operationKwargs[objId] = externalProcObj.kwargs |
|
195 | self.operationKwargs[objId] = externalProcObj.kwargs | |
197 |
|
196 | |||
198 | return True |
|
197 | return True | |
199 |
|
198 | |||
200 | def call(self, opType, opName=None, opId=None): |
|
199 | def call(self, opType, opName=None, opId=None): | |
201 |
|
200 | |||
202 | """ |
|
201 | """ | |
203 | Return True si ejecuta la operacion interna nombrada "opName" o la operacion externa |
|
202 | Return True si ejecuta la operacion interna nombrada "opName" o la operacion externa | |
204 | identificada con el id "opId"; con los argumentos "**kwargs". |
|
203 | identificada con el id "opId"; con los argumentos "**kwargs". | |
205 |
|
204 | |||
206 | False si la operacion no se ha ejecutado. |
|
205 | False si la operacion no se ha ejecutado. | |
207 |
|
206 | |||
208 | Input: |
|
207 | Input: | |
209 |
|
208 | |||
210 | opType : Puede ser "self" o "external" |
|
209 | opType : Puede ser "self" o "external" | |
211 |
|
210 | |||
212 | Depende del tipo de operacion para llamar a:callMethod or callObject: |
|
211 | Depende del tipo de operacion para llamar a:callMethod or callObject: | |
213 |
|
212 | |||
214 | 1. If opType = "self": Llama a un metodo propio de esta clase: |
|
213 | 1. If opType = "self": Llama a un metodo propio de esta clase: | |
215 |
|
214 | |||
216 | name_method = getattr(self, name) |
|
215 | name_method = getattr(self, name) | |
217 | name_method(**kwargs) |
|
216 | name_method(**kwargs) | |
218 |
|
217 | |||
219 |
|
218 | |||
220 | 2. If opType = "other" o"external": Llama al metodo "run()" de una instancia de la |
|
219 | 2. If opType = "other" o"external": Llama al metodo "run()" de una instancia de la | |
221 | clase "Operation" o de un derivado de ella: |
|
220 | clase "Operation" o de un derivado de ella: | |
222 |
|
221 | |||
223 | instanceName = self.operationList[opId] |
|
222 | instanceName = self.operationList[opId] | |
224 | instanceName.run(**kwargs) |
|
223 | instanceName.run(**kwargs) | |
225 |
|
224 | |||
226 | opName : Si la operacion es interna (opType = 'self'), entonces el "opName" sera |
|
225 | opName : Si la operacion es interna (opType = 'self'), entonces el "opName" sera | |
227 | usada para llamar a un metodo interno de la clase Processing |
|
226 | usada para llamar a un metodo interno de la clase Processing | |
228 |
|
227 | |||
229 | opId : Si la operacion es externa (opType = 'other' o 'external), entonces el |
|
228 | opId : Si la operacion es externa (opType = 'other' o 'external), entonces el | |
230 | "opId" sera usada para llamar al metodo "run" de la clase Operation |
|
229 | "opId" sera usada para llamar al metodo "run" de la clase Operation | |
231 | registrada anteriormente con ese Id |
|
230 | registrada anteriormente con ese Id | |
232 |
|
231 | |||
233 | Exception: |
|
232 | Exception: | |
234 | Este objeto de tipo Operation debe de haber sido agregado antes con el metodo: |
|
233 | Este objeto de tipo Operation debe de haber sido agregado antes con el metodo: | |
235 | "addOperation" e identificado con el valor "opId" = el id de la operacion. |
|
234 | "addOperation" e identificado con el valor "opId" = el id de la operacion. | |
236 | De lo contrario retornara un error del tipo ValueError |
|
235 | De lo contrario retornara un error del tipo ValueError | |
237 |
|
236 | |||
238 | """ |
|
237 | """ | |
239 |
|
238 | |||
240 | if opType == 'self': |
|
239 | if opType == 'self': | |
241 |
|
240 | |||
242 | if not opName: |
|
241 | if not opName: | |
243 | raise ValueError, "opName parameter should be defined" |
|
242 | raise ValueError, "opName parameter should be defined" | |
244 |
|
243 | |||
245 | sts = self.callMethod(opName, opId) |
|
244 | sts = self.callMethod(opName, opId) | |
246 |
|
245 | |||
247 | elif opType == 'other' or opType == 'external' or opType == 'plotter': |
|
246 | elif opType == 'other' or opType == 'external' or opType == 'plotter': | |
248 |
|
247 | |||
249 | if not opId: |
|
248 | if not opId: | |
250 | raise ValueError, "opId parameter should be defined" |
|
249 | raise ValueError, "opId parameter should be defined" | |
251 |
|
250 | |||
252 | if opId not in self.operations2RunDict.keys(): |
|
251 | if opId not in self.operations2RunDict.keys(): | |
253 | raise ValueError, "Any operation with id=%s has been added" %str(opId) |
|
252 | raise ValueError, "Any operation with id=%s has been added" %str(opId) | |
254 |
|
253 | |||
255 | sts = self.callObject(opId) |
|
254 | sts = self.callObject(opId) | |
256 |
|
255 | |||
257 | else: |
|
256 | else: | |
258 | raise ValueError, "opType should be 'self', 'external' or 'plotter'; and not '%s'" %opType |
|
257 | raise ValueError, "opType should be 'self', 'external' or 'plotter'; and not '%s'" %opType | |
259 |
|
258 | |||
260 | return sts |
|
259 | return sts | |
261 |
|
260 | |||
262 | def setInput(self, dataIn): |
|
261 | def setInput(self, dataIn): | |
263 |
|
262 | |||
264 | self.dataIn = dataIn |
|
263 | self.dataIn = dataIn | |
265 | self.dataInList.append(dataIn) |
|
264 | self.dataInList.append(dataIn) | |
266 |
|
265 | |||
267 | def getOutputObj(self): |
|
266 | def getOutputObj(self): | |
268 |
|
267 | |||
269 | return self.dataOut |
|
268 | return self.dataOut | |
270 |
|
269 | |||
271 | def checkInputs(self): |
|
270 | def checkInputs(self): | |
272 |
|
271 | |||
273 | for thisDataIn in self.dataInList: |
|
272 | for thisDataIn in self.dataInList: | |
274 |
|
273 | |||
275 | if thisDataIn.isEmpty(): |
|
274 | if thisDataIn.isEmpty(): | |
276 | return False |
|
275 | return False | |
277 |
|
276 | |||
278 | return True |
|
277 | return True | |
279 |
|
278 | |||
280 | def setup(self): |
|
279 | def setup(self): | |
281 |
|
280 | |||
282 | raise NotImplementedError |
|
281 | raise NotImplementedError | |
283 |
|
282 | |||
284 | def run(self): |
|
283 | def run(self): | |
285 |
|
284 | |||
286 | raise NotImplementedError |
|
285 | raise NotImplementedError | |
287 |
|
286 | |||
288 | def close(self): |
|
287 | def close(self): | |
289 | #Close every thread, queue or any other object here is it is neccesary. |
|
288 | #Close every thread, queue or any other object here is it is neccesary. | |
290 | return |
|
289 | return | |
291 |
|
290 | |||
292 | class Operation(object): |
|
291 | class Operation(object): | |
293 |
|
292 | |||
294 | """ |
|
293 | """ | |
295 | Clase base para definir las operaciones adicionales que se pueden agregar a la clase ProcessingUnit |
|
294 | Clase base para definir las operaciones adicionales que se pueden agregar a la clase ProcessingUnit | |
296 | y necesiten acumular informacion previa de los datos a procesar. De preferencia usar un buffer de |
|
295 | y necesiten acumular informacion previa de los datos a procesar. De preferencia usar un buffer de | |
297 | acumulacion dentro de esta clase |
|
296 | acumulacion dentro de esta clase | |
298 |
|
297 | |||
299 | Ejemplo: Integraciones coherentes, necesita la informacion previa de los n perfiles anteriores (bufffer) |
|
298 | Ejemplo: Integraciones coherentes, necesita la informacion previa de los n perfiles anteriores (bufffer) | |
300 |
|
299 | |||
301 | """ |
|
300 | """ | |
302 |
|
301 | |||
303 | __buffer = None |
|
302 | __buffer = None | |
304 | isConfig = False |
|
303 | isConfig = False | |
305 |
|
304 | |||
306 | def __init__(self, **kwargs): |
|
305 | def __init__(self, **kwargs): | |
307 |
|
306 | |||
308 | self.__buffer = None |
|
307 | self.__buffer = None | |
309 | self.isConfig = False |
|
308 | self.isConfig = False | |
310 | self.kwargs = kwargs |
|
309 | self.kwargs = kwargs | |
311 | checkKwargs(self.run, kwargs) |
|
310 | checkKwargs(self.run, kwargs) | |
312 |
|
311 | |||
313 | def getAllowedArgs(self): |
|
312 | def getAllowedArgs(self): | |
314 | return inspect.getargspec(self.run).args |
|
313 | return inspect.getargspec(self.run).args | |
315 |
|
314 | |||
316 | def setup(self): |
|
315 | def setup(self): | |
317 |
|
316 | |||
318 | self.isConfig = True |
|
317 | self.isConfig = True | |
319 |
|
318 | |||
320 | raise NotImplementedError |
|
319 | raise NotImplementedError | |
321 |
|
320 | |||
322 | def run(self, dataIn, **kwargs): |
|
321 | def run(self, dataIn, **kwargs): | |
323 |
|
322 | |||
324 | """ |
|
323 | """ | |
325 | Realiza las operaciones necesarias sobre la dataIn.data y actualiza los |
|
324 | Realiza las operaciones necesarias sobre la dataIn.data y actualiza los | |
326 | atributos del objeto dataIn. |
|
325 | atributos del objeto dataIn. | |
327 |
|
326 | |||
328 | Input: |
|
327 | Input: | |
329 |
|
328 | |||
330 | dataIn : objeto del tipo JROData |
|
329 | dataIn : objeto del tipo JROData | |
331 |
|
330 | |||
332 | Return: |
|
331 | Return: | |
333 |
|
332 | |||
334 | None |
|
333 | None | |
335 |
|
334 | |||
336 | Affected: |
|
335 | Affected: | |
337 | __buffer : buffer de recepcion de datos. |
|
336 | __buffer : buffer de recepcion de datos. | |
338 |
|
337 | |||
339 | """ |
|
338 | """ | |
340 | if not self.isConfig: |
|
339 | if not self.isConfig: | |
341 | self.setup(**kwargs) |
|
340 | self.setup(**kwargs) | |
342 |
|
341 | |||
343 | raise NotImplementedError |
|
342 | raise NotImplementedError | |
344 |
|
343 | |||
345 | def close(self): |
|
344 | def close(self): | |
346 |
|
345 | |||
347 | pass |
|
346 | pass |
@@ -1,96 +1,96 | |||||
1 | import argparse |
|
1 | import argparse | |
2 |
|
2 | |||
3 | from schainpy.controller import Project, multiSchain |
|
3 | from schainpy.controller import Project, multiSchain | |
4 |
|
4 | |||
5 | desc = "HF_EXAMPLE" |
|
5 | desc = "HF_EXAMPLE" | |
6 |
|
6 | |||
7 | def fiber(cursor, skip, q, dt): |
|
7 | def fiber(cursor, skip, q, dt): | |
8 |
|
8 | |||
9 | controllerObj = Project() |
|
9 | controllerObj = Project() | |
10 |
|
10 | |||
11 | controllerObj.setup(id='191', name='test01', description=desc) |
|
11 | controllerObj.setup(id='191', name='test01', description=desc) | |
12 |
|
12 | |||
13 | readUnitConfObj = controllerObj.addReadUnit(datatype='SpectraReader', |
|
13 | readUnitConfObj = controllerObj.addReadUnit(datatype='SpectraReader', | |
14 | path='/home/nanosat/data/julia', |
|
14 | path='/home/nanosat/data/julia', | |
15 | startDate=dt, |
|
15 | startDate=dt, | |
16 | endDate=dt, |
|
16 | endDate=dt, | |
17 | startTime="00:00:00", |
|
17 | startTime="00:00:00", | |
18 | endTie="23:59:59", |
|
18 | endTime="23:59:59", | |
19 | online=0, |
|
19 | online=0, | |
20 | #set=1426485881, |
|
20 | #set=1426485881, | |
21 | delay=10, |
|
21 | delay=10, | |
22 | walk=1, |
|
22 | walk=1, | |
23 | queue=q, |
|
23 | queue=q, | |
24 | cursor=cursor, |
|
24 | cursor=cursor, | |
25 | skip=skip, |
|
25 | skip=skip, | |
26 | #timezone=-5*3600 |
|
26 | #timezone=-5*3600 | |
27 | ) |
|
27 | ) | |
28 |
|
28 | |||
29 | # #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
29 | # #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') | |
30 | # |
|
30 | # | |
31 | procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId()) |
|
31 | procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId()) | |
32 | # procUnitConfObj2.addParameter(name='nipp', value='5', format='int') |
|
32 | # procUnitConfObj2.addParameter(name='nipp', value='5', format='int') | |
33 |
|
33 | |||
34 | procUnitConfObj3 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=readUnitConfObj.getId()) |
|
34 | procUnitConfObj3 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=readUnitConfObj.getId()) | |
35 | opObj11 = procUnitConfObj3.addOperation(name='SpectralMoments', optype='other') |
|
35 | opObj11 = procUnitConfObj3.addOperation(name='SpectralMoments', optype='other') | |
36 |
|
36 | |||
37 | # |
|
37 | # | |
38 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') |
|
38 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |
39 | # opObj11.addParameter(name='id', value='1000', format='int') |
|
39 | # opObj11.addParameter(name='id', value='1000', format='int') | |
40 | # opObj11.addParameter(name='wintitle', value='HF_Jicamarca_Spc', format='str') |
|
40 | # opObj11.addParameter(name='wintitle', value='HF_Jicamarca_Spc', format='str') | |
41 | # opObj11.addParameter(name='channelList', value='0', format='intlist') |
|
41 | # opObj11.addParameter(name='channelList', value='0', format='intlist') | |
42 | # opObj11.addParameter(name='zmin', value='-120', format='float') |
|
42 | # opObj11.addParameter(name='zmin', value='-120', format='float') | |
43 | # opObj11.addParameter(name='zmax', value='-70', format='float') |
|
43 | # opObj11.addParameter(name='zmax', value='-70', format='float') | |
44 | # opObj11.addParameter(name='save', value='1', format='int') |
|
44 | # opObj11.addParameter(name='save', value='1', format='int') | |
45 | # opObj11.addParameter(name='figpath', value=figpath, format='str') |
|
45 | # opObj11.addParameter(name='figpath', value=figpath, format='str') | |
46 |
|
46 | |||
47 | opObj11 = procUnitConfObj3.addOperation(name='Parameters1Plot', optype='other') |
|
47 | opObj11 = procUnitConfObj3.addOperation(name='Parameters1Plot', optype='other') | |
48 | opObj11.addParameter(name='channelList', value='0', format='intList') |
|
48 | opObj11.addParameter(name='channelList', value='0', format='intList') | |
49 |
|
49 | |||
50 | opObj11.addParameter(name='id', value='2000', format='int') |
|
50 | opObj11.addParameter(name='id', value='2000', format='int') | |
51 | # opObj11.addParameter(name='colormap', value='0', format='bool') |
|
51 | # opObj11.addParameter(name='colormap', value='0', format='bool') | |
52 | opObj11.addParameter(name='onlySNR', value='1', format='bool') |
|
52 | opObj11.addParameter(name='onlySNR', value='1', format='bool') | |
53 | opObj11.addParameter(name='DOP', value='0', format='bool') |
|
53 | opObj11.addParameter(name='DOP', value='0', format='bool') | |
54 | # opObj11.addParameter(name='showSNR', value='1', format='bool') |
|
54 | # opObj11.addParameter(name='showSNR', value='1', format='bool') | |
55 | # opObj11.addParameter(name='SNRthresh', value='0', format='int') |
|
55 | # opObj11.addParameter(name='SNRthresh', value='0', format='int') | |
56 | # opObj11.addParameter(name='SNRmin', value='-10', format='int') |
|
56 | # opObj11.addParameter(name='SNRmin', value='-10', format='int') | |
57 | # opObj11.addParameter(name='SNRmax', value='30', format='int') |
|
57 | # opObj11.addParameter(name='SNRmax', value='30', format='int') | |
58 |
|
58 | |||
59 | # opObj11.addParameter(name='showSNR', value='1', format='int') |
|
59 | # opObj11.addParameter(name='showSNR', value='1', format='int') | |
60 | # # opObj11.addParameter(name='channelList', value='0', format='intlist') |
|
60 | # # opObj11.addParameter(name='channelList', value='0', format='intlist') | |
61 | # # opObj11.addParameter(name='xmin', value='0', format='float') |
|
61 | # # opObj11.addParameter(name='xmin', value='0', format='float') | |
62 | # opObj11.addParameter(name='xmin', value='0', format='float') |
|
62 | # opObj11.addParameter(name='xmin', value='0', format='float') | |
63 | # opObj11.addParameter(name='xmax', value='24', format='float') |
|
63 | # opObj11.addParameter(name='xmax', value='24', format='float') | |
64 |
|
64 | |||
65 | # opObj11.addParameter(name='zmin', value='-110', format='float') |
|
65 | # opObj11.addParameter(name='zmin', value='-110', format='float') | |
66 | # opObj11.addParameter(name='zmax', value='-70', format='float') |
|
66 | # opObj11.addParameter(name='zmax', value='-70', format='float') | |
67 | # opObj11.addParameter(name='save', value='0', format='int') |
|
67 | # opObj11.addParameter(name='save', value='0', format='int') | |
68 | # # opObj11.addParameter(name='figpath', value='/tmp/', format='str') |
|
68 | # # opObj11.addParameter(name='figpath', value='/tmp/', format='str') | |
69 | # |
|
69 | # | |
70 | opObj12 = procUnitConfObj3.addOperation(name='PublishData', optype='other') |
|
70 | opObj12 = procUnitConfObj3.addOperation(name='PublishData', optype='other') | |
71 | opObj12.addParameter(name='zeromq', value=1, format='int') |
|
71 | opObj12.addParameter(name='zeromq', value=1, format='int') | |
72 |
|
72 | |||
73 |
|
73 | |||
74 | # opObj13 = procUnitConfObj3.addOperation(name='PublishData', optype='other') |
|
74 | # opObj13 = procUnitConfObj3.addOperation(name='PublishData', optype='other') | |
75 | # opObj13.addParameter(name='zeromq', value=1, format='int') |
|
75 | # opObj13.addParameter(name='zeromq', value=1, format='int') | |
76 | # opObj13.addParameter(name='server', value="juanca", format='str') |
|
76 | # opObj13.addParameter(name='server', value="juanca", format='str') | |
77 |
|
77 | |||
78 | opObj12.addParameter(name='delay', value=1, format='int') |
|
78 | opObj12.addParameter(name='delay', value=1, format='int') | |
79 |
|
79 | |||
80 |
|
80 | |||
81 | # print "Escribiendo el archivo XML" |
|
81 | # print "Escribiendo el archivo XML" | |
82 | # controllerObj.writeXml(filename) |
|
82 | # controllerObj.writeXml(filename) | |
83 | # print "Leyendo el archivo XML" |
|
83 | # print "Leyendo el archivo XML" | |
84 | # controllerObj.readXml(filename) |
|
84 | # controllerObj.readXml(filename) | |
85 |
|
85 | |||
86 |
|
86 | |||
87 | # timeit.timeit('controllerObj.run()', number=2) |
|
87 | # timeit.timeit('controllerObj.run()', number=2) | |
88 |
|
88 | |||
89 | controllerObj.start() |
|
89 | controllerObj.start() | |
90 |
|
90 | |||
91 |
|
91 | |||
92 | if __name__ == '__main__': |
|
92 | if __name__ == '__main__': | |
93 | parser = argparse.ArgumentParser(description='Set number of parallel processes') |
|
93 | parser = argparse.ArgumentParser(description='Set number of parallel processes') | |
94 | parser.add_argument('--nProcess', default=1, type=int) |
|
94 | parser.add_argument('--nProcess', default=1, type=int) | |
95 | args = parser.parse_args() |
|
95 | args = parser.parse_args() | |
96 | multiSchain(fiber, nProcess=args.nProcess, startDate='2015/09/26', endDate='2015/09/26') |
|
96 | multiSchain(fiber, nProcess=args.nProcess, startDate='2015/09/26', endDate='2015/09/26') |
@@ -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/julia" /><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="0" /><Parameter format="int" id="191119" name="skip" value="0" /><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="ParametersProc" id="1913" inputId="1911" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralMoments" priority="2" type="other" /><Operation id="19133" name="Parameters1Plot" priority="3" type="other"><Parameter format="intlist" id="191331" name="channelList" value="0" /><Parameter format="int" id="191332" name="id" value="2000" /><Parameter format="bool" id="191333" name="olySNR" value="1" /><Parameter format="bool" id="191334" name="DOP" value="0" /></Operation><Operation id="19134" name="PublishData" priority="4" type="other"><Parameter format="int" id="191341" name="zeromq" value="1" /><Parameter format="int" id="191342" name="delay" value="1" /></Operation></ProcUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /></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/julia" /><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="0" /><Parameter format="int" id="191119" name="skip" value="0" /><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="ParametersProc" id="1913" inputId="1911" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralMoments" priority="2" type="other" /><Operation id="19133" name="Parameters1Plot" priority="3" type="other"><Parameter format="intlist" id="191331" name="channelList" value="0" /><Parameter format="int" id="191332" name="id" value="2000" /><Parameter format="bool" id="191333" name="onlySNR" value="1" /><Parameter format="bool" id="191334" name="DOP" value="0" /></Operation><Operation id="19134" name="PublishData" priority="4" type="other"><Parameter format="int" id="191341" name="zeromq" value="1" /><Parameter format="int" id="191342" name="delay" value="1" /></Operation></ProcUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /></ProcUnit></Project> No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now