From d5210476252d58a3de57d4cf74853b101516dcb1 2012-11-26 13:43:09 From: Miguel Valdez Date: 2012-11-26 13:43:09 Subject: [PATCH] -Estandarizacion de los nombres de paquetes y modulos escritos en minusculas -Llamado del metodo setup dentro del metodo run en la clase CohInt --- diff --git a/schainpy/Controller/controller.py b/schainpy/controller/controller.py similarity index 85% rename from schainpy/Controller/controller.py rename to schainpy/controller/controller.py index a5e9e06..f44bf1c 100644 --- a/schainpy/Controller/controller.py +++ b/schainpy/controller/controller.py @@ -3,10 +3,17 @@ Created on September , 2012 @author: ''' from xml.etree.ElementTree import Element, SubElement, ElementTree -from element import prettify from xml.etree import ElementTree as ET +from xml.dom import minidom + import sys +def prettify(elem): + """Return a pretty-printed XML string for the Element. + """ + rough_string = ET.tostring(elem, 'utf-8') + reparsed = minidom.parseString(rough_string) + return reparsed.toprettyxml(indent=" ") #def save(a, b): # @@ -86,13 +93,24 @@ class Project(): ElementTree(self.projectElement).write(filename, method='xml') print prettify(self.projectElement) - def readXml(self,workspace): - print "Aqui estoy leyendo" - tree=ET.parse(workspace) - root=tree.getroot() - self.project=root.tag - self.idProyect= root.attrib.get('id') - self.nameProyect= root.attrib.get('name') + def readXml(self, filename): + + #tree = ET.parse(filename) + self.projectElement = None + tree = ElementTree(self.projectElement).parse(filename) + + self.project = self.projectElement.tag + + self.id = self.projectElement.get('id') + self.name = self.projectElement.get('name') + + readElement = self.projectElement.getiterator('readBranch') + + root = tree.getroot() + self.project = root.tag + self.id = root.attrib.get('id') + self.name = root.attrib.get('name') + for description in root.findall('description'): description = description.get('description') @@ -108,15 +126,6 @@ class Project(): self.idpb=id self.nameBranch=name # -# - print self.project - print self.idProyect - print self.nameProyect - print self.description - print self.idrb - print self.idpb - print self.nameBranch -# ####ESTO DEL MEDIO ESTABA COMENTADO # print root.tag , root.attrib # @@ -132,7 +141,7 @@ class Project(): # description=root.find('description').text # print description # ESTO FUNCIONABA HACIA ABAJO - print "Otra forma " + root=tree.getroot() print root.tag , root.attrib for child in root: @@ -331,7 +340,11 @@ class Parameter(): parmElement = SubElement(opElement, 'Parameter') parmElement.set('name', self.name) parmElement.set('value', self.value) + + def readXml(self, opElement): + + pass # se = SubElement(parmElement, 'value')#ESTO ES LO ULTIMO QUE SE TRABAJO # se.text = self.value @@ -340,8 +353,6 @@ if __name__ == '__main__': desc = "Este es un test" filename = "test.xml" - workspace=str("C:\\Users\\alex\\workspace\\GUIV2.0\\test.xml") - projectObj = Project() projectObj.setParms(id = '11', name='test01', description=desc) @@ -364,7 +375,10 @@ if __name__ == '__main__': opObj12.addParameter(name='code1', value='001110011') opObj12.addParameter(name='code2', value='001110011') + print "Escribiendo el XML" + projectObj.writeXml(filename) - projectObj.readXml(workspace) + print "Leyendo el XML" + projectObj.readXml(filename) \ No newline at end of file diff --git a/schainpy/Controller/controller1.py b/schainpy/controller/controller1.py similarity index 100% rename from schainpy/Controller/controller1.py rename to schainpy/controller/controller1.py diff --git a/schainpy/Model/JROData.py b/schainpy/model/jrodata.py similarity index 100% rename from schainpy/Model/JROData.py rename to schainpy/model/jrodata.py diff --git a/schainpy/Model/JRODataIO.py b/schainpy/model/jrodataIO.py similarity index 100% rename from schainpy/Model/JRODataIO.py rename to schainpy/model/jrodataIO.py diff --git a/schainpy/Model/JROHeaderIO.py b/schainpy/model/jroheaderIO.py similarity index 100% rename from schainpy/Model/JROHeaderIO.py rename to schainpy/model/jroheaderIO.py diff --git a/schainpy/Model/JROPlot.py b/schainpy/model/jroplot.py similarity index 100% rename from schainpy/Model/JROPlot.py rename to schainpy/model/jroplot.py diff --git a/schainpy/Model/JROProcessing.py b/schainpy/model/jroprocessing.py similarity index 88% rename from schainpy/Model/JROProcessing.py rename to schainpy/model/jroprocessing.py index 284eaa4..d4705f0 100644 --- a/schainpy/Model/JROProcessing.py +++ b/schainpy/model/jroprocessing.py @@ -155,6 +155,7 @@ class Operation(): """ __buffer = None + __isConfig = False def __init__(self): @@ -255,6 +256,7 @@ class CohInt(Operation): __byTime = False __initime = None + __lastdatatime = None __integrationtime = None __buffer = None @@ -266,7 +268,7 @@ class CohInt(Operation): def __init__(self): - pass + self.__isConfig = False def setup(self, nCohInt=None, timeInterval=None, overlapping=False): """ @@ -281,6 +283,7 @@ class CohInt(Operation): """ self.__initime = None + self.__lastdatatime = 0 self.__buffer = None self.__dataReady = False @@ -311,8 +314,6 @@ class CohInt(Operation): Add a profile to the __buffer and increase in one the __profileIndex """ - if self.__initime == None: - self.__initime = datatime if not self.__withOverapping: self.__buffer += data @@ -352,8 +353,6 @@ class CohInt(Operation): """ - self.__initime = None - if not self.__withOverapping: data = self.__buffer nCohInt = self.__profIndex @@ -373,6 +372,7 @@ class CohInt(Operation): self.__dataReady = False avg_data = None + nCohInt = None self.putData(data) @@ -387,7 +387,8 @@ class CohInt(Operation): self.__dataReady = False avg_data = None - + nCohInt = None + self.putData(data) if (datatime - self.__initime) >= self.__integrationtime: @@ -399,25 +400,45 @@ class CohInt(Operation): def integrate(self, data, datatime=None): - if not self.__byTime: - avg_data = self.byProfiles(data) + if self.__initime == None: + self.__initime = datatime + + if self.__byTime: + avgdata = self.byTime(data, datatime) else: - avg_data = self.byTime(data, datatime) + avgdata = self.byProfiles(data) - self.data = avg_data + self.__lastdatatime = datatime + + if avgdata == None: + return None + + avgdatatime = self.__initime + + deltatime = datatime -self.__lastdatatime + + if not self.__withOverapping: + self.__initime = datatime + else: + self.__initime += deltatime + + return avgdata, avgdatatime def run(self, dataOut, nCohInt=None, timeInterval=None, overlapping=False): + if not self.__isConfig: + self.setup(nCohInt, timeInterval, overlapping) + self.__isConfig = True + + avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) # self.dataOutObj.timeInterval *= nCohInt self.dataOutObj.flagNoData = True - if myCohIntObj.__dataReady: - self.dataOutObj.data = myCohIntObj.data - self.dataOutObj.timeInterval *= myCohIntObj.nCohInt - self.dataOutObj.nCohInt = myCohIntObj.nCohInt * self.dataInObj.nCohInt - self.dataOutObj.utctime = myCohIntObj.firstdatatime - self.dataOutObj.flagNoData = False - - return avg_data \ No newline at end of file + if self.__dataReady: + dataOutObj.data = avgdata + dataOutObj.timeInterval *= self.nCohInt + dataOutObj.nCohInt *= self.nCohInt + dataOutObj.utctime = avgdatatime + dataOutObj.flagNoData = False \ No newline at end of file