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