diff --git a/schainpy/Controller/Controller.py b/schainpy/Controller/Controller.py index b9bd77f..2e17c3d 100644 --- a/schainpy/Controller/Controller.py +++ b/schainpy/Controller/Controller.py @@ -131,7 +131,8 @@ class ExecUnit: def integrator(*args): inputs = args[0] N = inputs[0] - self.execProcObj.integrator(N) + timeInterval = inputs[1] + self.execProcObj.integrator(N, timeInterval) pfuncDict = { "setup": setup, "getdata": getData, diff --git a/schainpy/Controller/experiment.cfg b/schainpy/Controller/experiment.cfg index 71e2ae7..ca7e331 100644 --- a/schainpy/Controller/experiment.cfg +++ b/schainpy/Controller/experiment.cfg @@ -10,14 +10,14 @@ type = Voltage input = 0 setup = None,None init = None,None -integrator = int,10 - +integrator = int,4,None,None +plotData = float,None,float,None,float,None,float,None,str,iq,str,Test Data Voltage 2,int,1 [Processing1] id = 2 type = Spectra input = 1 -setup = int,1024,None,None +setup = int,8,None,None init = None,None -integrator = int,2 -plotData = float,None,float,None,float,None,float,None,str,Test Spectra Data,int,1 +integrator = int,4,int,3 +plotData = float,None,float,None,float,None,float,None,str,Test Spectra Data,int,2 diff --git a/schainpy/Graphics/VoltagePlot.py b/schainpy/Graphics/VoltagePlot.py index 8f5295a..20f928e 100644 --- a/schainpy/Graphics/VoltagePlot.py +++ b/schainpy/Graphics/VoltagePlot.py @@ -121,10 +121,7 @@ class Osciloscope: self.__isPlotIni = True - def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, idProfile=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq', winTitle="Voltage"): - - if idProfile != None and idProfile != self.voltageObj.idProfile: - return + def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq', winTitle="Voltage"): if not(self.__isPlotConfig): self.setup(titleList, xlabelList, ylabelList, XAxisAsTime) @@ -136,7 +133,7 @@ class Osciloscope: data = self.voltageObj.data - x = self.voltageObj.heights + x = self.voltageObj.heightList if xmin == None: xmin = x[0] if xmax == None: xmax = x[-1] diff --git a/schainpy/Model/Spectra.py b/schainpy/Model/Spectra.py index a243d7c..cd6bf73 100644 --- a/schainpy/Model/Spectra.py +++ b/schainpy/Model/Spectra.py @@ -67,6 +67,8 @@ class Spectra(JROData): self.nFFTPoints = None + self.nAvg = None + self.nPairs = 0 self.pairsList = None diff --git a/schainpy/Model/Voltage.py b/schainpy/Model/Voltage.py index 47bd903..e2d98fe 100644 --- a/schainpy/Model/Voltage.py +++ b/schainpy/Model/Voltage.py @@ -53,7 +53,7 @@ class Voltage(JROData): self.flagResetProcessing = False - + self.nAvg = None self.profileIndex = None diff --git a/schainpy/Processing/SpectraProcessor.py b/schainpy/Processing/SpectraProcessor.py index f325e50..fd75b7d 100644 --- a/schainpy/Processing/SpectraProcessor.py +++ b/schainpy/Processing/SpectraProcessor.py @@ -140,6 +140,9 @@ class SpectraProcessor: self.dataOutObj.m_ProcessingHeader.spectraComb self.dataOutObj.m_ProcessingHeader.shif_fft """ + if self.dataInObj.flagNoData: + return 0 + blocksize = 0 nFFTPoints = self.nFFTPoints nChannels, nheis = self.dataInObj.data.shape @@ -150,7 +153,7 @@ class SpectraProcessor: self.buffer[:,self.ptsId,:] = self.dataInObj.data self.ptsId += 1 - if self.ptsId < self.dataOutObj.nFFTPoints: + if self.ptsId < self.nFFTPoints: self.dataOutObj.flagNoData = True return @@ -241,12 +244,11 @@ class SpectraProcessor: self.plotterObjList.append(plotObj) - def addIntegrator(self,N): + def addIntegrator(self,N,timeInterval): - objIncohInt = IncoherentIntegration(N) + objIncohInt = IncoherentIntegration(N,timeInterval) self.integratorObjList.append(objIncohInt) - def writeData(self, wrpath): if self.dataOutObj.flagNoData: return 0 @@ -269,21 +271,24 @@ class SpectraProcessor: self.plotterObjIndex += 1 - def integrator(self, N): + def integrator(self, N=None, timeInterval=None): + if self.dataOutObj.flagNoData: return 0 if len(self.integratorObjList) <= self.integratorObjIndex: - self.addIntegrator(N) + self.addIntegrator(N,timeInterval) - myCohIntObj = self.integratorObjList[self.integratorObjIndex] - myCohIntObj.exe(self.dataOutObj.data_spc) + myIncohIntObj = self.integratorObjList[self.integratorObjIndex] + myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc) - if myCohIntObj.flag: - self.dataOutObj.data_spc = myCohIntObj.data - self.dataOutObj.m_ProcessingHeader.incoherentInt *= N + if myIncohIntObj.isReady: + self.dataOutObj.data_spc = myIncohIntObj.data + self.dataOutObj.nAvg = myIncohIntObj.navg + self.dataOutObj.m_ProcessingHeader.incoherentInt *= myIncohIntObj.navg + #print "myIncohIntObj.navg: ",myIncohIntObj.navg self.dataOutObj.flagNoData = False - + else: self.dataOutObj.flagNoData = True @@ -418,7 +423,6 @@ class SpectraProcessor: self.dataOutObj.nChannels = nChannels self.dataOutObj.m_ProcessingHeader.blockSize = blocksize - def selectHeightsByValue(self, minHei, maxHei): """ Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango @@ -462,8 +466,7 @@ class SpectraProcessor: break self.selectHeightsByIndex(minIndex, maxIndex) - - + def selectHeightsByIndex(self, minIndex, maxIndex): """ Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango @@ -536,34 +539,82 @@ class SpectraProcessor: class IncoherentIntegration: - profCounter = 1 + integ_counter = None data = None + navg = None buffer = None - flag = False nIncohInt = None - def __init__(self, N): + def __init__(self, N = None, timeInterval = None): + """ + N + timeInterval - interval time [min], integer value + """ - self.profCounter = 1 self.data = None + self.navg = None self.buffer = None - self.flag = False + self.timeOut = None + self.exitCondition = False + self.isReady = False self.nIncohInt = N + self.integ_counter = 0 + if timeInterval!=None: + self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line + + if ((timeInterval==None) and (N==None)): + print 'N = None ; timeInterval = None' + sys.exit(0) + elif timeInterval == None: + self.timeFlag = False + else: + self.timeFlag = True + - def exe(self,data): + def exe(self,data,timeOfData): + """ + data + + timeOfData [seconds] + """ - if self.buffer == None: - self.buffer = data + if self.timeFlag: + if self.timeOut == None: + self.timeOut = timeOfData + self.timeIntervalInSeconds + + if timeOfData < self.timeOut: + if self.buffer == None: + self.buffer = data + else: + self.buffer = self.buffer + data + self.integ_counter += 1 + else: + self.exitCondition = True + else: - self.buffer = self.buffer + data - - if self.profCounter == self.nIncohInt: + if self.integ_counter < self.nIncohInt: + if self.buffer == None: + self.buffer = data + else: + self.buffer = self.buffer + data + + self.integ_counter += 1 + + if self.integ_counter == self.nIncohInt: + self.exitCondition = True + + if self.exitCondition: self.data = self.buffer + self.navg = self.integ_counter + self.isReady = True self.buffer = None - self.profCounter = 0 - self.flag = True - else: - self.flag = False + self.timeOut = None + self.integ_counter = 0 + self.exitCondition = False - self.profCounter += 1 - + if self.timeFlag: + self.buffer = data + self.timeOut = timeOfData + self.timeIntervalInSeconds + else: + self.isReady = False + \ No newline at end of file diff --git a/schainpy/Processing/VoltageProcessor.py b/schainpy/Processing/VoltageProcessor.py index 06d6c94..bb86cb1 100644 --- a/schainpy/Processing/VoltageProcessor.py +++ b/schainpy/Processing/VoltageProcessor.py @@ -102,9 +102,9 @@ class VoltageProcessor: plotObj = Osciloscope(self.dataOutObj, index) self.plotterObjList.append(plotObj) - def addIntegrator(self, nCohInt): + def addIntegrator(self, N,timeInterval): - objCohInt = CoherentIntegrator(nCohInt) + objCohInt = CoherentIntegrator(N,timeInterval) self.integratorObjList.append(objCohInt) def addDecoder(self, code, ncode, nbaud): @@ -143,20 +143,22 @@ class VoltageProcessor: self.plotterObjIndex += 1 - def integrator(self, N): + def integrator(self, N=None, timeInterval=None): if self.dataOutObj.flagNoData: return 0 if len(self.integratorObjList) <= self.integratorObjIndex: - self.addIntegrator(N) + self.addIntegrator(N,timeInterval) myCohIntObj = self.integratorObjList[self.integratorObjIndex] - myCohIntObj.exe(self.dataOutObj.data) + myCohIntObj.exe(data=self.dataOutObj.data,timeOfData=self.dataOutObj.m_BasicHeader.utc) - if myCohIntObj.flag: + if myCohIntObj.isReady: self.dataOutObj.data = myCohIntObj.data - self.dataOutObj.m_ProcessingHeader.coherentInt *= N + self.dataOutObj.nAvg = myCohIntObj.navg + self.dataOutObj.m_ProcessingHeader.coherentInt *= myCohIntObj.navg + #print "myCohIntObj.navg: ",myCohIntObj.navg self.dataOutObj.flagNoData = False else: @@ -480,36 +482,76 @@ class Decoder: class CoherentIntegrator: - profCounter = 1 + integ_counter = None data = None + navg = None buffer = None - flag = False nCohInt = None - def __init__(self, N): + def __init__(self, N=None,timeInterval=None): - self.profCounter = 1 self.data = None + self.navg = None self.buffer = None - self.flag = False + self.timeOut = None + self.exitCondition = False + self.isReady = False self.nCohInt = N + self.integ_counter = 0 + if timeInterval!=None: + self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line + + if ((timeInterval==None) and (N==None)): + print 'N = None ; timeInterval = None' + sys.exit(0) + elif timeInterval == None: + self.timeFlag = False + else: + self.timeFlag = True - def exe(self, data): + def exe(self, data, timeOfData): - if self.buffer == None: - self.buffer = data + if self.timeFlag: + if self.timeOut == None: + self.timeOut = timeOfData + self.timeIntervalInSeconds + + if timeOfData < self.timeOut: + if self.buffer == None: + self.buffer = data + else: + self.buffer = self.buffer + data + self.integ_counter += 1 + else: + self.exitCondition = True + else: - self.buffer = self.buffer + data - - if self.profCounter == self.nCohInt: + if self.integ_counter < self.nCohInt: + if self.buffer == None: + self.buffer = data + else: + self.buffer = self.buffer + data + + self.integ_counter += 1 + + if self.integ_counter == self.nCohInt: + self.exitCondition = True + + if self.exitCondition: self.data = self.buffer + self.navg = self.integ_counter + self.isReady = True self.buffer = None - self.profCounter = 0 - self.flag = True + self.timeOut = None + self.integ_counter = 0 + self.exitCondition = False + + if self.timeFlag: + self.buffer = data + self.timeOut = timeOfData + self.timeIntervalInSeconds else: - self.flag = False + self.isReady = False - self.profCounter += 1 + class ProfileSelector: