diff --git a/schainpy/model/proc/jroproc_spectra.py b/schainpy/model/proc/jroproc_spectra.py index deb38cf..3cb5600 100644 --- a/schainpy/model/proc/jroproc_spectra.py +++ b/schainpy/model/proc/jroproc_spectra.py @@ -18,7 +18,7 @@ class SpectraProc(ProcessingUnit): self.id_min = None self.id_max = None - def __updateObjFromInput(self): + def __updateSpecFromVoltage(self): self.dataOut.timeZone = self.dataIn.timeZone self.dataOut.dstFlag = self.dataIn.dstFlag @@ -30,24 +30,23 @@ class SpectraProc(ProcessingUnit): self.dataOut.channelList = self.dataIn.channelList self.dataOut.heightList = self.dataIn.heightList self.dataOut.dtype = numpy.dtype([('real',' change this line - self.n = 9999 + self.__integrationtime = int(timeInterval) #if (type(timeInterval)!=integer) -> change this line + self.n = None self.__byTime = True - - if overlapping: - self.__withOverapping = True - else: - self.__withOverapping = False - self.__buffer_spc = 0 - self.__buffer_cspc = 0 - self.__buffer_dc = 0 - - self.__profIndex = 0 def putData(self, data_spc, data_cspc, data_dc): @@ -773,76 +766,22 @@ class IncohInt(Operation): """ - if not self.__withOverapping: - self.__buffer_spc += data_spc - - if data_cspc is None: - self.__buffer_cspc = None - else: - self.__buffer_cspc += data_cspc - - if data_dc is None: - self.__buffer_dc = None - else: - self.__buffer_dc += data_dc - - self.__profIndex += 1 - return - - #Overlapping data - nChannels, nFFTPoints, nHeis = data_spc.shape - data_spc = numpy.reshape(data_spc, (1, nChannels, nFFTPoints, nHeis)) - if data_cspc is not None: - data_cspc = numpy.reshape(data_cspc, (1, -1, nFFTPoints, nHeis)) - if data_dc is not None: - data_dc = numpy.reshape(data_dc, (1, -1, nHeis)) - - #If the buffer is empty then it takes the data value - if self.__buffer_spc is None: - self.__buffer_spc = data_spc - - if data_cspc is None: - self.__buffer_cspc = None - else: - self.__buffer_cspc += data_cspc - - if data_dc is None: - self.__buffer_dc = None - else: - self.__buffer_dc += data_dc - - self.__profIndex += 1 - return + self.__buffer_spc += data_spc - #If the buffer length is lower than n then stakcing the data value - if self.__profIndex < self.n: - self.__buffer_spc = numpy.vstack((self.__buffer_spc, data_spc)) - - if data_cspc is not None: - self.__buffer_cspc = numpy.vstack((self.__buffer_cspc, data_cspc)) - - if data_dc is not None: - self.__buffer_dc = numpy.vstack((self.__buffer_dc, data_dc)) - - self.__profIndex += 1 - return - - #If the buffer length is equal to n then replacing the last buffer value with the data value - self.__buffer_spc = numpy.roll(self.__buffer_spc, -1, axis=0) - self.__buffer_spc[self.n-1] = data_spc - - if data_cspc is not None: - self.__buffer_cspc = numpy.roll(self.__buffer_cspc, -1, axis=0) - self.__buffer_cspc[self.n-1] = data_cspc + if data_cspc is None: + self.__buffer_cspc = None + else: + self.__buffer_cspc += data_cspc - if data_dc is not None: - self.__buffer_dc = numpy.roll(self.__buffer_dc, -1, axis=0) - self.__buffer_dc[self.n-1] = data_dc + if data_dc is None: + self.__buffer_dc = None + else: + self.__buffer_dc += data_dc - self.__profIndex = self.n + self.__profIndex += 1 + return - def pushData(self): """ Return the sum of the last profiles and the profiles used in the sum. @@ -852,50 +791,29 @@ class IncohInt(Operation): self.__profileIndex """ - data_spc = None - data_cspc = None - data_dc = None - - if not self.__withOverapping: - data_spc = self.__buffer_spc - data_cspc = self.__buffer_cspc - data_dc = self.__buffer_dc - - n = self.__profIndex - - self.__buffer_spc = 0 - self.__buffer_cspc = 0 - self.__buffer_dc = 0 - self.__profIndex = 0 - - return data_spc, data_cspc, data_dc, n - - #Integration with Overlapping - data_spc = numpy.sum(self.__buffer_spc, axis=0) - - if self.__buffer_cspc is not None: - data_cspc = numpy.sum(self.__buffer_cspc, axis=0) - - if self.__buffer_dc is not None: - data_dc = numpy.sum(self.__buffer_dc, axis=0) + data_spc = self.__buffer_spc + data_cspc = self.__buffer_cspc + data_dc = self.__buffer_dc n = self.__profIndex + + self.__buffer_spc = 0 + self.__buffer_cspc = 0 + self.__buffer_dc = 0 + self.__profIndex = 0 return data_spc, data_cspc, data_dc, n def byProfiles(self, *args): self.__dataReady = False - avgdata_spc = None - avgdata_cspc = None - avgdata_dc = None -# n = None self.putData(*args) if self.__profIndex == self.n: avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() + self.n = n self.__dataReady = True return avgdata_spc, avgdata_cspc, avgdata_dc @@ -903,10 +821,6 @@ class IncohInt(Operation): def byTime(self, datatime, *args): self.__dataReady = False - avgdata_spc = None - avgdata_cspc = None - avgdata_dc = None - n = None self.putData(*args) @@ -919,7 +833,7 @@ class IncohInt(Operation): def integrate(self, datatime, *args): - if self.__initime == None: + if self.__profIndex == 0: self.__initime = datatime if self.__byTime: @@ -927,32 +841,18 @@ class IncohInt(Operation): else: avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(*args) - self.__lastdatatime = datatime - - if avgdata_spc is None: + if not self.__dataReady: return None, None, None, None - - avgdatatime = self.__initime - try: - self.__timeInterval = (self.__lastdatatime - self.__initime)/(self.n - 1) - except: - self.__timeInterval = self.__lastdatatime - self.__initime - - deltatime = datatime -self.__lastdatatime - - if not self.__withOverapping: - self.__initime = datatime - else: - self.__initime += deltatime - return avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc + return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc def run(self, dataOut, n=None, timeInterval=None, overlapping=False): if n==1: - dataOut.flagNoData = False return + dataOut.flagNoData = True + if not self.isConfig: self.setup(n, timeInterval, overlapping) self.isConfig = True @@ -962,9 +862,6 @@ class IncohInt(Operation): dataOut.data_cspc, dataOut.data_dc) -# dataOut.timeInterval *= n - dataOut.flagNoData = True - if self.__dataReady: dataOut.data_spc = avgdata_spc @@ -973,6 +870,4 @@ class IncohInt(Operation): dataOut.nIncohInt *= self.n dataOut.utctime = avgdatatime - #dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt * dataOut.nIncohInt * dataOut.nFFTPoints -# dataOut.timeInterval = self.__timeInterval*self.n dataOut.flagNoData = False