diff --git a/schainpy/Processing/VoltageProcessor.py b/schainpy/Processing/VoltageProcessor.py index c67f84d..5114f9f 100644 --- a/schainpy/Processing/VoltageProcessor.py +++ b/schainpy/Processing/VoltageProcessor.py @@ -37,13 +37,12 @@ class VoltageProcessor: plotterObjList = [] m_Voltage= Voltage() - m_ProfileSelector= ProfileSelector() + m_ProfileSelector = ProfileSelector() - m_Decoder= Decoder() + m_Decoder = Decoder() - m_CoherentIntegrator= CoherentIntegrator() - - + m_CoherentIntegrator = CoherentIntegrator() + def __init__(self, dataInObj, dataOutObj=None): ''' Constructor @@ -205,7 +204,7 @@ class VoltageProcessor: def selectChannels(self, channelList): """ - Selecciona un bloque de datos en base a canales y pares segun el channelList y el pairList + Selecciona un bloque de datos en base a canales segun el channelList Input: channelList : lista sencilla de canales a seleccionar por ej. [2,3,7] @@ -228,19 +227,16 @@ class VoltageProcessor: if channel not in self.dataOutObj.channelList: raise ValueError, "The value %d in channelList is not valid" %channel - nchannels = len(channelList) - profiles = self.dataOutObj.nProfiles - heights = self.dataOutObj.nHeights #m_ProcessingHeader.numHeights - - data = numpy.zeros( (nchannels,heights), dtype='complex' ) - for index,channel in enumerate(channelList): - data[index,:] = self.dataOutObj.data[channel,:] - + nChannels = len(channelList) + + data = self.dataOutObj.data[channelList,:] + self.dataOutObj.data = data self.dataOutObj.channelList = channelList - self.dataOutObj.nChannels = nchannels - self.dataOutObj.m_ProcessingHeader.totalSpectra = nchannels - self.dataOutObj.m_SystemHeader.numChannels = nchannels + self.dataOutObj.nChannels = nChannels + + self.dataOutObj.m_ProcessingHeader.totalSpectra = nChannels + self.dataOutObj.m_SystemHeader.numChannels = nChannels self.dataOutObj.m_ProcessingHeader.blockSize = data.size return 1 @@ -321,7 +317,6 @@ class VoltageProcessor: raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) nHeights = maxIndex - minIndex + 1 - firstHeight = 0 #voltage data = self.dataOutObj.data[:,minIndex:maxIndex+1] @@ -401,13 +396,11 @@ class Decoder: data = None profCounter = 1 - nCode = ncode - nBaud = nbaud + nCode = None + nBaud = None codeIndex = 0 - code = code #this is a List - fft_code = None + code = None flag = False - setCodeFft = False def __init__(self,code, ncode, nbaud): @@ -417,9 +410,7 @@ class Decoder: self.nBaud = nbaud self.codeIndex = 0 self.code = code #this is a List - self.fft_code = None self.flag = False - self.setCodeFft = False def exe(self, data, ndata=None, type = 0): @@ -445,9 +436,7 @@ class Decoder: conv = fft_data.copy() conv.fill(0) - conv = fft_data*fft_code # This other way to calculate multiplication between bidimensional arrays - # for i in range(ndata): - # conv[i,:] = fft_data[i,:]*fft_code[i] + conv = fft_data*fft_code self.data = numpy.fft.ifft(conv,axis=1) self.flag = True @@ -483,7 +472,7 @@ class CoherentIntegrator: data = None buffer = None flag = False - nCohInt = N + nCohInt = None def __init__(self, N): diff --git a/schainpy/TestSChain.py b/schainpy/TestSChain.py deleted file mode 100644 index c7d1f9d..0000000 --- a/schainpy/TestSChain.py +++ /dev/null @@ -1,98 +0,0 @@ -''' -Created on 23/01/2012 - -@author $Author$ -@version $Id$ -''' -import os, sys -import time, datetime - -from Model.Voltage import Voltage -from IO.VoltageIO import * -from Graphics.VoltagePlot import Osciloscope - -from Model.Spectra import Spectra -from IO.SpectraIO import * -from Graphics.SpectraPlot import Spectrum - -class TestSChain(): - - - def __init__(self): - self.setValues() - self.createObjects() - self.setupObjects() - self.testSChain() - pass - - def setValues(self): - - self.path = '/home/roj-idl71/Data/RAWDATA/DP_Faraday/' - self.path = '/Users/danielangelsuarezmunoz/Documents/Projects/testWR' - self.path = '/home/roj-idl71/Data/RAWDATA/IMAGING' - #self.path = '/remote/puma/2011_08/E-F_Valley' - #self.path = '/remote/puma/2011_12/EEJ+150km+ONAXIS+ESF+Twilight/Twilight/' - self.path = '/home/roj-idl71/tmp/data/' - - self.ppath = "/home/roj-idl71/tmp/data" - self.startDateTime = datetime.datetime(2011,1,31,0,20,0) - self.endDateTime = datetime.datetime(2011,12,5,18,10,0) - - def createObjects(self): - -# self.Obj = Voltage() -# self.readerObj = VoltageReader(self.Obj) -# self.plotObj = Osciloscope(self.Obj) -# self.writerObj = VoltageWriter(self.Obj) - - self.Obj = Spectra() - self.readerObj = SpectraReader(self.Obj) - self.plotObj = Spectrum(self.Obj) -# self.writerObj = SpectraWriter(self.Obj) - - def setupObjects(self): - - if not(self.readerObj.setup(self.path, self.startDateTime, self.endDateTime, expLabel='', online = 0)): - sys.exit(0) - - print "Parameters:" - - print "Num profiles: %s" %(self.readerObj.m_SystemHeader.numProfiles) - print "Num samples: %s" %(self.readerObj.m_SystemHeader.numSamples) - print "Num channels: %s" %(self.readerObj.m_SystemHeader.numChannels) - - print "Num profiles per block: %s" %(self.readerObj.m_ProcessingHeader.profilesPerBlock) - print "Num heights: %s" %(self.readerObj.m_ProcessingHeader.numHeights) - print "Num coh int: %s" %(self.readerObj.m_ProcessingHeader.coherentInt) - print "Num incoh int: %s" %(self.readerObj.m_ProcessingHeader.incoherentInt) - - print "Num code: %d" %(self.readerObj.m_ProcessingHeader.numCode) - print "Num baud: %d" %(self.readerObj.m_ProcessingHeader.numBaud) - -# if not(self.writerObj.setup(self.ppath)): -# sys.exit(0) - - def testSChain(self): - - ini = time.time() - while(True): - self.readerObj.getData() - self.plotObj.plotData(zmin=40, zmax=140, showColorbar=True, showPowerProfile=True) - #self.plotObj.plotData(idProfile=1, type="power") -# self.writerObj.putData() - - if self.readerObj.noMoreFiles: - break - - if self.readerObj.flagIsNewBlock: - print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks, - datetime.datetime.fromtimestamp(self.readerObj.m_BasicHeader.utc),) - fin = time.time() - print 'Tiempo de un bloque leido y escrito: [%6.5f]' %(fin - ini) - ini = time.time() - - #time.sleep(0.5) - self.plotObj.end() - -if __name__ == '__main__': - TestSChain() \ No newline at end of file