##// END OF EJS Templates
Version 2.1.3: ...
Miguel Valdez -
r664:9aee9f7a8e3e
parent child
Show More

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

@@ -1,8 +1,15
1 VERSIONS:
1 VERSIONS:
2
2
3 2.1.2:
3 2.1.2:
4 -jroutils_ftp.py: Bug fixed, Any error sending file stopped the Server Thread
4 -jroutils_ftp.py: Bug fixed, Any error sending file stopped the Server Thread
5 Server thread opens and closes remote server each time file list is sent
5 Server thread opens and closes remote server each time file list is sent
6 -jroplot_spectra.py: Noise path was not being created saving noise data.
6 -jroplot_spectra.py: Noise path was not being created saving noise data.
7 -jroIO_base.py: startTime can be greater than endTime
7 -jroIO_base.py: startTime can be greater than endTime
8 -jroplot_heispectra.py: SpectraHeisScope was not showing the right channel
8
9 2.1.3:
10 -jroplot_heispectra.py: SpectraHeisScope was not showing the right channels
11 -jroproc_voltage.py: Bug fixed selecting profiles (self.nProfiles took a wrong value),
12 Bug fixed selecting heights by block (selecting profiles instead heights)
13 -jroproc_voltage.py: New feature added: decoding data by block using FFT.
14 -jroIO_heispectra.py: Bug fixed in FitsReader. Using local Fits object instead schainpy.mode.data.jrodata.Fits object.
15 -jroIO_heispectra.py: Channel index list does not exist. No newline at end of file
@@ -1,7 +1,7
1 '''
1 '''
2 Created on Feb 7, 2012
2 Created on Feb 7, 2012
3
3
4 @author $Author$
4 @author $Author$
5 @version $Id$
5 @version $Id$
6 '''
6 '''
7 __version__ = "2.1.2" No newline at end of file
7 __version__ = "2.1.3" No newline at end of file
@@ -1,1097 +1,1096
1 '''
1 '''
2 Created on September , 2012
2 Created on September , 2012
3 @author:
3 @author:
4 '''
4 '''
5 from xml.etree.ElementTree import Element, SubElement
5 from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring
6 from xml.etree import ElementTree as ET
7 from xml.dom import minidom
6 from xml.dom import minidom
8
7
9 from model import *
8 from model import *
10
9
11 try:
10 try:
12 from gevent import sleep
11 from gevent import sleep
13 except:
12 except:
14 from time import sleep
13 from time import sleep
15
14
16 import ast
15 import ast
17
16
18 def prettify(elem):
17 def prettify(elem):
19 """Return a pretty-printed XML string for the Element.
18 """Return a pretty-printed XML string for the Element.
20 """
19 """
21 rough_string = ET.tostring(elem, 'utf-8')
20 rough_string = tostring(elem, 'utf-8')
22 reparsed = minidom.parseString(rough_string)
21 reparsed = minidom.parseString(rough_string)
23 return reparsed.toprettyxml(indent=" ")
22 return reparsed.toprettyxml(indent=" ")
24
23
25 class ParameterConf():
24 class ParameterConf():
26
25
27 id = None
26 id = None
28 name = None
27 name = None
29 value = None
28 value = None
30 format = None
29 format = None
31
30
32 __formated_value = None
31 __formated_value = None
33
32
34 ELEMENTNAME = 'Parameter'
33 ELEMENTNAME = 'Parameter'
35
34
36 def __init__(self):
35 def __init__(self):
37
36
38 self.format = 'str'
37 self.format = 'str'
39
38
40 def getElementName(self):
39 def getElementName(self):
41
40
42 return self.ELEMENTNAME
41 return self.ELEMENTNAME
43
42
44 def getValue(self):
43 def getValue(self):
45
44
46 value = self.value
45 value = self.value
47 format = self.format
46 format = self.format
48
47
49 if self.__formated_value != None:
48 if self.__formated_value != None:
50
49
51 return self.__formated_value
50 return self.__formated_value
52
51
53 if format == 'str':
52 if format == 'str':
54 self.__formated_value = str(value)
53 self.__formated_value = str(value)
55 return self.__formated_value
54 return self.__formated_value
56
55
57 if value == '':
56 if value == '':
58 raise ValueError, "%s: This parameter value is empty" %self.name
57 raise ValueError, "%s: This parameter value is empty" %self.name
59
58
60 if format == 'bool':
59 if format == 'bool':
61 value = int(value)
60 value = int(value)
62
61
63 if format == 'list':
62 if format == 'list':
64 strList = value.split(',')
63 strList = value.split(',')
65
64
66 self.__formated_value = strList
65 self.__formated_value = strList
67
66
68 return self.__formated_value
67 return self.__formated_value
69
68
70 if format == 'intlist':
69 if format == 'intlist':
71 """
70 """
72 Example:
71 Example:
73 value = (0,1,2)
72 value = (0,1,2)
74 """
73 """
75 value = value.replace('(', '')
74 value = value.replace('(', '')
76 value = value.replace(')', '')
75 value = value.replace(')', '')
77
76
78 value = value.replace('[', '')
77 value = value.replace('[', '')
79 value = value.replace(']', '')
78 value = value.replace(']', '')
80
79
81 strList = value.split(',')
80 strList = value.split(',')
82 intList = [int(float(x)) for x in strList]
81 intList = [int(float(x)) for x in strList]
83
82
84 self.__formated_value = intList
83 self.__formated_value = intList
85
84
86 return self.__formated_value
85 return self.__formated_value
87
86
88 if format == 'floatlist':
87 if format == 'floatlist':
89 """
88 """
90 Example:
89 Example:
91 value = (0.5, 1.4, 2.7)
90 value = (0.5, 1.4, 2.7)
92 """
91 """
93
92
94 value = value.replace('(', '')
93 value = value.replace('(', '')
95 value = value.replace(')', '')
94 value = value.replace(')', '')
96
95
97 value = value.replace('[', '')
96 value = value.replace('[', '')
98 value = value.replace(']', '')
97 value = value.replace(']', '')
99
98
100 strList = value.split(',')
99 strList = value.split(',')
101 floatList = [float(x) for x in strList]
100 floatList = [float(x) for x in strList]
102
101
103 self.__formated_value = floatList
102 self.__formated_value = floatList
104
103
105 return self.__formated_value
104 return self.__formated_value
106
105
107 if format == 'date':
106 if format == 'date':
108 strList = value.split('/')
107 strList = value.split('/')
109 intList = [int(x) for x in strList]
108 intList = [int(x) for x in strList]
110 date = datetime.date(intList[0], intList[1], intList[2])
109 date = datetime.date(intList[0], intList[1], intList[2])
111
110
112 self.__formated_value = date
111 self.__formated_value = date
113
112
114 return self.__formated_value
113 return self.__formated_value
115
114
116 if format == 'time':
115 if format == 'time':
117 strList = value.split(':')
116 strList = value.split(':')
118 intList = [int(x) for x in strList]
117 intList = [int(x) for x in strList]
119 time = datetime.time(intList[0], intList[1], intList[2])
118 time = datetime.time(intList[0], intList[1], intList[2])
120
119
121 self.__formated_value = time
120 self.__formated_value = time
122
121
123 return self.__formated_value
122 return self.__formated_value
124
123
125 if format == 'pairslist':
124 if format == 'pairslist':
126 """
125 """
127 Example:
126 Example:
128 value = (0,1),(1,2)
127 value = (0,1),(1,2)
129 """
128 """
130
129
131 value = value.replace('(', '')
130 value = value.replace('(', '')
132 value = value.replace(')', '')
131 value = value.replace(')', '')
133
132
134 value = value.replace('[', '')
133 value = value.replace('[', '')
135 value = value.replace(']', '')
134 value = value.replace(']', '')
136
135
137 strList = value.split(',')
136 strList = value.split(',')
138 intList = [int(item) for item in strList]
137 intList = [int(item) for item in strList]
139 pairList = []
138 pairList = []
140 for i in range(len(intList)/2):
139 for i in range(len(intList)/2):
141 pairList.append((intList[i*2], intList[i*2 + 1]))
140 pairList.append((intList[i*2], intList[i*2 + 1]))
142
141
143 self.__formated_value = pairList
142 self.__formated_value = pairList
144
143
145 return self.__formated_value
144 return self.__formated_value
146
145
147 if format == 'multilist':
146 if format == 'multilist':
148 """
147 """
149 Example:
148 Example:
150 value = (0,1,2),(3,4,5)
149 value = (0,1,2),(3,4,5)
151 """
150 """
152 multiList = ast.literal_eval(value)
151 multiList = ast.literal_eval(value)
153
152
154 if type(multiList[0]) == int:
153 if type(multiList[0]) == int:
155 multiList = ast.literal_eval("(" + value + ")")
154 multiList = ast.literal_eval("(" + value + ")")
156
155
157 self.__formated_value = multiList
156 self.__formated_value = multiList
158
157
159 return self.__formated_value
158 return self.__formated_value
160
159
161 format_func = eval(format)
160 format_func = eval(format)
162
161
163 self.__formated_value = format_func(value)
162 self.__formated_value = format_func(value)
164
163
165 return self.__formated_value
164 return self.__formated_value
166
165
167 def updateId(self, new_id):
166 def updateId(self, new_id):
168
167
169 self.id = str(new_id)
168 self.id = str(new_id)
170
169
171 def setup(self, id, name, value, format='str'):
170 def setup(self, id, name, value, format='str'):
172
171
173 self.id = str(id)
172 self.id = str(id)
174 self.name = name
173 self.name = name
175 self.value = str(value)
174 self.value = str(value)
176 self.format = str.lower(format)
175 self.format = str.lower(format)
177
176
178 try:
177 try:
179 self.getValue()
178 self.getValue()
180 except:
179 except:
181 return 0
180 return 0
182
181
183 return 1
182 return 1
184
183
185 def update(self, name, value, format='str'):
184 def update(self, name, value, format='str'):
186
185
187 self.name = name
186 self.name = name
188 self.value = str(value)
187 self.value = str(value)
189 self.format = format
188 self.format = format
190
189
191 def makeXml(self, opElement):
190 def makeXml(self, opElement):
192
191
193 parmElement = SubElement(opElement, self.ELEMENTNAME)
192 parmElement = SubElement(opElement, self.ELEMENTNAME)
194 parmElement.set('id', str(self.id))
193 parmElement.set('id', str(self.id))
195 parmElement.set('name', self.name)
194 parmElement.set('name', self.name)
196 parmElement.set('value', self.value)
195 parmElement.set('value', self.value)
197 parmElement.set('format', self.format)
196 parmElement.set('format', self.format)
198
197
199 def readXml(self, parmElement):
198 def readXml(self, parmElement):
200
199
201 self.id = parmElement.get('id')
200 self.id = parmElement.get('id')
202 self.name = parmElement.get('name')
201 self.name = parmElement.get('name')
203 self.value = parmElement.get('value')
202 self.value = parmElement.get('value')
204 self.format = str.lower(parmElement.get('format'))
203 self.format = str.lower(parmElement.get('format'))
205
204
206 #Compatible with old signal chain version
205 #Compatible with old signal chain version
207 if self.format == 'int' and self.name == 'idfigure':
206 if self.format == 'int' and self.name == 'idfigure':
208 self.name = 'id'
207 self.name = 'id'
209
208
210 def printattr(self):
209 def printattr(self):
211
210
212 print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format)
211 print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format)
213
212
214 class OperationConf():
213 class OperationConf():
215
214
216 id = None
215 id = None
217 name = None
216 name = None
218 priority = None
217 priority = None
219 type = None
218 type = None
220
219
221 parmConfObjList = []
220 parmConfObjList = []
222
221
223 ELEMENTNAME = 'Operation'
222 ELEMENTNAME = 'Operation'
224
223
225 def __init__(self):
224 def __init__(self):
226
225
227 self.id = '0'
226 self.id = '0'
228 self.name = None
227 self.name = None
229 self.priority = None
228 self.priority = None
230 self.type = 'self'
229 self.type = 'self'
231
230
232
231
233 def __getNewId(self):
232 def __getNewId(self):
234
233
235 return int(self.id)*10 + len(self.parmConfObjList) + 1
234 return int(self.id)*10 + len(self.parmConfObjList) + 1
236
235
237 def updateId(self, new_id):
236 def updateId(self, new_id):
238
237
239 self.id = str(new_id)
238 self.id = str(new_id)
240
239
241 n = 1
240 n = 1
242 for parmObj in self.parmConfObjList:
241 for parmObj in self.parmConfObjList:
243
242
244 idParm = str(int(new_id)*10 + n)
243 idParm = str(int(new_id)*10 + n)
245 parmObj.updateId(idParm)
244 parmObj.updateId(idParm)
246
245
247 n += 1
246 n += 1
248
247
249 def getElementName(self):
248 def getElementName(self):
250
249
251 return self.ELEMENTNAME
250 return self.ELEMENTNAME
252
251
253 def getParameterObjList(self):
252 def getParameterObjList(self):
254
253
255 return self.parmConfObjList
254 return self.parmConfObjList
256
255
257 def getParameterObj(self, parameterName):
256 def getParameterObj(self, parameterName):
258
257
259 for parmConfObj in self.parmConfObjList:
258 for parmConfObj in self.parmConfObjList:
260
259
261 if parmConfObj.name != parameterName:
260 if parmConfObj.name != parameterName:
262 continue
261 continue
263
262
264 return parmConfObj
263 return parmConfObj
265
264
266 return None
265 return None
267
266
268 def getParameterObjfromValue(self, parameterValue):
267 def getParameterObjfromValue(self, parameterValue):
269
268
270 for parmConfObj in self.parmConfObjList:
269 for parmConfObj in self.parmConfObjList:
271
270
272 if parmConfObj.getValue() != parameterValue:
271 if parmConfObj.getValue() != parameterValue:
273 continue
272 continue
274
273
275 return parmConfObj.getValue()
274 return parmConfObj.getValue()
276
275
277 return None
276 return None
278
277
279 def getParameterValue(self, parameterName):
278 def getParameterValue(self, parameterName):
280
279
281 parameterObj = self.getParameterObj(parameterName)
280 parameterObj = self.getParameterObj(parameterName)
282
281
283 # if not parameterObj:
282 # if not parameterObj:
284 # return None
283 # return None
285
284
286 value = parameterObj.getValue()
285 value = parameterObj.getValue()
287
286
288 return value
287 return value
289
288
290 def setup(self, id, name, priority, type):
289 def setup(self, id, name, priority, type):
291
290
292 self.id = str(id)
291 self.id = str(id)
293 self.name = name
292 self.name = name
294 self.type = type
293 self.type = type
295 self.priority = priority
294 self.priority = priority
296
295
297 self.parmConfObjList = []
296 self.parmConfObjList = []
298
297
299 def removeParameters(self):
298 def removeParameters(self):
300
299
301 for obj in self.parmConfObjList:
300 for obj in self.parmConfObjList:
302 del obj
301 del obj
303
302
304 self.parmConfObjList = []
303 self.parmConfObjList = []
305
304
306 def addParameter(self, name, value, format='str'):
305 def addParameter(self, name, value, format='str'):
307
306
308 id = self.__getNewId()
307 id = self.__getNewId()
309
308
310 parmConfObj = ParameterConf()
309 parmConfObj = ParameterConf()
311 if not parmConfObj.setup(id, name, value, format):
310 if not parmConfObj.setup(id, name, value, format):
312 return None
311 return None
313
312
314 self.parmConfObjList.append(parmConfObj)
313 self.parmConfObjList.append(parmConfObj)
315
314
316 return parmConfObj
315 return parmConfObj
317
316
318 def changeParameter(self, name, value, format='str'):
317 def changeParameter(self, name, value, format='str'):
319
318
320 parmConfObj = self.getParameterObj(name)
319 parmConfObj = self.getParameterObj(name)
321 parmConfObj.update(name, value, format)
320 parmConfObj.update(name, value, format)
322
321
323 return parmConfObj
322 return parmConfObj
324
323
325 def makeXml(self, upElement):
324 def makeXml(self, upElement):
326
325
327 opElement = SubElement(upElement, self.ELEMENTNAME)
326 opElement = SubElement(upElement, self.ELEMENTNAME)
328 opElement.set('id', str(self.id))
327 opElement.set('id', str(self.id))
329 opElement.set('name', self.name)
328 opElement.set('name', self.name)
330 opElement.set('type', self.type)
329 opElement.set('type', self.type)
331 opElement.set('priority', str(self.priority))
330 opElement.set('priority', str(self.priority))
332
331
333 for parmConfObj in self.parmConfObjList:
332 for parmConfObj in self.parmConfObjList:
334 parmConfObj.makeXml(opElement)
333 parmConfObj.makeXml(opElement)
335
334
336 def readXml(self, opElement):
335 def readXml(self, opElement):
337
336
338 self.id = opElement.get('id')
337 self.id = opElement.get('id')
339 self.name = opElement.get('name')
338 self.name = opElement.get('name')
340 self.type = opElement.get('type')
339 self.type = opElement.get('type')
341 self.priority = opElement.get('priority')
340 self.priority = opElement.get('priority')
342
341
343 #Compatible with old signal chain version
342 #Compatible with old signal chain version
344 #Use of 'run' method instead 'init'
343 #Use of 'run' method instead 'init'
345 if self.type == 'self' and self.name == 'init':
344 if self.type == 'self' and self.name == 'init':
346 self.name = 'run'
345 self.name = 'run'
347
346
348 self.parmConfObjList = []
347 self.parmConfObjList = []
349
348
350 parmElementList = opElement.getiterator(ParameterConf().getElementName())
349 parmElementList = opElement.getiterator(ParameterConf().getElementName())
351
350
352 for parmElement in parmElementList:
351 for parmElement in parmElementList:
353 parmConfObj = ParameterConf()
352 parmConfObj = ParameterConf()
354 parmConfObj.readXml(parmElement)
353 parmConfObj.readXml(parmElement)
355
354
356 #Compatible with old signal chain version
355 #Compatible with old signal chain version
357 #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER
356 #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER
358 if self.type != 'self' and self.name == 'Plot':
357 if self.type != 'self' and self.name == 'Plot':
359 if parmConfObj.format == 'str' and parmConfObj.name == 'type':
358 if parmConfObj.format == 'str' and parmConfObj.name == 'type':
360 self.name = parmConfObj.value
359 self.name = parmConfObj.value
361 continue
360 continue
362
361
363 self.parmConfObjList.append(parmConfObj)
362 self.parmConfObjList.append(parmConfObj)
364
363
365 def printattr(self):
364 def printattr(self):
366
365
367 print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME,
366 print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME,
368 self.id,
367 self.id,
369 self.name,
368 self.name,
370 self.type,
369 self.type,
371 self.priority)
370 self.priority)
372
371
373 for parmConfObj in self.parmConfObjList:
372 for parmConfObj in self.parmConfObjList:
374 parmConfObj.printattr()
373 parmConfObj.printattr()
375
374
376 def createObject(self):
375 def createObject(self):
377
376
378 if self.type == 'self':
377 if self.type == 'self':
379 raise ValueError, "This operation type cannot be created"
378 raise ValueError, "This operation type cannot be created"
380
379
381 if self.type == 'external' or self.type == 'other':
380 if self.type == 'external' or self.type == 'other':
382 className = eval(self.name)
381 className = eval(self.name)
383 opObj = className()
382 opObj = className()
384
383
385 return opObj
384 return opObj
386
385
387 class ProcUnitConf():
386 class ProcUnitConf():
388
387
389 id = None
388 id = None
390 name = None
389 name = None
391 datatype = None
390 datatype = None
392 inputId = None
391 inputId = None
393 parentId = None
392 parentId = None
394
393
395 opConfObjList = []
394 opConfObjList = []
396
395
397 procUnitObj = None
396 procUnitObj = None
398 opObjList = []
397 opObjList = []
399
398
400 ELEMENTNAME = 'ProcUnit'
399 ELEMENTNAME = 'ProcUnit'
401
400
402 def __init__(self):
401 def __init__(self):
403
402
404 self.id = None
403 self.id = None
405 self.datatype = None
404 self.datatype = None
406 self.name = None
405 self.name = None
407 self.inputId = None
406 self.inputId = None
408
407
409 self.opConfObjList = []
408 self.opConfObjList = []
410
409
411 self.procUnitObj = None
410 self.procUnitObj = None
412 self.opObjDict = {}
411 self.opObjDict = {}
413
412
414 def __getPriority(self):
413 def __getPriority(self):
415
414
416 return len(self.opConfObjList)+1
415 return len(self.opConfObjList)+1
417
416
418 def __getNewId(self):
417 def __getNewId(self):
419
418
420 return int(self.id)*10 + len(self.opConfObjList) + 1
419 return int(self.id)*10 + len(self.opConfObjList) + 1
421
420
422 def getElementName(self):
421 def getElementName(self):
423
422
424 return self.ELEMENTNAME
423 return self.ELEMENTNAME
425
424
426 def getId(self):
425 def getId(self):
427
426
428 return self.id
427 return self.id
429
428
430 def updateId(self, new_id, parentId=parentId):
429 def updateId(self, new_id, parentId=parentId):
431
430
432
431
433 new_id = int(parentId)*10 + (int(self.id) % 10)
432 new_id = int(parentId)*10 + (int(self.id) % 10)
434 new_inputId = int(parentId)*10 + (int(self.inputId) % 10)
433 new_inputId = int(parentId)*10 + (int(self.inputId) % 10)
435
434
436 #If this proc unit has not inputs
435 #If this proc unit has not inputs
437 if self.inputId == '0':
436 if self.inputId == '0':
438 new_inputId = 0
437 new_inputId = 0
439
438
440 n = 1
439 n = 1
441 for opConfObj in self.opConfObjList:
440 for opConfObj in self.opConfObjList:
442
441
443 idOp = str(int(new_id)*10 + n)
442 idOp = str(int(new_id)*10 + n)
444 opConfObj.updateId(idOp)
443 opConfObj.updateId(idOp)
445
444
446 n += 1
445 n += 1
447
446
448 self.parentId = str(parentId)
447 self.parentId = str(parentId)
449 self.id = str(new_id)
448 self.id = str(new_id)
450 self.inputId = str(new_inputId)
449 self.inputId = str(new_inputId)
451
450
452
451
453 def getInputId(self):
452 def getInputId(self):
454
453
455 return self.inputId
454 return self.inputId
456
455
457 def getOperationObjList(self):
456 def getOperationObjList(self):
458
457
459 return self.opConfObjList
458 return self.opConfObjList
460
459
461 def getOperationObj(self, name=None):
460 def getOperationObj(self, name=None):
462
461
463 for opConfObj in self.opConfObjList:
462 for opConfObj in self.opConfObjList:
464
463
465 if opConfObj.name != name:
464 if opConfObj.name != name:
466 continue
465 continue
467
466
468 return opConfObj
467 return opConfObj
469
468
470 return None
469 return None
471
470
472 def getOpObjfromParamValue(self, value=None):
471 def getOpObjfromParamValue(self, value=None):
473
472
474 for opConfObj in self.opConfObjList:
473 for opConfObj in self.opConfObjList:
475 if opConfObj.getParameterObjfromValue(parameterValue=value) != value:
474 if opConfObj.getParameterObjfromValue(parameterValue=value) != value:
476 continue
475 continue
477 return opConfObj
476 return opConfObj
478 return None
477 return None
479
478
480 def getProcUnitObj(self):
479 def getProcUnitObj(self):
481
480
482 return self.procUnitObj
481 return self.procUnitObj
483
482
484 def setup(self, id, name, datatype, inputId, parentId=None):
483 def setup(self, id, name, datatype, inputId, parentId=None):
485
484
486 #Compatible with old signal chain version
485 #Compatible with old signal chain version
487 if datatype==None and name==None:
486 if datatype==None and name==None:
488 raise ValueError, "datatype or name should be defined"
487 raise ValueError, "datatype or name should be defined"
489
488
490 if name==None:
489 if name==None:
491 if 'Proc' in datatype:
490 if 'Proc' in datatype:
492 name = datatype
491 name = datatype
493 else:
492 else:
494 name = '%sProc' %(datatype)
493 name = '%sProc' %(datatype)
495
494
496 if datatype==None:
495 if datatype==None:
497 datatype = name.replace('Proc','')
496 datatype = name.replace('Proc','')
498
497
499 self.id = str(id)
498 self.id = str(id)
500 self.name = name
499 self.name = name
501 self.datatype = datatype
500 self.datatype = datatype
502 self.inputId = inputId
501 self.inputId = inputId
503 self.parentId = parentId
502 self.parentId = parentId
504
503
505 self.opConfObjList = []
504 self.opConfObjList = []
506
505
507 self.addOperation(name='run', optype='self')
506 self.addOperation(name='run', optype='self')
508
507
509 def removeOperations(self):
508 def removeOperations(self):
510
509
511 for obj in self.opConfObjList:
510 for obj in self.opConfObjList:
512 del obj
511 del obj
513
512
514 self.opConfObjList = []
513 self.opConfObjList = []
515 self.addOperation(name='run')
514 self.addOperation(name='run')
516
515
517 def addParameter(self, **kwargs):
516 def addParameter(self, **kwargs):
518 '''
517 '''
519 Add parameters to "run" operation
518 Add parameters to "run" operation
520 '''
519 '''
521 opObj = self.opConfObjList[0]
520 opObj = self.opConfObjList[0]
522
521
523 opObj.addParameter(**kwargs)
522 opObj.addParameter(**kwargs)
524
523
525 return opObj
524 return opObj
526
525
527 def addOperation(self, name, optype='self'):
526 def addOperation(self, name, optype='self'):
528
527
529 id = self.__getNewId()
528 id = self.__getNewId()
530 priority = self.__getPriority()
529 priority = self.__getPriority()
531
530
532 opConfObj = OperationConf()
531 opConfObj = OperationConf()
533 opConfObj.setup(id, name=name, priority=priority, type=optype)
532 opConfObj.setup(id, name=name, priority=priority, type=optype)
534
533
535 self.opConfObjList.append(opConfObj)
534 self.opConfObjList.append(opConfObj)
536
535
537 return opConfObj
536 return opConfObj
538
537
539 def makeXml(self, procUnitElement):
538 def makeXml(self, procUnitElement):
540
539
541 upElement = SubElement(procUnitElement, self.ELEMENTNAME)
540 upElement = SubElement(procUnitElement, self.ELEMENTNAME)
542 upElement.set('id', str(self.id))
541 upElement.set('id', str(self.id))
543 upElement.set('name', self.name)
542 upElement.set('name', self.name)
544 upElement.set('datatype', self.datatype)
543 upElement.set('datatype', self.datatype)
545 upElement.set('inputId', str(self.inputId))
544 upElement.set('inputId', str(self.inputId))
546
545
547 for opConfObj in self.opConfObjList:
546 for opConfObj in self.opConfObjList:
548 opConfObj.makeXml(upElement)
547 opConfObj.makeXml(upElement)
549
548
550 def readXml(self, upElement):
549 def readXml(self, upElement):
551
550
552 self.id = upElement.get('id')
551 self.id = upElement.get('id')
553 self.name = upElement.get('name')
552 self.name = upElement.get('name')
554 self.datatype = upElement.get('datatype')
553 self.datatype = upElement.get('datatype')
555 self.inputId = upElement.get('inputId')
554 self.inputId = upElement.get('inputId')
556
555
557 if self.ELEMENTNAME == "ReadUnit":
556 if self.ELEMENTNAME == "ReadUnit":
558 self.datatype = self.datatype.replace("Reader", "")
557 self.datatype = self.datatype.replace("Reader", "")
559
558
560 if self.ELEMENTNAME == "ProcUnit":
559 if self.ELEMENTNAME == "ProcUnit":
561 self.datatype = self.datatype.replace("Proc", "")
560 self.datatype = self.datatype.replace("Proc", "")
562
561
563 if self.inputId == 'None':
562 if self.inputId == 'None':
564 self.inputId = '0'
563 self.inputId = '0'
565
564
566 self.opConfObjList = []
565 self.opConfObjList = []
567
566
568 opElementList = upElement.getiterator(OperationConf().getElementName())
567 opElementList = upElement.getiterator(OperationConf().getElementName())
569
568
570 for opElement in opElementList:
569 for opElement in opElementList:
571 opConfObj = OperationConf()
570 opConfObj = OperationConf()
572 opConfObj.readXml(opElement)
571 opConfObj.readXml(opElement)
573 self.opConfObjList.append(opConfObj)
572 self.opConfObjList.append(opConfObj)
574
573
575 def printattr(self):
574 def printattr(self):
576
575
577 print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME,
576 print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME,
578 self.id,
577 self.id,
579 self.name,
578 self.name,
580 self.datatype,
579 self.datatype,
581 self.inputId)
580 self.inputId)
582
581
583 for opConfObj in self.opConfObjList:
582 for opConfObj in self.opConfObjList:
584 opConfObj.printattr()
583 opConfObj.printattr()
585
584
586 def createObjects(self):
585 def createObjects(self):
587
586
588 className = eval(self.name)
587 className = eval(self.name)
589 procUnitObj = className()
588 procUnitObj = className()
590
589
591 for opConfObj in self.opConfObjList:
590 for opConfObj in self.opConfObjList:
592
591
593 if opConfObj.type == 'self':
592 if opConfObj.type == 'self':
594 continue
593 continue
595
594
596 opObj = opConfObj.createObject()
595 opObj = opConfObj.createObject()
597
596
598 self.opObjDict[opConfObj.id] = opObj
597 self.opObjDict[opConfObj.id] = opObj
599 procUnitObj.addOperation(opObj, opConfObj.id)
598 procUnitObj.addOperation(opObj, opConfObj.id)
600
599
601 self.procUnitObj = procUnitObj
600 self.procUnitObj = procUnitObj
602
601
603 return procUnitObj
602 return procUnitObj
604
603
605 def run(self):
604 def run(self):
606
605
607 finalSts = False
606 finalSts = False
608
607
609 for opConfObj in self.opConfObjList:
608 for opConfObj in self.opConfObjList:
610
609
611 kwargs = {}
610 kwargs = {}
612 for parmConfObj in opConfObj.getParameterObjList():
611 for parmConfObj in opConfObj.getParameterObjList():
613 if opConfObj.name == 'run' and parmConfObj.name == 'datatype':
612 if opConfObj.name == 'run' and parmConfObj.name == 'datatype':
614 continue
613 continue
615
614
616 kwargs[parmConfObj.name] = parmConfObj.getValue()
615 kwargs[parmConfObj.name] = parmConfObj.getValue()
617
616
618 #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id)
617 #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id)
619 sts = self.procUnitObj.call(opType = opConfObj.type,
618 sts = self.procUnitObj.call(opType = opConfObj.type,
620 opName = opConfObj.name,
619 opName = opConfObj.name,
621 opId = opConfObj.id,
620 opId = opConfObj.id,
622 **kwargs)
621 **kwargs)
623 finalSts = finalSts or sts
622 finalSts = finalSts or sts
624
623
625 return finalSts
624 return finalSts
626
625
627 def close(self):
626 def close(self):
628
627
629 for opConfObj in self.opConfObjList:
628 for opConfObj in self.opConfObjList:
630 if opConfObj.type == 'self':
629 if opConfObj.type == 'self':
631 continue
630 continue
632
631
633 opObj = self.procUnitObj.getOperationObj(opConfObj.id)
632 opObj = self.procUnitObj.getOperationObj(opConfObj.id)
634 opObj.close()
633 opObj.close()
635
634
636 self.procUnitObj.close()
635 self.procUnitObj.close()
637
636
638 return
637 return
639
638
640 class ReadUnitConf(ProcUnitConf):
639 class ReadUnitConf(ProcUnitConf):
641
640
642 path = None
641 path = None
643 startDate = None
642 startDate = None
644 endDate = None
643 endDate = None
645 startTime = None
644 startTime = None
646 endTime = None
645 endTime = None
647
646
648 ELEMENTNAME = 'ReadUnit'
647 ELEMENTNAME = 'ReadUnit'
649
648
650 def __init__(self):
649 def __init__(self):
651
650
652 self.id = None
651 self.id = None
653 self.datatype = None
652 self.datatype = None
654 self.name = None
653 self.name = None
655 self.inputId = None
654 self.inputId = None
656
655
657 self.parentId = None
656 self.parentId = None
658
657
659 self.opConfObjList = []
658 self.opConfObjList = []
660 self.opObjList = []
659 self.opObjList = []
661
660
662 def getElementName(self):
661 def getElementName(self):
663
662
664 return self.ELEMENTNAME
663 return self.ELEMENTNAME
665
664
666 def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs):
665 def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs):
667
666
668 #Compatible with old signal chain version
667 #Compatible with old signal chain version
669 if datatype==None and name==None:
668 if datatype==None and name==None:
670 raise ValueError, "datatype or name should be defined"
669 raise ValueError, "datatype or name should be defined"
671
670
672 if name==None:
671 if name==None:
673 if 'Reader' in datatype:
672 if 'Reader' in datatype:
674 name = datatype
673 name = datatype
675 else:
674 else:
676 name = '%sReader' %(datatype)
675 name = '%sReader' %(datatype)
677
676
678 if datatype==None:
677 if datatype==None:
679 datatype = name.replace('Reader','')
678 datatype = name.replace('Reader','')
680
679
681 self.id = id
680 self.id = id
682 self.name = name
681 self.name = name
683 self.datatype = datatype
682 self.datatype = datatype
684
683
685 self.path = path
684 self.path = path
686 self.startDate = startDate
685 self.startDate = startDate
687 self.endDate = endDate
686 self.endDate = endDate
688 self.startTime = startTime
687 self.startTime = startTime
689 self.endTime = endTime
688 self.endTime = endTime
690
689
691 self.inputId = '0'
690 self.inputId = '0'
692 self.parentId = parentId
691 self.parentId = parentId
693
692
694 self.addRunOperation(**kwargs)
693 self.addRunOperation(**kwargs)
695
694
696 def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs):
695 def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs):
697
696
698 #Compatible with old signal chain version
697 #Compatible with old signal chain version
699 if datatype==None and name==None:
698 if datatype==None and name==None:
700 raise ValueError, "datatype or name should be defined"
699 raise ValueError, "datatype or name should be defined"
701
700
702 if name==None:
701 if name==None:
703 if 'Reader' in datatype:
702 if 'Reader' in datatype:
704 name = datatype
703 name = datatype
705 else:
704 else:
706 name = '%sReader' %(datatype)
705 name = '%sReader' %(datatype)
707
706
708 if datatype==None:
707 if datatype==None:
709 datatype = name.replace('Reader','')
708 datatype = name.replace('Reader','')
710
709
711 self.datatype = datatype
710 self.datatype = datatype
712 self.name = name
711 self.name = name
713 self.path = path
712 self.path = path
714 self.startDate = startDate
713 self.startDate = startDate
715 self.endDate = endDate
714 self.endDate = endDate
716 self.startTime = startTime
715 self.startTime = startTime
717 self.endTime = endTime
716 self.endTime = endTime
718
717
719 self.inputId = '0'
718 self.inputId = '0'
720 self.parentId = parentId
719 self.parentId = parentId
721
720
722 self.updateRunOperation(**kwargs)
721 self.updateRunOperation(**kwargs)
723
722
724 def addRunOperation(self, **kwargs):
723 def addRunOperation(self, **kwargs):
725
724
726 opObj = self.addOperation(name = 'run', optype = 'self')
725 opObj = self.addOperation(name = 'run', optype = 'self')
727
726
728 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
727 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
729 opObj.addParameter(name='path' , value=self.path, format='str')
728 opObj.addParameter(name='path' , value=self.path, format='str')
730 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
729 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
731 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
730 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
732 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
731 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
733 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
732 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
734
733
735 for key, value in kwargs.items():
734 for key, value in kwargs.items():
736 opObj.addParameter(name=key, value=value, format=type(value).__name__)
735 opObj.addParameter(name=key, value=value, format=type(value).__name__)
737
736
738 return opObj
737 return opObj
739
738
740 def updateRunOperation(self, **kwargs):
739 def updateRunOperation(self, **kwargs):
741
740
742 opObj = self.getOperationObj(name = 'run')
741 opObj = self.getOperationObj(name = 'run')
743 opObj.removeParameters()
742 opObj.removeParameters()
744
743
745 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
744 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
746 opObj.addParameter(name='path' , value=self.path, format='str')
745 opObj.addParameter(name='path' , value=self.path, format='str')
747 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
746 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
748 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
747 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
749 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
748 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
750 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
749 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
751
750
752 for key, value in kwargs.items():
751 for key, value in kwargs.items():
753 opObj.addParameter(name=key, value=value, format=type(value).__name__)
752 opObj.addParameter(name=key, value=value, format=type(value).__name__)
754
753
755 return opObj
754 return opObj
756
755
757 class Project():
756 class Project():
758
757
759 id = None
758 id = None
760 name = None
759 name = None
761 description = None
760 description = None
762 # readUnitConfObjList = None
761 # readUnitConfObjList = None
763 procUnitConfObjDict = None
762 procUnitConfObjDict = None
764
763
765 ELEMENTNAME = 'Project'
764 ELEMENTNAME = 'Project'
766
765
767 def __init__(self, control=None, dataq=None):
766 def __init__(self, control=None, dataq=None):
768
767
769 self.id = None
768 self.id = None
770 self.name = None
769 self.name = None
771 self.description = None
770 self.description = None
772
771
773 self.procUnitConfObjDict = {}
772 self.procUnitConfObjDict = {}
774
773
775 #global data_q
774 #global data_q
776 #data_q = dataq
775 #data_q = dataq
777
776
778 if control==None:
777 if control==None:
779 control = {'stop':False,'pause':False}
778 control = {'stop':False,'pause':False}
780
779
781 self.control = control
780 self.control = control
782
781
783 def __getNewId(self):
782 def __getNewId(self):
784
783
785 id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1
784 id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1
786
785
787 return str(id)
786 return str(id)
788
787
789 def getElementName(self):
788 def getElementName(self):
790
789
791 return self.ELEMENTNAME
790 return self.ELEMENTNAME
792
791
793 def getId(self):
792 def getId(self):
794
793
795 return self.id
794 return self.id
796
795
797 def updateId(self, new_id):
796 def updateId(self, new_id):
798
797
799 self.id = str(new_id)
798 self.id = str(new_id)
800
799
801 keyList = self.procUnitConfObjDict.keys()
800 keyList = self.procUnitConfObjDict.keys()
802 keyList.sort()
801 keyList.sort()
803
802
804 n = 1
803 n = 1
805 newProcUnitConfObjDict = {}
804 newProcUnitConfObjDict = {}
806
805
807 for procKey in keyList:
806 for procKey in keyList:
808
807
809 procUnitConfObj = self.procUnitConfObjDict[procKey]
808 procUnitConfObj = self.procUnitConfObjDict[procKey]
810 idProcUnit = str(int(self.id)*10 + n)
809 idProcUnit = str(int(self.id)*10 + n)
811 procUnitConfObj.updateId(idProcUnit, parentId = self.id)
810 procUnitConfObj.updateId(idProcUnit, parentId = self.id)
812
811
813 newProcUnitConfObjDict[idProcUnit] = procUnitConfObj
812 newProcUnitConfObjDict[idProcUnit] = procUnitConfObj
814 n += 1
813 n += 1
815
814
816 self.procUnitConfObjDict = newProcUnitConfObjDict
815 self.procUnitConfObjDict = newProcUnitConfObjDict
817
816
818 def setup(self, id, name, description):
817 def setup(self, id, name, description):
819
818
820 self.id = str(id)
819 self.id = str(id)
821 self.name = name
820 self.name = name
822 self.description = description
821 self.description = description
823
822
824 def update(self, name, description):
823 def update(self, name, description):
825
824
826 self.name = name
825 self.name = name
827 self.description = description
826 self.description = description
828
827
829 def addReadUnit(self, datatype=None, name=None, **kwargs):
828 def addReadUnit(self, datatype=None, name=None, **kwargs):
830
829
831 idReadUnit = self.__getNewId()
830 idReadUnit = self.__getNewId()
832
831
833 readUnitConfObj = ReadUnitConf()
832 readUnitConfObj = ReadUnitConf()
834 readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs)
833 readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs)
835
834
836 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
835 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
837
836
838 return readUnitConfObj
837 return readUnitConfObj
839
838
840 def addProcUnit(self, inputId='0', datatype=None, name=None):
839 def addProcUnit(self, inputId='0', datatype=None, name=None):
841
840
842 idProcUnit = self.__getNewId()
841 idProcUnit = self.__getNewId()
843
842
844 procUnitConfObj = ProcUnitConf()
843 procUnitConfObj = ProcUnitConf()
845 procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id)
844 procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id)
846
845
847 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
846 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
848
847
849 return procUnitConfObj
848 return procUnitConfObj
850
849
851 def removeProcUnit(self, id):
850 def removeProcUnit(self, id):
852
851
853 if id in self.procUnitConfObjDict.keys():
852 if id in self.procUnitConfObjDict.keys():
854 self.procUnitConfObjDict.pop(id)
853 self.procUnitConfObjDict.pop(id)
855
854
856 def getReadUnitId(self):
855 def getReadUnitId(self):
857
856
858 readUnitConfObj = self.getReadUnitObj()
857 readUnitConfObj = self.getReadUnitObj()
859
858
860 return readUnitConfObj.id
859 return readUnitConfObj.id
861
860
862 def getReadUnitObj(self):
861 def getReadUnitObj(self):
863
862
864 for obj in self.procUnitConfObjDict.values():
863 for obj in self.procUnitConfObjDict.values():
865 if obj.getElementName() == "ReadUnit":
864 if obj.getElementName() == "ReadUnit":
866 return obj
865 return obj
867
866
868 return None
867 return None
869
868
870 def getProcUnitObj(self, id=None, name=None):
869 def getProcUnitObj(self, id=None, name=None):
871
870
872 if id != None:
871 if id != None:
873 return self.procUnitConfObjDict[id]
872 return self.procUnitConfObjDict[id]
874
873
875 if name != None:
874 if name != None:
876 return self.getProcUnitObjByName(name)
875 return self.getProcUnitObjByName(name)
877
876
878 return None
877 return None
879
878
880 def getProcUnitObjByName(self, name):
879 def getProcUnitObjByName(self, name):
881
880
882 for obj in self.procUnitConfObjDict.values():
881 for obj in self.procUnitConfObjDict.values():
883 if obj.name == name:
882 if obj.name == name:
884 return obj
883 return obj
885
884
886 return None
885 return None
887
886
888 def procUnitItems(self):
887 def procUnitItems(self):
889
888
890 return self.procUnitConfObjDict.items()
889 return self.procUnitConfObjDict.items()
891
890
892 def makeXml(self):
891 def makeXml(self):
893
892
894 projectElement = Element('Project')
893 projectElement = Element('Project')
895 projectElement.set('id', str(self.id))
894 projectElement.set('id', str(self.id))
896 projectElement.set('name', self.name)
895 projectElement.set('name', self.name)
897 projectElement.set('description', self.description)
896 projectElement.set('description', self.description)
898
897
899 for procUnitConfObj in self.procUnitConfObjDict.values():
898 for procUnitConfObj in self.procUnitConfObjDict.values():
900 procUnitConfObj.makeXml(projectElement)
899 procUnitConfObj.makeXml(projectElement)
901
900
902 self.projectElement = projectElement
901 self.projectElement = projectElement
903
902
904 def writeXml(self, filename):
903 def writeXml(self, filename):
905
904
906 self.makeXml()
905 self.makeXml()
907
906
908 #print prettify(self.projectElement)
907 #print prettify(self.projectElement)
909
908
910 ElementTree(self.projectElement).write(filename, method='xml')
909 ElementTree(self.projectElement).write(filename, method='xml')
911
910
912 def readXml(self, filename):
911 def readXml(self, filename):
913
912
914 self.projectElement = None
913 self.projectElement = None
915 self.procUnitConfObjDict = {}
914 self.procUnitConfObjDict = {}
916
915
917 self.projectElement = ElementTree().parse(filename)
916 self.projectElement = ElementTree().parse(filename)
918
917
919 self.project = self.projectElement.tag
918 self.project = self.projectElement.tag
920
919
921 self.id = self.projectElement.get('id')
920 self.id = self.projectElement.get('id')
922 self.name = self.projectElement.get('name')
921 self.name = self.projectElement.get('name')
923 self.description = self.projectElement.get('description')
922 self.description = self.projectElement.get('description')
924
923
925 readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName())
924 readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName())
926
925
927 for readUnitElement in readUnitElementList:
926 for readUnitElement in readUnitElementList:
928 readUnitConfObj = ReadUnitConf()
927 readUnitConfObj = ReadUnitConf()
929 readUnitConfObj.readXml(readUnitElement)
928 readUnitConfObj.readXml(readUnitElement)
930
929
931 if readUnitConfObj.parentId == None:
930 if readUnitConfObj.parentId == None:
932 readUnitConfObj.parentId = self.id
931 readUnitConfObj.parentId = self.id
933
932
934 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
933 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
935
934
936 procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName())
935 procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName())
937
936
938 for procUnitElement in procUnitElementList:
937 for procUnitElement in procUnitElementList:
939 procUnitConfObj = ProcUnitConf()
938 procUnitConfObj = ProcUnitConf()
940 procUnitConfObj.readXml(procUnitElement)
939 procUnitConfObj.readXml(procUnitElement)
941
940
942 if procUnitConfObj.parentId == None:
941 if procUnitConfObj.parentId == None:
943 procUnitConfObj.parentId = self.id
942 procUnitConfObj.parentId = self.id
944
943
945 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
944 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
946
945
947 def printattr(self):
946 def printattr(self):
948
947
949 print "Project[%s]: name = %s, description = %s" %(self.id,
948 print "Project[%s]: name = %s, description = %s" %(self.id,
950 self.name,
949 self.name,
951 self.description)
950 self.description)
952
951
953 for procUnitConfObj in self.procUnitConfObjDict.values():
952 for procUnitConfObj in self.procUnitConfObjDict.values():
954 procUnitConfObj.printattr()
953 procUnitConfObj.printattr()
955
954
956 def createObjects(self):
955 def createObjects(self):
957
956
958 for procUnitConfObj in self.procUnitConfObjDict.values():
957 for procUnitConfObj in self.procUnitConfObjDict.values():
959 procUnitConfObj.createObjects()
958 procUnitConfObj.createObjects()
960
959
961 def __connect(self, objIN, thisObj):
960 def __connect(self, objIN, thisObj):
962
961
963 thisObj.setInput(objIN.getOutputObj())
962 thisObj.setInput(objIN.getOutputObj())
964
963
965 def connectObjects(self):
964 def connectObjects(self):
966
965
967 for thisPUConfObj in self.procUnitConfObjDict.values():
966 for thisPUConfObj in self.procUnitConfObjDict.values():
968
967
969 inputId = thisPUConfObj.getInputId()
968 inputId = thisPUConfObj.getInputId()
970
969
971 if int(inputId) == 0:
970 if int(inputId) == 0:
972 continue
971 continue
973
972
974 #Get input object
973 #Get input object
975 puConfINObj = self.procUnitConfObjDict[inputId]
974 puConfINObj = self.procUnitConfObjDict[inputId]
976 puObjIN = puConfINObj.getProcUnitObj()
975 puObjIN = puConfINObj.getProcUnitObj()
977
976
978 #Get current object
977 #Get current object
979 thisPUObj = thisPUConfObj.getProcUnitObj()
978 thisPUObj = thisPUConfObj.getProcUnitObj()
980
979
981 self.__connect(puObjIN, thisPUObj)
980 self.__connect(puObjIN, thisPUObj)
982
981
983 def run(self):
982 def run(self):
984
983
985 print
984 print
986 print "*"*50
985 print "*"*50
987 print " Starting SIGNAL CHAIN PROCESSING "
986 print " Starting SIGNAL CHAIN PROCESSING "
988 print "*"*50
987 print "*"*50
989 print
988 print
990
989
991 keyList = self.procUnitConfObjDict.keys()
990 keyList = self.procUnitConfObjDict.keys()
992 keyList.sort()
991 keyList.sort()
993
992
994 while(True):
993 while(True):
995
994
996 finalSts = False
995 finalSts = False
997
996
998 for procKey in keyList:
997 for procKey in keyList:
999 # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id)
998 # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id)
1000
999
1001 procUnitConfObj = self.procUnitConfObjDict[procKey]
1000 procUnitConfObj = self.procUnitConfObjDict[procKey]
1002 sts = procUnitConfObj.run()
1001 sts = procUnitConfObj.run()
1003 finalSts = finalSts or sts
1002 finalSts = finalSts or sts
1004
1003
1005 #If every process unit finished so end process
1004 #If every process unit finished so end process
1006 if not(finalSts):
1005 if not(finalSts):
1007 print "Every process unit have finished"
1006 print "Every process unit have finished"
1008 break
1007 break
1009
1008
1010 if self.control['pause']:
1009 if self.control['pause']:
1011 print "Process suspended"
1010 print "Process suspended"
1012
1011
1013 while True:
1012 while True:
1014 sleep(0.1)
1013 sleep(0.1)
1015
1014
1016 if not self.control['pause']:
1015 if not self.control['pause']:
1017 break
1016 break
1018
1017
1019 if self.control['stop']:
1018 if self.control['stop']:
1020 break
1019 break
1021 print "Process reinitialized"
1020 print "Process reinitialized"
1022
1021
1023 if self.control['stop']:
1022 if self.control['stop']:
1024 # print "Process stopped"
1023 # print "Process stopped"
1025 break
1024 break
1026
1025
1027 #Closing every process
1026 #Closing every process
1028 for procKey in keyList:
1027 for procKey in keyList:
1029 procUnitConfObj = self.procUnitConfObjDict[procKey]
1028 procUnitConfObj = self.procUnitConfObjDict[procKey]
1030 procUnitConfObj.close()
1029 procUnitConfObj.close()
1031
1030
1032 print "Process finished"
1031 print "Process finished"
1033
1032
1034 def start(self, filename):
1033 def start(self, filename):
1035
1034
1036 self.writeXml(filename)
1035 self.writeXml(filename)
1037 self.readXml(filename)
1036 self.readXml(filename)
1038
1037
1039 self.createObjects()
1038 self.createObjects()
1040 self.connectObjects()
1039 self.connectObjects()
1041 self.run()
1040 self.run()
1042
1041
1043 if __name__ == '__main__':
1042 if __name__ == '__main__':
1044
1043
1045 desc = "Segundo Test"
1044 desc = "Segundo Test"
1046 filename = "schain.xml"
1045 filename = "schain.xml"
1047
1046
1048 controllerObj = Project()
1047 controllerObj = Project()
1049
1048
1050 controllerObj.setup(id = '191', name='test01', description=desc)
1049 controllerObj.setup(id = '191', name='test01', description=desc)
1051
1050
1052 readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage',
1051 readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage',
1053 path='data/rawdata/',
1052 path='data/rawdata/',
1054 startDate='2011/01/01',
1053 startDate='2011/01/01',
1055 endDate='2012/12/31',
1054 endDate='2012/12/31',
1056 startTime='00:00:00',
1055 startTime='00:00:00',
1057 endTime='23:59:59',
1056 endTime='23:59:59',
1058 online=1,
1057 online=1,
1059 walk=1)
1058 walk=1)
1060
1059
1061 procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
1060 procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
1062
1061
1063 opObj10 = procUnitConfObj0.addOperation(name='selectChannels')
1062 opObj10 = procUnitConfObj0.addOperation(name='selectChannels')
1064 opObj10.addParameter(name='channelList', value='3,4,5', format='intlist')
1063 opObj10.addParameter(name='channelList', value='3,4,5', format='intlist')
1065
1064
1066 opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
1065 opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
1067 opObj10.addParameter(name='minHei', value='90', format='float')
1066 opObj10.addParameter(name='minHei', value='90', format='float')
1068 opObj10.addParameter(name='maxHei', value='180', format='float')
1067 opObj10.addParameter(name='maxHei', value='180', format='float')
1069
1068
1070 opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
1069 opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
1071 opObj12.addParameter(name='n', value='10', format='int')
1070 opObj12.addParameter(name='n', value='10', format='int')
1072
1071
1073 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId())
1072 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId())
1074 procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int')
1073 procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int')
1075 # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='')
1074 # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='')
1076
1075
1077
1076
1078 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
1077 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
1079 opObj11.addParameter(name='idfigure', value='1', format='int')
1078 opObj11.addParameter(name='idfigure', value='1', format='int')
1080 opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str')
1079 opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str')
1081 opObj11.addParameter(name='zmin', value='40', format='int')
1080 opObj11.addParameter(name='zmin', value='40', format='int')
1082 opObj11.addParameter(name='zmax', value='90', format='int')
1081 opObj11.addParameter(name='zmax', value='90', format='int')
1083 opObj11.addParameter(name='showprofile', value='1', format='int')
1082 opObj11.addParameter(name='showprofile', value='1', format='int')
1084
1083
1085 print "Escribiendo el archivo XML"
1084 print "Escribiendo el archivo XML"
1086
1085
1087 controllerObj.writeXml(filename)
1086 controllerObj.writeXml(filename)
1088
1087
1089 print "Leyendo el archivo XML"
1088 print "Leyendo el archivo XML"
1090 controllerObj.readXml(filename)
1089 controllerObj.readXml(filename)
1091 #controllerObj.printattr()
1090 #controllerObj.printattr()
1092
1091
1093 controllerObj.createObjects()
1092 controllerObj.createObjects()
1094 controllerObj.connectObjects()
1093 controllerObj.connectObjects()
1095 controllerObj.run()
1094 controllerObj.run()
1096
1095
1097 No newline at end of file
1096
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,240 +1,240
1 from PyQt4 import QtCore, QtGui
1 from PyQt4 import QtCore, QtGui
2
2
3 try:
3 try:
4 _fromUtf8 = QtCore.QString.fromUtf8
4 _fromUtf8 = QtCore.QString.fromUtf8
5 except AttributeError:
5 except AttributeError:
6 def _fromUtf8(s):
6 def _fromUtf8(s):
7 return s
7 return s
8
8
9 try:
9 try:
10 _encoding = QtGui.QApplication.UnicodeUTF8
10 _encoding = QtGui.QApplication.UnicodeUTF8
11 def _translate(context, text, disambig):
11 def _translate(context, text, disambig):
12 return QtGui.QApplication.translate(context, text, disambig, _encoding)
12 return QtGui.QApplication.translate(context, text, disambig, _encoding)
13 except AttributeError:
13 except AttributeError:
14 def _translate(context, text, disambig):
14 def _translate(context, text, disambig):
15 return QtGui.QApplication.translate(context, text, disambig)
15 return QtGui.QApplication.translate(context, text, disambig)
16
16
17 class Ui_SpectraHeisTab(object):
17 class Ui_SpectraHeisTab(object):
18
18
19 def setupUi(self):
19 def setupUi(self):
20
20
21 self.tabSpectraHeis = QtGui.QWidget()
21 self.tabSpectraHeis = QtGui.QWidget()
22 self.tabSpectraHeis.setObjectName(_fromUtf8("tabSpectraHeis"))
22 self.tabSpectraHeis.setObjectName(_fromUtf8("tabSpectraHeis"))
23 self.gridLayout_23 = QtGui.QGridLayout(self.tabSpectraHeis)
23 self.gridLayout_23 = QtGui.QGridLayout(self.tabSpectraHeis)
24 self.gridLayout_23.setObjectName(_fromUtf8("gridLayout_23"))
24 self.gridLayout_23.setObjectName(_fromUtf8("gridLayout_23"))
25 self.frame_6 = QtGui.QFrame(self.tabSpectraHeis)
25 self.frame_6 = QtGui.QFrame(self.tabSpectraHeis)
26 self.frame_6.setFrameShape(QtGui.QFrame.StyledPanel)
26 self.frame_6.setFrameShape(QtGui.QFrame.StyledPanel)
27 self.frame_6.setFrameShadow(QtGui.QFrame.Raised)
27 self.frame_6.setFrameShadow(QtGui.QFrame.Raised)
28 self.frame_6.setObjectName(_fromUtf8("frame_6"))
28 self.frame_6.setObjectName(_fromUtf8("frame_6"))
29 self.gridLayout_22 = QtGui.QGridLayout(self.frame_6)
29 self.gridLayout_22 = QtGui.QGridLayout(self.frame_6)
30 self.gridLayout_22.setObjectName(_fromUtf8("gridLayout_22"))
30 self.gridLayout_22.setObjectName(_fromUtf8("gridLayout_22"))
31 self.specHeisGraphClear = QtGui.QPushButton(self.frame_6)
31 self.specHeisGraphClear = QtGui.QPushButton(self.frame_6)
32 self.specHeisGraphClear.setObjectName(_fromUtf8("specHeisGraphClear"))
32 self.specHeisGraphClear.setObjectName(_fromUtf8("specHeisGraphClear"))
33 self.gridLayout_22.addWidget(self.specHeisGraphClear, 0, 1, 1, 1)
33 self.gridLayout_22.addWidget(self.specHeisGraphClear, 0, 1, 1, 1)
34 self.specHeisOpOk = QtGui.QPushButton(self.frame_6)
34 self.specHeisOpOk = QtGui.QPushButton(self.frame_6)
35 self.specHeisOpOk.setObjectName(_fromUtf8("specHeisOpOk"))
35 self.specHeisOpOk.setObjectName(_fromUtf8("specHeisOpOk"))
36 self.gridLayout_22.addWidget(self.specHeisOpOk, 0, 0, 1, 1)
36 self.gridLayout_22.addWidget(self.specHeisOpOk, 0, 0, 1, 1)
37 self.gridLayout_23.addWidget(self.frame_6, 1, 0, 1, 1)
37 self.gridLayout_23.addWidget(self.frame_6, 1, 0, 1, 1)
38 self.tabWidgetSpectraHeis = QtGui.QTabWidget(self.tabSpectraHeis)
38 self.tabWidgetSpectraHeis = QtGui.QTabWidget(self.tabSpectraHeis)
39 self.tabWidgetSpectraHeis.setObjectName(_fromUtf8("tabWidgetSpectraHeis"))
39 self.tabWidgetSpectraHeis.setObjectName(_fromUtf8("tabWidgetSpectraHeis"))
40 self.tabopSpectraHeis = QtGui.QWidget()
40 self.tabopSpectraHeis = QtGui.QWidget()
41 self.tabopSpectraHeis.setObjectName(_fromUtf8("tabopSpectraHeis"))
41 self.tabopSpectraHeis.setObjectName(_fromUtf8("tabopSpectraHeis"))
42 self.gridLayout_21 = QtGui.QGridLayout(self.tabopSpectraHeis)
42 self.gridLayout_21 = QtGui.QGridLayout(self.tabopSpectraHeis)
43 self.gridLayout_21.setObjectName(_fromUtf8("gridLayout_21"))
43 self.gridLayout_21.setObjectName(_fromUtf8("gridLayout_21"))
44 spacerItem21 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
44 spacerItem21 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
45 self.gridLayout_21.addItem(spacerItem21, 0, 1, 1, 1)
45 self.gridLayout_21.addItem(spacerItem21, 0, 1, 1, 1)
46 self.specHeisOpCobIncInt = QtGui.QComboBox(self.tabopSpectraHeis)
46 self.specHeisOpCobIncInt = QtGui.QComboBox(self.tabopSpectraHeis)
47 self.specHeisOpCobIncInt.setObjectName(_fromUtf8("specHeisOpCobIncInt"))
47 self.specHeisOpCobIncInt.setObjectName(_fromUtf8("specHeisOpCobIncInt"))
48 self.specHeisOpCobIncInt.addItem(_fromUtf8(""))
48 self.specHeisOpCobIncInt.addItem(_fromUtf8(""))
49 self.gridLayout_21.addWidget(self.specHeisOpCobIncInt, 1, 0, 1, 1)
49 self.gridLayout_21.addWidget(self.specHeisOpCobIncInt, 1, 0, 1, 1)
50 self.specHeisOpCebIncoherent = QtGui.QCheckBox(self.tabopSpectraHeis)
50 self.specHeisOpCebIncoherent = QtGui.QCheckBox(self.tabopSpectraHeis)
51 self.specHeisOpCebIncoherent.setObjectName(_fromUtf8("specHeisOpCebIncoherent"))
51 self.specHeisOpCebIncoherent.setObjectName(_fromUtf8("specHeisOpCebIncoherent"))
52 self.gridLayout_21.addWidget(self.specHeisOpCebIncoherent, 0, 0, 1, 1)
52 self.gridLayout_21.addWidget(self.specHeisOpCebIncoherent, 0, 0, 1, 1)
53 self.specHeisOpIncoherent = QtGui.QLineEdit(self.tabopSpectraHeis)
53 self.specHeisOpIncoherent = QtGui.QLineEdit(self.tabopSpectraHeis)
54 self.specHeisOpIncoherent.setObjectName(_fromUtf8("specHeisOpIncoherent"))
54 self.specHeisOpIncoherent.setObjectName(_fromUtf8("specHeisOpIncoherent"))
55 self.gridLayout_21.addWidget(self.specHeisOpIncoherent, 1, 1, 1, 1)
55 self.gridLayout_21.addWidget(self.specHeisOpIncoherent, 1, 1, 1, 1)
56 spacerItem22 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
56 spacerItem22 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
57 self.gridLayout_21.addItem(spacerItem22, 2, 0, 1, 1)
57 self.gridLayout_21.addItem(spacerItem22, 2, 0, 1, 1)
58 self.tabWidgetSpectraHeis.addTab(self.tabopSpectraHeis, _fromUtf8(""))
58 self.tabWidgetSpectraHeis.addTab(self.tabopSpectraHeis, _fromUtf8(""))
59 self.tabgraphSpectraHeis = QtGui.QWidget()
59 self.tabgraphSpectraHeis = QtGui.QWidget()
60 self.tabgraphSpectraHeis.setObjectName(_fromUtf8("tabgraphSpectraHeis"))
60 self.tabgraphSpectraHeis.setObjectName(_fromUtf8("tabgraphSpectraHeis"))
61 self.gridLayout_20 = QtGui.QGridLayout(self.tabgraphSpectraHeis)
61 self.gridLayout_20 = QtGui.QGridLayout(self.tabgraphSpectraHeis)
62 self.gridLayout_20.setObjectName(_fromUtf8("gridLayout_20"))
62 self.gridLayout_20.setObjectName(_fromUtf8("gridLayout_20"))
63 self.label_54 = QtGui.QLabel(self.tabgraphSpectraHeis)
63 self.label_54 = QtGui.QLabel(self.tabgraphSpectraHeis)
64 self.label_54.setObjectName(_fromUtf8("label_54"))
64 self.label_54.setObjectName(_fromUtf8("label_54"))
65 self.gridLayout_20.addWidget(self.label_54, 1, 0, 1, 1)
65 self.gridLayout_20.addWidget(self.label_54, 1, 0, 1, 1)
66 self.specHeisGraphToolPath = QtGui.QToolButton(self.tabgraphSpectraHeis)
66 self.specHeisGraphToolPath = QtGui.QToolButton(self.tabgraphSpectraHeis)
67 self.specHeisGraphToolPath.setObjectName(_fromUtf8("specHeisGraphToolPath"))
67 self.specHeisGraphToolPath.setObjectName(_fromUtf8("specHeisGraphToolPath"))
68 self.gridLayout_20.addWidget(self.specHeisGraphToolPath, 0, 6, 1, 1)
68 self.gridLayout_20.addWidget(self.specHeisGraphToolPath, 0, 6, 1, 1)
69 self.specHeisGraphCebRTIplot = QtGui.QCheckBox(self.tabgraphSpectraHeis)
69 self.specHeisGraphCebRTIplot = QtGui.QCheckBox(self.tabgraphSpectraHeis)
70 self.specHeisGraphCebRTIplot.setText(_fromUtf8(""))
70 self.specHeisGraphCebRTIplot.setText(_fromUtf8(""))
71 self.specHeisGraphCebRTIplot.setObjectName(_fromUtf8("specHeisGraphCebRTIplot"))
71 self.specHeisGraphCebRTIplot.setObjectName(_fromUtf8("specHeisGraphCebRTIplot"))
72 self.gridLayout_20.addWidget(self.specHeisGraphCebRTIplot, 4, 2, 1, 1)
72 self.gridLayout_20.addWidget(self.specHeisGraphCebRTIplot, 4, 2, 1, 1)
73 self.label_62 = QtGui.QLabel(self.tabgraphSpectraHeis)
73 self.label_62 = QtGui.QLabel(self.tabgraphSpectraHeis)
74 self.label_62.setObjectName(_fromUtf8("label_62"))
74 self.label_62.setObjectName(_fromUtf8("label_62"))
75 self.gridLayout_20.addWidget(self.label_62, 7, 0, 1, 1)
75 self.gridLayout_20.addWidget(self.label_62, 7, 0, 1, 1)
76 self.label_63 = QtGui.QLabel(self.tabgraphSpectraHeis)
76 self.label_63 = QtGui.QLabel(self.tabgraphSpectraHeis)
77 self.label_63.setObjectName(_fromUtf8("label_63"))
77 self.label_63.setObjectName(_fromUtf8("label_63"))
78 self.gridLayout_20.addWidget(self.label_63, 8, 0, 1, 1)
78 self.gridLayout_20.addWidget(self.label_63, 8, 0, 1, 1)
79 self.label_64 = QtGui.QLabel(self.tabgraphSpectraHeis)
79 self.label_64 = QtGui.QLabel(self.tabgraphSpectraHeis)
80 self.label_64.setObjectName(_fromUtf8("label_64"))
80 self.label_64.setObjectName(_fromUtf8("label_64"))
81 self.gridLayout_20.addWidget(self.label_64, 9, 0, 1, 1)
81 self.gridLayout_20.addWidget(self.label_64, 9, 0, 1, 1)
82 self.label_65 = QtGui.QLabel(self.tabgraphSpectraHeis)
82 self.label_65 = QtGui.QLabel(self.tabgraphSpectraHeis)
83 self.label_65.setObjectName(_fromUtf8("label_65"))
83 self.label_65.setObjectName(_fromUtf8("label_65"))
84 self.gridLayout_20.addWidget(self.label_65, 10, 0, 1, 1)
84 self.gridLayout_20.addWidget(self.label_65, 10, 0, 1, 1)
85 spacerItem23 = QtGui.QSpacerItem(134, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
85 spacerItem23 = QtGui.QSpacerItem(134, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
86 self.gridLayout_20.addItem(spacerItem23, 11, 0, 1, 2)
86 self.gridLayout_20.addItem(spacerItem23, 11, 0, 1, 2)
87 self.specHeisGgraphftpratio = QtGui.QLineEdit(self.tabgraphSpectraHeis)
87 self.specHeisGgraphftpratio = QtGui.QLineEdit(self.tabgraphSpectraHeis)
88 self.specHeisGgraphftpratio.setObjectName(_fromUtf8("specHeisGgraphftpratio"))
88 self.specHeisGgraphftpratio.setObjectName(_fromUtf8("specHeisGgraphftpratio"))
89 self.gridLayout_20.addWidget(self.specHeisGgraphftpratio, 10, 1, 1, 6)
89 self.gridLayout_20.addWidget(self.specHeisGgraphftpratio, 10, 1, 1, 6)
90 self.specHeisGraphftpRTIplot = QtGui.QCheckBox(self.tabgraphSpectraHeis)
90 self.specHeisGraphftpRTIplot = QtGui.QCheckBox(self.tabgraphSpectraHeis)
91 self.specHeisGraphftpRTIplot.setText(_fromUtf8(""))
91 self.specHeisGraphftpRTIplot.setText(_fromUtf8(""))
92 self.specHeisGraphftpRTIplot.setObjectName(_fromUtf8("specHeisGraphftpRTIplot"))
92 self.specHeisGraphftpRTIplot.setObjectName(_fromUtf8("specHeisGraphftpRTIplot"))
93 self.gridLayout_20.addWidget(self.specHeisGraphftpRTIplot, 4, 6, 1, 1)
93 self.gridLayout_20.addWidget(self.specHeisGraphftpRTIplot, 4, 6, 1, 1)
94 self.specHeisGgraphTminTmax = QtGui.QLineEdit(self.tabgraphSpectraHeis)
94 self.specHeisGgraphTminTmax = QtGui.QLineEdit(self.tabgraphSpectraHeis)
95 self.specHeisGgraphTminTmax.setObjectName(_fromUtf8("specHeisGgraphTminTmax"))
95 self.specHeisGgraphTminTmax.setObjectName(_fromUtf8("specHeisGgraphTminTmax"))
96 self.gridLayout_20.addWidget(self.specHeisGgraphTminTmax, 8, 1, 1, 6)
96 self.gridLayout_20.addWidget(self.specHeisGgraphTminTmax, 8, 1, 1, 6)
97 self.label_60 = QtGui.QLabel(self.tabgraphSpectraHeis)
97 self.label_60 = QtGui.QLabel(self.tabgraphSpectraHeis)
98 self.label_60.setObjectName(_fromUtf8("label_60"))
98 self.label_60.setObjectName(_fromUtf8("label_60"))
99 self.gridLayout_20.addWidget(self.label_60, 5, 0, 1, 1)
99 self.gridLayout_20.addWidget(self.label_60, 5, 0, 1, 1)
100 self.label_61 = QtGui.QLabel(self.tabgraphSpectraHeis)
100 self.label_61 = QtGui.QLabel(self.tabgraphSpectraHeis)
101 self.label_61.setObjectName(_fromUtf8("label_61"))
101 self.label_61.setObjectName(_fromUtf8("label_61"))
102 self.gridLayout_20.addWidget(self.label_61, 6, 0, 1, 1)
102 self.gridLayout_20.addWidget(self.label_61, 6, 0, 1, 1)
103 self.specHeisGraphPrefix = QtGui.QLineEdit(self.tabgraphSpectraHeis)
103 self.specHeisGraphPrefix = QtGui.QLineEdit(self.tabgraphSpectraHeis)
104 self.specHeisGraphPrefix.setObjectName(_fromUtf8("specHeisGraphPrefix"))
104 self.specHeisGraphPrefix.setObjectName(_fromUtf8("specHeisGraphPrefix"))
105 self.gridLayout_20.addWidget(self.specHeisGraphPrefix, 1, 1, 1, 6)
105 self.gridLayout_20.addWidget(self.specHeisGraphPrefix, 1, 1, 1, 6)
106 self.label_56 = QtGui.QLabel(self.tabgraphSpectraHeis)
106 self.label_56 = QtGui.QLabel(self.tabgraphSpectraHeis)
107 self.label_56.setObjectName(_fromUtf8("label_56"))
107 self.label_56.setObjectName(_fromUtf8("label_56"))
108 self.gridLayout_20.addWidget(self.label_56, 2, 4, 1, 1)
108 self.gridLayout_20.addWidget(self.label_56, 2, 4, 1, 1)
109 self.label_57 = QtGui.QLabel(self.tabgraphSpectraHeis)
109 self.label_57 = QtGui.QLabel(self.tabgraphSpectraHeis)
110 self.label_57.setObjectName(_fromUtf8("label_57"))
110 self.label_57.setObjectName(_fromUtf8("label_57"))
111 self.gridLayout_20.addWidget(self.label_57, 2, 6, 1, 1)
111 self.gridLayout_20.addWidget(self.label_57, 2, 6, 1, 1)
112 self.label_58 = QtGui.QLabel(self.tabgraphSpectraHeis)
112 self.label_58 = QtGui.QLabel(self.tabgraphSpectraHeis)
113 self.label_58.setObjectName(_fromUtf8("label_58"))
113 self.label_58.setObjectName(_fromUtf8("label_58"))
114 self.gridLayout_20.addWidget(self.label_58, 3, 0, 1, 1)
114 self.gridLayout_20.addWidget(self.label_58, 3, 0, 1, 1)
115 self.specHeisGraphCebSpectraplot = QtGui.QCheckBox(self.tabgraphSpectraHeis)
115 self.specHeisGraphCebSpectraplot = QtGui.QCheckBox(self.tabgraphSpectraHeis)
116 self.specHeisGraphCebSpectraplot.setText(_fromUtf8(""))
116 self.specHeisGraphCebSpectraplot.setText(_fromUtf8(""))
117 self.specHeisGraphCebSpectraplot.setObjectName(_fromUtf8("specHeisGraphCebSpectraplot"))
117 self.specHeisGraphCebSpectraplot.setObjectName(_fromUtf8("specHeisGraphCebSpectraplot"))
118 self.gridLayout_20.addWidget(self.specHeisGraphCebSpectraplot, 3, 2, 1, 1)
118 self.gridLayout_20.addWidget(self.specHeisGraphCebSpectraplot, 3, 2, 1, 1)
119 self.specHeisGgraphYminYmax = QtGui.QLineEdit(self.tabgraphSpectraHeis)
119 self.specHeisGgraphYminYmax = QtGui.QLineEdit(self.tabgraphSpectraHeis)
120 self.specHeisGgraphYminYmax.setObjectName(_fromUtf8("specHeisGgraphYminYmax"))
120 self.specHeisGgraphYminYmax.setObjectName(_fromUtf8("specHeisGgraphYminYmax"))
121 self.gridLayout_20.addWidget(self.specHeisGgraphYminYmax, 7, 1, 1, 6)
121 self.gridLayout_20.addWidget(self.specHeisGgraphYminYmax, 7, 1, 1, 6)
122 self.label_53 = QtGui.QLabel(self.tabgraphSpectraHeis)
122 self.label_53 = QtGui.QLabel(self.tabgraphSpectraHeis)
123 self.label_53.setObjectName(_fromUtf8("label_53"))
123 self.label_53.setObjectName(_fromUtf8("label_53"))
124 self.gridLayout_20.addWidget(self.label_53, 0, 0, 1, 1)
124 self.gridLayout_20.addWidget(self.label_53, 0, 0, 1, 1)
125 self.label_55 = QtGui.QLabel(self.tabgraphSpectraHeis)
125 self.label_55 = QtGui.QLabel(self.tabgraphSpectraHeis)
126 self.label_55.setObjectName(_fromUtf8("label_55"))
126 self.label_55.setObjectName(_fromUtf8("label_55"))
127 self.gridLayout_20.addWidget(self.label_55, 2, 2, 1, 1)
127 self.gridLayout_20.addWidget(self.label_55, 2, 2, 1, 1)
128 self.specHeisGraphSaveRTIplot = QtGui.QCheckBox(self.tabgraphSpectraHeis)
128 self.specHeisGraphSaveRTIplot = QtGui.QCheckBox(self.tabgraphSpectraHeis)
129 self.specHeisGraphSaveRTIplot.setText(_fromUtf8(""))
129 self.specHeisGraphSaveRTIplot.setText(_fromUtf8(""))
130 self.specHeisGraphSaveRTIplot.setObjectName(_fromUtf8("specHeisGraphSaveRTIplot"))
130 self.specHeisGraphSaveRTIplot.setObjectName(_fromUtf8("specHeisGraphSaveRTIplot"))
131 self.gridLayout_20.addWidget(self.specHeisGraphSaveRTIplot, 4, 4, 1, 1)
131 self.gridLayout_20.addWidget(self.specHeisGraphSaveRTIplot, 4, 4, 1, 1)
132 spacerItem24 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
132 spacerItem24 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
133 self.gridLayout_20.addItem(spacerItem24, 2, 3, 1, 1)
133 self.gridLayout_20.addItem(spacerItem24, 2, 3, 1, 1)
134 self.specHeisGgraphXminXmax = QtGui.QLineEdit(self.tabgraphSpectraHeis)
134 self.specHeisGgraphXminXmax = QtGui.QLineEdit(self.tabgraphSpectraHeis)
135 self.specHeisGgraphXminXmax.setObjectName(_fromUtf8("specHeisGgraphXminXmax"))
135 self.specHeisGgraphXminXmax.setObjectName(_fromUtf8("specHeisGgraphXminXmax"))
136 self.gridLayout_20.addWidget(self.specHeisGgraphXminXmax, 6, 1, 1, 6)
136 self.gridLayout_20.addWidget(self.specHeisGgraphXminXmax, 6, 1, 1, 6)
137 self.specHeisGgraphChannelList = QtGui.QLineEdit(self.tabgraphSpectraHeis)
137 self.specHeisGgraphChannelList = QtGui.QLineEdit(self.tabgraphSpectraHeis)
138 self.specHeisGgraphChannelList.setObjectName(_fromUtf8("specHeisGgraphChannelList"))
138 self.specHeisGgraphChannelList.setObjectName(_fromUtf8("specHeisGgraphChannelList"))
139 self.gridLayout_20.addWidget(self.specHeisGgraphChannelList, 5, 1, 1, 6)
139 self.gridLayout_20.addWidget(self.specHeisGgraphChannelList, 5, 1, 1, 6)
140 self.specHeisGgraphTimeRange = QtGui.QLineEdit(self.tabgraphSpectraHeis)
140 self.specHeisGgraphTimeRange = QtGui.QLineEdit(self.tabgraphSpectraHeis)
141 self.specHeisGgraphTimeRange.setObjectName(_fromUtf8("specHeisGgraphTimeRange"))
141 self.specHeisGgraphTimeRange.setObjectName(_fromUtf8("specHeisGgraphTimeRange"))
142 self.gridLayout_20.addWidget(self.specHeisGgraphTimeRange, 9, 1, 1, 6)
142 self.gridLayout_20.addWidget(self.specHeisGgraphTimeRange, 9, 1, 1, 6)
143 spacerItem25 = QtGui.QSpacerItem(106, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
143 spacerItem25 = QtGui.QSpacerItem(106, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
144 self.gridLayout_20.addItem(spacerItem25, 11, 3, 1, 3)
144 self.gridLayout_20.addItem(spacerItem25, 11, 3, 1, 3)
145 self.specHeisGraphSaveSpectra = QtGui.QCheckBox(self.tabgraphSpectraHeis)
145 self.specHeisGraphSaveSpectra = QtGui.QCheckBox(self.tabgraphSpectraHeis)
146 self.specHeisGraphSaveSpectra.setText(_fromUtf8(""))
146 self.specHeisGraphSaveSpectra.setText(_fromUtf8(""))
147 self.specHeisGraphSaveSpectra.setObjectName(_fromUtf8("specHeisGraphSaveSpectra"))
147 self.specHeisGraphSaveSpectra.setObjectName(_fromUtf8("specHeisGraphSaveSpectra"))
148 self.gridLayout_20.addWidget(self.specHeisGraphSaveSpectra, 3, 4, 1, 1)
148 self.gridLayout_20.addWidget(self.specHeisGraphSaveSpectra, 3, 4, 1, 1)
149 self.specHeisGraphftpSpectra = QtGui.QCheckBox(self.tabgraphSpectraHeis)
149 self.specHeisGraphftpSpectra = QtGui.QCheckBox(self.tabgraphSpectraHeis)
150 self.specHeisGraphftpSpectra.setText(_fromUtf8(""))
150 self.specHeisGraphftpSpectra.setText(_fromUtf8(""))
151 self.specHeisGraphftpSpectra.setObjectName(_fromUtf8("specHeisGraphftpSpectra"))
151 self.specHeisGraphftpSpectra.setObjectName(_fromUtf8("specHeisGraphftpSpectra"))
152 self.gridLayout_20.addWidget(self.specHeisGraphftpSpectra, 3, 6, 1, 1)
152 self.gridLayout_20.addWidget(self.specHeisGraphftpSpectra, 3, 6, 1, 1)
153 self.label_59 = QtGui.QLabel(self.tabgraphSpectraHeis)
153 self.label_59 = QtGui.QLabel(self.tabgraphSpectraHeis)
154 self.label_59.setObjectName(_fromUtf8("label_59"))
154 self.label_59.setObjectName(_fromUtf8("label_59"))
155 self.gridLayout_20.addWidget(self.label_59, 4, 0, 1, 1)
155 self.gridLayout_20.addWidget(self.label_59, 4, 0, 1, 1)
156 spacerItem26 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
156 spacerItem26 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
157 self.gridLayout_20.addItem(spacerItem26, 2, 5, 1, 1)
157 self.gridLayout_20.addItem(spacerItem26, 2, 5, 1, 1)
158 self.specHeisGraphPath = QtGui.QLineEdit(self.tabgraphSpectraHeis)
158 self.specHeisGraphPath = QtGui.QLineEdit(self.tabgraphSpectraHeis)
159 self.specHeisGraphPath.setObjectName(_fromUtf8("specHeisGraphPath"))
159 self.specHeisGraphPath.setObjectName(_fromUtf8("specHeisGraphPath"))
160 self.gridLayout_20.addWidget(self.specHeisGraphPath, 0, 1, 1, 5)
160 self.gridLayout_20.addWidget(self.specHeisGraphPath, 0, 1, 1, 5)
161 self.tabWidgetSpectraHeis.addTab(self.tabgraphSpectraHeis, _fromUtf8(""))
161 self.tabWidgetSpectraHeis.addTab(self.tabgraphSpectraHeis, _fromUtf8(""))
162 self.taboutputSpectraHeis = QtGui.QWidget()
162 self.taboutputSpectraHeis = QtGui.QWidget()
163 self.taboutputSpectraHeis.setObjectName(_fromUtf8("taboutputSpectraHeis"))
163 self.taboutputSpectraHeis.setObjectName(_fromUtf8("taboutputSpectraHeis"))
164 self.gridLayout_19 = QtGui.QGridLayout(self.taboutputSpectraHeis)
164 self.gridLayout_19 = QtGui.QGridLayout(self.taboutputSpectraHeis)
165 self.gridLayout_19.setObjectName(_fromUtf8("gridLayout_19"))
165 self.gridLayout_19.setObjectName(_fromUtf8("gridLayout_19"))
166 self.label_67 = QtGui.QLabel(self.taboutputSpectraHeis)
166 self.label_67 = QtGui.QLabel(self.taboutputSpectraHeis)
167 self.label_67.setObjectName(_fromUtf8("label_67"))
167 self.label_67.setObjectName(_fromUtf8("label_67"))
168 self.gridLayout_19.addWidget(self.label_67, 1, 0, 1, 1)
168 self.gridLayout_19.addWidget(self.label_67, 1, 0, 1, 1)
169 self.label_68 = QtGui.QLabel(self.taboutputSpectraHeis)
169 self.label_68 = QtGui.QLabel(self.taboutputSpectraHeis)
170 self.label_68.setObjectName(_fromUtf8("label_68"))
170 self.label_68.setObjectName(_fromUtf8("label_68"))
171 self.gridLayout_19.addWidget(self.label_68, 2, 0, 1, 2)
171 self.gridLayout_19.addWidget(self.label_68, 2, 0, 1, 2)
172 self.label_66 = QtGui.QLabel(self.taboutputSpectraHeis)
172 self.label_66 = QtGui.QLabel(self.taboutputSpectraHeis)
173 self.label_66.setObjectName(_fromUtf8("label_66"))
173 self.label_66.setObjectName(_fromUtf8("label_66"))
174 self.gridLayout_19.addWidget(self.label_66, 0, 0, 1, 1)
174 self.gridLayout_19.addWidget(self.label_66, 0, 0, 1, 1)
175 spacerItem27 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
175 spacerItem27 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
176 self.gridLayout_19.addItem(spacerItem27, 4, 0, 1, 1)
176 self.gridLayout_19.addItem(spacerItem27, 4, 0, 1, 1)
177 self.specHeisOutputToolPath = QtGui.QToolButton(self.taboutputSpectraHeis)
177 self.specHeisOutputToolPath = QtGui.QToolButton(self.taboutputSpectraHeis)
178 self.specHeisOutputToolPath.setObjectName(_fromUtf8("specHeisOutputToolPath"))
178 self.specHeisOutputToolPath.setObjectName(_fromUtf8("specHeisOutputToolPath"))
179 self.gridLayout_19.addWidget(self.specHeisOutputToolPath, 1, 4, 1, 1)
179 self.gridLayout_19.addWidget(self.specHeisOutputToolPath, 1, 4, 1, 1)
180 self.specHeisOutputPath = QtGui.QLineEdit(self.taboutputSpectraHeis)
180 self.specHeisOutputPath = QtGui.QLineEdit(self.taboutputSpectraHeis)
181 self.specHeisOutputPath.setObjectName(_fromUtf8("specHeisOutputPath"))
181 self.specHeisOutputPath.setObjectName(_fromUtf8("specHeisOutputPath"))
182 self.gridLayout_19.addWidget(self.specHeisOutputPath, 1, 3, 1, 1)
182 self.gridLayout_19.addWidget(self.specHeisOutputPath, 1, 3, 1, 1)
183 self.specHeisOutputComdata = QtGui.QComboBox(self.taboutputSpectraHeis)
183 self.specHeisOutputComdata = QtGui.QComboBox(self.taboutputSpectraHeis)
184 self.specHeisOutputComdata.setObjectName(_fromUtf8("specHeisOutputComdata"))
184 self.specHeisOutputComdata.setObjectName(_fromUtf8("specHeisOutputComdata"))
185 self.specHeisOutputComdata.addItem(_fromUtf8(""))
185 self.specHeisOutputComdata.addItem(_fromUtf8(""))
186 self.gridLayout_19.addWidget(self.specHeisOutputComdata, 0, 3, 1, 2)
186 self.gridLayout_19.addWidget(self.specHeisOutputComdata, 0, 3, 1, 2)
187 self.label_69 = QtGui.QLabel(self.taboutputSpectraHeis)
187 self.label_69 = QtGui.QLabel(self.taboutputSpectraHeis)
188 self.label_69.setObjectName(_fromUtf8("label_69"))
188 self.label_69.setObjectName(_fromUtf8("label_69"))
189 self.gridLayout_19.addWidget(self.label_69, 3, 0, 1, 2)
189 self.gridLayout_19.addWidget(self.label_69, 3, 0, 1, 2)
190 self.specHeisOutputblocksperfile = QtGui.QLineEdit(self.taboutputSpectraHeis)
190 self.specHeisOutputblocksperfile = QtGui.QLineEdit(self.taboutputSpectraHeis)
191 self.specHeisOutputblocksperfile.setObjectName(_fromUtf8("specHeisOutputblocksperfile"))
191 self.specHeisOutputblocksperfile.setObjectName(_fromUtf8("specHeisOutputblocksperfile"))
192 self.gridLayout_19.addWidget(self.specHeisOutputblocksperfile, 2, 3, 1, 1)
192 self.gridLayout_19.addWidget(self.specHeisOutputblocksperfile, 2, 3, 1, 1)
193 self.specHeisOutputMetada = QtGui.QLineEdit(self.taboutputSpectraHeis)
193 self.specHeisOutputMetada = QtGui.QLineEdit(self.taboutputSpectraHeis)
194 self.specHeisOutputMetada.setObjectName(_fromUtf8("specHeisOutputMetada"))
194 self.specHeisOutputMetada.setObjectName(_fromUtf8("specHeisOutputMetada"))
195 self.gridLayout_19.addWidget(self.specHeisOutputMetada, 3, 3, 1, 1)
195 self.gridLayout_19.addWidget(self.specHeisOutputMetada, 3, 3, 1, 1)
196 self.specHeisOutputMetadaToolPath = QtGui.QToolButton(self.taboutputSpectraHeis)
196 self.specHeisOutputMetadaToolPath = QtGui.QToolButton(self.taboutputSpectraHeis)
197 self.specHeisOutputMetadaToolPath.setObjectName(_fromUtf8("specHeisOutputMetadaToolPath"))
197 self.specHeisOutputMetadaToolPath.setObjectName(_fromUtf8("specHeisOutputMetadaToolPath"))
198 self.gridLayout_19.addWidget(self.specHeisOutputMetadaToolPath, 3, 4, 1, 1)
198 self.gridLayout_19.addWidget(self.specHeisOutputMetadaToolPath, 3, 4, 1, 1)
199 self.tabWidgetSpectraHeis.addTab(self.taboutputSpectraHeis, _fromUtf8(""))
199 self.tabWidgetSpectraHeis.addTab(self.taboutputSpectraHeis, _fromUtf8(""))
200 self.gridLayout_23.addWidget(self.tabWidgetSpectraHeis, 0, 0, 1, 1)
200 self.gridLayout_23.addWidget(self.tabWidgetSpectraHeis, 0, 0, 1, 1)
201
201
202 self.tabWidgetProject.addTab(self.tabSpectraHeis, _fromUtf8(""))
202 self.tabWidgetProject.addTab(self.tabSpectraHeis, _fromUtf8(""))
203
203
204 self.tabWidgetSpectraHeis.setCurrentIndex(0)
204 self.tabWidgetSpectraHeis.setCurrentIndex(0)
205
205
206 def retranslateUi(self):
206 def retranslateUi(self):
207
207
208 self.specHeisGraphClear.setText(_translate("MainWindow", "Clear", None))
208 self.specHeisGraphClear.setText(_translate("MainWindow", "Clear", None))
209 self.specHeisOpOk.setText(_translate("MainWindow", "Ok", None))
209 self.specHeisOpOk.setText(_translate("MainWindow", "Ok", None))
210 self.specHeisOpCobIncInt.setItemText(0, _translate("MainWindow", "Time Interval", None))
210 self.specHeisOpCobIncInt.setItemText(0, _translate("MainWindow", "Time Interval", None))
211 self.specHeisOpCebIncoherent.setText(_translate("MainWindow", "Incoherent Intergration", None))
211 self.specHeisOpCebIncoherent.setText(_translate("MainWindow", "Incoherent Intergration", None))
212
212
213 self.tabWidgetSpectraHeis.setTabText(self.tabWidgetSpectraHeis.indexOf(self.tabopSpectraHeis), _translate("MainWindow", "Operation", None))
213 self.tabWidgetSpectraHeis.setTabText(self.tabWidgetSpectraHeis.indexOf(self.tabopSpectraHeis), _translate("MainWindow", "Operation", None))
214 self.label_54.setText(_translate("MainWindow", "Prefix", None))
214 self.label_54.setText(_translate("MainWindow", "Prefix", None))
215 self.specHeisGraphToolPath.setText(_translate("MainWindow", "...", None))
215 self.specHeisGraphToolPath.setText(_translate("MainWindow", "...", None))
216 self.label_62.setText(_translate("MainWindow", "Intensity range (dB)", None))
216 self.label_62.setText(_translate("MainWindow", "Intensity range (dB)", None))
217 self.label_63.setText(_translate("MainWindow", "Time range (hours):", None))
217 self.label_63.setText(_translate("MainWindow", "Time range (hours):", None))
218 self.label_64.setText(_translate("MainWindow", "Time interval:", None))
218 self.label_64.setText(_translate("MainWindow", "Time interval:", None))
219 self.label_65.setText(_translate("MainWindow", "Wr Period", None))
219 self.label_65.setText(_translate("MainWindow", "Wr Period", None))
220 self.label_60.setText(_translate("MainWindow", "Channel List:", None))
220 self.label_60.setText(_translate("MainWindow", "Channel List:", None))
221 self.label_61.setText(_translate("MainWindow", "Frequency range", None))
221 self.label_61.setText(_translate("MainWindow", "Frequency range", None))
222 self.label_56.setText(_translate("MainWindow", "Save", None))
222 self.label_56.setText(_translate("MainWindow", "Save", None))
223 self.label_57.setText(_translate("MainWindow", "ftp", None))
223 self.label_57.setText(_translate("MainWindow", "ftp", None))
224 self.label_58.setText(_translate("MainWindow", "Spectra Plot", None))
224 self.label_58.setText(_translate("MainWindow", "Spectra Plot", None))
225 self.label_53.setText(_translate("MainWindow", "Path", None))
225 self.label_53.setText(_translate("MainWindow", "Path", None))
226 self.label_55.setText(_translate("MainWindow", "Show", None))
226 self.label_55.setText(_translate("MainWindow", "Show", None))
227 self.label_59.setText(_translate("MainWindow", "RTI Plot", None))
227 self.label_59.setText(_translate("MainWindow", "RTI Plot", None))
228
228
229 self.tabWidgetSpectraHeis.setTabText(self.tabWidgetSpectraHeis.indexOf(self.tabgraphSpectraHeis), _translate("MainWindow", "Graphics", None))
229 self.tabWidgetSpectraHeis.setTabText(self.tabWidgetSpectraHeis.indexOf(self.tabgraphSpectraHeis), _translate("MainWindow", "Graphics", None))
230 self.label_67.setText(_translate("MainWindow", "Path:", None))
230 self.label_67.setText(_translate("MainWindow", "Path:", None))
231 self.label_68.setText(_translate("MainWindow", "Blocks per File:", None))
231 self.label_68.setText(_translate("MainWindow", "Blocks per file:", None))
232 self.label_66.setText(_translate("MainWindow", "Type:", None))
232 self.label_66.setText(_translate("MainWindow", "Type:", None))
233
233
234 self.tabWidgetSpectraHeis.setTabText(self.tabWidgetSpectraHeis.indexOf(self.taboutputSpectraHeis), _translate("MainWindow", "Output", None))
234 self.tabWidgetSpectraHeis.setTabText(self.tabWidgetSpectraHeis.indexOf(self.taboutputSpectraHeis), _translate("MainWindow", "Output", None))
235 self.specHeisOutputToolPath.setText(_translate("MainWindow", "...", None))
235 self.specHeisOutputToolPath.setText(_translate("MainWindow", "...", None))
236 self.specHeisOutputComdata.setItemText(0, _translate("MainWindow", ".fits", None))
236 self.specHeisOutputComdata.setItemText(0, _translate("MainWindow", ".fits", None))
237 self.label_69.setText(_translate("MainWindow", "Metada", None))
237 self.label_69.setText(_translate("MainWindow", "Metadata file:", None))
238 self.specHeisOutputMetadaToolPath.setText(_translate("MainWindow", "...", None))
238 self.specHeisOutputMetadaToolPath.setText(_translate("MainWindow", "...", None))
239
239
240 self.tabWidgetProject.setTabText(self.tabWidgetProject.indexOf(self.tabSpectraHeis), _translate("MainWindow", "SpectraHeis", None))
240 self.tabWidgetProject.setTabText(self.tabWidgetProject.indexOf(self.tabSpectraHeis), _translate("MainWindow", "SpectraHeis", None))
@@ -1,1132 +1,1128
1 '''
1 '''
2
2
3 $Author: murco $
3 $Author: murco $
4 $Id: JROData.py 173 2012-11-20 15:06:21Z murco $
4 $Id: JROData.py 173 2012-11-20 15:06:21Z murco $
5 '''
5 '''
6
6
7 import copy
7 import copy
8 import numpy
8 import numpy
9 import datetime
9 import datetime
10
10
11 from jroheaderIO import SystemHeader, RadarControllerHeader
11 from jroheaderIO import SystemHeader, RadarControllerHeader
12
12
13 def getNumpyDtype(dataTypeCode):
13 def getNumpyDtype(dataTypeCode):
14
14
15 if dataTypeCode == 0:
15 if dataTypeCode == 0:
16 numpyDtype = numpy.dtype([('real','<i1'),('imag','<i1')])
16 numpyDtype = numpy.dtype([('real','<i1'),('imag','<i1')])
17 elif dataTypeCode == 1:
17 elif dataTypeCode == 1:
18 numpyDtype = numpy.dtype([('real','<i2'),('imag','<i2')])
18 numpyDtype = numpy.dtype([('real','<i2'),('imag','<i2')])
19 elif dataTypeCode == 2:
19 elif dataTypeCode == 2:
20 numpyDtype = numpy.dtype([('real','<i4'),('imag','<i4')])
20 numpyDtype = numpy.dtype([('real','<i4'),('imag','<i4')])
21 elif dataTypeCode == 3:
21 elif dataTypeCode == 3:
22 numpyDtype = numpy.dtype([('real','<i8'),('imag','<i8')])
22 numpyDtype = numpy.dtype([('real','<i8'),('imag','<i8')])
23 elif dataTypeCode == 4:
23 elif dataTypeCode == 4:
24 numpyDtype = numpy.dtype([('real','<f4'),('imag','<f4')])
24 numpyDtype = numpy.dtype([('real','<f4'),('imag','<f4')])
25 elif dataTypeCode == 5:
25 elif dataTypeCode == 5:
26 numpyDtype = numpy.dtype([('real','<f8'),('imag','<f8')])
26 numpyDtype = numpy.dtype([('real','<f8'),('imag','<f8')])
27 else:
27 else:
28 raise ValueError, 'dataTypeCode was not defined'
28 raise ValueError, 'dataTypeCode was not defined'
29
29
30 return numpyDtype
30 return numpyDtype
31
31
32 def getDataTypeCode(numpyDtype):
32 def getDataTypeCode(numpyDtype):
33
33
34 if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]):
34 if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]):
35 datatype = 0
35 datatype = 0
36 elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]):
36 elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]):
37 datatype = 1
37 datatype = 1
38 elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]):
38 elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]):
39 datatype = 2
39 datatype = 2
40 elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]):
40 elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]):
41 datatype = 3
41 datatype = 3
42 elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]):
42 elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]):
43 datatype = 4
43 datatype = 4
44 elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]):
44 elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]):
45 datatype = 5
45 datatype = 5
46 else:
46 else:
47 datatype = None
47 datatype = None
48
48
49 return datatype
49 return datatype
50
50
51 def hildebrand_sekhon(data, navg):
51 def hildebrand_sekhon(data, navg):
52 """
52 """
53 This method is for the objective determination of the noise level in Doppler spectra. This
53 This method is for the objective determination of the noise level in Doppler spectra. This
54 implementation technique is based on the fact that the standard deviation of the spectral
54 implementation technique is based on the fact that the standard deviation of the spectral
55 densities is equal to the mean spectral density for white Gaussian noise
55 densities is equal to the mean spectral density for white Gaussian noise
56
56
57 Inputs:
57 Inputs:
58 Data : heights
58 Data : heights
59 navg : numbers of averages
59 navg : numbers of averages
60
60
61 Return:
61 Return:
62 -1 : any error
62 -1 : any error
63 anoise : noise's level
63 anoise : noise's level
64 """
64 """
65
65
66 sortdata = numpy.sort(data,axis=None)
66 sortdata = numpy.sort(data,axis=None)
67 lenOfData = len(sortdata)
67 lenOfData = len(sortdata)
68 nums_min = lenOfData/10
68 nums_min = lenOfData/10
69
69
70 if (lenOfData/10) > 2:
70 if (lenOfData/10) > 2:
71 nums_min = lenOfData/10
71 nums_min = lenOfData/10
72 else:
72 else:
73 nums_min = 2
73 nums_min = 2
74
74
75 sump = 0.
75 sump = 0.
76
76
77 sumq = 0.
77 sumq = 0.
78
78
79 j = 0
79 j = 0
80
80
81 cont = 1
81 cont = 1
82
82
83 while((cont==1)and(j<lenOfData)):
83 while((cont==1)and(j<lenOfData)):
84
84
85 sump += sortdata[j]
85 sump += sortdata[j]
86
86
87 sumq += sortdata[j]**2
87 sumq += sortdata[j]**2
88
88
89 if j > nums_min:
89 if j > nums_min:
90 rtest = float(j)/(j-1) + 1.0/navg
90 rtest = float(j)/(j-1) + 1.0/navg
91 if ((sumq*j) > (rtest*sump**2)):
91 if ((sumq*j) > (rtest*sump**2)):
92 j = j - 1
92 j = j - 1
93 sump = sump - sortdata[j]
93 sump = sump - sortdata[j]
94 sumq = sumq - sortdata[j]**2
94 sumq = sumq - sortdata[j]**2
95 cont = 0
95 cont = 0
96
96
97 j += 1
97 j += 1
98
98
99 lnoise = sump /j
99 lnoise = sump /j
100 stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1))
100 stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1))
101 return lnoise
101 return lnoise
102
102
103 class Beam:
103 class Beam:
104 def __init__(self):
104 def __init__(self):
105 self.codeList = []
105 self.codeList = []
106 self.azimuthList = []
106 self.azimuthList = []
107 self.zenithList = []
107 self.zenithList = []
108
108
109 class GenericData(object):
109 class GenericData(object):
110
110
111 flagNoData = True
111 flagNoData = True
112
112
113 def __init__(self):
113 def __init__(self):
114
114
115 raise ValueError, "This class has not been implemented"
115 raise ValueError, "This class has not been implemented"
116
116
117 def copy(self, inputObj=None):
117 def copy(self, inputObj=None):
118
118
119 if inputObj == None:
119 if inputObj == None:
120 return copy.deepcopy(self)
120 return copy.deepcopy(self)
121
121
122 for key in inputObj.__dict__.keys():
122 for key in inputObj.__dict__.keys():
123 self.__dict__[key] = inputObj.__dict__[key]
123 self.__dict__[key] = inputObj.__dict__[key]
124
124
125 def deepcopy(self):
125 def deepcopy(self):
126
126
127 return copy.deepcopy(self)
127 return copy.deepcopy(self)
128
128
129 def isEmpty(self):
129 def isEmpty(self):
130
130
131 return self.flagNoData
131 return self.flagNoData
132
132
133 class JROData(GenericData):
133 class JROData(GenericData):
134
134
135 # m_BasicHeader = BasicHeader()
135 # m_BasicHeader = BasicHeader()
136 # m_ProcessingHeader = ProcessingHeader()
136 # m_ProcessingHeader = ProcessingHeader()
137
137
138 systemHeaderObj = SystemHeader()
138 systemHeaderObj = SystemHeader()
139
139
140 radarControllerHeaderObj = RadarControllerHeader()
140 radarControllerHeaderObj = RadarControllerHeader()
141
141
142 # data = None
142 # data = None
143
143
144 type = None
144 type = None
145
145
146 datatype = None #dtype but in string
146 datatype = None #dtype but in string
147
147
148 # dtype = None
148 # dtype = None
149
149
150 # nChannels = None
150 # nChannels = None
151
151
152 # nHeights = None
152 # nHeights = None
153
153
154 nProfiles = None
154 nProfiles = None
155
155
156 heightList = None
156 heightList = None
157
157
158 channelList = None
158 channelList = None
159
159
160 flagDiscontinuousBlock = False
160 flagDiscontinuousBlock = False
161
161
162 useLocalTime = False
162 useLocalTime = False
163
163
164 utctime = None
164 utctime = None
165
165
166 timeZone = None
166 timeZone = None
167
167
168 dstFlag = None
168 dstFlag = None
169
169
170 errorCount = None
170 errorCount = None
171
171
172 blocksize = None
172 blocksize = None
173
173
174 # nCode = None
174 # nCode = None
175 #
175 #
176 # nBaud = None
176 # nBaud = None
177 #
177 #
178 # code = None
178 # code = None
179
179
180 flagDecodeData = False #asumo q la data no esta decodificada
180 flagDecodeData = False #asumo q la data no esta decodificada
181
181
182 flagDeflipData = False #asumo q la data no esta sin flip
182 flagDeflipData = False #asumo q la data no esta sin flip
183
183
184 flagShiftFFT = False
184 flagShiftFFT = False
185
185
186 # ippSeconds = None
186 # ippSeconds = None
187
187
188 # timeInterval = None
188 # timeInterval = None
189
189
190 nCohInt = None
190 nCohInt = None
191
191
192 # noise = None
192 # noise = None
193
193
194 windowOfFilter = 1
194 windowOfFilter = 1
195
195
196 #Speed of ligth
196 #Speed of ligth
197 C = 3e8
197 C = 3e8
198
198
199 frequency = 49.92e6
199 frequency = 49.92e6
200
200
201 realtime = False
201 realtime = False
202
202
203 beacon_heiIndexList = None
203 beacon_heiIndexList = None
204
204
205 last_block = None
205 last_block = None
206
206
207 blocknow = None
207 blocknow = None
208
208
209 azimuth = None
209 azimuth = None
210
210
211 zenith = None
211 zenith = None
212
212
213 beam = Beam()
213 beam = Beam()
214
214
215 profileIndex = None
215 profileIndex = None
216
216
217 def __init__(self):
217 def __init__(self):
218
218
219 raise ValueError, "This class has not been implemented"
219 raise ValueError, "This class has not been implemented"
220
220
221 def getNoise(self):
221 def getNoise(self):
222
222
223 raise ValueError, "Not implemented"
223 raise ValueError, "Not implemented"
224
224
225 def getNChannels(self):
225 def getNChannels(self):
226
226
227 return len(self.channelList)
227 return len(self.channelList)
228
228
229 def getChannelIndexList(self):
229 def getChannelIndexList(self):
230
230
231 return range(self.nChannels)
231 return range(self.nChannels)
232
232
233 def getNHeights(self):
233 def getNHeights(self):
234
234
235 return len(self.heightList)
235 return len(self.heightList)
236
236
237 def getHeiRange(self, extrapoints=0):
237 def getHeiRange(self, extrapoints=0):
238
238
239 heis = self.heightList
239 heis = self.heightList
240 # deltah = self.heightList[1] - self.heightList[0]
240 # deltah = self.heightList[1] - self.heightList[0]
241 #
241 #
242 # heis.append(self.heightList[-1])
242 # heis.append(self.heightList[-1])
243
243
244 return heis
244 return heis
245
245
246 def getltctime(self):
246 def getltctime(self):
247
247
248 if self.useLocalTime:
248 if self.useLocalTime:
249 return self.utctime - self.timeZone*60
249 return self.utctime - self.timeZone*60
250
250
251 return self.utctime
251 return self.utctime
252
252
253 def getDatatime(self):
253 def getDatatime(self):
254
254
255 datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime)
255 datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime)
256 return datatimeValue
256 return datatimeValue
257
257
258 def getTimeRange(self):
258 def getTimeRange(self):
259
259
260 datatime = []
260 datatime = []
261
261
262 datatime.append(self.ltctime)
262 datatime.append(self.ltctime)
263 datatime.append(self.ltctime + self.timeInterval+60)
263 datatime.append(self.ltctime + self.timeInterval+60)
264
264
265 datatime = numpy.array(datatime)
265 datatime = numpy.array(datatime)
266
266
267 return datatime
267 return datatime
268
268
269 def getFmax(self):
269 def getFmax(self):
270
270
271 PRF = 1./(self.ippSeconds * self.nCohInt)
271 PRF = 1./(self.ippSeconds * self.nCohInt)
272
272
273 fmax = PRF/2.
273 fmax = PRF/2.
274
274
275 return fmax
275 return fmax
276
276
277 def getVmax(self):
277 def getVmax(self):
278
278
279 _lambda = self.C/self.frequency
279 _lambda = self.C/self.frequency
280
280
281 vmax = self.getFmax() * _lambda
281 vmax = self.getFmax() * _lambda
282
282
283 return vmax
283 return vmax
284
284
285 def get_ippSeconds(self):
285 def get_ippSeconds(self):
286 '''
286 '''
287 '''
287 '''
288 return self.radarControllerHeaderObj.ippSeconds
288 return self.radarControllerHeaderObj.ippSeconds
289
289
290 def set_ippSeconds(self, ippSeconds):
290 def set_ippSeconds(self, ippSeconds):
291 '''
291 '''
292 '''
292 '''
293
293
294 self.radarControllerHeaderObj.ippSeconds = ippSeconds
294 self.radarControllerHeaderObj.ippSeconds = ippSeconds
295
295
296 return
296 return
297
297
298 def get_dtype(self):
298 def get_dtype(self):
299 '''
299 '''
300 '''
300 '''
301 return getNumpyDtype(self.datatype)
301 return getNumpyDtype(self.datatype)
302
302
303 def set_dtype(self, numpyDtype):
303 def set_dtype(self, numpyDtype):
304 '''
304 '''
305 '''
305 '''
306
306
307 self.datatype = getDataTypeCode(numpyDtype)
307 self.datatype = getDataTypeCode(numpyDtype)
308
308
309 def get_code(self):
309 def get_code(self):
310 '''
310 '''
311 '''
311 '''
312 return self.radarControllerHeaderObj.code
312 return self.radarControllerHeaderObj.code
313
313
314 def set_code(self, code):
314 def set_code(self, code):
315 '''
315 '''
316 '''
316 '''
317 self.radarControllerHeaderObj.code = code
317 self.radarControllerHeaderObj.code = code
318
318
319 return
319 return
320
320
321 def get_ncode(self):
321 def get_ncode(self):
322 '''
322 '''
323 '''
323 '''
324 return self.radarControllerHeaderObj.nCode
324 return self.radarControllerHeaderObj.nCode
325
325
326 def set_ncode(self, nCode):
326 def set_ncode(self, nCode):
327 '''
327 '''
328 '''
328 '''
329 self.radarControllerHeaderObj.nCode = nCode
329 self.radarControllerHeaderObj.nCode = nCode
330
330
331 return
331 return
332
332
333 def get_nbaud(self):
333 def get_nbaud(self):
334 '''
334 '''
335 '''
335 '''
336 return self.radarControllerHeaderObj.nBaud
336 return self.radarControllerHeaderObj.nBaud
337
337
338 def set_nbaud(self, nBaud):
338 def set_nbaud(self, nBaud):
339 '''
339 '''
340 '''
340 '''
341 self.radarControllerHeaderObj.nBaud = nBaud
341 self.radarControllerHeaderObj.nBaud = nBaud
342
342
343 return
343 return
344 # def getTimeInterval(self):
344 # def getTimeInterval(self):
345 #
345 #
346 # raise IOError, "This method should be implemented inside each Class"
346 # raise IOError, "This method should be implemented inside each Class"
347
347
348 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
348 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
349 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
349 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
350 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
350 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
351 #noise = property(getNoise, "I'm the 'nHeights' property.")
351 #noise = property(getNoise, "I'm the 'nHeights' property.")
352 datatime = property(getDatatime, "I'm the 'datatime' property")
352 datatime = property(getDatatime, "I'm the 'datatime' property")
353 ltctime = property(getltctime, "I'm the 'ltctime' property")
353 ltctime = property(getltctime, "I'm the 'ltctime' property")
354 ippSeconds = property(get_ippSeconds, set_ippSeconds)
354 ippSeconds = property(get_ippSeconds, set_ippSeconds)
355 dtype = property(get_dtype, set_dtype)
355 dtype = property(get_dtype, set_dtype)
356 # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
356 # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
357 code = property(get_code, set_code)
357 code = property(get_code, set_code)
358 nCode = property(get_ncode, set_ncode)
358 nCode = property(get_ncode, set_ncode)
359 nBaud = property(get_nbaud, set_nbaud)
359 nBaud = property(get_nbaud, set_nbaud)
360
360
361 class Voltage(JROData):
361 class Voltage(JROData):
362
362
363 #data es un numpy array de 2 dmensiones (canales, alturas)
363 #data es un numpy array de 2 dmensiones (canales, alturas)
364 data = None
364 data = None
365
365
366 def __init__(self):
366 def __init__(self):
367 '''
367 '''
368 Constructor
368 Constructor
369 '''
369 '''
370
370
371 self.useLocalTime = True
371 self.useLocalTime = True
372
372
373 self.radarControllerHeaderObj = RadarControllerHeader()
373 self.radarControllerHeaderObj = RadarControllerHeader()
374
374
375 self.systemHeaderObj = SystemHeader()
375 self.systemHeaderObj = SystemHeader()
376
376
377 self.type = "Voltage"
377 self.type = "Voltage"
378
378
379 self.data = None
379 self.data = None
380
380
381 # self.dtype = None
381 # self.dtype = None
382
382
383 # self.nChannels = 0
383 # self.nChannels = 0
384
384
385 # self.nHeights = 0
385 # self.nHeights = 0
386
386
387 self.nProfiles = None
387 self.nProfiles = None
388
388
389 self.heightList = None
389 self.heightList = None
390
390
391 self.channelList = None
391 self.channelList = None
392
392
393 # self.channelIndexList = None
393 # self.channelIndexList = None
394
394
395 self.flagNoData = True
395 self.flagNoData = True
396
396
397 self.flagDiscontinuousBlock = False
397 self.flagDiscontinuousBlock = False
398
398
399 self.utctime = None
399 self.utctime = None
400
400
401 self.timeZone = None
401 self.timeZone = None
402
402
403 self.dstFlag = None
403 self.dstFlag = None
404
404
405 self.errorCount = None
405 self.errorCount = None
406
406
407 self.nCohInt = None
407 self.nCohInt = None
408
408
409 self.blocksize = None
409 self.blocksize = None
410
410
411 self.flagDecodeData = False #asumo q la data no esta decodificada
411 self.flagDecodeData = False #asumo q la data no esta decodificada
412
412
413 self.flagDeflipData = False #asumo q la data no esta sin flip
413 self.flagDeflipData = False #asumo q la data no esta sin flip
414
414
415 self.flagShiftFFT = False
415 self.flagShiftFFT = False
416
416
417 self.flagDataAsBlock = False #Asumo que la data es leida perfil a perfil
417 self.flagDataAsBlock = False #Asumo que la data es leida perfil a perfil
418
418
419 self.profileIndex = 0
419 self.profileIndex = 0
420
420
421 def getNoisebyHildebrand(self, channel = None):
421 def getNoisebyHildebrand(self, channel = None):
422 """
422 """
423 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
423 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
424
424
425 Return:
425 Return:
426 noiselevel
426 noiselevel
427 """
427 """
428
428
429 if channel != None:
429 if channel != None:
430 data = self.data[channel]
430 data = self.data[channel]
431 nChannels = 1
431 nChannels = 1
432 else:
432 else:
433 data = self.data
433 data = self.data
434 nChannels = self.nChannels
434 nChannels = self.nChannels
435
435
436 noise = numpy.zeros(nChannels)
436 noise = numpy.zeros(nChannels)
437 power = data * numpy.conjugate(data)
437 power = data * numpy.conjugate(data)
438
438
439 for thisChannel in range(nChannels):
439 for thisChannel in range(nChannels):
440 if nChannels == 1:
440 if nChannels == 1:
441 daux = power[:].real
441 daux = power[:].real
442 else:
442 else:
443 daux = power[thisChannel,:].real
443 daux = power[thisChannel,:].real
444 noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt)
444 noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt)
445
445
446 return noise
446 return noise
447
447
448 def getNoise(self, type = 1, channel = None):
448 def getNoise(self, type = 1, channel = None):
449
449
450 if type == 1:
450 if type == 1:
451 noise = self.getNoisebyHildebrand(channel)
451 noise = self.getNoisebyHildebrand(channel)
452
452
453 return 10*numpy.log10(noise)
453 return 10*numpy.log10(noise)
454
454
455 def getPower(self, channel = None):
455 def getPower(self, channel = None):
456
456
457 if channel != None:
457 if channel != None:
458 data = self.data[channel]
458 data = self.data[channel]
459 else:
459 else:
460 data = self.data
460 data = self.data
461
461
462 power = data * numpy.conjugate(data)
462 power = data * numpy.conjugate(data)
463
463
464 return 10*numpy.log10(power.real)
464 return 10*numpy.log10(power.real)
465
465
466 def getTimeInterval(self):
466 def getTimeInterval(self):
467
467
468 timeInterval = self.ippSeconds * self.nCohInt
468 timeInterval = self.ippSeconds * self.nCohInt
469
469
470 return timeInterval
470 return timeInterval
471
471
472 noise = property(getNoise, "I'm the 'nHeights' property.")
472 noise = property(getNoise, "I'm the 'nHeights' property.")
473 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
473 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
474
474
475 class Spectra(JROData):
475 class Spectra(JROData):
476
476
477 #data es un numpy array de 2 dmensiones (canales, perfiles, alturas)
477 #data es un numpy array de 2 dmensiones (canales, perfiles, alturas)
478 data_spc = None
478 data_spc = None
479
479
480 #data es un numpy array de 2 dmensiones (canales, pares, alturas)
480 #data es un numpy array de 2 dmensiones (canales, pares, alturas)
481 data_cspc = None
481 data_cspc = None
482
482
483 #data es un numpy array de 2 dmensiones (canales, alturas)
483 #data es un numpy array de 2 dmensiones (canales, alturas)
484 data_dc = None
484 data_dc = None
485
485
486 nFFTPoints = None
486 nFFTPoints = None
487
487
488 # nPairs = None
488 # nPairs = None
489
489
490 pairsList = None
490 pairsList = None
491
491
492 nIncohInt = None
492 nIncohInt = None
493
493
494 wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia
494 wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia
495
495
496 nCohInt = None #se requiere para determinar el valor de timeInterval
496 nCohInt = None #se requiere para determinar el valor de timeInterval
497
497
498 ippFactor = None
498 ippFactor = None
499
499
500 profileIndex = 0
500 profileIndex = 0
501
501
502 def __init__(self):
502 def __init__(self):
503 '''
503 '''
504 Constructor
504 Constructor
505 '''
505 '''
506
506
507 self.useLocalTime = True
507 self.useLocalTime = True
508
508
509 self.radarControllerHeaderObj = RadarControllerHeader()
509 self.radarControllerHeaderObj = RadarControllerHeader()
510
510
511 self.systemHeaderObj = SystemHeader()
511 self.systemHeaderObj = SystemHeader()
512
512
513 self.type = "Spectra"
513 self.type = "Spectra"
514
514
515 # self.data = None
515 # self.data = None
516
516
517 # self.dtype = None
517 # self.dtype = None
518
518
519 # self.nChannels = 0
519 # self.nChannels = 0
520
520
521 # self.nHeights = 0
521 # self.nHeights = 0
522
522
523 self.nProfiles = None
523 self.nProfiles = None
524
524
525 self.heightList = None
525 self.heightList = None
526
526
527 self.channelList = None
527 self.channelList = None
528
528
529 # self.channelIndexList = None
529 # self.channelIndexList = None
530
530
531 self.pairsList = None
531 self.pairsList = None
532
532
533 self.flagNoData = True
533 self.flagNoData = True
534
534
535 self.flagDiscontinuousBlock = False
535 self.flagDiscontinuousBlock = False
536
536
537 self.utctime = None
537 self.utctime = None
538
538
539 self.nCohInt = None
539 self.nCohInt = None
540
540
541 self.nIncohInt = None
541 self.nIncohInt = None
542
542
543 self.blocksize = None
543 self.blocksize = None
544
544
545 self.nFFTPoints = None
545 self.nFFTPoints = None
546
546
547 self.wavelength = None
547 self.wavelength = None
548
548
549 self.flagDecodeData = False #asumo q la data no esta decodificada
549 self.flagDecodeData = False #asumo q la data no esta decodificada
550
550
551 self.flagDeflipData = False #asumo q la data no esta sin flip
551 self.flagDeflipData = False #asumo q la data no esta sin flip
552
552
553 self.flagShiftFFT = False
553 self.flagShiftFFT = False
554
554
555 self.ippFactor = 1
555 self.ippFactor = 1
556
556
557 #self.noise = None
557 #self.noise = None
558
558
559 self.beacon_heiIndexList = []
559 self.beacon_heiIndexList = []
560
560
561 self.noise_estimation = None
561 self.noise_estimation = None
562
562
563
563
564 def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
564 def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
565 """
565 """
566 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
566 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
567
567
568 Return:
568 Return:
569 noiselevel
569 noiselevel
570 """
570 """
571
571
572 noise = numpy.zeros(self.nChannels)
572 noise = numpy.zeros(self.nChannels)
573
573
574 for channel in range(self.nChannels):
574 for channel in range(self.nChannels):
575 daux = self.data_spc[channel,xmin_index:xmax_index,ymin_index:ymax_index]
575 daux = self.data_spc[channel,xmin_index:xmax_index,ymin_index:ymax_index]
576 noise[channel] = hildebrand_sekhon(daux, self.nIncohInt)
576 noise[channel] = hildebrand_sekhon(daux, self.nIncohInt)
577
577
578 return noise
578 return noise
579
579
580 def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
580 def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
581
581
582 if self.noise_estimation != None:
582 if self.noise_estimation != None:
583 return self.noise_estimation #this was estimated by getNoise Operation defined in jroproc_spectra.py
583 return self.noise_estimation #this was estimated by getNoise Operation defined in jroproc_spectra.py
584 else:
584 else:
585 noise = self.getNoisebyHildebrand(xmin_index, xmax_index, ymin_index, ymax_index)
585 noise = self.getNoisebyHildebrand(xmin_index, xmax_index, ymin_index, ymax_index)
586 return noise
586 return noise
587
587
588
588
589 def getFreqRange(self, extrapoints=0):
589 def getFreqRange(self, extrapoints=0):
590
590
591 deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor)
591 deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor)
592 freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
592 freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
593
593
594 return freqrange
594 return freqrange
595
595
596 def getVelRange(self, extrapoints=0):
596 def getVelRange(self, extrapoints=0):
597
597
598 deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor)
598 deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor)
599 velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2
599 velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2
600
600
601 return velrange
601 return velrange
602
602
603 def getNPairs(self):
603 def getNPairs(self):
604
604
605 return len(self.pairsList)
605 return len(self.pairsList)
606
606
607 def getPairsIndexList(self):
607 def getPairsIndexList(self):
608
608
609 return range(self.nPairs)
609 return range(self.nPairs)
610
610
611 def getNormFactor(self):
611 def getNormFactor(self):
612
612
613 pwcode = 1
613 pwcode = 1
614
614
615 if self.flagDecodeData:
615 if self.flagDecodeData:
616 pwcode = numpy.sum(self.code[0]**2)
616 pwcode = numpy.sum(self.code[0]**2)
617 #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter
617 #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter
618 normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter
618 normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter
619
619
620 return normFactor
620 return normFactor
621
621
622 def getFlagCspc(self):
622 def getFlagCspc(self):
623
623
624 if self.data_cspc is None:
624 if self.data_cspc is None:
625 return True
625 return True
626
626
627 return False
627 return False
628
628
629 def getFlagDc(self):
629 def getFlagDc(self):
630
630
631 if self.data_dc is None:
631 if self.data_dc is None:
632 return True
632 return True
633
633
634 return False
634 return False
635
635
636 def getTimeInterval(self):
636 def getTimeInterval(self):
637
637
638 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles
638 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles
639
639
640 return timeInterval
640 return timeInterval
641
641
642 def setValue(self, value):
642 def setValue(self, value):
643
643
644 print "This property should not be initialized"
644 print "This property should not be initialized"
645
645
646 return
646 return
647
647
648 nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.")
648 nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.")
649 pairsIndexList = property(getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.")
649 pairsIndexList = property(getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.")
650 normFactor = property(getNormFactor, setValue, "I'm the 'getNormFactor' property.")
650 normFactor = property(getNormFactor, setValue, "I'm the 'getNormFactor' property.")
651 flag_cspc = property(getFlagCspc, setValue)
651 flag_cspc = property(getFlagCspc, setValue)
652 flag_dc = property(getFlagDc, setValue)
652 flag_dc = property(getFlagDc, setValue)
653 noise = property(getNoise, setValue, "I'm the 'nHeights' property.")
653 noise = property(getNoise, setValue, "I'm the 'nHeights' property.")
654 timeInterval = property(getTimeInterval, setValue, "I'm the 'timeInterval' property")
654 timeInterval = property(getTimeInterval, setValue, "I'm the 'timeInterval' property")
655
655
656 class SpectraHeis(Spectra):
656 class SpectraHeis(Spectra):
657
657
658 data_spc = None
658 data_spc = None
659
659
660 data_cspc = None
660 data_cspc = None
661
661
662 data_dc = None
662 data_dc = None
663
663
664 nFFTPoints = None
664 nFFTPoints = None
665
665
666 # nPairs = None
666 # nPairs = None
667
667
668 pairsList = None
668 pairsList = None
669
669
670 nCohInt = None
670 nCohInt = None
671
671
672 nIncohInt = None
672 nIncohInt = None
673
673
674 def __init__(self):
674 def __init__(self):
675
675
676 self.radarControllerHeaderObj = RadarControllerHeader()
676 self.radarControllerHeaderObj = RadarControllerHeader()
677
677
678 self.systemHeaderObj = SystemHeader()
678 self.systemHeaderObj = SystemHeader()
679
679
680 self.type = "SpectraHeis"
680 self.type = "SpectraHeis"
681
681
682 # self.dtype = None
682 # self.dtype = None
683
683
684 # self.nChannels = 0
684 # self.nChannels = 0
685
685
686 # self.nHeights = 0
686 # self.nHeights = 0
687
687
688 self.nProfiles = None
688 self.nProfiles = None
689
689
690 self.heightList = None
690 self.heightList = None
691
691
692 self.channelList = None
692 self.channelList = None
693
693
694 # self.channelIndexList = None
694 # self.channelIndexList = None
695
695
696 self.flagNoData = True
696 self.flagNoData = True
697
697
698 self.flagDiscontinuousBlock = False
698 self.flagDiscontinuousBlock = False
699
699
700 # self.nPairs = 0
700 # self.nPairs = 0
701
701
702 self.utctime = None
702 self.utctime = None
703
703
704 self.blocksize = None
704 self.blocksize = None
705
705
706 self.profileIndex = 0
706 self.profileIndex = 0
707
707
708 self.nCohInt = 1
708 self.nCohInt = 1
709
709
710 self.nIncohInt = 1
710 self.nIncohInt = 1
711
711
712 def getNormFactor(self):
712 def getNormFactor(self):
713 pwcode = 1
713 pwcode = 1
714 if self.flagDecodeData:
714 if self.flagDecodeData:
715 pwcode = numpy.sum(self.code[0]**2)
715 pwcode = numpy.sum(self.code[0]**2)
716
716
717 normFactor = self.nIncohInt*self.nCohInt*pwcode
717 normFactor = self.nIncohInt*self.nCohInt*pwcode
718
718
719 return normFactor
719 return normFactor
720
720
721 def getTimeInterval(self):
721 def getTimeInterval(self):
722
722
723 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
723 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
724
724
725 return timeInterval
725 return timeInterval
726
726
727 normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.")
727 normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.")
728 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
728 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
729
729
730 class Fits(JROData):
730 class Fits(JROData):
731
731
732 heightList = None
732 heightList = None
733
733
734 channelList = None
734 channelList = None
735
735
736 flagNoData = True
736 flagNoData = True
737
737
738 flagDiscontinuousBlock = False
738 flagDiscontinuousBlock = False
739
739
740 useLocalTime = False
740 useLocalTime = False
741
741
742 utctime = None
742 utctime = None
743
743
744 timeZone = None
744 timeZone = None
745
745
746 # ippSeconds = None
746 # ippSeconds = None
747
747
748 # timeInterval = None
748 # timeInterval = None
749
749
750 nCohInt = None
750 nCohInt = None
751
751
752 nIncohInt = None
752 nIncohInt = None
753
753
754 noise = None
754 noise = None
755
755
756 windowOfFilter = 1
756 windowOfFilter = 1
757
757
758 #Speed of ligth
758 #Speed of ligth
759 C = 3e8
759 C = 3e8
760
760
761 frequency = 49.92e6
761 frequency = 49.92e6
762
762
763 realtime = False
763 realtime = False
764
764
765
765
766 def __init__(self):
766 def __init__(self):
767
767
768 self.type = "Fits"
768 self.type = "Fits"
769
769
770 self.nProfiles = None
770 self.nProfiles = None
771
771
772 self.heightList = None
772 self.heightList = None
773
773
774 self.channelList = None
774 self.channelList = None
775
775
776 # self.channelIndexList = None
776 # self.channelIndexList = None
777
777
778 self.flagNoData = True
778 self.flagNoData = True
779
779
780 self.utctime = None
780 self.utctime = None
781
781
782 self.nCohInt = 1
782 self.nCohInt = 1
783
783
784 self.nIncohInt = 1
784 self.nIncohInt = 1
785
785
786 self.useLocalTime = True
786 self.useLocalTime = True
787
787
788 self.profileIndex = 0
788 self.profileIndex = 0
789
789
790 # self.utctime = None
790 # self.utctime = None
791 # self.timeZone = None
791 # self.timeZone = None
792 # self.ltctime = None
792 # self.ltctime = None
793 # self.timeInterval = None
793 # self.timeInterval = None
794 # self.header = None
794 # self.header = None
795 # self.data_header = None
795 # self.data_header = None
796 # self.data = None
796 # self.data = None
797 # self.datatime = None
797 # self.datatime = None
798 # self.flagNoData = False
798 # self.flagNoData = False
799 # self.expName = ''
799 # self.expName = ''
800 # self.nChannels = None
800 # self.nChannels = None
801 # self.nSamples = None
801 # self.nSamples = None
802 # self.dataBlocksPerFile = None
802 # self.dataBlocksPerFile = None
803 # self.comments = ''
803 # self.comments = ''
804 #
804 #
805
805
806
806
807 def getltctime(self):
807 def getltctime(self):
808
808
809 if self.useLocalTime:
809 if self.useLocalTime:
810 return self.utctime - self.timeZone*60
810 return self.utctime - self.timeZone*60
811
811
812 return self.utctime
812 return self.utctime
813
813
814 def getDatatime(self):
814 def getDatatime(self):
815
815
816 datatime = datetime.datetime.utcfromtimestamp(self.ltctime)
816 datatime = datetime.datetime.utcfromtimestamp(self.ltctime)
817 return datatime
817 return datatime
818
818
819 def getTimeRange(self):
819 def getTimeRange(self):
820
820
821 datatime = []
821 datatime = []
822
822
823 datatime.append(self.ltctime)
823 datatime.append(self.ltctime)
824 datatime.append(self.ltctime + self.timeInterval)
824 datatime.append(self.ltctime + self.timeInterval)
825
825
826 datatime = numpy.array(datatime)
826 datatime = numpy.array(datatime)
827
827
828 return datatime
828 return datatime
829
829
830 def getHeiRange(self):
830 def getHeiRange(self):
831
831
832 heis = self.heightList
832 heis = self.heightList
833
833
834 return heis
834 return heis
835
835
836 def isEmpty(self):
837
838 return self.flagNoData
839
840 def getNHeights(self):
836 def getNHeights(self):
841
837
842 return len(self.heightList)
838 return len(self.heightList)
843
839
844 def getNChannels(self):
840 def getNChannels(self):
845
841
846 return len(self.channelList)
842 return len(self.channelList)
847
843
848 def getChannelIndexList(self):
844 def getChannelIndexList(self):
849
845
850 return range(self.nChannels)
846 return range(self.nChannels)
851
847
852 def getNoise(self, type = 1):
848 def getNoise(self, type = 1):
853
849
854 #noise = numpy.zeros(self.nChannels)
850 #noise = numpy.zeros(self.nChannels)
855
851
856 if type == 1:
852 if type == 1:
857 noise = self.getNoisebyHildebrand()
853 noise = self.getNoisebyHildebrand()
858
854
859 if type == 2:
855 if type == 2:
860 noise = self.getNoisebySort()
856 noise = self.getNoisebySort()
861
857
862 if type == 3:
858 if type == 3:
863 noise = self.getNoisebyWindow()
859 noise = self.getNoisebyWindow()
864
860
865 return noise
861 return noise
866
862
867 def getTimeInterval(self):
863 def getTimeInterval(self):
868
864
869 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
865 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
870
866
871 return timeInterval
867 return timeInterval
872
868
873 datatime = property(getDatatime, "I'm the 'datatime' property")
869 datatime = property(getDatatime, "I'm the 'datatime' property")
874 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
870 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
875 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
871 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
876 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
872 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
877 noise = property(getNoise, "I'm the 'nHeights' property.")
873 noise = property(getNoise, "I'm the 'nHeights' property.")
878
874
879 ltctime = property(getltctime, "I'm the 'ltctime' property")
875 ltctime = property(getltctime, "I'm the 'ltctime' property")
880 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
876 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
881
877
882 class Correlation(JROData):
878 class Correlation(JROData):
883
879
884 noise = None
880 noise = None
885
881
886 SNR = None
882 SNR = None
887
883
888 pairsAutoCorr = None #Pairs of Autocorrelation
884 pairsAutoCorr = None #Pairs of Autocorrelation
889
885
890 #--------------------------------------------------
886 #--------------------------------------------------
891
887
892 data_corr = None
888 data_corr = None
893
889
894 data_volt = None
890 data_volt = None
895
891
896 lagT = None # each element value is a profileIndex
892 lagT = None # each element value is a profileIndex
897
893
898 lagR = None # each element value is in km
894 lagR = None # each element value is in km
899
895
900 pairsList = None
896 pairsList = None
901
897
902 calculateVelocity = None
898 calculateVelocity = None
903
899
904 nPoints = None
900 nPoints = None
905
901
906 nAvg = None
902 nAvg = None
907
903
908 bufferSize = None
904 bufferSize = None
909
905
910 def __init__(self):
906 def __init__(self):
911 '''
907 '''
912 Constructor
908 Constructor
913 '''
909 '''
914 self.radarControllerHeaderObj = RadarControllerHeader()
910 self.radarControllerHeaderObj = RadarControllerHeader()
915
911
916 self.systemHeaderObj = SystemHeader()
912 self.systemHeaderObj = SystemHeader()
917
913
918 self.type = "Correlation"
914 self.type = "Correlation"
919
915
920 self.data = None
916 self.data = None
921
917
922 self.dtype = None
918 self.dtype = None
923
919
924 self.nProfiles = None
920 self.nProfiles = None
925
921
926 self.heightList = None
922 self.heightList = None
927
923
928 self.channelList = None
924 self.channelList = None
929
925
930 self.flagNoData = True
926 self.flagNoData = True
931
927
932 self.flagDiscontinuousBlock = False
928 self.flagDiscontinuousBlock = False
933
929
934 self.utctime = None
930 self.utctime = None
935
931
936 self.timeZone = None
932 self.timeZone = None
937
933
938 self.dstFlag = None
934 self.dstFlag = None
939
935
940 self.errorCount = None
936 self.errorCount = None
941
937
942 self.blocksize = None
938 self.blocksize = None
943
939
944 self.flagDecodeData = False #asumo q la data no esta decodificada
940 self.flagDecodeData = False #asumo q la data no esta decodificada
945
941
946 self.flagDeflipData = False #asumo q la data no esta sin flip
942 self.flagDeflipData = False #asumo q la data no esta sin flip
947
943
948 self.pairsList = None
944 self.pairsList = None
949
945
950 self.nPoints = None
946 self.nPoints = None
951
947
952 def getLagTRange(self, extrapoints=0):
948 def getLagTRange(self, extrapoints=0):
953
949
954 lagTRange = self.lagT
950 lagTRange = self.lagT
955 diff = lagTRange[1] - lagTRange[0]
951 diff = lagTRange[1] - lagTRange[0]
956 extra = numpy.arange(1,extrapoints + 1)*diff + lagTRange[-1]
952 extra = numpy.arange(1,extrapoints + 1)*diff + lagTRange[-1]
957 lagTRange = numpy.hstack((lagTRange, extra))
953 lagTRange = numpy.hstack((lagTRange, extra))
958
954
959 return lagTRange
955 return lagTRange
960
956
961 def getLagRRange(self, extrapoints=0):
957 def getLagRRange(self, extrapoints=0):
962
958
963 return self.lagR
959 return self.lagR
964
960
965 def getPairsList(self):
961 def getPairsList(self):
966
962
967 return self.pairsList
963 return self.pairsList
968
964
969 def getCalculateVelocity(self):
965 def getCalculateVelocity(self):
970
966
971 return self.calculateVelocity
967 return self.calculateVelocity
972
968
973 def getNPoints(self):
969 def getNPoints(self):
974
970
975 return self.nPoints
971 return self.nPoints
976
972
977 def getNAvg(self):
973 def getNAvg(self):
978
974
979 return self.nAvg
975 return self.nAvg
980
976
981 def getBufferSize(self):
977 def getBufferSize(self):
982
978
983 return self.bufferSize
979 return self.bufferSize
984
980
985 def getPairsAutoCorr(self):
981 def getPairsAutoCorr(self):
986 pairsList = self.pairsList
982 pairsList = self.pairsList
987 pairsAutoCorr = numpy.zeros(self.nChannels, dtype = 'int')*numpy.nan
983 pairsAutoCorr = numpy.zeros(self.nChannels, dtype = 'int')*numpy.nan
988
984
989 for l in range(len(pairsList)):
985 for l in range(len(pairsList)):
990 firstChannel = pairsList[l][0]
986 firstChannel = pairsList[l][0]
991 secondChannel = pairsList[l][1]
987 secondChannel = pairsList[l][1]
992
988
993 #Obteniendo pares de Autocorrelacion
989 #Obteniendo pares de Autocorrelacion
994 if firstChannel == secondChannel:
990 if firstChannel == secondChannel:
995 pairsAutoCorr[firstChannel] = int(l)
991 pairsAutoCorr[firstChannel] = int(l)
996
992
997 pairsAutoCorr = pairsAutoCorr.astype(int)
993 pairsAutoCorr = pairsAutoCorr.astype(int)
998
994
999 return pairsAutoCorr
995 return pairsAutoCorr
1000
996
1001 def getNoise(self, mode = 2):
997 def getNoise(self, mode = 2):
1002
998
1003 indR = numpy.where(self.lagR == 0)[0][0]
999 indR = numpy.where(self.lagR == 0)[0][0]
1004 indT = numpy.where(self.lagT == 0)[0][0]
1000 indT = numpy.where(self.lagT == 0)[0][0]
1005
1001
1006 jspectra0 = self.data_corr[:,:,indR,:]
1002 jspectra0 = self.data_corr[:,:,indR,:]
1007 jspectra = copy.copy(jspectra0)
1003 jspectra = copy.copy(jspectra0)
1008
1004
1009 num_chan = jspectra.shape[0]
1005 num_chan = jspectra.shape[0]
1010 num_hei = jspectra.shape[2]
1006 num_hei = jspectra.shape[2]
1011
1007
1012 freq_dc = jspectra.shape[1]/2
1008 freq_dc = jspectra.shape[1]/2
1013 ind_vel = numpy.array([-2,-1,1,2]) + freq_dc
1009 ind_vel = numpy.array([-2,-1,1,2]) + freq_dc
1014
1010
1015 if ind_vel[0]<0:
1011 if ind_vel[0]<0:
1016 ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof
1012 ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof
1017
1013
1018 if mode == 1:
1014 if mode == 1:
1019 jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION
1015 jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION
1020
1016
1021 if mode == 2:
1017 if mode == 2:
1022
1018
1023 vel = numpy.array([-2,-1,1,2])
1019 vel = numpy.array([-2,-1,1,2])
1024 xx = numpy.zeros([4,4])
1020 xx = numpy.zeros([4,4])
1025
1021
1026 for fil in range(4):
1022 for fil in range(4):
1027 xx[fil,:] = vel[fil]**numpy.asarray(range(4))
1023 xx[fil,:] = vel[fil]**numpy.asarray(range(4))
1028
1024
1029 xx_inv = numpy.linalg.inv(xx)
1025 xx_inv = numpy.linalg.inv(xx)
1030 xx_aux = xx_inv[0,:]
1026 xx_aux = xx_inv[0,:]
1031
1027
1032 for ich in range(num_chan):
1028 for ich in range(num_chan):
1033 yy = jspectra[ich,ind_vel,:]
1029 yy = jspectra[ich,ind_vel,:]
1034 jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy)
1030 jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy)
1035
1031
1036 junkid = jspectra[ich,freq_dc,:]<=0
1032 junkid = jspectra[ich,freq_dc,:]<=0
1037 cjunkid = sum(junkid)
1033 cjunkid = sum(junkid)
1038
1034
1039 if cjunkid.any():
1035 if cjunkid.any():
1040 jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2
1036 jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2
1041
1037
1042 noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:]
1038 noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:]
1043
1039
1044 return noise
1040 return noise
1045
1041
1046 def getTimeInterval(self):
1042 def getTimeInterval(self):
1047
1043
1048 timeInterval = self.ippSeconds * self.nCohInt * self.nPoints
1044 timeInterval = self.ippSeconds * self.nCohInt * self.nPoints
1049
1045
1050 return timeInterval
1046 return timeInterval
1051
1047
1052 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
1048 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
1053 # pairsList = property(getPairsList, "I'm the 'pairsList' property.")
1049 # pairsList = property(getPairsList, "I'm the 'pairsList' property.")
1054 # nPoints = property(getNPoints, "I'm the 'nPoints' property.")
1050 # nPoints = property(getNPoints, "I'm the 'nPoints' property.")
1055 calculateVelocity = property(getCalculateVelocity, "I'm the 'calculateVelocity' property.")
1051 calculateVelocity = property(getCalculateVelocity, "I'm the 'calculateVelocity' property.")
1056 nAvg = property(getNAvg, "I'm the 'nAvg' property.")
1052 nAvg = property(getNAvg, "I'm the 'nAvg' property.")
1057 bufferSize = property(getBufferSize, "I'm the 'bufferSize' property.")
1053 bufferSize = property(getBufferSize, "I'm the 'bufferSize' property.")
1058
1054
1059
1055
1060 class Parameters(JROData):
1056 class Parameters(JROData):
1061
1057
1062 #Information from previous data
1058 #Information from previous data
1063
1059
1064 inputUnit = None #Type of data to be processed
1060 inputUnit = None #Type of data to be processed
1065
1061
1066 operation = None #Type of operation to parametrize
1062 operation = None #Type of operation to parametrize
1067
1063
1068 normFactor = None #Normalization Factor
1064 normFactor = None #Normalization Factor
1069
1065
1070 groupList = None #List of Pairs, Groups, etc
1066 groupList = None #List of Pairs, Groups, etc
1071
1067
1072 #Parameters
1068 #Parameters
1073
1069
1074 data_param = None #Parameters obtained
1070 data_param = None #Parameters obtained
1075
1071
1076 data_pre = None #Data Pre Parametrization
1072 data_pre = None #Data Pre Parametrization
1077
1073
1078 data_SNR = None #Signal to Noise Ratio
1074 data_SNR = None #Signal to Noise Ratio
1079
1075
1080 # heightRange = None #Heights
1076 # heightRange = None #Heights
1081
1077
1082 abscissaList = None #Abscissa, can be velocities, lags or time
1078 abscissaList = None #Abscissa, can be velocities, lags or time
1083
1079
1084 noise = None #Noise Potency
1080 noise = None #Noise Potency
1085
1081
1086 utctimeInit = None #Initial UTC time
1082 utctimeInit = None #Initial UTC time
1087
1083
1088 paramInterval = None #Time interval to calculate Parameters in seconds
1084 paramInterval = None #Time interval to calculate Parameters in seconds
1089
1085
1090 #Fitting
1086 #Fitting
1091
1087
1092 data_error = None #Error of the estimation
1088 data_error = None #Error of the estimation
1093
1089
1094 constants = None
1090 constants = None
1095
1091
1096 library = None
1092 library = None
1097
1093
1098 #Output signal
1094 #Output signal
1099
1095
1100 outputInterval = None #Time interval to calculate output signal in seconds
1096 outputInterval = None #Time interval to calculate output signal in seconds
1101
1097
1102 data_output = None #Out signal
1098 data_output = None #Out signal
1103
1099
1104
1100
1105
1101
1106 def __init__(self):
1102 def __init__(self):
1107 '''
1103 '''
1108 Constructor
1104 Constructor
1109 '''
1105 '''
1110 self.radarControllerHeaderObj = RadarControllerHeader()
1106 self.radarControllerHeaderObj = RadarControllerHeader()
1111
1107
1112 self.systemHeaderObj = SystemHeader()
1108 self.systemHeaderObj = SystemHeader()
1113
1109
1114 self.type = "Parameters"
1110 self.type = "Parameters"
1115
1111
1116 def getTimeRange1(self):
1112 def getTimeRange1(self):
1117
1113
1118 datatime = []
1114 datatime = []
1119
1115
1120 if self.useLocalTime:
1116 if self.useLocalTime:
1121 time1 = self.utctimeInit - self.timeZone*60
1117 time1 = self.utctimeInit - self.timeZone*60
1122 else:
1118 else:
1123 time1 = utctimeInit
1119 time1 = utctimeInit
1124
1120
1125 # datatime.append(self.utctimeInit)
1121 # datatime.append(self.utctimeInit)
1126 # datatime.append(self.utctimeInit + self.outputInterval)
1122 # datatime.append(self.utctimeInit + self.outputInterval)
1127 datatime.append(time1)
1123 datatime.append(time1)
1128 datatime.append(time1 + self.outputInterval)
1124 datatime.append(time1 + self.outputInterval)
1129
1125
1130 datatime = numpy.array(datatime)
1126 datatime = numpy.array(datatime)
1131
1127
1132 return datatime
1128 return datatime
@@ -1,19 +1,14
1 '''
1 '''
2
2
3 $Author: murco $
3 $Author: murco $
4 $Id: JRODataIO.py 169 2012-11-19 21:57:03Z murco $
4 $Id: JRODataIO.py 169 2012-11-19 21:57:03Z murco $
5 '''
5 '''
6
6
7 from jroIO_voltage import *
7 from jroIO_voltage import *
8 from jroIO_spectra import *
8 from jroIO_spectra import *
9 from jroIO_heispectra import *
9 from jroIO_heispectra import *
10 from jroIO_usrp import *
10 from jroIO_usrp import *
11
12 # try:
13 # from jroIO_usrp_api import *
14 # except:
15 # print "jroIO_usrp_api could not be imported"
16
11
17 from jroIO_amisr import *
12 from jroIO_amisr import *
18 from jroIO_HDF5 import *
13 from jroIO_HDF5 import *
19 from jroIO_hf import * No newline at end of file
14 from jroIO_hf import *
@@ -1,849 +1,845
1 '''
1 '''
2 Created on Jul 3, 2014
2 Created on Jul 3, 2014
3
3
4 @author: roj-idl71
4 @author: roj-idl71
5 '''
5 '''
6
6
7 import os, sys
7 import os, sys
8 import time, datetime
8 import time, datetime
9 import numpy
9 import numpy
10 import fnmatch
10 import fnmatch
11 import glob
11 import glob
12
12 from time import sleep
13 try:
14 from gevent import sleep
15 except:
16 from time import sleep
17
13
18 try:
14 try:
19 import pyfits
15 import pyfits
20 except:
16 except ImportError, e:
21 """
17 print "Fits data cannot be used. Install pyfits module"
22 """
23
18
24 from xml.etree.ElementTree import ElementTree
19 from xml.etree.ElementTree import ElementTree
25
20
26 from jroIO_base import isRadarFolder, isNumber
21 from jroIO_base import isRadarFolder, isNumber
22 from schainpy.model.data.jrodata import Fits
27 from schainpy.model.proc.jroproc_base import Operation, ProcessingUnit
23 from schainpy.model.proc.jroproc_base import Operation, ProcessingUnit
28
24
29 class Fits:
25 class PyFits(object):
30 name=None
26 name=None
31 format=None
27 format=None
32 array =None
28 array =None
33 data =None
29 data =None
34 thdulist=None
30 thdulist=None
35 prihdr=None
31 prihdr=None
36 hdu=None
32 hdu=None
37
33
38 def __init__(self):
34 def __init__(self):
39
35
40 pass
36 pass
41
37
42 def setColF(self,name,format,array):
38 def setColF(self,name,format,array):
43 self.name=name
39 self.name=name
44 self.format=format
40 self.format=format
45 self.array=array
41 self.array=array
46 a1=numpy.array([self.array],dtype=numpy.float32)
42 a1=numpy.array([self.array],dtype=numpy.float32)
47 self.col1 = pyfits.Column(name=self.name, format=self.format, array=a1)
43 self.col1 = pyfits.Column(name=self.name, format=self.format, array=a1)
48 return self.col1
44 return self.col1
49
45
50 # def setColP(self,name,format,data):
46 # def setColP(self,name,format,data):
51 # self.name=name
47 # self.name=name
52 # self.format=format
48 # self.format=format
53 # self.data=data
49 # self.data=data
54 # a2=numpy.array([self.data],dtype=numpy.float32)
50 # a2=numpy.array([self.data],dtype=numpy.float32)
55 # self.col2 = pyfits.Column(name=self.name, format=self.format, array=a2)
51 # self.col2 = pyfits.Column(name=self.name, format=self.format, array=a2)
56 # return self.col2
52 # return self.col2
57
53
58
54
59 def writeData(self,name,format,data):
55 def writeData(self,name,format,data):
60 self.name=name
56 self.name=name
61 self.format=format
57 self.format=format
62 self.data=data
58 self.data=data
63 a2=numpy.array([self.data],dtype=numpy.float32)
59 a2=numpy.array([self.data],dtype=numpy.float32)
64 self.col2 = pyfits.Column(name=self.name, format=self.format, array=a2)
60 self.col2 = pyfits.Column(name=self.name, format=self.format, array=a2)
65 return self.col2
61 return self.col2
66
62
67 def cFImage(self,idblock,year,month,day,hour,minute,second):
63 def cFImage(self,idblock,year,month,day,hour,minute,second):
68 self.hdu= pyfits.PrimaryHDU(idblock)
64 self.hdu= pyfits.PrimaryHDU(idblock)
69 self.hdu.header.set("Year",year)
65 self.hdu.header.set("Year",year)
70 self.hdu.header.set("Month",month)
66 self.hdu.header.set("Month",month)
71 self.hdu.header.set("Day",day)
67 self.hdu.header.set("Day",day)
72 self.hdu.header.set("Hour",hour)
68 self.hdu.header.set("Hour",hour)
73 self.hdu.header.set("Minute",minute)
69 self.hdu.header.set("Minute",minute)
74 self.hdu.header.set("Second",second)
70 self.hdu.header.set("Second",second)
75 return self.hdu
71 return self.hdu
76
72
77
73
78 def Ctable(self,colList):
74 def Ctable(self,colList):
79 self.cols=pyfits.ColDefs(colList)
75 self.cols=pyfits.ColDefs(colList)
80 self.tbhdu = pyfits.new_table(self.cols)
76 self.tbhdu = pyfits.new_table(self.cols)
81 return self.tbhdu
77 return self.tbhdu
82
78
83
79
84 def CFile(self,hdu,tbhdu):
80 def CFile(self,hdu,tbhdu):
85 self.thdulist=pyfits.HDUList([hdu,tbhdu])
81 self.thdulist=pyfits.HDUList([hdu,tbhdu])
86
82
87 def wFile(self,filename):
83 def wFile(self,filename):
88 if os.path.isfile(filename):
84 if os.path.isfile(filename):
89 os.remove(filename)
85 os.remove(filename)
90 self.thdulist.writeto(filename)
86 self.thdulist.writeto(filename)
91
87
92
88
93 class ParameterConf:
89 class ParameterConf:
94 ELEMENTNAME = 'Parameter'
90 ELEMENTNAME = 'Parameter'
95 def __init__(self):
91 def __init__(self):
96 self.name = ''
92 self.name = ''
97 self.value = ''
93 self.value = ''
98
94
99 def readXml(self, parmElement):
95 def readXml(self, parmElement):
100 self.name = parmElement.get('name')
96 self.name = parmElement.get('name')
101 self.value = parmElement.get('value')
97 self.value = parmElement.get('value')
102
98
103 def getElementName(self):
99 def getElementName(self):
104 return self.ELEMENTNAME
100 return self.ELEMENTNAME
105
101
106 class Metadata:
102 class Metadata(object):
107
103
108 def __init__(self, filename):
104 def __init__(self, filename):
109 self.parmConfObjList = []
105 self.parmConfObjList = []
110 self.readXml(filename)
106 self.readXml(filename)
111
107
112 def readXml(self, filename):
108 def readXml(self, filename):
113 self.projectElement = None
109 self.projectElement = None
114 self.procUnitConfObjDict = {}
110 self.procUnitConfObjDict = {}
115 self.projectElement = ElementTree().parse(filename)
111 self.projectElement = ElementTree().parse(filename)
116 self.project = self.projectElement.tag
112 self.project = self.projectElement.tag
117
113
118 parmElementList = self.projectElement.getiterator(ParameterConf().getElementName())
114 parmElementList = self.projectElement.getiterator(ParameterConf().getElementName())
119
115
120 for parmElement in parmElementList:
116 for parmElement in parmElementList:
121 parmConfObj = ParameterConf()
117 parmConfObj = ParameterConf()
122 parmConfObj.readXml(parmElement)
118 parmConfObj.readXml(parmElement)
123 self.parmConfObjList.append(parmConfObj)
119 self.parmConfObjList.append(parmConfObj)
124
120
125 class FitsWriter(Operation):
121 class FitsWriter(Operation):
126
122
127 def __init__(self):
123 def __init__(self):
128 self.isConfig = False
124 self.isConfig = False
129 self.dataBlocksPerFile = None
125 self.dataBlocksPerFile = None
130 self.blockIndex = 0
126 self.blockIndex = 0
131 self.flagIsNewFile = 1
127 self.flagIsNewFile = 1
132 self.fitsObj = None
128 self.fitsObj = None
133 self.optchar = 'P'
129 self.optchar = 'P'
134 self.ext = '.fits'
130 self.ext = '.fits'
135 self.setFile = 0
131 self.setFile = 0
136
132
137 def setFitsHeader(self, dataOut, metadatafile):
133 def setFitsHeader(self, dataOut, metadatafile=None):
138
134
139 header_data = pyfits.PrimaryHDU()
135 header_data = pyfits.PrimaryHDU()
140
136
141 metadata4fits = Metadata(metadatafile)
137 header_data.header['EXPNAME'] = "RADAR DATA"
142 for parameter in metadata4fits.parmConfObjList:
138 header_data.header['DATATYPE'] = "SPECTRA"
143 parm_name = parameter.name
139 header_data.header['COMMENT'] = ""
144 parm_value = parameter.value
140
141 if metadatafile:
145
142
146 # if parm_value == 'fromdatadatetime':
143 metadata4fits = Metadata(metadatafile)
147 # value = time.strftime("%b %d %Y %H:%M:%S", dataOut.datatime.timetuple())
148 # elif parm_value == 'fromdataheights':
149 # value = dataOut.nHeights
150 # elif parm_value == 'fromdatachannel':
151 # value = dataOut.nChannels
152 # elif parm_value == 'fromdatasamples':
153 # value = dataOut.nFFTPoints
154 # else:
155 # value = parm_value
156
157 header_data.header[parm_name] = parm_value
158
144
145 for parameter in metadata4fits.parmConfObjList:
146 parm_name = parameter.name
147 parm_value = parameter.value
148
149 header_data.header[parm_name] = parm_value
159
150
160 header_data.header['DATETIME'] = time.strftime("%b %d %Y %H:%M:%S", dataOut.datatime.timetuple())
151 header_data.header['DATETIME'] = time.strftime("%b %d %Y %H:%M:%S", dataOut.datatime.timetuple())
161 header_data.header['CHANNELLIST'] = str(dataOut.channelList)
152 header_data.header['CHANNELLIST'] = str(dataOut.channelList)
162 header_data.header['NCHANNELS'] = dataOut.nChannels
153 header_data.header['NCHANNELS'] = dataOut.nChannels
163 #header_data.header['HEIGHTS'] = dataOut.heightList
154 #header_data.header['HEIGHTS'] = dataOut.heightList
164 header_data.header['NHEIGHTS'] = dataOut.nHeights
155 header_data.header['NHEIGHTS'] = dataOut.nHeights
165
156
166 header_data.header['IPPSECONDS'] = dataOut.ippSeconds
157 header_data.header['IPPSECONDS'] = dataOut.ippSeconds
167 header_data.header['NCOHINT'] = dataOut.nCohInt
158 header_data.header['NCOHINT'] = dataOut.nCohInt
168 header_data.header['NINCOHINT'] = dataOut.nIncohInt
159 header_data.header['NINCOHINT'] = dataOut.nIncohInt
169 header_data.header['TIMEZONE'] = dataOut.timeZone
160 header_data.header['TIMEZONE'] = dataOut.timeZone
170 header_data.header['NBLOCK'] = self.blockIndex
161 header_data.header['NBLOCK'] = self.blockIndex
171
162
172 header_data.writeto(self.filename)
163 header_data.writeto(self.filename)
173
164
174 self.addExtension(dataOut.heightList,'HEIGHTLIST')
165 self.addExtension(dataOut.heightList,'HEIGHTLIST')
175
166
176
167
177 def setup(self, dataOut, path, dataBlocksPerFile, metadatafile):
168 def setup(self, dataOut, path, dataBlocksPerFile=100, metadatafile=None):
178
169
179 self.path = path
170 self.path = path
180 self.dataOut = dataOut
171 self.dataOut = dataOut
181 self.metadatafile = metadatafile
172 self.metadatafile = metadatafile
182 self.dataBlocksPerFile = dataBlocksPerFile
173 self.dataBlocksPerFile = dataBlocksPerFile
183
174
184 def open(self):
175 def open(self):
185 self.fitsObj = pyfits.open(self.filename, mode='update')
176 self.fitsObj = pyfits.open(self.filename, mode='update')
186
177
187
178
188 def addExtension(self, data, tagname):
179 def addExtension(self, data, tagname):
189 self.open()
180 self.open()
190 extension = pyfits.ImageHDU(data=data, name=tagname)
181 extension = pyfits.ImageHDU(data=data, name=tagname)
191 #extension.header['TAG'] = tagname
182 #extension.header['TAG'] = tagname
192 self.fitsObj.append(extension)
183 self.fitsObj.append(extension)
193 self.write()
184 self.write()
194
185
195 def addData(self, data):
186 def addData(self, data):
196 self.open()
187 self.open()
197 extension = pyfits.ImageHDU(data=data, name=self.fitsObj[0].header['DATATYPE'])
188 extension = pyfits.ImageHDU(data=data, name=self.fitsObj[0].header['DATATYPE'])
198 extension.header['UTCTIME'] = self.dataOut.utctime
189 extension.header['UTCTIME'] = self.dataOut.utctime
199 self.fitsObj.append(extension)
190 self.fitsObj.append(extension)
200 self.blockIndex += 1
191 self.blockIndex += 1
201 self.fitsObj[0].header['NBLOCK'] = self.blockIndex
192 self.fitsObj[0].header['NBLOCK'] = self.blockIndex
202
193
203 self.write()
194 self.write()
204
195
205 def write(self):
196 def write(self):
206
197
207 self.fitsObj.flush(verbose=True)
198 self.fitsObj.flush(verbose=True)
208 self.fitsObj.close()
199 self.fitsObj.close()
209
200
210
201
211 def setNextFile(self):
202 def setNextFile(self):
212
203
213 ext = self.ext
204 ext = self.ext
214 path = self.path
205 path = self.path
215
206
216 timeTuple = time.localtime( self.dataOut.utctime)
207 timeTuple = time.localtime( self.dataOut.utctime)
217 subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday)
208 subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday)
218
209
219 fullpath = os.path.join( path, subfolder )
210 fullpath = os.path.join( path, subfolder )
220 if not( os.path.exists(fullpath) ):
211 if not( os.path.exists(fullpath) ):
221 os.mkdir(fullpath)
212 os.mkdir(fullpath)
222 self.setFile = -1 #inicializo mi contador de seteo
213 self.setFile = -1 #inicializo mi contador de seteo
223 else:
214 else:
224 filesList = os.listdir( fullpath )
215 filesList = os.listdir( fullpath )
225 if len( filesList ) > 0:
216 if len( filesList ) > 0:
226 filesList = sorted( filesList, key=str.lower )
217 filesList = sorted( filesList, key=str.lower )
227 filen = filesList[-1]
218 filen = filesList[-1]
228
219
229 if isNumber( filen[8:11] ):
220 if isNumber( filen[8:11] ):
230 self.setFile = int( filen[8:11] ) #inicializo mi contador de seteo al seteo del ultimo file
221 self.setFile = int( filen[8:11] ) #inicializo mi contador de seteo al seteo del ultimo file
231 else:
222 else:
232 self.setFile = -1
223 self.setFile = -1
233 else:
224 else:
234 self.setFile = -1 #inicializo mi contador de seteo
225 self.setFile = -1 #inicializo mi contador de seteo
235
226
236 setFile = self.setFile
227 setFile = self.setFile
237 setFile += 1
228 setFile += 1
238
229
239 thisFile = '%s%4.4d%3.3d%3.3d%s' % (self.optchar,
230 thisFile = '%s%4.4d%3.3d%3.3d%s' % (self.optchar,
240 timeTuple.tm_year,
231 timeTuple.tm_year,
241 timeTuple.tm_yday,
232 timeTuple.tm_yday,
242 setFile,
233 setFile,
243 ext )
234 ext )
244
235
245 filename = os.path.join( path, subfolder, thisFile )
236 filename = os.path.join( path, subfolder, thisFile )
246
237
247 self.blockIndex = 0
238 self.blockIndex = 0
248 self.filename = filename
239 self.filename = filename
249 self.setFile = setFile
240 self.setFile = setFile
250 self.flagIsNewFile = 1
241 self.flagIsNewFile = 1
251
242
252 print 'Writing the file: %s'%self.filename
243 print 'Writing the file: %s'%self.filename
253
244
254 self.setFitsHeader(self.dataOut, self.metadatafile)
245 self.setFitsHeader(self.dataOut, self.metadatafile)
255
246
256 return 1
247 return 1
257
248
258 def writeBlock(self):
249 def writeBlock(self):
259 self.addData(self.dataOut.data_spc)
250 self.addData(self.dataOut.data_spc)
260 self.flagIsNewFile = 0
251 self.flagIsNewFile = 0
261
252
262
253
263 def __setNewBlock(self):
254 def __setNewBlock(self):
264
255
265 if self.flagIsNewFile:
256 if self.flagIsNewFile:
266 return 1
257 return 1
267
258
268 if self.blockIndex < self.dataBlocksPerFile:
259 if self.blockIndex < self.dataBlocksPerFile:
269 return 1
260 return 1
270
261
271 if not( self.setNextFile() ):
262 if not( self.setNextFile() ):
272 return 0
263 return 0
273
264
274 return 1
265 return 1
275
266
276 def writeNextBlock(self):
267 def writeNextBlock(self):
277 if not( self.__setNewBlock() ):
268 if not( self.__setNewBlock() ):
278 return 0
269 return 0
279 self.writeBlock()
270 self.writeBlock()
280 return 1
271 return 1
281
272
282 def putData(self):
273 def putData(self):
283 if self.flagIsNewFile:
274 if self.flagIsNewFile:
284 self.setNextFile()
275 self.setNextFile()
285 self.writeNextBlock()
276 self.writeNextBlock()
286
277
287 def run(self, dataOut, **kwargs):
278 def run(self, dataOut, **kwargs):
288 if not(self.isConfig):
279 if not(self.isConfig):
289 self.setup(dataOut, **kwargs)
280 self.setup(dataOut, **kwargs)
290 self.isConfig = True
281 self.isConfig = True
291 self.putData()
282 self.putData()
292
283
293
284
294 class FitsReader(ProcessingUnit):
285 class FitsReader(ProcessingUnit):
295
286
296 # __TIMEZONE = time.timezone
287 # __TIMEZONE = time.timezone
297
288
298 expName = None
289 expName = None
299 datetimestr = None
290 datetimestr = None
300 utc = None
291 utc = None
301 nChannels = None
292 nChannels = None
302 nSamples = None
293 nSamples = None
303 dataBlocksPerFile = None
294 dataBlocksPerFile = None
304 comments = None
295 comments = None
305 lastUTTime = None
296 lastUTTime = None
306 header_dict = None
297 header_dict = None
307 data = None
298 data = None
308 data_header_dict = None
299 data_header_dict = None
309
300
310 def __init__(self):
301 def __init__(self):
311 self.isConfig = False
302 self.isConfig = False
312 self.ext = '.fits'
303 self.ext = '.fits'
313 self.setFile = 0
304 self.setFile = 0
314 self.flagNoMoreFiles = 0
305 self.flagNoMoreFiles = 0
315 self.flagIsNewFile = 1
306 self.flagIsNewFile = 1
316 self.flagDiscontinuousBlock = None
307 self.flagDiscontinuousBlock = None
317 self.fileIndex = None
308 self.fileIndex = None
318 self.filename = None
309 self.filename = None
319 self.fileSize = None
310 self.fileSize = None
320 self.fitsObj = None
311 self.fitsObj = None
321 self.timeZone = None
312 self.timeZone = None
322 self.nReadBlocks = 0
313 self.nReadBlocks = 0
323 self.nTotalBlocks = 0
314 self.nTotalBlocks = 0
324 self.dataOut = self.createObjByDefault()
315 self.dataOut = self.createObjByDefault()
325 self.maxTimeStep = 10# deberia ser definido por el usuario usando el metodo setup()
316 self.maxTimeStep = 10# deberia ser definido por el usuario usando el metodo setup()
326 self.blockIndex = 1
317 self.blockIndex = 1
327
318
328 def createObjByDefault(self):
319 def createObjByDefault(self):
329
320
330 dataObj = Fits()
321 dataObj = Fits()
331
322
332 return dataObj
323 return dataObj
333
324
334 def isFileinThisTime(self, filename, startTime, endTime, useLocalTime=False):
325 def isFileinThisTime(self, filename, startTime, endTime, useLocalTime=False):
335 try:
326 try:
336 fitsObj = pyfits.open(filename,'readonly')
327 fitsObj = pyfits.open(filename,'readonly')
337 except:
328 except:
338 raise IOError, "The file %s can't be opened" %(filename)
329 raise IOError, "The file %s can't be opened" %(filename)
339
330
340 header = fitsObj[0].header
331 header = fitsObj[0].header
341 struct_time = time.strptime(header['DATETIME'], "%b %d %Y %H:%M:%S")
332 struct_time = time.strptime(header['DATETIME'], "%b %d %Y %H:%M:%S")
342 utc = time.mktime(struct_time) - time.timezone #TIMEZONE debe ser un parametro del header FITS
333 utc = time.mktime(struct_time) - time.timezone #TIMEZONE debe ser un parametro del header FITS
343
334
344 ltc = utc
335 ltc = utc
345 if useLocalTime:
336 if useLocalTime:
346 ltc -= time.timezone
337 ltc -= time.timezone
347 thisDatetime = datetime.datetime.utcfromtimestamp(ltc)
338 thisDatetime = datetime.datetime.utcfromtimestamp(ltc)
348 thisTime = thisDatetime.time()
339 thisTime = thisDatetime.time()
349
340
350 if not ((startTime <= thisTime) and (endTime > thisTime)):
341 if not ((startTime <= thisTime) and (endTime > thisTime)):
351 return None
342 return None
352
343
353 return thisDatetime
344 return thisDatetime
354
345
355 def __setNextFileOnline(self):
346 def __setNextFileOnline(self):
356 raise ValueError, "No implemented"
347 raise ValueError, "No implemented"
357
348
358 def __setNextFileOffline(self):
349 def __setNextFileOffline(self):
359 idFile = self.fileIndex
350 idFile = self.fileIndex
360
351
361 while (True):
352 while (True):
362 idFile += 1
353 idFile += 1
363 if not(idFile < len(self.filenameList)):
354 if not(idFile < len(self.filenameList)):
364 self.flagNoMoreFiles = 1
355 self.flagNoMoreFiles = 1
365 print "No more Files"
356 print "No more Files"
366 return 0
357 return 0
367
358
368 filename = self.filenameList[idFile]
359 filename = self.filenameList[idFile]
369
360
370 # if not(self.__verifyFile(filename)):
361 # if not(self.__verifyFile(filename)):
371 # continue
362 # continue
372
363
373 fileSize = os.path.getsize(filename)
364 fileSize = os.path.getsize(filename)
374 fitsObj = pyfits.open(filename,'readonly')
365 fitsObj = pyfits.open(filename,'readonly')
375 break
366 break
376
367
377 self.flagIsNewFile = 1
368 self.flagIsNewFile = 1
378 self.fileIndex = idFile
369 self.fileIndex = idFile
379 self.filename = filename
370 self.filename = filename
380 self.fileSize = fileSize
371 self.fileSize = fileSize
381 self.fitsObj = fitsObj
372 self.fitsObj = fitsObj
382 self.blockIndex = 0
373 self.blockIndex = 0
383 print "Setting the file: %s"%self.filename
374 print "Setting the file: %s"%self.filename
384
375
385 return 1
376 return 1
386
377
387 def __setValuesFromHeader(self):
378 def __setValuesFromHeader(self):
388
379
389 self.dataOut.header = self.header_dict
380 self.dataOut.header = self.header_dict
390 self.dataOut.expName = self.expName
381 self.dataOut.expName = self.expName
391 self.dataOut.nChannels = self.nChannels
382
392 self.dataOut.timeZone = self.timeZone
383 self.dataOut.timeZone = self.timeZone
393 self.dataOut.dataBlocksPerFile = self.dataBlocksPerFile
384 self.dataOut.dataBlocksPerFile = self.dataBlocksPerFile
394 self.dataOut.comments = self.comments
385 self.dataOut.comments = self.comments
395 # self.dataOut.timeInterval = self.timeInterval
386 # self.dataOut.timeInterval = self.timeInterval
396 self.dataOut.channelList = self.channelList
387 self.dataOut.channelList = self.channelList
397 self.dataOut.heightList = self.heightList
388 self.dataOut.heightList = self.heightList
398
389
399 self.dataOut.nCohInt = self.nCohInt
390 self.dataOut.nCohInt = self.nCohInt
400 self.dataOut.nIncohInt = self.nIncohInt
391 self.dataOut.nIncohInt = self.nIncohInt
401
392
393 self.dataOut.ippSeconds = self.ippSeconds
394
402 def readHeader(self):
395 def readHeader(self):
403 headerObj = self.fitsObj[0]
396 headerObj = self.fitsObj[0]
404
397
405 self.header_dict = headerObj.header
398 self.header_dict = headerObj.header
406 if 'EXPNAME' in headerObj.header.keys():
399 if 'EXPNAME' in headerObj.header.keys():
407 self.expName = headerObj.header['EXPNAME']
400 self.expName = headerObj.header['EXPNAME']
408
401
409 if 'DATATYPE' in headerObj.header.keys():
402 if 'DATATYPE' in headerObj.header.keys():
410 self.dataType = headerObj.header['DATATYPE']
403 self.dataType = headerObj.header['DATATYPE']
411
404
412 self.datetimestr = headerObj.header['DATETIME']
405 self.datetimestr = headerObj.header['DATETIME']
413 channelList = headerObj.header['CHANNELLIST']
406 channelList = headerObj.header['CHANNELLIST']
414 channelList = channelList.split('[')
407 channelList = channelList.split('[')
415 channelList = channelList[1].split(']')
408 channelList = channelList[1].split(']')
416 channelList = channelList[0].split(',')
409 channelList = channelList[0].split(',')
417 channelList = [int(ch) for ch in channelList]
410 channelList = [int(ch) for ch in channelList]
418 self.channelList = channelList
411 self.channelList = channelList
419 self.nChannels = headerObj.header['NCHANNELS']
412 self.nChannels = headerObj.header['NCHANNELS']
420 self.nHeights = headerObj.header['NHEIGHTS']
413 self.nHeights = headerObj.header['NHEIGHTS']
421 self.ippSeconds = headerObj.header['IPPSECONDS']
414 self.ippSeconds = headerObj.header['IPPSECONDS']
422 self.nCohInt = headerObj.header['NCOHINT']
415 self.nCohInt = headerObj.header['NCOHINT']
423 self.nIncohInt = headerObj.header['NINCOHINT']
416 self.nIncohInt = headerObj.header['NINCOHINT']
424 self.dataBlocksPerFile = headerObj.header['NBLOCK']
417 self.dataBlocksPerFile = headerObj.header['NBLOCK']
425 self.timeZone = headerObj.header['TIMEZONE']
418 self.timeZone = headerObj.header['TIMEZONE']
426
419
427 # self.timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
420 # self.timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
428
421
429 if 'COMMENT' in headerObj.header.keys():
422 if 'COMMENT' in headerObj.header.keys():
430 self.comments = headerObj.header['COMMENT']
423 self.comments = headerObj.header['COMMENT']
431
424
432 self.readHeightList()
425 self.readHeightList()
433
426
434 def readHeightList(self):
427 def readHeightList(self):
435 self.blockIndex = self.blockIndex + 1
428 self.blockIndex = self.blockIndex + 1
436 obj = self.fitsObj[self.blockIndex]
429 obj = self.fitsObj[self.blockIndex]
437 self.heightList = obj.data
430 self.heightList = obj.data
438 self.blockIndex = self.blockIndex + 1
431 self.blockIndex = self.blockIndex + 1
439
432
440 def readExtension(self):
433 def readExtension(self):
441 obj = self.fitsObj[self.blockIndex]
434 obj = self.fitsObj[self.blockIndex]
442 self.heightList = obj.data
435 self.heightList = obj.data
443 self.blockIndex = self.blockIndex + 1
436 self.blockIndex = self.blockIndex + 1
444
437
445 def setNextFile(self):
438 def setNextFile(self):
446
439
447 if self.online:
440 if self.online:
448 newFile = self.__setNextFileOnline()
441 newFile = self.__setNextFileOnline()
449 else:
442 else:
450 newFile = self.__setNextFileOffline()
443 newFile = self.__setNextFileOffline()
451
444
452 if not(newFile):
445 if not(newFile):
453 return 0
446 return 0
454
447
455 self.readHeader()
448 self.readHeader()
456 self.__setValuesFromHeader()
449 self.__setValuesFromHeader()
457 self.nReadBlocks = 0
450 self.nReadBlocks = 0
458 # self.blockIndex = 1
451 # self.blockIndex = 1
459 return 1
452 return 1
460
453
461 def __searchFilesOffLine(self,
454 def __searchFilesOffLine(self,
462 path,
455 path,
463 startDate,
456 startDate,
464 endDate,
457 endDate,
465 startTime=datetime.time(0,0,0),
458 startTime=datetime.time(0,0,0),
466 endTime=datetime.time(23,59,59),
459 endTime=datetime.time(23,59,59),
467 set=None,
460 set=None,
468 expLabel='',
461 expLabel='',
469 ext='.fits',
462 ext='.fits',
470 walk=True):
463 walk=True):
471
464
472 pathList = []
465 pathList = []
473
466
474 if not walk:
467 if not walk:
475 pathList.append(path)
468 pathList.append(path)
476
469
477 else:
470 else:
478 dirList = []
471 dirList = []
479 for thisPath in os.listdir(path):
472 for thisPath in os.listdir(path):
480 if not os.path.isdir(os.path.join(path,thisPath)):
473 if not os.path.isdir(os.path.join(path,thisPath)):
481 continue
474 continue
482 if not isRadarFolder(thisPath):
475 if not isRadarFolder(thisPath):
483 continue
476 continue
484
477
485 dirList.append(thisPath)
478 dirList.append(thisPath)
486
479
487 if not(dirList):
480 if not(dirList):
488 return None, None
481 return None, None
489
482
490 thisDate = startDate
483 thisDate = startDate
491
484
492 while(thisDate <= endDate):
485 while(thisDate <= endDate):
493 year = thisDate.timetuple().tm_year
486 year = thisDate.timetuple().tm_year
494 doy = thisDate.timetuple().tm_yday
487 doy = thisDate.timetuple().tm_yday
495
488
496 matchlist = fnmatch.filter(dirList, '?' + '%4.4d%3.3d' % (year,doy) + '*')
489 matchlist = fnmatch.filter(dirList, '?' + '%4.4d%3.3d' % (year,doy) + '*')
497 if len(matchlist) == 0:
490 if len(matchlist) == 0:
498 thisDate += datetime.timedelta(1)
491 thisDate += datetime.timedelta(1)
499 continue
492 continue
500 for match in matchlist:
493 for match in matchlist:
501 pathList.append(os.path.join(path,match,expLabel))
494 pathList.append(os.path.join(path,match,expLabel))
502
495
503 thisDate += datetime.timedelta(1)
496 thisDate += datetime.timedelta(1)
504
497
505 if pathList == []:
498 if pathList == []:
506 print "Any folder was found for the date range: %s-%s" %(startDate, endDate)
499 print "Any folder was found for the date range: %s-%s" %(startDate, endDate)
507 return None, None
500 return None, None
508
501
509 print "%d folder(s) was(were) found for the date range: %s - %s" %(len(pathList), startDate, endDate)
502 print "%d folder(s) was(were) found for the date range: %s - %s" %(len(pathList), startDate, endDate)
510
503
511 filenameList = []
504 filenameList = []
512 datetimeList = []
505 datetimeList = []
513
506
514 for i in range(len(pathList)):
507 for i in range(len(pathList)):
515
508
516 thisPath = pathList[i]
509 thisPath = pathList[i]
517
510
518 fileList = glob.glob1(thisPath, "*%s" %ext)
511 fileList = glob.glob1(thisPath, "*%s" %ext)
519 fileList.sort()
512 fileList.sort()
520
513
521 for thisFile in fileList:
514 for thisFile in fileList:
522
515
523 filename = os.path.join(thisPath,thisFile)
516 filename = os.path.join(thisPath,thisFile)
524 thisDatetime = self.isFileinThisTime(filename, startTime, endTime)
517 thisDatetime = self.isFileinThisTime(filename, startTime, endTime)
525
518
526 if not(thisDatetime):
519 if not(thisDatetime):
527 continue
520 continue
528
521
529 filenameList.append(filename)
522 filenameList.append(filename)
530 datetimeList.append(thisDatetime)
523 datetimeList.append(thisDatetime)
531
524
532 if not(filenameList):
525 if not(filenameList):
533 print "Any file was found for the time range %s - %s" %(startTime, endTime)
526 print "Any file was found for the time range %s - %s" %(startTime, endTime)
534 return None, None
527 return None, None
535
528
536 print "%d file(s) was(were) found for the time range: %s - %s" %(len(filenameList), startTime, endTime)
529 print "%d file(s) was(were) found for the time range: %s - %s" %(len(filenameList), startTime, endTime)
537 print
530 print
538
531
539 for i in range(len(filenameList)):
532 for i in range(len(filenameList)):
540 print "%s -> [%s]" %(filenameList[i], datetimeList[i].ctime())
533 print "%s -> [%s]" %(filenameList[i], datetimeList[i].ctime())
541
534
542 self.filenameList = filenameList
535 self.filenameList = filenameList
543 self.datetimeList = datetimeList
536 self.datetimeList = datetimeList
544
537
545 return pathList, filenameList
538 return pathList, filenameList
546
539
547 def setup(self, path=None,
540 def setup(self, path=None,
548 startDate=None,
541 startDate=None,
549 endDate=None,
542 endDate=None,
550 startTime=datetime.time(0,0,0),
543 startTime=datetime.time(0,0,0),
551 endTime=datetime.time(23,59,59),
544 endTime=datetime.time(23,59,59),
552 set=0,
545 set=0,
553 expLabel = "",
546 expLabel = "",
554 ext = None,
547 ext = None,
555 online = False,
548 online = False,
556 delay = 60,
549 delay = 60,
557 walk = True):
550 walk = True):
558
551
559 if path == None:
552 if path == None:
560 raise ValueError, "The path is not valid"
553 raise ValueError, "The path is not valid"
561
554
562 if ext == None:
555 if ext == None:
563 ext = self.ext
556 ext = self.ext
564
557
565 if not(online):
558 if not(online):
566 print "Searching files in offline mode ..."
559 print "Searching files in offline mode ..."
567 pathList, filenameList = self.__searchFilesOffLine(path, startDate=startDate, endDate=endDate,
560 pathList, filenameList = self.__searchFilesOffLine(path, startDate=startDate, endDate=endDate,
568 startTime=startTime, endTime=endTime,
561 startTime=startTime, endTime=endTime,
569 set=set, expLabel=expLabel, ext=ext,
562 set=set, expLabel=expLabel, ext=ext,
570 walk=walk)
563 walk=walk)
571
564
572 if not(pathList):
565 if not(pathList):
573 print "No *%s files into the folder %s \nfor the range: %s - %s"%(ext, path,
566 print "No *%s files into the folder %s \nfor the range: %s - %s"%(ext, path,
574 datetime.datetime.combine(startDate,startTime).ctime(),
567 datetime.datetime.combine(startDate,startTime).ctime(),
575 datetime.datetime.combine(endDate,endTime).ctime())
568 datetime.datetime.combine(endDate,endTime).ctime())
576
569
577 sys.exit(-1)
570 sys.exit(-1)
578
571
579 self.fileIndex = -1
572 self.fileIndex = -1
580 self.pathList = pathList
573 self.pathList = pathList
581 self.filenameList = filenameList
574 self.filenameList = filenameList
582
575
583 self.online = online
576 self.online = online
584 self.delay = delay
577 self.delay = delay
585 ext = ext.lower()
578 ext = ext.lower()
586 self.ext = ext
579 self.ext = ext
587
580
588 if not(self.setNextFile()):
581 if not(self.setNextFile()):
589 if (startDate!=None) and (endDate!=None):
582 if (startDate!=None) and (endDate!=None):
590 print "No files in range: %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())
583 print "No files in range: %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())
591 elif startDate != None:
584 elif startDate != None:
592 print "No files in range: %s" %(datetime.datetime.combine(startDate,startTime).ctime())
585 print "No files in range: %s" %(datetime.datetime.combine(startDate,startTime).ctime())
593 else:
586 else:
594 print "No files"
587 print "No files"
595
588
596 sys.exit(-1)
589 sys.exit(-1)
597
590
598
591
599
592
600 def readBlock(self):
593 def readBlock(self):
601 dataObj = self.fitsObj[self.blockIndex]
594 dataObj = self.fitsObj[self.blockIndex]
602
595
603 self.data = dataObj.data
596 self.data = dataObj.data
604 self.data_header_dict = dataObj.header
597 self.data_header_dict = dataObj.header
605 self.utc = self.data_header_dict['UTCTIME']
598 self.utc = self.data_header_dict['UTCTIME']
606
599
607 self.flagIsNewFile = 0
600 self.flagIsNewFile = 0
608 self.blockIndex += 1
601 self.blockIndex += 1
609 self.nTotalBlocks += 1
602 self.nTotalBlocks += 1
610 self.nReadBlocks += 1
603 self.nReadBlocks += 1
611
604
612 return 1
605 return 1
613
606
614 def __jumpToLastBlock(self):
607 def __jumpToLastBlock(self):
615 raise ValueError, "No implemented"
608 raise ValueError, "No implemented"
616
609
617 def __waitNewBlock(self):
610 def __waitNewBlock(self):
618 """
611 """
619 Return 1 si se encontro un nuevo bloque de datos, 0 de otra forma.
612 Return 1 si se encontro un nuevo bloque de datos, 0 de otra forma.
620
613
621 Si el modo de lectura es OffLine siempre retorn 0
614 Si el modo de lectura es OffLine siempre retorn 0
622 """
615 """
623 if not self.online:
616 if not self.online:
624 return 0
617 return 0
625
618
626 if (self.nReadBlocks >= self.dataBlocksPerFile):
619 if (self.nReadBlocks >= self.dataBlocksPerFile):
627 return 0
620 return 0
628
621
629 currentPointer = self.fp.tell()
622 currentPointer = self.fp.tell()
630
623
631 neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize
624 neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize
632
625
633 for nTries in range( self.nTries ):
626 for nTries in range( self.nTries ):
634
627
635 self.fp.close()
628 self.fp.close()
636 self.fp = open( self.filename, 'rb' )
629 self.fp = open( self.filename, 'rb' )
637 self.fp.seek( currentPointer )
630 self.fp.seek( currentPointer )
638
631
639 self.fileSize = os.path.getsize( self.filename )
632 self.fileSize = os.path.getsize( self.filename )
640 currentSize = self.fileSize - currentPointer
633 currentSize = self.fileSize - currentPointer
641
634
642 if ( currentSize >= neededSize ):
635 if ( currentSize >= neededSize ):
643 self.__rdBasicHeader()
636 self.__rdBasicHeader()
644 return 1
637 return 1
645
638
646 print "\tWaiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries+1)
639 print "\tWaiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries+1)
647 sleep( self.delay )
640 sleep( self.delay )
648
641
649
642
650 return 0
643 return 0
651
644
652 def __setNewBlock(self):
645 def __setNewBlock(self):
653
646
654 if self.online:
647 if self.online:
655 self.__jumpToLastBlock()
648 self.__jumpToLastBlock()
656
649
657 if self.flagIsNewFile:
650 if self.flagIsNewFile:
658 return 1
651 return 1
659
652
660 self.lastUTTime = self.utc
653 self.lastUTTime = self.utc
661
654
662 if self.online:
655 if self.online:
663 if self.__waitNewBlock():
656 if self.__waitNewBlock():
664 return 1
657 return 1
665
658
666 if self.nReadBlocks < self.dataBlocksPerFile:
659 if self.nReadBlocks < self.dataBlocksPerFile:
667 return 1
660 return 1
668
661
669 if not(self.setNextFile()):
662 if not(self.setNextFile()):
670 return 0
663 return 0
671
664
672 deltaTime = self.utc - self.lastUTTime
665 deltaTime = self.utc - self.lastUTTime
673
666
674 self.flagDiscontinuousBlock = 0
667 self.flagDiscontinuousBlock = 0
675
668
676 if deltaTime > self.maxTimeStep:
669 if deltaTime > self.maxTimeStep:
677 self.flagDiscontinuousBlock = 1
670 self.flagDiscontinuousBlock = 1
678
671
679 return 1
672 return 1
680
673
681
674
682 def readNextBlock(self):
675 def readNextBlock(self):
683 if not(self.__setNewBlock()):
676 if not(self.__setNewBlock()):
684 return 0
677 return 0
685
678
686 if not(self.readBlock()):
679 if not(self.readBlock()):
687 return 0
680 return 0
688
681
689 return 1
682 return 1
690
683
684 def printInfo(self):
685
686 pass
691
687
692 def getData(self):
688 def getData(self):
693
689
694 if self.flagNoMoreFiles:
690 if self.flagNoMoreFiles:
695 self.dataOut.flagNoData = True
691 self.dataOut.flagNoData = True
696 print 'Process finished'
692 print 'Process finished'
697 return 0
693 return 0
698
694
699 self.flagDiscontinuousBlock = 0
695 self.flagDiscontinuousBlock = 0
700 self.flagIsNewBlock = 0
696 self.flagIsNewBlock = 0
701
697
702 if not(self.readNextBlock()):
698 if not(self.readNextBlock()):
703 return 0
699 return 0
704
700
705 if self.data == None:
701 if self.data is None:
706 self.dataOut.flagNoData = True
702 self.dataOut.flagNoData = True
707 return 0
703 return 0
708
704
709 self.dataOut.data = self.data
705 self.dataOut.data = self.data
710 self.dataOut.data_header = self.data_header_dict
706 self.dataOut.data_header = self.data_header_dict
711 self.dataOut.utctime = self.utc
707 self.dataOut.utctime = self.utc
712
708
713 # self.dataOut.header = self.header_dict
709 # self.dataOut.header = self.header_dict
714 # self.dataOut.expName = self.expName
710 # self.dataOut.expName = self.expName
715 # self.dataOut.nChannels = self.nChannels
711 # self.dataOut.nChannels = self.nChannels
716 # self.dataOut.timeZone = self.timeZone
712 # self.dataOut.timeZone = self.timeZone
717 # self.dataOut.dataBlocksPerFile = self.dataBlocksPerFile
713 # self.dataOut.dataBlocksPerFile = self.dataBlocksPerFile
718 # self.dataOut.comments = self.comments
714 # self.dataOut.comments = self.comments
719 # # self.dataOut.timeInterval = self.timeInterval
715 # # self.dataOut.timeInterval = self.timeInterval
720 # self.dataOut.channelList = self.channelList
716 # self.dataOut.channelList = self.channelList
721 # self.dataOut.heightList = self.heightList
717 # self.dataOut.heightList = self.heightList
722 self.dataOut.flagNoData = False
718 self.dataOut.flagNoData = False
723
719
724 return self.dataOut.data
720 return self.dataOut.data
725
721
726 def run(self, **kwargs):
722 def run(self, **kwargs):
727
723
728 if not(self.isConfig):
724 if not(self.isConfig):
729 self.setup(**kwargs)
725 self.setup(**kwargs)
730 self.isConfig = True
726 self.isConfig = True
731
727
732 self.getData()
728 self.getData()
733
729
734 class SpectraHeisWriter(Operation):
730 class SpectraHeisWriter(Operation):
735 # set = None
731 # set = None
736 setFile = None
732 setFile = None
737 idblock = None
733 idblock = None
738 doypath = None
734 doypath = None
739 subfolder = None
735 subfolder = None
740
736
741 def __init__(self):
737 def __init__(self):
742 self.wrObj = Fits()
738 self.wrObj = PyFits()
743 # self.dataOut = dataOut
739 # self.dataOut = dataOut
744 self.nTotalBlocks=0
740 self.nTotalBlocks=0
745 # self.set = None
741 # self.set = None
746 self.setFile = None
742 self.setFile = None
747 self.idblock = 0
743 self.idblock = 0
748 self.wrpath = None
744 self.wrpath = None
749 self.doypath = None
745 self.doypath = None
750 self.subfolder = None
746 self.subfolder = None
751 self.isConfig = False
747 self.isConfig = False
752
748
753 def isNumber(str):
749 def isNumber(str):
754 """
750 """
755 Chequea si el conjunto de caracteres que componen un string puede ser convertidos a un numero.
751 Chequea si el conjunto de caracteres que componen un string puede ser convertidos a un numero.
756
752
757 Excepciones:
753 Excepciones:
758 Si un determinado string no puede ser convertido a numero
754 Si un determinado string no puede ser convertido a numero
759 Input:
755 Input:
760 str, string al cual se le analiza para determinar si convertible a un numero o no
756 str, string al cual se le analiza para determinar si convertible a un numero o no
761
757
762 Return:
758 Return:
763 True : si el string es uno numerico
759 True : si el string es uno numerico
764 False : no es un string numerico
760 False : no es un string numerico
765 """
761 """
766 try:
762 try:
767 float( str )
763 float( str )
768 return True
764 return True
769 except:
765 except:
770 return False
766 return False
771
767
772 def setup(self, dataOut, wrpath):
768 def setup(self, dataOut, wrpath):
773
769
774 if not(os.path.exists(wrpath)):
770 if not(os.path.exists(wrpath)):
775 os.mkdir(wrpath)
771 os.mkdir(wrpath)
776
772
777 self.wrpath = wrpath
773 self.wrpath = wrpath
778 # self.setFile = 0
774 # self.setFile = 0
779 self.dataOut = dataOut
775 self.dataOut = dataOut
780
776
781 def putData(self):
777 def putData(self):
782 name= time.localtime( self.dataOut.utctime)
778 name= time.localtime( self.dataOut.utctime)
783 ext=".fits"
779 ext=".fits"
784
780
785 if self.doypath == None:
781 if self.doypath == None:
786 self.subfolder = 'F%4.4d%3.3d_%d' % (name.tm_year,name.tm_yday,time.mktime(datetime.datetime.now().timetuple()))
782 self.subfolder = 'F%4.4d%3.3d_%d' % (name.tm_year,name.tm_yday,time.mktime(datetime.datetime.now().timetuple()))
787 self.doypath = os.path.join( self.wrpath, self.subfolder )
783 self.doypath = os.path.join( self.wrpath, self.subfolder )
788 os.mkdir(self.doypath)
784 os.mkdir(self.doypath)
789
785
790 if self.setFile == None:
786 if self.setFile == None:
791 # self.set = self.dataOut.set
787 # self.set = self.dataOut.set
792 self.setFile = 0
788 self.setFile = 0
793 # if self.set != self.dataOut.set:
789 # if self.set != self.dataOut.set:
794 ## self.set = self.dataOut.set
790 ## self.set = self.dataOut.set
795 # self.setFile = 0
791 # self.setFile = 0
796
792
797 #make the filename
793 #make the filename
798 thisFile = 'D%4.4d%3.3d_%3.3d%s' % (name.tm_year,name.tm_yday,self.setFile,ext)
794 thisFile = 'D%4.4d%3.3d_%3.3d%s' % (name.tm_year,name.tm_yday,self.setFile,ext)
799
795
800 filename = os.path.join(self.wrpath,self.subfolder, thisFile)
796 filename = os.path.join(self.wrpath,self.subfolder, thisFile)
801
797
802 idblock = numpy.array([self.idblock],dtype="int64")
798 idblock = numpy.array([self.idblock],dtype="int64")
803 header=self.wrObj.cFImage(idblock=idblock,
799 header=self.wrObj.cFImage(idblock=idblock,
804 year=time.gmtime(self.dataOut.utctime).tm_year,
800 year=time.gmtime(self.dataOut.utctime).tm_year,
805 month=time.gmtime(self.dataOut.utctime).tm_mon,
801 month=time.gmtime(self.dataOut.utctime).tm_mon,
806 day=time.gmtime(self.dataOut.utctime).tm_mday,
802 day=time.gmtime(self.dataOut.utctime).tm_mday,
807 hour=time.gmtime(self.dataOut.utctime).tm_hour,
803 hour=time.gmtime(self.dataOut.utctime).tm_hour,
808 minute=time.gmtime(self.dataOut.utctime).tm_min,
804 minute=time.gmtime(self.dataOut.utctime).tm_min,
809 second=time.gmtime(self.dataOut.utctime).tm_sec)
805 second=time.gmtime(self.dataOut.utctime).tm_sec)
810
806
811 c=3E8
807 c=3E8
812 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
808 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
813 freq=numpy.arange(-1*self.dataOut.nHeights/2.,self.dataOut.nHeights/2.)*(c/(2*deltaHeight*1000))
809 freq=numpy.arange(-1*self.dataOut.nHeights/2.,self.dataOut.nHeights/2.)*(c/(2*deltaHeight*1000))
814
810
815 colList = []
811 colList = []
816
812
817 colFreq=self.wrObj.setColF(name="freq", format=str(self.dataOut.nFFTPoints)+'E', array=freq)
813 colFreq=self.wrObj.setColF(name="freq", format=str(self.dataOut.nFFTPoints)+'E', array=freq)
818
814
819 colList.append(colFreq)
815 colList.append(colFreq)
820
816
821 nchannel=self.dataOut.nChannels
817 nchannel=self.dataOut.nChannels
822
818
823 for i in range(nchannel):
819 for i in range(nchannel):
824 col = self.wrObj.writeData(name="PCh"+str(i+1),
820 col = self.wrObj.writeData(name="PCh"+str(i+1),
825 format=str(self.dataOut.nFFTPoints)+'E',
821 format=str(self.dataOut.nFFTPoints)+'E',
826 data=10*numpy.log10(self.dataOut.data_spc[i,:]))
822 data=10*numpy.log10(self.dataOut.data_spc[i,:]))
827
823
828 colList.append(col)
824 colList.append(col)
829
825
830 data=self.wrObj.Ctable(colList=colList)
826 data=self.wrObj.Ctable(colList=colList)
831
827
832 self.wrObj.CFile(header,data)
828 self.wrObj.CFile(header,data)
833
829
834 self.wrObj.wFile(filename)
830 self.wrObj.wFile(filename)
835
831
836 #update the setFile
832 #update the setFile
837 self.setFile += 1
833 self.setFile += 1
838 self.idblock += 1
834 self.idblock += 1
839
835
840 return 1
836 return 1
841
837
842 def run(self, dataOut, **kwargs):
838 def run(self, dataOut, **kwargs):
843
839
844 if not(self.isConfig):
840 if not(self.isConfig):
845
841
846 self.setup(dataOut, **kwargs)
842 self.setup(dataOut, **kwargs)
847 self.isConfig = True
843 self.isConfig = True
848
844
849 self.putData() No newline at end of file
845 self.putData()
@@ -1,343 +1,343
1 import numpy
1 import numpy
2
2
3 from jroproc_base import ProcessingUnit, Operation
3 from jroproc_base import ProcessingUnit, Operation
4 from schainpy.model.data.jrodata import SpectraHeis
4 from schainpy.model.data.jrodata import SpectraHeis
5
5
6 class SpectraHeisProc(ProcessingUnit):
6 class SpectraHeisProc(ProcessingUnit):
7
7
8 def __init__(self):
8 def __init__(self):
9
9
10 ProcessingUnit.__init__(self)
10 ProcessingUnit.__init__(self)
11
11
12 # self.buffer = None
12 # self.buffer = None
13 # self.firstdatatime = None
13 # self.firstdatatime = None
14 # self.profIndex = 0
14 # self.profIndex = 0
15 self.dataOut = SpectraHeis()
15 self.dataOut = SpectraHeis()
16
16
17 def __updateObjFromVoltage(self):
17 def __updateObjFromVoltage(self):
18
18
19 self.dataOut.timeZone = self.dataIn.timeZone
19 self.dataOut.timeZone = self.dataIn.timeZone
20 self.dataOut.dstFlag = self.dataIn.dstFlag
20 self.dataOut.dstFlag = self.dataIn.dstFlag
21 self.dataOut.errorCount = self.dataIn.errorCount
21 self.dataOut.errorCount = self.dataIn.errorCount
22 self.dataOut.useLocalTime = self.dataIn.useLocalTime
22 self.dataOut.useLocalTime = self.dataIn.useLocalTime
23
23
24 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()#
24 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()#
25 self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy()#
25 self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy()#
26 self.dataOut.channelList = self.dataIn.channelList
26 self.dataOut.channelList = self.dataIn.channelList
27 self.dataOut.heightList = self.dataIn.heightList
27 self.dataOut.heightList = self.dataIn.heightList
28 # self.dataOut.dtype = self.dataIn.dtype
28 # self.dataOut.dtype = self.dataIn.dtype
29 self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')])
29 self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')])
30 # self.dataOut.nHeights = self.dataIn.nHeights
30 # self.dataOut.nHeights = self.dataIn.nHeights
31 # self.dataOut.nChannels = self.dataIn.nChannels
31 # self.dataOut.nChannels = self.dataIn.nChannels
32 self.dataOut.nBaud = self.dataIn.nBaud
32 self.dataOut.nBaud = self.dataIn.nBaud
33 self.dataOut.nCode = self.dataIn.nCode
33 self.dataOut.nCode = self.dataIn.nCode
34 self.dataOut.code = self.dataIn.code
34 self.dataOut.code = self.dataIn.code
35 # self.dataOut.nProfiles = 1
35 # self.dataOut.nProfiles = 1
36 # self.dataOut.nProfiles = self.dataOut.nFFTPoints
36 # self.dataOut.nProfiles = self.dataOut.nFFTPoints
37 self.dataOut.nFFTPoints = self.dataIn.nHeights
37 self.dataOut.nFFTPoints = self.dataIn.nHeights
38 # self.dataOut.channelIndexList = self.dataIn.channelIndexList
38 # self.dataOut.channelIndexList = self.dataIn.channelIndexList
39 # self.dataOut.flagNoData = self.dataIn.flagNoData
39 # self.dataOut.flagNoData = self.dataIn.flagNoData
40 self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock
40 self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock
41 self.dataOut.utctime = self.dataIn.utctime
41 self.dataOut.utctime = self.dataIn.utctime
42 # self.dataOut.utctime = self.firstdatatime
42 # self.dataOut.utctime = self.firstdatatime
43 self.dataOut.flagDecodeData = self.dataIn.flagDecodeData #asumo q la data esta decodificada
43 self.dataOut.flagDecodeData = self.dataIn.flagDecodeData #asumo q la data esta decodificada
44 self.dataOut.flagDeflipData = self.dataIn.flagDeflipData #asumo q la data esta sin flip
44 self.dataOut.flagDeflipData = self.dataIn.flagDeflipData #asumo q la data esta sin flip
45 # self.dataOut.flagShiftFFT = self.dataIn.flagShiftFFT
45 # self.dataOut.flagShiftFFT = self.dataIn.flagShiftFFT
46 self.dataOut.nCohInt = self.dataIn.nCohInt
46 self.dataOut.nCohInt = self.dataIn.nCohInt
47 self.dataOut.nIncohInt = 1
47 self.dataOut.nIncohInt = 1
48 # self.dataOut.ippSeconds= self.dataIn.ippSeconds
48 # self.dataOut.ippSeconds= self.dataIn.ippSeconds
49 self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
49 self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
50
50
51 # self.dataOut.timeInterval = self.dataIn.timeInterval*self.dataOut.nIncohInt
51 # self.dataOut.timeInterval = self.dataIn.timeInterval*self.dataOut.nIncohInt
52 # self.dataOut.set=self.dataIn.set
52 # self.dataOut.set=self.dataIn.set
53 # self.dataOut.deltaHeight=self.dataIn.deltaHeight
53 # self.dataOut.deltaHeight=self.dataIn.deltaHeight
54
54
55
55
56 def __updateObjFromFits(self):
56 def __updateObjFromFits(self):
57
57
58 self.dataOut.utctime = self.dataIn.utctime
58 self.dataOut.utctime = self.dataIn.utctime
59 self.dataOut.channelIndexList = self.dataIn.channelIndexList
59 # self.dataOut.channelIndexList = self.dataIn.channelIndexList
60
60
61 self.dataOut.channelList = self.dataIn.channelList
61 self.dataOut.channelList = self.dataIn.channelList
62 self.dataOut.heightList = self.dataIn.heightList
62 self.dataOut.heightList = self.dataIn.heightList
63 self.dataOut.data_spc = self.dataIn.data
63 self.dataOut.data_spc = self.dataIn.data
64 self.dataOut.ippSeconds = self.dataIn.ippSeconds
64 self.dataOut.ippSeconds = self.dataIn.ippSeconds
65 self.dataOut.nCohInt = self.dataIn.nCohInt
65 self.dataOut.nCohInt = self.dataIn.nCohInt
66 self.dataOut.nIncohInt = self.dataIn.nIncohInt
66 self.dataOut.nIncohInt = self.dataIn.nIncohInt
67 # self.dataOut.timeInterval = self.dataIn.timeInterval
67 # self.dataOut.timeInterval = self.dataIn.timeInterval
68 self.dataOut.timeZone = self.dataIn.timeZone
68 self.dataOut.timeZone = self.dataIn.timeZone
69 self.dataOut.useLocalTime = True
69 self.dataOut.useLocalTime = True
70 # self.dataOut.
70 # self.dataOut.
71 # self.dataOut.
71 # self.dataOut.
72
72
73 def __getFft(self):
73 def __getFft(self):
74
74
75 fft_volt = numpy.fft.fft(self.dataIn.data, axis=1)
75 fft_volt = numpy.fft.fft(self.dataIn.data, axis=1)
76 fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,))
76 fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,))
77 spc = numpy.abs(fft_volt * numpy.conjugate(fft_volt))/(self.dataOut.nFFTPoints)
77 spc = numpy.abs(fft_volt * numpy.conjugate(fft_volt))/(self.dataOut.nFFTPoints)
78 self.dataOut.data_spc = spc
78 self.dataOut.data_spc = spc
79
79
80 def run(self):
80 def run(self):
81
81
82 self.dataOut.flagNoData = True
82 self.dataOut.flagNoData = True
83
83
84 if self.dataIn.type == "Fits":
84 if self.dataIn.type == "Fits":
85 self.__updateObjFromFits()
85 self.__updateObjFromFits()
86 self.dataOut.flagNoData = False
86 self.dataOut.flagNoData = False
87 return
87 return
88
88
89 if self.dataIn.type == "SpectraHeis":
89 if self.dataIn.type == "SpectraHeis":
90 self.dataOut.copy(self.dataIn)
90 self.dataOut.copy(self.dataIn)
91 return
91 return
92
92
93 if self.dataIn.type == "Voltage":
93 if self.dataIn.type == "Voltage":
94 self.__updateObjFromVoltage()
94 self.__updateObjFromVoltage()
95 self.__getFft()
95 self.__getFft()
96 self.dataOut.flagNoData = False
96 self.dataOut.flagNoData = False
97
97
98 return
98 return
99
99
100 raise ValueError, "The type object %s is not valid"%(self.dataIn.type)
100 raise ValueError, "The type object %s is not valid"%(self.dataIn.type)
101
101
102
102
103 def selectChannels(self, channelList):
103 def selectChannels(self, channelList):
104
104
105 channelIndexList = []
105 channelIndexList = []
106
106
107 for channel in channelList:
107 for channel in channelList:
108 index = self.dataOut.channelList.index(channel)
108 index = self.dataOut.channelList.index(channel)
109 channelIndexList.append(index)
109 channelIndexList.append(index)
110
110
111 self.selectChannelsByIndex(channelIndexList)
111 self.selectChannelsByIndex(channelIndexList)
112
112
113 def selectChannelsByIndex(self, channelIndexList):
113 def selectChannelsByIndex(self, channelIndexList):
114 """
114 """
115 Selecciona un bloque de datos en base a canales segun el channelIndexList
115 Selecciona un bloque de datos en base a canales segun el channelIndexList
116
116
117 Input:
117 Input:
118 channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
118 channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
119
119
120 Affected:
120 Affected:
121 self.dataOut.data
121 self.dataOut.data
122 self.dataOut.channelIndexList
122 self.dataOut.channelIndexList
123 self.dataOut.nChannels
123 self.dataOut.nChannels
124 self.dataOut.m_ProcessingHeader.totalSpectra
124 self.dataOut.m_ProcessingHeader.totalSpectra
125 self.dataOut.systemHeaderObj.numChannels
125 self.dataOut.systemHeaderObj.numChannels
126 self.dataOut.m_ProcessingHeader.blockSize
126 self.dataOut.m_ProcessingHeader.blockSize
127
127
128 Return:
128 Return:
129 None
129 None
130 """
130 """
131
131
132 for channelIndex in channelIndexList:
132 for channelIndex in channelIndexList:
133 if channelIndex not in self.dataOut.channelIndexList:
133 if channelIndex not in self.dataOut.channelIndexList:
134 print channelIndexList
134 print channelIndexList
135 raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex
135 raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex
136
136
137 # nChannels = len(channelIndexList)
137 # nChannels = len(channelIndexList)
138
138
139 data_spc = self.dataOut.data_spc[channelIndexList,:]
139 data_spc = self.dataOut.data_spc[channelIndexList,:]
140
140
141 self.dataOut.data_spc = data_spc
141 self.dataOut.data_spc = data_spc
142 self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList]
142 self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList]
143
143
144 return 1
144 return 1
145
145
146 class IncohInt4SpectraHeis(Operation):
146 class IncohInt4SpectraHeis(Operation):
147
147
148 isConfig = False
148 isConfig = False
149
149
150 __profIndex = 0
150 __profIndex = 0
151 __withOverapping = False
151 __withOverapping = False
152
152
153 __byTime = False
153 __byTime = False
154 __initime = None
154 __initime = None
155 __lastdatatime = None
155 __lastdatatime = None
156 __integrationtime = None
156 __integrationtime = None
157
157
158 __buffer = None
158 __buffer = None
159
159
160 __dataReady = False
160 __dataReady = False
161
161
162 n = None
162 n = None
163
163
164
164
165 def __init__(self):
165 def __init__(self):
166
166
167 Operation.__init__(self)
167 Operation.__init__(self)
168 # self.isConfig = False
168 # self.isConfig = False
169
169
170 def setup(self, n=None, timeInterval=None, overlapping=False):
170 def setup(self, n=None, timeInterval=None, overlapping=False):
171 """
171 """
172 Set the parameters of the integration class.
172 Set the parameters of the integration class.
173
173
174 Inputs:
174 Inputs:
175
175
176 n : Number of coherent integrations
176 n : Number of coherent integrations
177 timeInterval : Time of integration. If the parameter "n" is selected this one does not work
177 timeInterval : Time of integration. If the parameter "n" is selected this one does not work
178 overlapping :
178 overlapping :
179
179
180 """
180 """
181
181
182 self.__initime = None
182 self.__initime = None
183 self.__lastdatatime = 0
183 self.__lastdatatime = 0
184 self.__buffer = None
184 self.__buffer = None
185 self.__dataReady = False
185 self.__dataReady = False
186
186
187
187
188 if n == None and timeInterval == None:
188 if n == None and timeInterval == None:
189 raise ValueError, "n or timeInterval should be specified ..."
189 raise ValueError, "n or timeInterval should be specified ..."
190
190
191 if n != None:
191 if n != None:
192 self.n = n
192 self.n = n
193 self.__byTime = False
193 self.__byTime = False
194 else:
194 else:
195 self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line
195 self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line
196 self.n = 9999
196 self.n = 9999
197 self.__byTime = True
197 self.__byTime = True
198
198
199 if overlapping:
199 if overlapping:
200 self.__withOverapping = True
200 self.__withOverapping = True
201 self.__buffer = None
201 self.__buffer = None
202 else:
202 else:
203 self.__withOverapping = False
203 self.__withOverapping = False
204 self.__buffer = 0
204 self.__buffer = 0
205
205
206 self.__profIndex = 0
206 self.__profIndex = 0
207
207
208 def putData(self, data):
208 def putData(self, data):
209
209
210 """
210 """
211 Add a profile to the __buffer and increase in one the __profileIndex
211 Add a profile to the __buffer and increase in one the __profileIndex
212
212
213 """
213 """
214
214
215 if not self.__withOverapping:
215 if not self.__withOverapping:
216 self.__buffer += data.copy()
216 self.__buffer += data.copy()
217 self.__profIndex += 1
217 self.__profIndex += 1
218 return
218 return
219
219
220 #Overlapping data
220 #Overlapping data
221 nChannels, nHeis = data.shape
221 nChannels, nHeis = data.shape
222 data = numpy.reshape(data, (1, nChannels, nHeis))
222 data = numpy.reshape(data, (1, nChannels, nHeis))
223
223
224 #If the buffer is empty then it takes the data value
224 #If the buffer is empty then it takes the data value
225 if self.__buffer is None:
225 if self.__buffer is None:
226 self.__buffer = data
226 self.__buffer = data
227 self.__profIndex += 1
227 self.__profIndex += 1
228 return
228 return
229
229
230 #If the buffer length is lower than n then stakcing the data value
230 #If the buffer length is lower than n then stakcing the data value
231 if self.__profIndex < self.n:
231 if self.__profIndex < self.n:
232 self.__buffer = numpy.vstack((self.__buffer, data))
232 self.__buffer = numpy.vstack((self.__buffer, data))
233 self.__profIndex += 1
233 self.__profIndex += 1
234 return
234 return
235
235
236 #If the buffer length is equal to n then replacing the last buffer value with the data value
236 #If the buffer length is equal to n then replacing the last buffer value with the data value
237 self.__buffer = numpy.roll(self.__buffer, -1, axis=0)
237 self.__buffer = numpy.roll(self.__buffer, -1, axis=0)
238 self.__buffer[self.n-1] = data
238 self.__buffer[self.n-1] = data
239 self.__profIndex = self.n
239 self.__profIndex = self.n
240 return
240 return
241
241
242
242
243 def pushData(self):
243 def pushData(self):
244 """
244 """
245 Return the sum of the last profiles and the profiles used in the sum.
245 Return the sum of the last profiles and the profiles used in the sum.
246
246
247 Affected:
247 Affected:
248
248
249 self.__profileIndex
249 self.__profileIndex
250
250
251 """
251 """
252
252
253 if not self.__withOverapping:
253 if not self.__withOverapping:
254 data = self.__buffer
254 data = self.__buffer
255 n = self.__profIndex
255 n = self.__profIndex
256
256
257 self.__buffer = 0
257 self.__buffer = 0
258 self.__profIndex = 0
258 self.__profIndex = 0
259
259
260 return data, n
260 return data, n
261
261
262 #Integration with Overlapping
262 #Integration with Overlapping
263 data = numpy.sum(self.__buffer, axis=0)
263 data = numpy.sum(self.__buffer, axis=0)
264 n = self.__profIndex
264 n = self.__profIndex
265
265
266 return data, n
266 return data, n
267
267
268 def byProfiles(self, data):
268 def byProfiles(self, data):
269
269
270 self.__dataReady = False
270 self.__dataReady = False
271 avgdata = None
271 avgdata = None
272 # n = None
272 # n = None
273
273
274 self.putData(data)
274 self.putData(data)
275
275
276 if self.__profIndex == self.n:
276 if self.__profIndex == self.n:
277
277
278 avgdata, n = self.pushData()
278 avgdata, n = self.pushData()
279 self.__dataReady = True
279 self.__dataReady = True
280
280
281 return avgdata
281 return avgdata
282
282
283 def byTime(self, data, datatime):
283 def byTime(self, data, datatime):
284
284
285 self.__dataReady = False
285 self.__dataReady = False
286 avgdata = None
286 avgdata = None
287 n = None
287 n = None
288
288
289 self.putData(data)
289 self.putData(data)
290
290
291 if (datatime - self.__initime) >= self.__integrationtime:
291 if (datatime - self.__initime) >= self.__integrationtime:
292 avgdata, n = self.pushData()
292 avgdata, n = self.pushData()
293 self.n = n
293 self.n = n
294 self.__dataReady = True
294 self.__dataReady = True
295
295
296 return avgdata
296 return avgdata
297
297
298 def integrate(self, data, datatime=None):
298 def integrate(self, data, datatime=None):
299
299
300 if self.__initime == None:
300 if self.__initime == None:
301 self.__initime = datatime
301 self.__initime = datatime
302
302
303 if self.__byTime:
303 if self.__byTime:
304 avgdata = self.byTime(data, datatime)
304 avgdata = self.byTime(data, datatime)
305 else:
305 else:
306 avgdata = self.byProfiles(data)
306 avgdata = self.byProfiles(data)
307
307
308
308
309 self.__lastdatatime = datatime
309 self.__lastdatatime = datatime
310
310
311 if avgdata is None:
311 if avgdata is None:
312 return None, None
312 return None, None
313
313
314 avgdatatime = self.__initime
314 avgdatatime = self.__initime
315
315
316 deltatime = datatime -self.__lastdatatime
316 deltatime = datatime -self.__lastdatatime
317
317
318 if not self.__withOverapping:
318 if not self.__withOverapping:
319 self.__initime = datatime
319 self.__initime = datatime
320 else:
320 else:
321 self.__initime += deltatime
321 self.__initime += deltatime
322
322
323 return avgdata, avgdatatime
323 return avgdata, avgdatatime
324
324
325 def run(self, dataOut, **kwargs):
325 def run(self, dataOut, **kwargs):
326
326
327 if not self.isConfig:
327 if not self.isConfig:
328 self.setup(**kwargs)
328 self.setup(**kwargs)
329 self.isConfig = True
329 self.isConfig = True
330
330
331 avgdata, avgdatatime = self.integrate(dataOut.data_spc, dataOut.utctime)
331 avgdata, avgdatatime = self.integrate(dataOut.data_spc, dataOut.utctime)
332
332
333 # dataOut.timeInterval *= n
333 # dataOut.timeInterval *= n
334 dataOut.flagNoData = True
334 dataOut.flagNoData = True
335
335
336 if self.__dataReady:
336 if self.__dataReady:
337 dataOut.data_spc = avgdata
337 dataOut.data_spc = avgdata
338 dataOut.nIncohInt *= self.n
338 dataOut.nIncohInt *= self.n
339 # dataOut.nCohInt *= self.n
339 # dataOut.nCohInt *= self.n
340 dataOut.utctime = avgdatatime
340 dataOut.utctime = avgdatatime
341 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nIncohInt
341 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nIncohInt
342 # dataOut.timeInterval = self.__timeInterval*self.n
342 # dataOut.timeInterval = self.__timeInterval*self.n
343 dataOut.flagNoData = False No newline at end of file
343 dataOut.flagNoData = False
General Comments 0
You need to be logged in to leave comments. Login now