##// END OF EJS Templates
Se ha definido que el arreglo de datos debe tener el formato [canales, perfiles, alturas]; se han modificado los metodos de lectura, escritura, ploteo, procesamiento que estan relacionados.
Daniel Valdez -
r73:ea60e7ccc5aa
parent child
Show More
@@ -130,7 +130,7 class Spectrum():
130 130 data = 10.*numpy.log10(self.m_Spectra.data_spc)
131 131
132 132 #data.shape = Channels x Heights x Profiles
133 data = numpy.transpose( data, (0,2,1) )
133 # data = numpy.transpose( data, (0,2,1) )
134 134 #data.shape = Channels x Profiles x Heights
135 135
136 136 nChan, nX, nY = numpy.shape(data)
@@ -70,13 +70,13 class Osciloscope():
70 70 myXlabel = ""
71 71 myYlabel = ""
72 72
73 for i in range(nChan):
73 for chan in range(nChan):
74 74 if titleList != None:
75 myTitle = titleList[i]
76 myXlabel = xlabelList[i]
77 myYlabel = ylabelList[i]
75 myTitle = titleList[chan]
76 myXlabel = xlabelList[chan]
77 myYlabel = ylabelList[chan]
78 78
79 self.__addGraph(i+1, title=myTitle, xlabel=myXlabel, ylabel=myYlabel, XAxisAsTime=XAxisAsTime)
79 self.__addGraph(chan+1, title=myTitle, xlabel=myXlabel, ylabel=myYlabel, XAxisAsTime=XAxisAsTime)
80 80
81 81 self.nGraphs = nChan
82 82 self.__isPlotConfig = True
@@ -118,11 +118,11 class Osciloscope():
118 118 if ymax == None: ymax = numpy.nanmax(abs(data))
119 119
120 120 plplot.plbop()
121 for i in range(self.nGraphs):
122 y = data[:,i]
121 for chan in range(self.nGraphs):
122 y = data[chan,:]
123 123
124 self.graphObjList[i].iniSubpage()
125 self.graphObjList[i].plotComplexData(x, y, xmin, xmax, ymin, ymax, 8, type)
124 self.graphObjList[chan].iniSubpage()
125 self.graphObjList[chan].plotComplexData(x, y, xmin, xmax, ymin, ymax, 8, type)
126 126
127 127 plplot.plflush()
128 128 plplot.pleop()
@@ -177,6 +177,7 class VoltageReader(JRODataReader):
177 177 print "Data file %s is invalid" % self.filename
178 178 return 0
179 179
180 junk = numpy.transpose(junk, (2,0,1))
180 181 self.datablock = junk['real'] + junk['imag']*1j
181 182
182 183 self.datablockIndex = 0
@@ -249,7 +250,7 class VoltageReader(JRODataReader):
249 250 self.m_DataObj.flagNoData = False
250 251 self.m_DataObj.flagResetProcessing = self.flagResetProcessing
251 252
252 self.m_DataObj.data = self.datablock[self.datablockIndex,:,:]
253 self.m_DataObj.data = self.datablock[:,self.datablockIndex,:]
253 254 self.m_DataObj.idProfile = self.idProfile
254 255
255 256 self.datablockIndex += 1
@@ -319,7 +320,10 class VoltageWriter( JRODataWriter ):
319 320 self.m_ProcessingHeader.numHeights,
320 321 self.m_SystemHeader.numChannels )
321 322
322 self.datablock = numpy.zeros(self.shapeBuffer, numpy.dtype('complex'))
323 self.datablock = numpy.zeros(self.m_SystemHeader.numChannels,
324 self.m_ProcessingHeader.profilesPerBlock,
325 self.m_ProcessingHeader.numHeights,
326 numpy.dtype('complex'))
323 327
324 328
325 329 def writeBlock(self):
@@ -337,8 +341,10 class VoltageWriter( JRODataWriter ):
337 341 """
338 342 data = numpy.zeros( self.shapeBuffer, self.dataType )
339 343
340 data['real'] = self.datablock.real
341 data['imag'] = self.datablock.imag
344 junk = numpy.transpose(self.datablock, (1,2,0))
345
346 data['real'] = junk.real
347 data['imag'] = junk.imag
342 348
343 349 data = data.reshape( (-1) )
344 350
@@ -375,7 +381,7 class VoltageWriter( JRODataWriter ):
375 381 self.datablockIndex = 0
376 382 self.setNextFile()
377 383
378 self.datablock[self.datablockIndex,:,:] = self.m_DataObj.data
384 self.datablock[:,self.datablockIndex,:] = self.m_DataObj.data
379 385
380 386 self.datablockIndex += 1
381 387
@@ -65,35 +65,35 class SpectraProcessor:
65 65 def getFft(self):
66 66
67 67 if self.buffer == None:
68 nheis = self.spectraInObj.data.shape[0]
69 nchannel = self.spectraInObj.data.shape[1]
68 nheis = self.spectraInObj.data.shape[1]
69 nchannel = self.spectraInObj.data.shape[0]
70 70 npoints = self.spectraOutObj.nPoints
71 self.buffer = numpy.zeros((nchannel,nheis,npoints),dtype='complex')
71 self.buffer = numpy.zeros((nchannel,npoints,nheis),dtype='complex')
72 72
73 data = numpy.transpose(self.spectraInObj.data)
74 self.buffer[:,:,self.ptsId] = data
73 self.buffer[:,self.ptsId,:] = self.spectraInObj.data
75 74 self.ptsId += 1
76 75 self.spectraOutObj.flagNoData = True
77 76 if self.ptsId >= self.spectraOutObj.nPoints:
78 data_spc = numpy.fft.fft(self.buffer,axis=2)
77 data_spc = numpy.fft.fft(self.buffer,axis=1)
79 78 self.ptsId = 0
80 79 self.buffer = None
81 80
82 81 #calculo de self-spectra
83 82 self.spectraOutObj.data_spc = numpy.abs(data_spc * numpy.conjugate(data_spc))
84 83
85
86
87 84 #calculo de cross-spectra
88 85 #self.m_Spectra.data_cspc = self.__data_cspc
89 86
90
91 87 #escribiendo dc
92 88 #self.m_Spectra.data_dc = self.__data_dc
93 89
94
95 90 self.spectraOutObj.flagNoData = False
96 91
92 self.spectraOutObj.heights = self.spectraInObj.heights
93 self.spectraOutObj.m_BasicHeader = self.spectraInObj.m_BasicHeader.copy()
94 self.spectraOutObj.m_ProcessingHeader = self.spectraInObj.m_ProcessingHeader.copy()
95 self.spectraOutObj.m_RadarControllerHeader = self.spectraInObj.m_RadarControllerHeader.copy()
96 self.spectraOutObj.m_SystemHeader = self.spectraInObj.m_SystemHeader.copy()
97 97
98 98 def addWriter(self,wrpath):
99 99 objWriter = SpectraWriter(self.spectraOutObj)
@@ -101,9 +101,12 class SpectraProcessor:
101 101 self.writerList.append(objWriter)
102 102
103 103
104 def addPlotter(self):
104 def addPlotter(self, index=None):
105
106 if index==None:
107 index = self.plotterIndex
105 108
106 plotObj = Spectrum(self.spectraOutObj,self.plotterIndex)
109 plotObj = Spectrum(self.spectraOutObj, index)
107 110 self.plotterList.append(plotObj)
108 111
109 112
@@ -124,12 +127,12 class SpectraProcessor:
124 127
125 128 self.writerIndex += 1
126 129
127 def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''):
130 def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, winTitle='', index=None):
128 131 if self.spectraOutObj.flagNoData:
129 132 return 0
130 133
131 134 if len(self.plotterList) <= self.plotterIndex:
132 self.addPlotter()
135 self.addPlotter(index)
133 136
134 137 self.plotterList[self.plotterIndex].plotData(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle)
135 138
@@ -164,7 +164,7 class Decoder:
164 164 self.setCodeFft = False
165 165
166 166 def exe(self, data, ndata=None, type = 0):
167 if ndata == None: ndata = data.shape[0]
167 if ndata == None: ndata = data.shape[1]
168 168
169 169 if type == 0:
170 170 self.convolutionInFreq(data,ndata)
@@ -179,9 +179,9 class Decoder:
179 179
180 180 self.codeIndex += 1
181 181
182 fft_data = numpy.fft.fft(data, axis=0)
182 fft_data = numpy.fft.fft(data, axis=1)
183 183 fft_code = numpy.conj(numpy.fft.fft(newcode))
184 fft_code = fft_code.reshape(len(fft_code),1)
184 fft_code = fft_code.reshape(1,len(fft_code))
185 185
186 186 conv = fft_data.copy()
187 187 conv.fill(0)
@@ -190,7 +190,7 class Decoder:
190 190 # for i in range(ndata):
191 191 # conv[i,:] = fft_data[i,:]*fft_code[i]
192 192
193 self.data = numpy.fft.ifft(conv,axis=0)
193 self.data = numpy.fft.ifft(conv,axis=1)
194 194 self.flag = True
195 195
196 196 if self.profCounter == self.nCode:
@@ -206,7 +206,7 class Decoder:
206 206 self.codeIndex += 1
207 207 conv = data.copy()
208 208 for i in range(nchannel):
209 conv[:,i] = numpy.correlate(data[:,i], newcode, 'same')
209 conv[i,:] = numpy.correlate(data[i,:], newcode, 'same')
210 210
211 211 self.data = conv
212 212 self.flag = True
@@ -28,9 +28,11 class TestSChain():
28 28
29 29 def setValues(self):
30 30
31 self.path = "/home/valentin/Tmp/RAWDATA"
32 self.startDateTime = datetime.datetime(2009,11,2,00,00,0)
33 self.endDateTime = datetime.datetime(2009,11,30,18,10,0)
31 #self.path = "/home/valentin/Tmp/RAWDATA"
32 self.path = "/home/dsuarez/Projects"
33 #self.wrpath = "/home/dsuarez/Projects/testWR"
34 self.startDateTime = datetime.datetime(2007,5,1,15,49,0)
35 self.endDateTime = datetime.datetime(2007,5,1,16,0,0)
34 36
35 37 def createObjects(self):
36 38
@@ -9,7 +9,13 import time, datetime
9 9
10 10 from Model.Voltage import Voltage
11 11 from IO.VoltageIO import *
12 from Graphics.VoltagePlot import Osciloscope
12 #from Graphics.VoltagePlot import Osciloscope
13
14 from Model.Spectra import Spectra
15 from IO.SpectraIO import *
16
17 from Processing.VoltageProcessor import *
18 from Processing.SpectraProcessor import *
13 19
14 20 class TestSChain():
15 21
@@ -17,43 +23,80 class TestSChain():
17 23 self.setValues()
18 24 self.createObjects()
19 25 self.testSChain()
20 pass
26
21 27
22 28 def setValues( self ):
23 29
24 self.path = "/home/valentin/Tmp/VOLTAGE" #1
30 self.path = "/home/dsuarez/Projects" #1
25 31 #self.path = "/home/valentin/Tmp/VOLTAGE2" #2
26 self.startDateTime = datetime.datetime(2011,10,4,00,00,0)
27 self.endDateTime = datetime.datetime(2011,10,31,23,59,59)
32 # self.startDateTime = datetime.datetime(2007,5,1,15,49,0)
33 # self.endDateTime = datetime.datetime(2007,5,1,23,0,0)
34
35 self.startDateTime = datetime.datetime(2011,10,4,0,0,0)
36 self.endDateTime = datetime.datetime(2011,10,4,0,20,0)
37 self.N = 2
38 self.npts = 4
28 39
29 40 def createObjects( self ):
30 41
31 42 self.Obj = Voltage()
43 self.OutObj = Voltage()
32 44 self.readerObj = VoltageReader(self.Obj)
33 self.plotObj = Osciloscope(self.Obj)
45 self.procObj = VoltageProcessor(self.Obj, self.OutObj)
46
47 self.spectraObj = Spectra()
48 self.specProcObj = SpectraProcessor(self.OutObj, self.spectraObj,self.npts)
49
50
51 #self.plotObj = Osciloscope(self.Obj)
34 52
35 53 if not(self.readerObj.setup( self.path, self.startDateTime, self.endDateTime, expLabel='', online =0) ):
36 54 sys.exit(0)
37 55
56 # if not(self.readerObj.setup(self.path, self.startDateTime, self.endDateTime)):
57 # sys.exit(0)
58
38 59 def testSChain( self ):
39 60
40 61 ini = time.time()
41 62 while(True):
42 if self.readerObj.getData():
43 self.plotObj.plotData(idProfile=0, type='power' )
63 self.readerObj.getData()
44 64
45 if self.readerObj.flagNoMoreFiles:
46 break
65 self.procObj.init()
47 66
67 self.procObj.plotData(idProfile = 1, type='power',winTitle='figura 1')
68
69 self.procObj.decoder(type=0)
70
71 # self.procObj.plotData(idProfile = 1, type='iq', xmin=0, xmax=100,winTitle='figura 2')
72 #
73 # self.procObj.integrator(self.N)
74
75 self.procObj.plotData(idProfile = 1, type='power',winTitle='figura 3')
76
77 self.specProcObj.init()
78
79 self.specProcObj.integrator(2)
80
81 self.specProcObj.plotData(winTitle='Spectra 1', index=2)
82
83 # if self.readerObj.getData():
84 # self.plotObj.plotData(idProfile=0, type='power' )
85 #
86 #
87 # if self.readerObj.flagNoMoreFiles:
88 # break
89 #
48 90 if self.readerObj.flagIsNewBlock:
49 91 print 'Block No %04d, Time: %s' %(self.readerObj.nReadBlocks,
50 92 datetime.datetime.fromtimestamp(self.readerObj.m_BasicHeader.utc),)
93
51 94 # fin = time.time()
52 95 # print 'Tiempo de un bloque leido y escrito: [%6.5f]' %(fin - ini)
53 96 # ini = time.time()
54 97
55 98 #time.sleep(0.5)
56 self.plotObj.end()
99 # self.plotObj.end()
57 100
58 101 if __name__ == '__main__':
59 102 TestSChain() No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now