From 70dd31f0d29439145f1372bedf9481f3ea4e6c2f 2012-12-05 03:28:10 From: Miguel Valdez Date: 2012-12-05 03:28:10 Subject: [PATCH] Se agrego selectHeisa VoltageProc --- diff --git a/schainpy/controller.py b/schainpy/controller.py index ddfb54e..8759f41 100644 --- a/schainpy/controller.py +++ b/schainpy/controller.py @@ -258,7 +258,15 @@ class ProcUnitConf(): self.opConfObjList = [] self.addOperation(name='init', optype='self') + + def addParameter(self, **kwargs): + + opObj = self.opConfObjList[0] + + opObj.addParameter(**kwargs) + return opObj + def addOperation(self, name, optype='self'): id = self.__getNewId() @@ -585,36 +593,47 @@ if __name__ == '__main__': controllerObj.setup(id = '191', name='test01', description=desc) - readUnitConfObj = controllerObj.addReadUnit(datatype='Spectra', - path='/Users/dsuarez/Remote/IMAGING', - startDate='2011/03/20', + readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', + path='data/rawdata/', + startDate='2011/01/01', endDate='2012/12/31', - startTime='06:10:00', + startTime='00:00:00', endTime='23:59:59', online=0) opObj00 = readUnitConfObj.addOperation(name='printTotalBlocks') - procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId()) + procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) + + opObj10 = procUnitConfObj0.addOperation(name='selectChannels') + opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') + + opObj10 = procUnitConfObj0.addOperation(name='selectHeights') + opObj10.addParameter(name='minHei', value='90', format='float') + opObj10.addParameter(name='maxHei', value='180', format='float') + + opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='other') + opObj12.addParameter(name='n', value='10', format='int') - opObj10 = procUnitConfObj1.addOperation(name='selectChannels') - opObj10.addParameter(name='channelList', value='0,1,2,4,6,7', format='intlist') + procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) + procUnitConfObj1.addParameter(name='nFFTPoints', value='16', format='int') opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') opObj11.addParameter(name='idfigure', value='1', format='int') opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str') -# opObj11.addParameter(name='zmin', value='70', format='int') -# opObj11.addParameter(name='zmax', value='90', format='int') - opObj11.addParameter(name='showprofile', value='0', format='int') - opObj11.addParameter(name='save', value='1', format='int') - opObj11.addParameter(name='filename', value='/Users/dsuarez/Pictures/SpectraPlot.png', format='str') + opObj11.addParameter(name='zmin', value='40', format='int') + opObj11.addParameter(name='zmax', value='80', format='int') + opObj11.addParameter(name='showprofile', value='1', format='int') opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') opObj11.addParameter(name='idfigure', value='10', format='int') opObj11.addParameter(name='wintitle', value='RTI', format='str') -# opObj11.addParameter(name='zmin', value='70', format='int') -# opObj11.addParameter(name='zmax', value='90', format='int') - opObj11.addParameter(name='showprofile', value='0', format='int') +# opObj11.addParameter(name='xmin', value='21', format='float') +# opObj11.addParameter(name='xmax', value='22', format='float') + opObj11.addParameter(name='zmin', value='40', format='int') + opObj11.addParameter(name='zmax', value='80', format='int') + opObj11.addParameter(name='showprofile', value='1', format='int') + opObj11.addParameter(name='timerange', value=str(20), format='int') # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') # opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist') diff --git a/schainpy/model/jroheaderIO.py b/schainpy/model/jroheaderIO.py index 0dabe74..6770bde 100644 --- a/schainpy/model/jroheaderIO.py +++ b/schainpy/model/jroheaderIO.py @@ -367,8 +367,8 @@ class ProcessingHeader(Header): self.totalSpectra = int(header['nTotalSpectra'][0]) self.samplingWindow = numpy.fromfile(fp,self.structSamplingWindow,self.nWindows) self.nHeights = int(numpy.sum(self.samplingWindow['nsa'])) - self.firstHeight = int(self.samplingWindow['h0'][0]) - self.deltaHeight = int(self.samplingWindow['dh'][0]) + self.firstHeight = float(self.samplingWindow['h0'][0]) + self.deltaHeight = float(self.samplingWindow['dh'][0]) self.samplesWin = self.samplingWindow['nsa'] self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra) diff --git a/schainpy/model/jroprocessing.py b/schainpy/model/jroprocessing.py index 7ec2cf6..181c5a1 100644 --- a/schainpy/model/jroprocessing.py +++ b/schainpy/model/jroprocessing.py @@ -266,6 +266,87 @@ class VoltageProc(ProcessingUnit): # self.dataOut.nChannels = nChannels return 1 + + def selectHeights(self, minHei, maxHei): + """ + Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango + minHei <= height <= maxHei + + Input: + minHei : valor minimo de altura a considerar + maxHei : valor maximo de altura a considerar + + Affected: + Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex + + Return: + 1 si el metodo se ejecuto con exito caso contrario devuelve 0 + """ + if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): + raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) + + if (maxHei > self.dataOut.heightList[-1]): + maxHei = self.dataOut.heightList[-1] +# raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) + + minIndex = 0 + maxIndex = 0 + data = self.dataOut.heightList + + for i,val in enumerate(data): + if val < minHei: + continue + else: + minIndex = i; + break + + for i,val in enumerate(data): + if val <= maxHei: + maxIndex = i; + else: + break + + self.selectHeightsByIndex(minIndex, maxIndex) + + return 1 + + + def selectHeightsByIndex(self, minIndex, maxIndex): + """ + Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango + minIndex <= index <= maxIndex + + Input: + minIndex : valor de indice minimo de altura a considerar + maxIndex : valor de indice maximo de altura a considerar + + Affected: + self.dataOut.data + self.dataOut.heightList + + Return: + 1 si el metodo se ejecuto con exito caso contrario devuelve 0 + """ + + if (minIndex < 0) or (minIndex > maxIndex): + raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) + + if (maxIndex >= self.dataOut.nHeights): + maxIndex = self.dataOut.nHeights-1 +# raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) + + nHeights = maxIndex - minIndex + 1 + + #voltage + data = self.dataOut.data[:,minIndex:maxIndex+1] + + firstHeight = self.dataOut.heightList[minIndex] + + self.dataOut.data = data + self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex+1] + + return 1 + class CohInt(Operation): @@ -494,8 +575,9 @@ class SpectraProc(ProcessingUnit): self.dataOut.nCohInt = self.dataIn.nCohInt self.dataOut.nIncohInt = 1 self.dataOut.ippSeconds = self.dataIn.ippSeconds - self.dataOut.timeInterval = self.dataIn.timeInterval*self.dataOut.nFFTPoints*self.dataOut.nConInt*self.dataOut.nIncohInt - + + self.dataOut.timeInterval = self.dataIn.timeInterval*self.dataOut.nFFTPoints*self.dataOut.nCohInt*self.dataOut.nIncohInt + def __getFft(self): """ Convierte valores de Voltaje a Spectra