@@ -3,10 +3,17 Created on September , 2012 | |||
|
3 | 3 | @author: |
|
4 | 4 | ''' |
|
5 | 5 | from xml.etree.ElementTree import Element, SubElement, ElementTree |
|
6 | from element import prettify | |
|
7 | 6 | from xml.etree import ElementTree as ET |
|
7 | from xml.dom import minidom | |
|
8 | ||
|
8 | 9 | import sys |
|
9 | 10 | |
|
11 | def prettify(elem): | |
|
12 | """Return a pretty-printed XML string for the Element. | |
|
13 | """ | |
|
14 | rough_string = ET.tostring(elem, 'utf-8') | |
|
15 | reparsed = minidom.parseString(rough_string) | |
|
16 | return reparsed.toprettyxml(indent=" ") | |
|
10 | 17 | |
|
11 | 18 | #def save(a, b): |
|
12 | 19 | # |
@@ -86,13 +93,24 class Project(): | |||
|
86 | 93 | ElementTree(self.projectElement).write(filename, method='xml') |
|
87 | 94 | print prettify(self.projectElement) |
|
88 | 95 | |
|
89 |
def readXml(self, |
|
|
90 | print "Aqui estoy leyendo" | |
|
91 |
tree=ET.parse( |
|
|
92 | root=tree.getroot() | |
|
93 | self.project=root.tag | |
|
94 | self.idProyect= root.attrib.get('id') | |
|
95 | self.nameProyect= root.attrib.get('name') | |
|
96 | def readXml(self, filename): | |
|
97 | ||
|
98 | #tree = ET.parse(filename) | |
|
99 | self.projectElement = None | |
|
100 | tree = ElementTree(self.projectElement).parse(filename) | |
|
101 | ||
|
102 | self.project = self.projectElement.tag | |
|
103 | ||
|
104 | self.id = self.projectElement.get('id') | |
|
105 | self.name = self.projectElement.get('name') | |
|
106 | ||
|
107 | readElement = self.projectElement.getiterator('readBranch') | |
|
108 | ||
|
109 | root = tree.getroot() | |
|
110 | self.project = root.tag | |
|
111 | self.id = root.attrib.get('id') | |
|
112 | self.name = root.attrib.get('name') | |
|
113 | ||
|
96 | 114 | for description in root.findall('description'): |
|
97 | 115 | description = description.get('description') |
|
98 | 116 | |
@@ -108,15 +126,6 class Project(): | |||
|
108 | 126 | self.idpb=id |
|
109 | 127 | self.nameBranch=name |
|
110 | 128 | # |
|
111 | # | |
|
112 | print self.project | |
|
113 | print self.idProyect | |
|
114 | print self.nameProyect | |
|
115 | print self.description | |
|
116 | print self.idrb | |
|
117 | print self.idpb | |
|
118 | print self.nameBranch | |
|
119 | # | |
|
120 | 129 | ####ESTO DEL MEDIO ESTABA COMENTADO |
|
121 | 130 | # print root.tag , root.attrib |
|
122 | 131 | # |
@@ -132,7 +141,7 class Project(): | |||
|
132 | 141 | # description=root.find('description').text |
|
133 | 142 | # print description |
|
134 | 143 | # ESTO FUNCIONABA HACIA ABAJO |
|
135 | print "Otra forma " | |
|
144 | ||
|
136 | 145 | root=tree.getroot() |
|
137 | 146 | print root.tag , root.attrib |
|
138 | 147 | for child in root: |
@@ -331,7 +340,11 class Parameter(): | |||
|
331 | 340 | parmElement = SubElement(opElement, 'Parameter') |
|
332 | 341 | parmElement.set('name', self.name) |
|
333 | 342 | parmElement.set('value', self.value) |
|
343 | ||
|
344 | def readXml(self, opElement): | |
|
334 | 345 | |
|
346 | ||
|
347 | pass | |
|
335 | 348 | # se = SubElement(parmElement, 'value')#ESTO ES LO ULTIMO QUE SE TRABAJO |
|
336 | 349 | # se.text = self.value |
|
337 | 350 | |
@@ -340,8 +353,6 if __name__ == '__main__': | |||
|
340 | 353 | desc = "Este es un test" |
|
341 | 354 | filename = "test.xml" |
|
342 | 355 | |
|
343 | workspace=str("C:\\Users\\alex\\workspace\\GUIV2.0\\test.xml") | |
|
344 | ||
|
345 | 356 | projectObj = Project() |
|
346 | 357 | |
|
347 | 358 | projectObj.setParms(id = '11', name='test01', description=desc) |
@@ -364,7 +375,10 if __name__ == '__main__': | |||
|
364 | 375 | opObj12.addParameter(name='code1', value='001110011') |
|
365 | 376 | opObj12.addParameter(name='code2', value='001110011') |
|
366 | 377 | |
|
378 | print "Escribiendo el XML" | |
|
379 | ||
|
367 | 380 | projectObj.writeXml(filename) |
|
368 | 381 | |
|
369 | projectObj.readXml(workspace) | |
|
382 | print "Leyendo el XML" | |
|
383 | projectObj.readXml(filename) | |
|
370 | 384 | No newline at end of file |
|
1 | NO CONTENT: file renamed from schainpy/Controller/controller1.py to schainpy/controller/controller1.py |
|
1 | NO CONTENT: file renamed from schainpy/Model/JROData.py to schainpy/model/jrodata.py |
|
1 | NO CONTENT: file renamed from schainpy/Model/JRODataIO.py to schainpy/model/jrodataIO.py |
|
1 | NO CONTENT: file renamed from schainpy/Model/JROHeaderIO.py to schainpy/model/jroheaderIO.py |
|
1 | NO CONTENT: file renamed from schainpy/Model/JROPlot.py to schainpy/model/jroplot.py |
@@ -155,6 +155,7 class Operation(): | |||
|
155 | 155 | """ |
|
156 | 156 | |
|
157 | 157 | __buffer = None |
|
158 | __isConfig = False | |
|
158 | 159 | |
|
159 | 160 | def __init__(self): |
|
160 | 161 | |
@@ -255,6 +256,7 class CohInt(Operation): | |||
|
255 | 256 | |
|
256 | 257 | __byTime = False |
|
257 | 258 | __initime = None |
|
259 | __lastdatatime = None | |
|
258 | 260 | __integrationtime = None |
|
259 | 261 | |
|
260 | 262 | __buffer = None |
@@ -266,7 +268,7 class CohInt(Operation): | |||
|
266 | 268 | |
|
267 | 269 | def __init__(self): |
|
268 | 270 | |
|
269 | pass | |
|
271 | self.__isConfig = False | |
|
270 | 272 | |
|
271 | 273 | def setup(self, nCohInt=None, timeInterval=None, overlapping=False): |
|
272 | 274 | """ |
@@ -281,6 +283,7 class CohInt(Operation): | |||
|
281 | 283 | """ |
|
282 | 284 | |
|
283 | 285 | self.__initime = None |
|
286 | self.__lastdatatime = 0 | |
|
284 | 287 | self.__buffer = None |
|
285 | 288 | self.__dataReady = False |
|
286 | 289 | |
@@ -311,8 +314,6 class CohInt(Operation): | |||
|
311 | 314 | Add a profile to the __buffer and increase in one the __profileIndex |
|
312 | 315 | |
|
313 | 316 | """ |
|
314 | if self.__initime == None: | |
|
315 | self.__initime = datatime | |
|
316 | 317 | |
|
317 | 318 | if not self.__withOverapping: |
|
318 | 319 | self.__buffer += data |
@@ -352,8 +353,6 class CohInt(Operation): | |||
|
352 | 353 | |
|
353 | 354 | """ |
|
354 | 355 | |
|
355 | self.__initime = None | |
|
356 | ||
|
357 | 356 | if not self.__withOverapping: |
|
358 | 357 | data = self.__buffer |
|
359 | 358 | nCohInt = self.__profIndex |
@@ -373,6 +372,7 class CohInt(Operation): | |||
|
373 | 372 | |
|
374 | 373 | self.__dataReady = False |
|
375 | 374 | avg_data = None |
|
375 | nCohInt = None | |
|
376 | 376 | |
|
377 | 377 | self.putData(data) |
|
378 | 378 | |
@@ -387,7 +387,8 class CohInt(Operation): | |||
|
387 | 387 | |
|
388 | 388 | self.__dataReady = False |
|
389 | 389 | avg_data = None |
|
390 | ||
|
390 | nCohInt = None | |
|
391 | ||
|
391 | 392 | self.putData(data) |
|
392 | 393 | |
|
393 | 394 | if (datatime - self.__initime) >= self.__integrationtime: |
@@ -399,25 +400,45 class CohInt(Operation): | |||
|
399 | 400 | |
|
400 | 401 | def integrate(self, data, datatime=None): |
|
401 | 402 | |
|
402 |
if |
|
|
403 | avg_data = self.byProfiles(data) | |
|
403 | if self.__initime == None: | |
|
404 | self.__initime = datatime | |
|
405 | ||
|
406 | if self.__byTime: | |
|
407 | avgdata = self.byTime(data, datatime) | |
|
404 | 408 | else: |
|
405 |
avg |
|
|
409 | avgdata = self.byProfiles(data) | |
|
406 | 410 | |
|
407 | self.data = avg_data | |
|
408 | 411 | |
|
412 | self.__lastdatatime = datatime | |
|
413 | ||
|
414 | if avgdata == None: | |
|
415 | return None | |
|
416 | ||
|
417 | avgdatatime = self.__initime | |
|
418 | ||
|
419 | deltatime = datatime -self.__lastdatatime | |
|
420 | ||
|
421 | if not self.__withOverapping: | |
|
422 | self.__initime = datatime | |
|
423 | else: | |
|
424 | self.__initime += deltatime | |
|
425 | ||
|
426 | return avgdata, avgdatatime | |
|
409 | 427 | |
|
410 | 428 | def run(self, dataOut, nCohInt=None, timeInterval=None, overlapping=False): |
|
411 | 429 | |
|
430 | if not self.__isConfig: | |
|
431 | self.setup(nCohInt, timeInterval, overlapping) | |
|
432 | self.__isConfig = True | |
|
433 | ||
|
434 | avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) | |
|
412 | 435 | |
|
413 | 436 | # self.dataOutObj.timeInterval *= nCohInt |
|
414 | 437 | self.dataOutObj.flagNoData = True |
|
415 | 438 | |
|
416 |
if |
|
|
417 |
|
|
|
418 |
|
|
|
419 |
|
|
|
420 |
|
|
|
421 |
|
|
|
422 | ||
|
423 | return avg_data No newline at end of file | |
|
439 | if self.__dataReady: | |
|
440 | dataOutObj.data = avgdata | |
|
441 | dataOutObj.timeInterval *= self.nCohInt | |
|
442 | dataOutObj.nCohInt *= self.nCohInt | |
|
443 | dataOutObj.utctime = avgdatatime | |
|
444 | dataOutObj.flagNoData = False No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now