@@ -1,396 +1,452 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
8 | import os, sys |
|
8 | import os, sys | |
9 | import numpy |
|
9 | import numpy | |
10 |
|
10 | |||
11 | path = os.path.split(os.getcwd())[0] |
|
11 | path = os.path.split(os.getcwd())[0] | |
12 | sys.path.append(path) |
|
12 | sys.path.append(path) | |
13 |
|
13 | |||
14 | from Model.Voltage import Voltage |
|
14 | from Model.Voltage import Voltage | |
15 | from IO.VoltageIO import VoltageWriter |
|
15 | from IO.VoltageIO import VoltageWriter | |
16 | from Graphics.VoltagePlot import Osciloscope |
|
16 | from Graphics.VoltagePlot import Osciloscope | |
17 |
|
17 | |||
18 | class VoltageProcessor: |
|
18 | class VoltageProcessor: | |
19 | ''' |
|
19 | ''' | |
20 | classdocs |
|
20 | classdocs | |
21 | ''' |
|
21 | ''' | |
22 |
|
22 | |||
23 | def __init__(self, voltageInObj, voltageOutObj=None): |
|
23 | def __init__(self, voltageInObj, voltageOutObj=None): | |
24 | ''' |
|
24 | ''' | |
25 | Constructor |
|
25 | Constructor | |
26 | ''' |
|
26 | ''' | |
27 |
|
27 | |||
28 | self.voltageInObj = voltageInObj |
|
28 | self.voltageInObj = voltageInObj | |
29 |
|
29 | |||
30 | if voltageOutObj == None: |
|
30 | if voltageOutObj == None: | |
31 | self.voltageOutObj = Voltage() |
|
31 | self.voltageOutObj = Voltage() | |
32 | else: |
|
32 | else: | |
33 | self.voltageOutObj = voltageOutObj |
|
33 | self.voltageOutObj = voltageOutObj | |
34 |
|
34 | |||
35 | self.integratorIndex = None |
|
35 | self.integratorIndex = None | |
36 | self.decoderIndex = None |
|
36 | self.decoderIndex = None | |
|
37 | self.profSelectorIndex = None | |||
37 | self.writerIndex = None |
|
38 | self.writerIndex = None | |
38 | self.plotterIndex = None |
|
39 | self.plotterIndex = None | |
39 |
|
40 | |||
40 | self.integratorList = [] |
|
41 | self.integratorList = [] | |
41 | self.decoderList = [] |
|
42 | self.decoderList = [] | |
|
43 | self.profileSelectorList = [] | |||
42 | self.writerList = [] |
|
44 | self.writerList = [] | |
43 | self.plotterList = [] |
|
45 | self.plotterList = [] | |
44 |
|
46 | |||
45 | def init(self): |
|
47 | def init(self): | |
|
48 | ||||
46 | self.integratorIndex = 0 |
|
49 | self.integratorIndex = 0 | |
47 | self.decoderIndex = 0 |
|
50 | self.decoderIndex = 0 | |
|
51 | self.profSelectorIndex = 0 | |||
48 | self.writerIndex = 0 |
|
52 | self.writerIndex = 0 | |
49 | self.plotterIndex = 0 |
|
53 | self.plotterIndex = 0 | |
50 | self.voltageOutObj.copy(self.voltageInObj) |
|
54 | self.voltageOutObj.copy(self.voltageInObj) | |
51 |
|
55 | |||
52 | def addWriter(self,wrpath): |
|
56 | def addWriter(self, wrpath): | |
53 | objWriter = VoltageWriter(self.voltageOutObj) |
|
57 | objWriter = VoltageWriter(self.voltageOutObj) | |
54 | objWriter.setup(wrpath) |
|
58 | objWriter.setup(wrpath) | |
55 | self.writerList.append(objWriter) |
|
59 | self.writerList.append(objWriter) | |
56 |
|
60 | |||
57 | def addPlotter(self): |
|
61 | def addPlotter(self): | |
58 |
|
62 | |||
59 | plotObj = Osciloscope(self.voltageOutObj,self.plotterIndex) |
|
63 | plotObj = Osciloscope(self.voltageOutObj,self.plotterIndex) | |
60 | self.plotterList.append(plotObj) |
|
64 | self.plotterList.append(plotObj) | |
61 |
|
65 | |||
62 |
def addIntegrator(self, |
|
66 | def addIntegrator(self, nCohInt): | |
63 |
|
67 | |||
64 |
objCohInt = CoherentIntegrator( |
|
68 | objCohInt = CoherentIntegrator(nCohInt) | |
65 | self.integratorList.append(objCohInt) |
|
69 | self.integratorList.append(objCohInt) | |
66 |
|
70 | |||
67 | def addDecoder(self,code,ncode,nbaud): |
|
71 | def addDecoder(self, code, ncode, nbaud): | |
68 |
|
72 | |||
69 | objDecoder = Decoder(code,ncode,nbaud) |
|
73 | objDecoder = Decoder(code,ncode,nbaud) | |
70 | self.decoderList.append(objDecoder) |
|
74 | self.decoderList.append(objDecoder) | |
71 |
|
75 | |||
|
76 | def addProfileSelector(self, nProfiles): | |||
|
77 | ||||
|
78 | objProfSelector = ProfileSelector(nProfiles) | |||
|
79 | self.profileSelectorList.append(objProfSelector) | |||
|
80 | ||||
72 | def writeData(self,wrpath): |
|
81 | def writeData(self,wrpath): | |
|
82 | ||||
73 | if self.voltageOutObj.flagNoData: |
|
83 | if self.voltageOutObj.flagNoData: | |
74 |
|
|
84 | return 0 | |
75 |
|
85 | |||
76 | if len(self.writerList) <= self.writerIndex: |
|
86 | if len(self.writerList) <= self.writerIndex: | |
77 | self.addWriter(wrpath) |
|
87 | self.addWriter(wrpath) | |
78 |
|
88 | |||
79 | self.writerList[self.writerIndex].putData() |
|
89 | self.writerList[self.writerIndex].putData() | |
80 |
|
90 | |||
81 | # myWrObj = self.writerList[self.writerIndex] |
|
91 | # myWrObj = self.writerList[self.writerIndex] | |
82 | # myWrObj.putData() |
|
92 | # myWrObj.putData() | |
83 |
|
93 | |||
84 | self.writerIndex += 1 |
|
94 | self.writerIndex += 1 | |
85 |
|
95 | |||
86 | def plotData(self,idProfile, type, xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''): |
|
96 | def plotData(self,idProfile, type, xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''): | |
87 | if self.voltageOutObj.flagNoData: |
|
97 | if self.voltageOutObj.flagNoData: | |
88 |
|
|
98 | return 0 | |
89 |
|
99 | |||
90 | if len(self.plotterList) <= self.plotterIndex: |
|
100 | if len(self.plotterList) <= self.plotterIndex: | |
91 | self.addPlotter() |
|
101 | self.addPlotter() | |
92 |
|
102 | |||
93 | self.plotterList[self.plotterIndex].plotData(type=type, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle) |
|
103 | self.plotterList[self.plotterIndex].plotData(type=type, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle) | |
94 |
|
104 | |||
95 | self.plotterIndex += 1 |
|
105 | self.plotterIndex += 1 | |
96 |
|
106 | |||
97 | def integrator(self, N): |
|
107 | def integrator(self, N): | |
|
108 | ||||
98 | if self.voltageOutObj.flagNoData: |
|
109 | if self.voltageOutObj.flagNoData: | |
99 |
|
|
110 | return 0 | |
100 |
|
111 | |||
101 | if len(self.integratorList) <= self.integratorIndex: |
|
112 | if len(self.integratorList) <= self.integratorIndex: | |
102 | self.addIntegrator(N) |
|
113 | self.addIntegrator(N) | |
103 |
|
114 | |||
104 | myCohIntObj = self.integratorList[self.integratorIndex] |
|
115 | myCohIntObj = self.integratorList[self.integratorIndex] | |
105 | myCohIntObj.exe(self.voltageOutObj.data) |
|
116 | myCohIntObj.exe(self.voltageOutObj.data) | |
106 |
|
117 | |||
107 | if myCohIntObj.flag: |
|
118 | if myCohIntObj.flag: | |
108 | self.voltageOutObj.data = myCohIntObj.data |
|
119 | self.voltageOutObj.data = myCohIntObj.data | |
109 | self.voltageOutObj.m_ProcessingHeader.coherentInt *= N |
|
120 | self.voltageOutObj.m_ProcessingHeader.coherentInt *= N | |
110 | self.voltageOutObj.flagNoData = False |
|
121 | self.voltageOutObj.flagNoData = False | |
111 |
|
122 | |||
112 | else: |
|
123 | else: | |
113 | self.voltageOutObj.flagNoData = True |
|
124 | self.voltageOutObj.flagNoData = True | |
114 |
|
125 | |||
115 | self.integratorIndex += 1 |
|
126 | self.integratorIndex += 1 | |
116 |
|
127 | |||
117 | def decoder(self,code=None,type = 0): |
|
128 | def decoder(self,code=None,type = 0): | |
|
129 | ||||
118 | if self.voltageOutObj.flagNoData: |
|
130 | if self.voltageOutObj.flagNoData: | |
119 |
|
|
131 | return 0 | |
|
132 | ||||
120 | if code == None: |
|
133 | if code == None: | |
121 | code = self.voltageOutObj.m_RadarControllerHeader.code |
|
134 | code = self.voltageOutObj.m_RadarControllerHeader.code | |
122 | ncode, nbaud = code.shape |
|
135 | ncode, nbaud = code.shape | |
123 |
|
136 | |||
124 | if len(self.decoderList) <= self.decoderIndex: |
|
137 | if len(self.decoderList) <= self.decoderIndex: | |
125 | self.addDecoder(code,ncode,nbaud) |
|
138 | self.addDecoder(code,ncode,nbaud) | |
126 |
|
139 | |||
127 | myDecodObj = self.decoderList[self.decoderIndex] |
|
140 | myDecodObj = self.decoderList[self.decoderIndex] | |
128 | myDecodObj.exe(data=self.voltageOutObj.data,type=type) |
|
141 | myDecodObj.exe(data=self.voltageOutObj.data,type=type) | |
129 |
|
142 | |||
130 | if myDecodObj.flag: |
|
143 | if myDecodObj.flag: | |
131 | self.voltageOutObj.data = myDecodObj.data |
|
144 | self.voltageOutObj.data = myDecodObj.data | |
132 | self.voltageOutObj.flagNoData = False |
|
145 | self.voltageOutObj.flagNoData = False | |
133 | else: |
|
146 | else: | |
134 | self.voltageOutObj.flagNoData = True |
|
147 | self.voltageOutObj.flagNoData = True | |
135 |
|
148 | |||
136 | self.decoderIndex += 1 |
|
149 | self.decoderIndex += 1 | |
137 |
|
150 | |||
138 |
|
151 | |||
139 | def filterByHei(self, window): |
|
152 | def filterByHei(self, window): | |
140 | pass |
|
153 | pass | |
141 |
|
154 | |||
142 |
|
155 | |||
143 | def selectChannels(self, channelList): |
|
156 | def selectChannels(self, channelList): | |
144 | """ |
|
157 | """ | |
145 | Selecciona un bloque de datos en base a canales y pares segun el channelList y el pairList |
|
158 | Selecciona un bloque de datos en base a canales y pares segun el channelList y el pairList | |
146 |
|
159 | |||
147 | Input: |
|
160 | Input: | |
148 | channelList : lista sencilla de canales a seleccionar por ej. (2,3,7) |
|
161 | channelList : lista sencilla de canales a seleccionar por ej. (2,3,7) | |
149 | pairList : tupla de pares que se desea selecionar por ej. ( (0,1), (0,2) ) |
|
162 | pairList : tupla de pares que se desea selecionar por ej. ( (0,1), (0,2) ) | |
150 |
|
163 | |||
151 | Affected: |
|
164 | Affected: | |
152 | self.dataOutObj.datablock |
|
165 | self.dataOutObj.datablock | |
153 | self.dataOutObj.nChannels |
|
166 | self.dataOutObj.nChannels | |
154 | self.dataOutObj.m_SystemHeader.numChannels |
|
167 | self.dataOutObj.m_SystemHeader.numChannels | |
155 | self.voltageOutObj.m_ProcessingHeader.blockSize |
|
168 | self.voltageOutObj.m_ProcessingHeader.blockSize | |
156 |
|
169 | |||
157 | Return: |
|
170 | Return: | |
158 | None |
|
171 | None | |
159 | """ |
|
172 | """ | |
160 | if not(channelList): |
|
173 | if not(channelList): | |
161 | return |
|
174 | return | |
162 |
|
175 | |||
163 | channels = 0 |
|
176 | channels = 0 | |
164 | profiles = self.voltageOutObj.nProfiles |
|
177 | profiles = self.voltageOutObj.nProfiles | |
165 | heights = self.voltageOutObj.m_ProcessingHeader.numHeights |
|
178 | heights = self.voltageOutObj.m_ProcessingHeader.numHeights | |
166 |
|
179 | |||
167 | #self spectra |
|
180 | #self spectra | |
168 | channels = len(channelList) |
|
181 | channels = len(channelList) | |
169 | data = numpy.zeros( (channels,profiles,heights), dtype='complex' ) |
|
182 | data = numpy.zeros( (channels,profiles,heights), dtype='complex' ) | |
170 | for index,channel in enumerate(channelList): |
|
183 | for index,channel in enumerate(channelList): | |
171 | data[index,:,:] = self.voltageOutObj.data_spc[channel,:,:] |
|
184 | data[index,:,:] = self.voltageOutObj.data_spc[channel,:,:] | |
172 |
|
185 | |||
173 | self.voltageOutObj.datablock = data |
|
186 | self.voltageOutObj.datablock = data | |
174 |
|
187 | |||
175 | #fill the m_ProcessingHeader.spectraComb up |
|
188 | #fill the m_ProcessingHeader.spectraComb up | |
176 | channels = len(channelList) |
|
189 | channels = len(channelList) | |
177 |
|
190 | |||
178 | self.voltageOutObj.channelList = channelList |
|
191 | self.voltageOutObj.channelList = channelList | |
179 | self.voltageOutObj.nChannels = nchannels |
|
192 | self.voltageOutObj.nChannels = nchannels | |
180 | self.voltageOutObj.m_ProcessingHeader.totalSpectra = nchannels |
|
193 | self.voltageOutObj.m_ProcessingHeader.totalSpectra = nchannels | |
181 | self.voltageOutObj.m_SystemHeader.numChannels = nchannels |
|
194 | self.voltageOutObj.m_SystemHeader.numChannels = nchannels | |
182 | self.voltageOutObj.m_ProcessingHeader.blockSize = data.size |
|
195 | self.voltageOutObj.m_ProcessingHeader.blockSize = data.size | |
183 |
|
196 | |||
184 |
|
197 | |||
185 | def selectHeightsByValue(self, minHei, maxHei): |
|
198 | def selectHeightsByValue(self, minHei, maxHei): | |
186 | """ |
|
199 | """ | |
187 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango |
|
200 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango | |
188 | minHei <= height <= maxHei |
|
201 | minHei <= height <= maxHei | |
189 |
|
202 | |||
190 | Input: |
|
203 | Input: | |
191 | minHei : valor minimo de altura a considerar |
|
204 | minHei : valor minimo de altura a considerar | |
192 | maxHei : valor maximo de altura a considerar |
|
205 | maxHei : valor maximo de altura a considerar | |
193 |
|
206 | |||
194 | Affected: |
|
207 | Affected: | |
195 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex |
|
208 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex | |
196 |
|
209 | |||
197 | Return: |
|
210 | Return: | |
198 | None |
|
211 | None | |
199 | """ |
|
212 | """ | |
200 | minIndex = 0 |
|
213 | minIndex = 0 | |
201 | maxIndex = 0 |
|
214 | maxIndex = 0 | |
202 | data = self.dataOutObj.heightList |
|
215 | data = self.dataOutObj.heightList | |
203 |
|
216 | |||
204 | for i,val in enumerate(data): |
|
217 | for i,val in enumerate(data): | |
205 | if val < minHei: |
|
218 | if val < minHei: | |
206 | continue |
|
219 | continue | |
207 | else: |
|
220 | else: | |
208 | minIndex = i; |
|
221 | minIndex = i; | |
209 | break |
|
222 | break | |
210 |
|
223 | |||
211 | for i,val in enumerate(data): |
|
224 | for i,val in enumerate(data): | |
212 | if val <= maxHei: |
|
225 | if val <= maxHei: | |
213 | maxIndex = i; |
|
226 | maxIndex = i; | |
214 | else: |
|
227 | else: | |
215 | break |
|
228 | break | |
216 |
|
229 | |||
217 | self.selectHeightsByIndex(minIndex, maxIndex) |
|
230 | self.selectHeightsByIndex(minIndex, maxIndex) | |
218 |
|
231 | |||
219 |
|
232 | |||
220 | def selectHeightsByIndex(self, minIndex, maxIndex): |
|
233 | def selectHeightsByIndex(self, minIndex, maxIndex): | |
221 | """ |
|
234 | """ | |
222 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango |
|
235 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango | |
223 | minIndex <= index <= maxIndex |
|
236 | minIndex <= index <= maxIndex | |
224 |
|
237 | |||
225 | Input: |
|
238 | Input: | |
226 | minIndex : valor minimo de altura a considerar |
|
239 | minIndex : valor minimo de altura a considerar | |
227 | maxIndex : valor maximo de altura a considerar |
|
240 | maxIndex : valor maximo de altura a considerar | |
228 |
|
241 | |||
229 | Affected: |
|
242 | Affected: | |
230 | self.voltageOutObj.datablock |
|
243 | self.voltageOutObj.datablock | |
231 | self.voltageOutObj.m_ProcessingHeader.numHeights |
|
244 | self.voltageOutObj.m_ProcessingHeader.numHeights | |
232 | self.voltageOutObj.m_ProcessingHeader.blockSize |
|
245 | self.voltageOutObj.m_ProcessingHeader.blockSize | |
233 | self.voltageOutObj.heightList |
|
246 | self.voltageOutObj.heightList | |
234 | self.voltageOutObj.nHeights |
|
247 | self.voltageOutObj.nHeights | |
235 | self.voltageOutObj.m_RadarControllerHeader.numHeights |
|
248 | self.voltageOutObj.m_RadarControllerHeader.numHeights | |
236 |
|
249 | |||
237 | Return: |
|
250 | Return: | |
238 | None |
|
251 | None | |
239 | """ |
|
252 | """ | |
240 | channels = self.voltageOutObj.nChannels |
|
253 | channels = self.voltageOutObj.nChannels | |
241 | profiles = self.voltageOutObj.nProfiles |
|
254 | profiles = self.voltageOutObj.nProfiles | |
242 | newheis = maxIndex - minIndex + 1 |
|
255 | newheis = maxIndex - minIndex + 1 | |
243 | firstHeight = 0 |
|
256 | firstHeight = 0 | |
244 |
|
257 | |||
245 | #voltage |
|
258 | #voltage | |
246 | data = numpy.zeros( (channels,profiles,newheis), dtype='complex' ) |
|
259 | data = numpy.zeros( (channels,profiles,newheis), dtype='complex' ) | |
247 | for i in range(channels): |
|
260 | for i in range(channels): | |
248 | data[i] = self.voltageOutObj.data_spc[i,:,minIndex:maxIndex+1] |
|
261 | data[i] = self.voltageOutObj.data_spc[i,:,minIndex:maxIndex+1] | |
249 |
|
262 | |||
250 | self.voltageOutObj.datablock = data |
|
263 | self.voltageOutObj.datablock = data | |
251 |
|
264 | |||
252 | firstHeight = self.dataOutObj.heightList[minIndex] |
|
265 | firstHeight = self.dataOutObj.heightList[minIndex] | |
253 |
|
266 | |||
254 | self.voltageOutObj.nHeights = newheis |
|
267 | self.voltageOutObj.nHeights = newheis | |
255 | self.voltageOutObj.m_ProcessingHeader.blockSize = data.size |
|
268 | self.voltageOutObj.m_ProcessingHeader.blockSize = data.size | |
256 | self.voltageOutObj.m_ProcessingHeader.numHeights = newheis |
|
269 | self.voltageOutObj.m_ProcessingHeader.numHeights = newheis | |
257 | self.voltageOutObj.m_ProcessingHeader.firstHeight = firstHeight |
|
270 | self.voltageOutObj.m_ProcessingHeader.firstHeight = firstHeight | |
258 | self.voltageOutObj.m_RadarControllerHeader = newheis |
|
271 | self.voltageOutObj.m_RadarControllerHeader = newheis | |
259 |
|
272 | |||
260 | xi = firstHeight |
|
273 | xi = firstHeight | |
261 | step = self.voltageOutObj.m_ProcessingHeader.deltaHeight |
|
274 | step = self.voltageOutObj.m_ProcessingHeader.deltaHeight | |
262 | xf = xi + newheis * step |
|
275 | xf = xi + newheis * step | |
263 | self.voltageOutObj.heightList = numpy.arange(xi, xf, step) |
|
276 | self.voltageOutObj.heightList = numpy.arange(xi, xf, step) | |
264 |
|
277 | |||
265 |
|
278 | |||
266 | def selectProfiles(self, minIndex, maxIndex): |
|
279 | def selectProfiles(self, minIndex, maxIndex, nProfiles): | |
267 | """ |
|
280 | """ | |
268 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango |
|
281 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango | |
269 | minIndex <= index <= maxIndex |
|
282 | minIndex <= index <= maxIndex | |
270 |
|
283 | |||
271 | Input: |
|
284 | Input: | |
272 | minIndex : valor minimo de altura a considerar |
|
285 | minIndex : valor minimo de altura a considerar | |
273 | maxIndex : valor maximo de altura a considerar |
|
286 | maxIndex : valor maximo de altura a considerar | |
274 |
|
287 | |||
275 | Affected: |
|
288 | Affected: | |
276 | self.voltageOutObj.datablock |
|
289 | self.voltageOutObj.datablock | |
277 | self.voltageOutObj.m_ProcessingHeader.numHeights |
|
290 | self.voltageOutObj.m_ProcessingHeader.numHeights | |
278 | self.voltageOutObj.heightList |
|
291 | self.voltageOutObj.heightList | |
279 |
|
292 | |||
280 | Return: |
|
293 | Return: | |
281 | None |
|
294 | None | |
282 | """ |
|
295 | """ | |
283 | channels = self.voltageOutObj.nChannels |
|
296 | ||
284 | heights = self.voltageOutObj.m_ProcessingHeader.numHeights |
|
297 | if self.voltageOutObj.flagNoData: | |
285 | newprofiles = maxIndex - minIndex + 1 |
|
298 | return 0 | |
286 |
|
299 | |||
287 | #voltage |
|
300 | if self.profSelectorIndex >= len(self.profileSelectorList): | |
288 | data = numpy.zeros( (channels,newprofiles,heights), dtype='complex' ) |
|
301 | self.addProfileSelector(nProfiles) | |
289 | for i in range(channels): |
|
302 | ||
290 | data[i,:,:] = self.voltageOutObj.data_spc[i,minIndex:maxIndex+1,:] |
|
303 | profileSelectorObj = self.profileSelectorList[self.profSelectorIndex] | |
291 |
|
304 | |||
292 | self.voltageOutObj.datablock = data |
|
305 | if profileSelectorObj.isProfileInRange(minIndex, maxIndex): | |
293 |
|
306 | self.voltageOutObj.flagNoData = False | ||
294 | self.voltageOutObj.m_ProcessingHeader.blockSize = data.size |
|
307 | self.profSelectorIndex += 1 | |
295 | self.voltageOutObj.nProfiles = newprofiles |
|
308 | return 1 | |
296 | self.voltageOutObj.m_SystemHeader.numProfiles = newprofiles |
|
309 | ||
297 |
|
310 | self.voltageOutObj.flagNoData = True | ||
|
311 | self.profSelectorIndex += 1 | |||
|
312 | ||||
|
313 | return 0 | |||
298 |
|
314 | |||
299 | def selectNtxs(self, ntx): |
|
315 | def selectNtxs(self, ntx): | |
300 | pass |
|
316 | pass | |
301 |
|
317 | |||
302 |
|
318 | |||
303 | class Decoder: |
|
319 | class Decoder: | |
|
320 | ||||
304 | def __init__(self,code, ncode, nbaud): |
|
321 | def __init__(self,code, ncode, nbaud): | |
|
322 | ||||
305 | self.buffer = None |
|
323 | self.buffer = None | |
306 | self.profCounter = 1 |
|
324 | self.profCounter = 1 | |
307 | self.nCode = ncode |
|
325 | self.nCode = ncode | |
308 | self.nBaud = nbaud |
|
326 | self.nBaud = nbaud | |
309 | self.codeIndex = 0 |
|
327 | self.codeIndex = 0 | |
310 | self.code = code #this is a List |
|
328 | self.code = code #this is a List | |
311 | self.fft_code = None |
|
329 | self.fft_code = None | |
312 | self.flag = False |
|
330 | self.flag = False | |
313 | self.setCodeFft = False |
|
331 | self.setCodeFft = False | |
314 |
|
332 | |||
315 | def exe(self, data, ndata=None, type = 0): |
|
333 | def exe(self, data, ndata=None, type = 0): | |
|
334 | ||||
316 | if ndata == None: ndata = data.shape[1] |
|
335 | if ndata == None: ndata = data.shape[1] | |
317 |
|
336 | |||
318 | if type == 0: |
|
337 | if type == 0: | |
319 | self.convolutionInFreq(data,ndata) |
|
338 | self.convolutionInFreq(data,ndata) | |
320 |
|
339 | |||
321 | if type == 1: |
|
340 | if type == 1: | |
322 | self.convolutionInTime(data, ndata) |
|
341 | self.convolutionInTime(data, ndata) | |
323 |
|
342 | |||
324 | def convolutionInFreq(self,data,ndata): |
|
343 | def convolutionInFreq(self,data, ndata): | |
325 |
|
344 | |||
326 | newcode = numpy.zeros(ndata) |
|
345 | newcode = numpy.zeros(ndata) | |
327 | newcode[0:self.nBaud] = self.code[self.codeIndex] |
|
346 | newcode[0:self.nBaud] = self.code[self.codeIndex] | |
328 |
|
347 | |||
329 | self.codeIndex += 1 |
|
348 | self.codeIndex += 1 | |
330 |
|
349 | |||
331 | fft_data = numpy.fft.fft(data, axis=1) |
|
350 | fft_data = numpy.fft.fft(data, axis=1) | |
332 | fft_code = numpy.conj(numpy.fft.fft(newcode)) |
|
351 | fft_code = numpy.conj(numpy.fft.fft(newcode)) | |
333 | fft_code = fft_code.reshape(1,len(fft_code)) |
|
352 | fft_code = fft_code.reshape(1,len(fft_code)) | |
334 |
|
353 | |||
335 | conv = fft_data.copy() |
|
354 | conv = fft_data.copy() | |
336 | conv.fill(0) |
|
355 | conv.fill(0) | |
337 |
|
356 | |||
338 | conv = fft_data*fft_code # This other way to calculate multiplication between bidimensional arrays |
|
357 | conv = fft_data*fft_code # This other way to calculate multiplication between bidimensional arrays | |
339 | # for i in range(ndata): |
|
358 | # for i in range(ndata): | |
340 | # conv[i,:] = fft_data[i,:]*fft_code[i] |
|
359 | # conv[i,:] = fft_data[i,:]*fft_code[i] | |
341 |
|
360 | |||
342 | self.data = numpy.fft.ifft(conv,axis=1) |
|
361 | self.data = numpy.fft.ifft(conv,axis=1) | |
343 | self.flag = True |
|
362 | self.flag = True | |
344 |
|
363 | |||
345 | if self.profCounter == self.nCode: |
|
364 | if self.profCounter == self.nCode: | |
346 | self.profCounter = 0 |
|
365 | self.profCounter = 0 | |
347 | self.codeIndex = 0 |
|
366 | self.codeIndex = 0 | |
348 |
|
367 | |||
349 | self.profCounter += 1 |
|
368 | self.profCounter += 1 | |
350 |
|
369 | |||
351 | def convolutionInTime(self, data, ndata): |
|
370 | def convolutionInTime(self, data, ndata): | |
352 |
|
371 | |||
353 | nchannel = data.shape[1] |
|
372 | nchannel = data.shape[1] | |
354 | newcode = self.code[self.codeIndex] |
|
373 | newcode = self.code[self.codeIndex] | |
355 | self.codeIndex += 1 |
|
374 | self.codeIndex += 1 | |
356 | conv = data.copy() |
|
375 | conv = data.copy() | |
357 | for i in range(nchannel): |
|
376 | for i in range(nchannel): | |
358 | conv[i,:] = numpy.correlate(data[i,:], newcode, 'same') |
|
377 | conv[i,:] = numpy.correlate(data[i,:], newcode, 'same') | |
359 |
|
378 | |||
360 | self.data = conv |
|
379 | self.data = conv | |
361 | self.flag = True |
|
380 | self.flag = True | |
362 |
|
381 | |||
363 | if self.profCounter == self.nCode: |
|
382 | if self.profCounter == self.nCode: | |
364 | self.profCounter = 0 |
|
383 | self.profCounter = 0 | |
365 | self.codeIndex = 0 |
|
384 | self.codeIndex = 0 | |
366 |
|
385 | |||
367 | self.profCounter += 1 |
|
386 | self.profCounter += 1 | |
368 |
|
387 | |||
369 |
|
388 | |||
370 | class CoherentIntegrator: |
|
389 | class CoherentIntegrator: | |
|
390 | ||||
371 | def __init__(self, N): |
|
391 | def __init__(self, N): | |
|
392 | ||||
372 | self.profCounter = 1 |
|
393 | self.profCounter = 1 | |
373 | self.data = None |
|
394 | self.data = None | |
374 | self.buffer = None |
|
395 | self.buffer = None | |
375 | self.flag = False |
|
396 | self.flag = False | |
376 | self.nCohInt = N |
|
397 | self.nCohInt = N | |
377 |
|
398 | |||
378 | def exe(self,data): |
|
399 | def exe(self, data): | |
379 |
|
400 | |||
380 | if self.buffer == None: |
|
401 | if self.buffer == None: | |
381 | self.buffer = data |
|
402 | self.buffer = data | |
382 | else: |
|
403 | else: | |
383 | self.buffer = self.buffer + data |
|
404 | self.buffer = self.buffer + data | |
384 |
|
405 | |||
385 | if self.profCounter == self.nCohInt: |
|
406 | if self.profCounter == self.nCohInt: | |
386 | self.data = self.buffer |
|
407 | self.data = self.buffer | |
387 | self.buffer = None |
|
408 | self.buffer = None | |
388 | self.profCounter = 0 |
|
409 | self.profCounter = 0 | |
389 | self.flag = True |
|
410 | self.flag = True | |
390 | else: |
|
411 | else: | |
391 | self.flag = False |
|
412 | self.flag = False | |
392 |
|
413 | |||
393 | self.profCounter += 1 |
|
414 | self.profCounter += 1 | |
394 |
|
415 | |||
395 |
|
416 | class ProfileSelector(): | ||
|
417 | ||||
|
418 | indexProfile = None | |||
|
419 | # Tamaño total de los perfiles | |||
|
420 | nProfiles = None | |||
|
421 | ||||
|
422 | def __init__(self, nProfiles): | |||
|
423 | ||||
|
424 | self.indexProfile = 0 | |||
|
425 | self.nProfiles = nProfiles | |||
|
426 | ||||
|
427 | def isProfileInRange(self, minIndex, maxIndex): | |||
|
428 | ||||
|
429 | if minIndex < self.indexProfile: | |||
|
430 | self.indexProfile += 1 | |||
|
431 | return False | |||
|
432 | ||||
|
433 | if maxIndex > self.indexProfile: | |||
|
434 | self.indexProfile += 1 | |||
|
435 | return False | |||
|
436 | ||||
|
437 | self.indexProfile += 1 | |||
|
438 | ||||
|
439 | return True | |||
|
440 | ||||
|
441 | def isProfileInList(self, profileList): | |||
|
442 | ||||
|
443 | if self.indexProfile not in profileList: | |||
|
444 | self.indexProfile += 1 | |||
|
445 | return False | |||
|
446 | ||||
|
447 | self.indexProfile += 1 | |||
|
448 | ||||
|
449 | return True | |||
|
450 | ||||
|
451 | ||||
396 | No newline at end of file |
|
452 |
General Comments 0
You need to be logged in to leave comments.
Login now