@@ -142,6 +142,7 class SpectraReader( JRODataReader ): | |||||
142 |
|
142 | |||
143 | self.blocksize = self.pts2read_SelfSpectra + self.pts2read_CrossSpectra + self.pts2read_DCchannels |
|
143 | self.blocksize = self.pts2read_SelfSpectra + self.pts2read_CrossSpectra + self.pts2read_DCchannels | |
144 |
|
144 | |||
|
145 | self.m_DataObj.nPoints = self.m_ProcessingHeader.profilesPerBlock | |||
145 | self.m_DataObj.nPairsEqualChannels = self.nPairsEqualChannels |
|
146 | self.m_DataObj.nPairsEqualChannels = self.nPairsEqualChannels | |
146 | self.m_DataObj.nPairsUnequalChannels = self.nPairsUnequalChannels |
|
147 | self.m_DataObj.nPairsUnequalChannels = self.nPairsUnequalChannels | |
147 |
|
148 |
@@ -122,6 +122,7 class VoltageReader(JRODataReader): | |||||
122 | """ |
|
122 | """ | |
123 | self.pts2read = self.m_ProcessingHeader.profilesPerBlock * self.m_ProcessingHeader.numHeights * self.m_SystemHeader.numChannels |
|
123 | self.pts2read = self.m_ProcessingHeader.profilesPerBlock * self.m_ProcessingHeader.numHeights * self.m_SystemHeader.numChannels | |
124 | self.blocksize = self.pts2read |
|
124 | self.blocksize = self.pts2read | |
|
125 | self.m_DataObj.nProfiles = self.m_ProcessingHeader.profilesPerBlock | |||
125 |
|
126 | |||
126 |
|
127 | |||
127 | def readBlock(self): |
|
128 | def readBlock(self): |
@@ -53,7 +53,7 class BasicHeader(Header): | |||||
53 | ('nDstflag','<i2'), |
|
53 | ('nDstflag','<i2'), | |
54 | ('nErrorCount','<u4') |
|
54 | ('nErrorCount','<u4') | |
55 | ]) |
|
55 | ]) | |
56 |
|
|
56 | ||
57 |
|
57 | |||
58 | def read(self, fp): |
|
58 | def read(self, fp): | |
59 | try: |
|
59 | try: | |
@@ -184,11 +184,27 class RadarControllerHeader(Header): | |||||
184 | ('sRangeTxA','<a20'), |
|
184 | ('sRangeTxA','<a20'), | |
185 | ('sRangeTxB','<a20'), |
|
185 | ('sRangeTxB','<a20'), | |
186 | ]) |
|
186 | ]) | |
|
187 | ||||
|
188 | self.samplingWindowStruct = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) | |||
|
189 | ||||
|
190 | self.samplingWindow = None | |||
|
191 | self.numHeights = None | |||
|
192 | self.firstHeight = None | |||
|
193 | self.deltaHeight = None | |||
|
194 | self.samplesWin = None | |||
|
195 | ||||
|
196 | self.numCode = None | |||
|
197 | self.numBaud = None | |||
|
198 | self.code = None | |||
|
199 | self.flip1 = None | |||
|
200 | self.flip2 = None | |||
|
201 | ||||
187 | self.dynamic = numpy.array([],numpy.dtype('byte')) |
|
202 | self.dynamic = numpy.array([],numpy.dtype('byte')) | |
188 |
|
203 | |||
189 |
|
204 | |||
190 | def read(self, fp): |
|
205 | def read(self, fp): | |
191 | try: |
|
206 | try: | |
|
207 | startFp = fp.tell() | |||
192 | header = numpy.fromfile(fp,self.struct,1) |
|
208 | header = numpy.fromfile(fp,self.struct,1) | |
193 | self.size = header['nSize'][0] |
|
209 | self.size = header['nSize'][0] | |
194 | self.expType = header['nExpType'][0] |
|
210 | self.expType = header['nExpType'][0] | |
@@ -208,8 +224,42 class RadarControllerHeader(Header): | |||||
208 | self.rangeTxA = header['sRangeTxA'][0] |
|
224 | self.rangeTxA = header['sRangeTxA'][0] | |
209 | self.rangeTxB = header['sRangeTxB'][0] |
|
225 | self.rangeTxB = header['sRangeTxB'][0] | |
210 | # jump Dynamic Radar Controller Header |
|
226 | # jump Dynamic Radar Controller Header | |
211 |
jump |
|
227 | jumpFp = self.size - 116 | |
212 |
self.dynamic = numpy.fromfile(fp,numpy.dtype('byte'),jump |
|
228 | self.dynamic = numpy.fromfile(fp,numpy.dtype('byte'),jumpFp) | |
|
229 | #pointer backward to dynamic header and read | |||
|
230 | backFp = fp.tell() - jumpFp | |||
|
231 | fp.seek(backFp) | |||
|
232 | ||||
|
233 | self.samplingWindow = numpy.fromfile(fp,self.samplingWindowStruct,self.numWindows) | |||
|
234 | self.numHeights = numpy.sum(self.samplingWindow['nsa']) | |||
|
235 | self.firstHeight = self.samplingWindow['h0'] | |||
|
236 | self.deltaHeight = self.samplingWindow['dh'] | |||
|
237 | self.samplesWin = self.samplingWindow['nsa'] | |||
|
238 | ||||
|
239 | self.Taus = numpy.fromfile(fp,'<f4',self.numTaus) | |||
|
240 | ||||
|
241 | if self.codeType != 0: | |||
|
242 | self.numCode = numpy.fromfile(fp,'<u4',1) | |||
|
243 | self.numBaud = numpy.fromfile(fp,'<u4',1) | |||
|
244 | self.code = numpy.empty([self.numCode,self.numBaud],dtype='u1') | |||
|
245 | tempList = [] | |||
|
246 | for ic in range(self.numCode): | |||
|
247 | temp = numpy.fromfile(fp,'u1',4*numpy.ceil(self.numBaud/32.)) | |||
|
248 | tempList.append(temp) | |||
|
249 | self.code[ic] = numpy.unpackbits(temp[::-1])[-1*self.numBaud:] | |||
|
250 | self.code = 2.0*self.code - 1.0 | |||
|
251 | ||||
|
252 | if self.line5Function == RCfunction.FLIP: | |||
|
253 | self.flip1 = numpy.fromfile(fp,'<u4',1) | |||
|
254 | ||||
|
255 | if self.line6Function == RCfunction.FLIP: | |||
|
256 | self.flip2 = numpy.fromfile(fp,'<u4',1) | |||
|
257 | ||||
|
258 | endFp = self.size + startFp | |||
|
259 | jumpFp = endFp - fp.tell() | |||
|
260 | if jumpFp > 0: | |||
|
261 | fp.seek(jumpFp) | |||
|
262 | ||||
213 | except: |
|
263 | except: | |
214 | return 0 |
|
264 | return 0 | |
215 |
|
265 | |||
@@ -289,7 +339,7 class ProcessingHeader(Header): | |||||
289 | self.samplesWin = 0 |
|
339 | self.samplesWin = 0 | |
290 | self.spectraComb = 0 |
|
340 | self.spectraComb = 0 | |
291 | self.numCode = 0 |
|
341 | self.numCode = 0 | |
292 |
self.code |
|
342 | self.code = 0 | |
293 | self.numBaud = 0 |
|
343 | self.numBaud = 0 | |
294 | self.shif_fft = False |
|
344 | self.shif_fft = False | |
295 |
|
345 | |||
@@ -316,7 +366,7 class ProcessingHeader(Header): | |||||
316 | if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: |
|
366 | if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: | |
317 | self.numCode = numpy.fromfile(fp,'<u4',1) |
|
367 | self.numCode = numpy.fromfile(fp,'<u4',1) | |
318 | self.numBaud = numpy.fromfile(fp,'<u4',1) |
|
368 | self.numBaud = numpy.fromfile(fp,'<u4',1) | |
319 |
self.code |
|
369 | self.code = numpy.fromfile(fp,'<f4',self.numCode*self.numBaud).reshape(self.numBaud,self.numCode) | |
320 |
|
370 | |||
321 | if self.processFlags & PROCFLAG.SHIFT_FFT_DATA == PROCFLAG.SHIFT_FFT_DATA: |
|
371 | if self.processFlags & PROCFLAG.SHIFT_FFT_DATA == PROCFLAG.SHIFT_FFT_DATA: | |
322 | self.shif_fft = True |
|
372 | self.shif_fft = True | |
@@ -361,11 +411,38 class ProcessingHeader(Header): | |||||
361 | numBaud = self.numBaud |
|
411 | numBaud = self.numBaud | |
362 | numBaud.tofile(fp) |
|
412 | numBaud.tofile(fp) | |
363 |
|
413 | |||
364 |
code |
|
414 | code = self.code.reshape(numCode*numBaud) | |
365 |
code |
|
415 | code.tofile(fp) | |
366 |
|
416 | |||
367 | return 1 |
|
417 | return 1 | |
368 |
|
418 | |||
|
419 | class RCfunction: | |||
|
420 | NONE=0 | |||
|
421 | FLIP=1 | |||
|
422 | CODE=2 | |||
|
423 | SAMPLING=3 | |||
|
424 | LIN6DIV256=4 | |||
|
425 | SYNCHRO=5 | |||
|
426 | ||||
|
427 | class nCodeType: | |||
|
428 | NONE=0 | |||
|
429 | USERDEFINE=1 | |||
|
430 | BARKER2=2 | |||
|
431 | BARKER3=3 | |||
|
432 | BARKER4=4 | |||
|
433 | BARKER5=5 | |||
|
434 | BARKER7=6 | |||
|
435 | BARKER11=7 | |||
|
436 | BARKER13=8 | |||
|
437 | AC128=9 | |||
|
438 | COMPLEMENTARYCODE2=10 | |||
|
439 | COMPLEMENTARYCODE4=11 | |||
|
440 | COMPLEMENTARYCODE8=12 | |||
|
441 | COMPLEMENTARYCODE16=13 | |||
|
442 | COMPLEMENTARYCODE32=14 | |||
|
443 | COMPLEMENTARYCODE64=15 | |||
|
444 | COMPLEMENTARYCODE128=16 | |||
|
445 | CODE_BINARY28=17 | |||
369 |
|
446 | |||
370 | class PROCFLAG: |
|
447 | class PROCFLAG: | |
371 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) |
|
448 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) |
@@ -47,6 +47,8 class Spectra(JROData): | |||||
47 |
|
47 | |||
48 | self.nProfiles = None |
|
48 | self.nProfiles = None | |
49 |
|
49 | |||
|
50 | self.nPoints = None | |||
|
51 | ||||
50 | self.dataType = None |
|
52 | self.dataType = None | |
51 |
|
53 | |||
52 | self.flagResetProcessing = False |
|
54 | self.flagResetProcessing = False |
@@ -4,15 +4,180 Created on Feb 7, 2012 | |||||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
|
7 | import os, sys | |||
|
8 | import numpy | |||
|
9 | ||||
|
10 | path = os.path.split(os.getcwd())[0] | |||
|
11 | sys.path.append(path) | |||
|
12 | ||||
|
13 | from Model.Spectra import Spectra | |||
|
14 | from IO.SpectraIO import SpectraWriter | |||
|
15 | from Graphics.SpectraPlot import Spectrum | |||
|
16 | ||||
7 |
|
17 | |||
8 | class SpectraProcessor: |
|
18 | class SpectraProcessor: | |
9 | ''' |
|
19 | ''' | |
10 | classdocs |
|
20 | classdocs | |
11 | ''' |
|
21 | ''' | |
12 |
|
22 | |||
13 |
|
23 | def __init__(self, spectraInObj, spectraOutObj=None, npts = None): | ||
14 | def __init__(self): |
|
|||
15 | ''' |
|
24 | ''' | |
16 | Constructor |
|
25 | Constructor | |
17 | ''' |
|
26 | ''' | |
18 | pass No newline at end of file |
|
27 | self.spectraInObj = spectraInObj | |
|
28 | ||||
|
29 | if spectraOutObj == None: | |||
|
30 | self.spectraOutObj = Spectra() | |||
|
31 | else: | |||
|
32 | self.spectraOutObj = spectraOutObj | |||
|
33 | ||||
|
34 | ||||
|
35 | self.integratorIndex = None | |||
|
36 | self.decoderIndex = None | |||
|
37 | self.writerIndex = None | |||
|
38 | self.plotterIndex = None | |||
|
39 | ||||
|
40 | if npts != None: | |||
|
41 | self.spectraOutObj.nPoints = npts | |||
|
42 | ||||
|
43 | self.npts = self.spectraOutObj.nPoints | |||
|
44 | ||||
|
45 | self.integratorList = [] | |||
|
46 | self.decoderList = [] | |||
|
47 | self.writerList = [] | |||
|
48 | self.plotterList = [] | |||
|
49 | ||||
|
50 | self.buffer = None | |||
|
51 | self.ptsId = 0 | |||
|
52 | ||||
|
53 | def init(self): | |||
|
54 | self.integratorIndex = 0 | |||
|
55 | self.decoderIndex = 0 | |||
|
56 | self.writerIndex = 0 | |||
|
57 | self.plotterIndex = 0 | |||
|
58 | ||||
|
59 | if not( isinstance(self.spectraInObj, Spectra) ): | |||
|
60 | self.getFft() | |||
|
61 | else: | |||
|
62 | self.spectraOutObj.copy(self.spectraInObj) | |||
|
63 | ||||
|
64 | ||||
|
65 | def getFft(self): | |||
|
66 | ||||
|
67 | if self.buffer == None: | |||
|
68 | nheis = self.spectraInObj.data.shape[0] | |||
|
69 | nchannel = self.spectraInObj.data.shape[1] | |||
|
70 | npoints = self.spectraOutObj.nPoints | |||
|
71 | self.buffer = numpy.zeros((nchannel,nheis,npoints),dtype='complex') | |||
|
72 | ||||
|
73 | data = numpy.transpose(self.spectraInObj.data) | |||
|
74 | self.buffer[:,:,self.ptsId] = data | |||
|
75 | self.ptsId += 1 | |||
|
76 | self.spectraOutObj.flagNoData = True | |||
|
77 | if self.ptsId >= self.spectraOutObj.nPoints: | |||
|
78 | data_spc = numpy.fft.fft(self.buffer,axis=2) | |||
|
79 | self.ptsId = 0 | |||
|
80 | self.buffer = None | |||
|
81 | ||||
|
82 | #calculo de self-spectra | |||
|
83 | self.spectraOutObj.data_spc = numpy.abs(data_spc * numpy.conjugate(data_spc)) | |||
|
84 | ||||
|
85 | ||||
|
86 | ||||
|
87 | #calculo de cross-spectra | |||
|
88 | #self.m_Spectra.data_cspc = self.__data_cspc | |||
|
89 | ||||
|
90 | ||||
|
91 | #escribiendo dc | |||
|
92 | #self.m_Spectra.data_dc = self.__data_dc | |||
|
93 | ||||
|
94 | ||||
|
95 | self.spectraOutObj.flagNoData = False | |||
|
96 | ||||
|
97 | ||||
|
98 | def addWriter(self,wrpath): | |||
|
99 | objWriter = SpectraWriter(self.spectraOutObj) | |||
|
100 | objWriter.setup(wrpath) | |||
|
101 | self.writerList.append(objWriter) | |||
|
102 | ||||
|
103 | ||||
|
104 | def addPlotter(self): | |||
|
105 | ||||
|
106 | plotObj = Spectrum(self.spectraOutObj,self.plotterIndex) | |||
|
107 | self.plotterList.append(plotObj) | |||
|
108 | ||||
|
109 | ||||
|
110 | def addIntegrator(self,N): | |||
|
111 | ||||
|
112 | objIncohInt = IncoherentIntegration(N) | |||
|
113 | self.integratorList.append(objIncohInt) | |||
|
114 | ||||
|
115 | ||||
|
116 | def writeData(self): | |||
|
117 | if self.voltageOutObj.flagNoData: | |||
|
118 | return 0 | |||
|
119 | ||||
|
120 | if len(self.writerList) <= self.writerIndex: | |||
|
121 | self.addWriter(wrpath) | |||
|
122 | ||||
|
123 | self.writerList[self.writerIndex].putData() | |||
|
124 | ||||
|
125 | self.writerIndex += 1 | |||
|
126 | ||||
|
127 | def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''): | |||
|
128 | if self.spectraOutObj.flagNoData: | |||
|
129 | return 0 | |||
|
130 | ||||
|
131 | if len(self.plotterList) <= self.plotterIndex: | |||
|
132 | self.addPlotter() | |||
|
133 | ||||
|
134 | self.plotterList[self.plotterIndex].plotData(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle) | |||
|
135 | ||||
|
136 | self.plotterIndex += 1 | |||
|
137 | ||||
|
138 | def integrator(self, N): | |||
|
139 | if self.spectraOutObj.flagNoData: | |||
|
140 | return 0 | |||
|
141 | ||||
|
142 | if len(self.integratorList) <= self.integratorIndex: | |||
|
143 | self.addIntegrator(N) | |||
|
144 | ||||
|
145 | myCohIntObj = self.integratorList[self.integratorIndex] | |||
|
146 | myCohIntObj.exe(self.spectraOutObj.data_spc) | |||
|
147 | ||||
|
148 | if myCohIntObj.flag: | |||
|
149 | self.spectraOutObj.data_spc = myCohIntObj.data | |||
|
150 | self.spectraOutObj.m_ProcessingHeader.incoherentInt *= N | |||
|
151 | self.spectraOutObj.flagNoData = False | |||
|
152 | ||||
|
153 | else: | |||
|
154 | self.spectraOutObj.flagNoData = True | |||
|
155 | ||||
|
156 | self.integratorIndex += 1 | |||
|
157 | ||||
|
158 | class IncoherentIntegration: | |||
|
159 | def __init__(self, N): | |||
|
160 | self.profCounter = 1 | |||
|
161 | self.data = None | |||
|
162 | self.buffer = None | |||
|
163 | self.flag = False | |||
|
164 | self.nIncohInt = N | |||
|
165 | ||||
|
166 | def exe(self,data): | |||
|
167 | print 'intg:', self.profCounter | |||
|
168 | ||||
|
169 | if self.buffer == None: | |||
|
170 | self.buffer = data | |||
|
171 | else: | |||
|
172 | self.buffer = self.buffer + data | |||
|
173 | ||||
|
174 | if self.profCounter == self.nIncohInt: | |||
|
175 | self.data = self.buffer | |||
|
176 | self.buffer = None | |||
|
177 | self.profCounter = 0 | |||
|
178 | self.flag = True | |||
|
179 | else: | |||
|
180 | self.flag = False | |||
|
181 | ||||
|
182 | self.profCounter += 1 | |||
|
183 |
@@ -5,14 +5,243 Created on Feb 7, 2012 | |||||
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
|
8 | import os, sys | |||
|
9 | import numpy | |||
|
10 | ||||
|
11 | path = os.path.split(os.getcwd())[0] | |||
|
12 | sys.path.append(path) | |||
|
13 | ||||
|
14 | from Model.Voltage import Voltage | |||
|
15 | from IO.VoltageIO import VoltageWriter | |||
|
16 | from Graphics.VoltagePlot import Osciloscope | |||
|
17 | ||||
8 | class VoltageProcessor: |
|
18 | class VoltageProcessor: | |
9 | ''' |
|
19 | ''' | |
10 | classdocs |
|
20 | classdocs | |
11 | ''' |
|
21 | ''' | |
12 |
|
22 | |||
13 |
|
23 | def __init__(self, voltageInObj, voltageOutObj=None): | ||
14 | def __init__(self): |
|
|||
15 | ''' |
|
24 | ''' | |
16 | Constructor |
|
25 | Constructor | |
17 | ''' |
|
26 | ''' | |
18 |
|
|
27 | ||
|
28 | self.voltageInObj = voltageInObj | |||
|
29 | ||||
|
30 | if voltageOutObj == None: | |||
|
31 | self.voltageOutObj = Voltage() | |||
|
32 | else: | |||
|
33 | self.voltageOutObj = voltageOutObj | |||
|
34 | ||||
|
35 | self.integratorIndex = None | |||
|
36 | self.decoderIndex = None | |||
|
37 | self.writerIndex = None | |||
|
38 | self.plotterIndex = None | |||
|
39 | ||||
|
40 | self.integratorList = [] | |||
|
41 | self.decoderList = [] | |||
|
42 | self.writerList = [] | |||
|
43 | self.plotterList = [] | |||
|
44 | ||||
|
45 | def init(self): | |||
|
46 | self.integratorIndex = 0 | |||
|
47 | self.decoderIndex = 0 | |||
|
48 | self.writerIndex = 0 | |||
|
49 | self.plotterIndex = 0 | |||
|
50 | self.voltageOutObj.copy(self.voltageInObj) | |||
|
51 | ||||
|
52 | def addWriter(self,wrpath): | |||
|
53 | objWriter = VoltageWriter(self.voltageOutObj) | |||
|
54 | objWriter.setup(wrpath) | |||
|
55 | self.writerList.append(objWriter) | |||
|
56 | ||||
|
57 | def addPlotter(self): | |||
|
58 | ||||
|
59 | plotObj = Osciloscope(self.voltageOutObj,self.plotterIndex) | |||
|
60 | self.plotterList.append(plotObj) | |||
|
61 | ||||
|
62 | def addIntegrator(self,N): | |||
|
63 | ||||
|
64 | objCohInt = CoherentIntegrator(N) | |||
|
65 | self.integratorList.append(objCohInt) | |||
|
66 | ||||
|
67 | def addDecoder(self,code,ncode,nbaud): | |||
|
68 | ||||
|
69 | objDecoder = Decoder(code,ncode,nbaud) | |||
|
70 | self.decoderList.append(objDecoder) | |||
|
71 | ||||
|
72 | def writeData(self,wrpath): | |||
|
73 | if self.voltageOutObj.flagNoData: | |||
|
74 | return 0 | |||
|
75 | ||||
|
76 | if len(self.writerList) <= self.writerIndex: | |||
|
77 | self.addWriter(wrpath) | |||
|
78 | ||||
|
79 | self.writerList[self.writerIndex].putData() | |||
|
80 | ||||
|
81 | # myWrObj = self.writerList[self.writerIndex] | |||
|
82 | # myWrObj.putData() | |||
|
83 | ||||
|
84 | self.writerIndex += 1 | |||
|
85 | ||||
|
86 | def plotData(self,idProfile, type, xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''): | |||
|
87 | if self.voltageOutObj.flagNoData: | |||
|
88 | return 0 | |||
|
89 | ||||
|
90 | if len(self.plotterList) <= self.plotterIndex: | |||
|
91 | self.addPlotter() | |||
|
92 | ||||
|
93 | self.plotterList[self.plotterIndex].plotData(type=type, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle) | |||
|
94 | ||||
|
95 | self.plotterIndex += 1 | |||
|
96 | ||||
|
97 | def integrator(self, N): | |||
|
98 | if self.voltageOutObj.flagNoData: | |||
|
99 | return 0 | |||
|
100 | ||||
|
101 | if len(self.integratorList) <= self.integratorIndex: | |||
|
102 | self.addIntegrator(N) | |||
|
103 | ||||
|
104 | myCohIntObj = self.integratorList[self.integratorIndex] | |||
|
105 | myCohIntObj.exe(self.voltageOutObj.data) | |||
|
106 | ||||
|
107 | if myCohIntObj.flag: | |||
|
108 | self.voltageOutObj.data = myCohIntObj.data | |||
|
109 | self.voltageOutObj.m_ProcessingHeader.coherentInt *= N | |||
|
110 | self.voltageOutObj.flagNoData = False | |||
|
111 | ||||
|
112 | else: | |||
|
113 | self.voltageOutObj.flagNoData = True | |||
|
114 | ||||
|
115 | self.integratorIndex += 1 | |||
|
116 | ||||
|
117 | def decoder(self,code=None,type = 0): | |||
|
118 | if self.voltageOutObj.flagNoData: | |||
|
119 | return 0 | |||
|
120 | if code == None: | |||
|
121 | code = self.voltageOutObj.m_RadarControllerHeader.code | |||
|
122 | ncode, nbaud = code.shape | |||
|
123 | ||||
|
124 | if len(self.decoderList) <= self.decoderIndex: | |||
|
125 | self.addDecoder(code,ncode,nbaud) | |||
|
126 | ||||
|
127 | myDecodObj = self.decoderList[self.decoderIndex] | |||
|
128 | myDecodObj.exe(data=self.voltageOutObj.data,type=type) | |||
|
129 | ||||
|
130 | if myDecodObj.flag: | |||
|
131 | self.voltageOutObj.data = myDecodObj.data | |||
|
132 | self.voltageOutObj.flagNoData = False | |||
|
133 | else: | |||
|
134 | self.voltageOutObj.flagNoData = True | |||
|
135 | ||||
|
136 | self.decoderIndex += 1 | |||
|
137 | ||||
|
138 | def removeDC(self): | |||
|
139 | pass | |||
|
140 | ||||
|
141 | def removeSignalInt(self): | |||
|
142 | pass | |||
|
143 | ||||
|
144 | def selChannel(self): | |||
|
145 | pass | |||
|
146 | ||||
|
147 | def selRange(self): | |||
|
148 | pass | |||
|
149 | ||||
|
150 | def selProfiles(self): | |||
|
151 | pass | |||
|
152 | ||||
|
153 | ||||
|
154 | class Decoder: | |||
|
155 | def __init__(self,code, ncode, nbaud): | |||
|
156 | self.buffer = None | |||
|
157 | self.profCounter = 1 | |||
|
158 | self.nCode = ncode | |||
|
159 | self.nBaud = nbaud | |||
|
160 | self.codeIndex = 0 | |||
|
161 | self.code = code #this is a List | |||
|
162 | self.fft_code = None | |||
|
163 | self.flag = False | |||
|
164 | self.setCodeFft = False | |||
|
165 | ||||
|
166 | def exe(self, data, ndata=None, type = 0): | |||
|
167 | if ndata == None: ndata = data.shape[0] | |||
|
168 | ||||
|
169 | if type == 0: | |||
|
170 | self.convolutionInFreq(data,ndata) | |||
|
171 | ||||
|
172 | if type == 1: | |||
|
173 | self.convolutionInTime(data, ndata) | |||
|
174 | ||||
|
175 | def convolutionInFreq(self,data,ndata): | |||
|
176 | ||||
|
177 | newcode = numpy.zeros(ndata) | |||
|
178 | newcode[0:self.nBaud] = self.code[self.codeIndex] | |||
|
179 | ||||
|
180 | self.codeIndex += 1 | |||
|
181 | ||||
|
182 | fft_data = numpy.fft.fft(data, axis=0) | |||
|
183 | fft_code = numpy.conj(numpy.fft.fft(newcode)) | |||
|
184 | fft_code = fft_code.reshape(len(fft_code),1) | |||
|
185 | ||||
|
186 | conv = fft_data.copy() | |||
|
187 | conv.fill(0) | |||
|
188 | ||||
|
189 | conv = fft_data*fft_code # This other way to calculate multiplication between bidimensional arrays | |||
|
190 | # for i in range(ndata): | |||
|
191 | # conv[i,:] = fft_data[i,:]*fft_code[i] | |||
|
192 | ||||
|
193 | self.data = numpy.fft.ifft(conv,axis=0) | |||
|
194 | self.flag = True | |||
|
195 | ||||
|
196 | if self.profCounter == self.nCode: | |||
|
197 | self.profCounter = 0 | |||
|
198 | self.codeIndex = 0 | |||
|
199 | ||||
|
200 | self.profCounter += 1 | |||
|
201 | ||||
|
202 | def convolutionInTime(self, data, ndata): | |||
|
203 | ||||
|
204 | nchannel = data.shape[1] | |||
|
205 | newcode = self.code[self.codeIndex] | |||
|
206 | self.codeIndex += 1 | |||
|
207 | conv = data.copy() | |||
|
208 | for i in range(nchannel): | |||
|
209 | conv[:,i] = numpy.correlate(data[:,i], newcode, 'same') | |||
|
210 | ||||
|
211 | self.data = conv | |||
|
212 | self.flag = True | |||
|
213 | ||||
|
214 | if self.profCounter == self.nCode: | |||
|
215 | self.profCounter = 0 | |||
|
216 | self.codeIndex = 0 | |||
|
217 | ||||
|
218 | self.profCounter += 1 | |||
|
219 | ||||
|
220 | ||||
|
221 | class CoherentIntegrator: | |||
|
222 | def __init__(self, N): | |||
|
223 | self.profCounter = 1 | |||
|
224 | self.data = None | |||
|
225 | self.buffer = None | |||
|
226 | self.flag = False | |||
|
227 | self.nCohInt = N | |||
|
228 | ||||
|
229 | def exe(self,data): | |||
|
230 | ||||
|
231 | if self.buffer == None: | |||
|
232 | self.buffer = data | |||
|
233 | else: | |||
|
234 | self.buffer = self.buffer + data | |||
|
235 | ||||
|
236 | if self.profCounter == self.nCohInt: | |||
|
237 | self.data = self.buffer | |||
|
238 | self.buffer = None | |||
|
239 | self.profCounter = 0 | |||
|
240 | self.flag = True | |||
|
241 | else: | |||
|
242 | self.flag = False | |||
|
243 | ||||
|
244 | self.profCounter += 1 | |||
|
245 | ||||
|
246 | ||||
|
247 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now