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