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