##// END OF EJS Templates
Se traslado el codigo antiguo a la carpeta old y se creo la estructura de directorios Model, Controller y GUI
Miguel Valdez -
r169:661bb8af254a
parent child
Show More
1 NO CONTENT: file renamed from schainpy/Controller/Controller.py to schainpy/old/Controller/Controller.py
1 NO CONTENT: file renamed from schainpy/Controller/experiment.cfg to schainpy/old/Controller/experiment.cfg
1 NO CONTENT: file renamed from schainpy/Graphics/BaseGraph.py to schainpy/old/Graphics/BaseGraph.py
1 NO CONTENT: file renamed from schainpy/Graphics/BaseGraph_mpl.py to schainpy/old/Graphics/BaseGraph_mpl.py
1 NO CONTENT: file renamed from schainpy/Graphics/SpectraPlot.py to schainpy/old/Graphics/SpectraPlot.py
1 NO CONTENT: file renamed from schainpy/Graphics/SpectraPlot2.py to schainpy/old/Graphics/SpectraPlot2.py
1 NO CONTENT: file renamed from schainpy/Graphics/VoltagePlot.py to schainpy/old/Graphics/VoltagePlot.py
1 NO CONTENT: file renamed from schainpy/Graphics/__init__.py to schainpy/old/Graphics/__init__.py
1 NO CONTENT: file renamed from schainpy/Graphics/schainPlot.py to schainpy/old/Graphics/schainPlot.py
1 NO CONTENT: file renamed from schainpy/Graphics/schainPlotLib.py to schainpy/old/Graphics/schainPlotLib.py
1 NO CONTENT: file renamed from schainpy/Graphics/schainPlotTypes.py to schainpy/old/Graphics/schainPlotTypes.py
1 NO CONTENT: file renamed from schainpy/IO/CorrelationIO.py to schainpy/old/IO/CorrelationIO.py
1 NO CONTENT: file renamed from schainpy/IO/JRODataIO.py to schainpy/old/IO/JRODataIO.py
1 NO CONTENT: file renamed from schainpy/IO/SpectraIO.py to schainpy/old/IO/SpectraIO.py
1 NO CONTENT: file renamed from schainpy/IO/VoltageIO.py to schainpy/old/IO/VoltageIO.py
1 NO CONTENT: file renamed from schainpy/IO/__init__.py to schainpy/old/IO/__init__.py
1 NO CONTENT: file renamed from schainpy/Model/Correlation.py to schainpy/old/Model/Correlation.py
@@ -1,105 +1,105
1 1 '''
2 2 Created on Feb 7, 2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7 import copy
8 8 import numpy
9 9
10 10 from JROHeader import RadarControllerHeader, ProcessingHeader, SystemHeader, BasicHeader
11 11
12 12 class Data:
13 13 '''
14 14 classdocs
15 15 '''
16 16
17 17 def __init__(self):
18 18 '''
19 19 Constructor
20 20 '''
21 21 raise ValueError, "This class has not been implemented"
22 22
23 23 def copy(self, objIn=None):
24 24
25 25 if objIn == None:
26 26 return copy.deepcopy(self)
27 27
28 28 for key in objIn.__dict__.keys():
29 29 self.__dict__[key] = objIn.__dict__[key]
30 30
31 31 def deepcopy(self):
32 32
33 33 return copy.deepcopy(self)
34 34
35 35
36 36
37 37 class JROData(Data):
38 38 '''
39 39 classdocs
40 40 '''
41 41
42 m_RadarControllerHeader = RadarControllerHeader()
42 radarControllerHeaderObj = RadarControllerHeader()
43 43
44 44 m_ProcessingHeader = ProcessingHeader()
45 45
46 m_SystemHeader = SystemHeader()
46 systemHeaderObj = SystemHeader()
47 47
48 48 m_BasicHeader = BasicHeader()
49 49
50 50 noise = None
51 51
52 52 type = None
53 53
54 54 dataType = None
55 55
56 56 nHeights = None
57 57
58 58 nProfiles = None
59 59
60 60 nChannels = None
61 61
62 62 heightList = None
63 63
64 64 channelList = None
65 65
66 66 channelIndexList = None
67 67
68 68 pairList = None
69 69
70 70 flagNoData = False
71 71
72 72 flagResetProcessing = False
73 73
74 74 def __init__(self):
75 75 '''
76 76 Constructor
77 77 '''
78 78 raise ValueError, "This class has not been implemented"
79 79
80 80 def updateHeaderFromObj(self):
81 81
82 82 xi = self.heightList[0]
83 83 step = self.heightList[1] - self.heightList[0]
84 84
85 85 self.m_ProcessingHeader.firstHeight = xi
86 86 self.m_ProcessingHeader.deltaHeight = step
87 87
88 88 self.m_ProcessingHeader.numHeights = self.nHeights
89 self.m_SystemHeader.numChannels = self.nChannels
90 self.m_SystemHeader.numProfiles = self.nProfiles
89 self.systemHeaderObj.numChannels = self.nChannels
90 self.systemHeaderObj.numProfiles = self.nProfiles
91 91
92 92 def updateObjFromHeader(self):
93 93
94 94 xi = self.m_ProcessingHeader.firstHeight
95 95 step = self.m_ProcessingHeader.deltaHeight
96 96 xf = xi + self.m_ProcessingHeader.numHeights*step
97 97
98 98 self.heightList = numpy.arange(xi, xf, step)
99 self.channelIndexList = numpy.arange(self.m_SystemHeader.numChannels)
100 self.channelList = numpy.arange(self.m_SystemHeader.numChannels)
99 self.channelIndexList = numpy.arange(self.systemHeaderObj.numChannels)
100 self.channelList = numpy.arange(self.systemHeaderObj.numChannels)
101 101
102 102 self.nHeights = len(self.heightList)
103 self.nProfiles = self.m_SystemHeader.numProfiles
103 self.nProfiles = self.systemHeaderObj.numProfiles
104 104 self.nChannels = len(self.channelList)
105 105 No newline at end of file
1 NO CONTENT: file renamed from schainpy/Model/JROHeader.py to schainpy/old/Model/JROHeader.py
1 NO CONTENT: file renamed from schainpy/Model/Spectra.py to schainpy/old/Model/Spectra.py
1 NO CONTENT: file renamed from schainpy/Model/Voltage.py to schainpy/old/Model/Voltage.py
1 NO CONTENT: file renamed from schainpy/Model/__init__.py to schainpy/old/Model/__init__.py
1 NO CONTENT: file renamed from schainpy/Processing/CorrelationProcessor.py to schainpy/old/Processing/CorrelationProcessor.py
1 NO CONTENT: file renamed from schainpy/Processing/JRONoise.py to schainpy/old/Processing/JRONoise.py
@@ -1,700 +1,700
1 1 '''
2 2 Created on Feb 7, 2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7 import os, sys
8 8 import numpy
9 9 import time
10 10
11 11 path = os.path.split(os.getcwd())[0]
12 12 sys.path.append(path)
13 13
14 14 from Model.Spectra import Spectra
15 15 from IO.SpectraIO import SpectraWriter
16 16 from Graphics.SpectraPlot import Spectrum
17 17 from JRONoise import Noise
18 18
19 19 class SpectraProcessor:
20 20 '''
21 21 classdocs
22 22 '''
23 23
24 24 dataInObj = None
25 25
26 26 dataOutObj = None
27 27
28 28 noiseObj = None
29 29
30 30 integratorObjList = []
31 31
32 32 decoderObjList = []
33 33
34 34 writerObjList = []
35 35
36 36 plotterObjList = []
37 37
38 38 integratorObjIndex = None
39 39
40 40 decoderObjIndex = None
41 41
42 42 writerObjIndex = None
43 43
44 44 plotterObjIndex = None
45 45
46 46 buffer = None
47 47
48 48 profIndex = 0
49 49
50 50 nFFTPoints = None
51 51
52 52 nChannels = None
53 53
54 54 nHeights = None
55 55
56 56 nPairs = None
57 57
58 58 pairList = None
59 59
60 60
61 61 def __init__(self):
62 62 '''
63 63 Constructor
64 64 '''
65 65
66 66 self.integratorObjIndex = None
67 67 self.decoderObjIndex = None
68 68 self.writerObjIndex = None
69 69 self.plotterObjIndex = None
70 70
71 71 self.integratorObjList = []
72 72 self.decoderObjList = []
73 73 self.writerObjList = []
74 74 self.plotterObjList = []
75 75
76 76 self.noiseObj = None
77 77 self.buffer = None
78 78 self.profIndex = 0
79 79
80 80 def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairList=None):
81 81
82 82 if dataInObj == None:
83 83 raise ValueError, ""
84 84
85 85 if nFFTPoints == None:
86 86 raise ValueError, ""
87 87
88 88 self.dataInObj = dataInObj
89 89
90 90 if dataOutObj == None:
91 91 dataOutObj = Spectra()
92 92
93 93 self.dataOutObj = dataOutObj
94 94 self.noiseObj = Noise()
95 95
96 96 ##########################################
97 97 self.nFFTPoints = nFFTPoints
98 98 self.nChannels = self.dataInObj.nChannels
99 99 self.nHeights = self.dataInObj.nHeights
100 100 self.pairList = pairList
101 101 if pairList != None:
102 102 self.nPairs = len(pairList)
103 103 else:
104 104 self.nPairs = 0
105 105
106 106 self.dataOutObj.heightList = self.dataInObj.heightList
107 107 self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList
108 108 self.dataOutObj.m_BasicHeader = self.dataInObj.m_BasicHeader.copy()
109 109 self.dataOutObj.m_ProcessingHeader = self.dataInObj.m_ProcessingHeader.copy()
110 self.dataOutObj.m_RadarControllerHeader = self.dataInObj.m_RadarControllerHeader.copy()
111 self.dataOutObj.m_SystemHeader = self.dataInObj.m_SystemHeader.copy()
110 self.dataOutObj.radarControllerHeaderObj = self.dataInObj.radarControllerHeaderObj.copy()
111 self.dataOutObj.systemHeaderObj = self.dataInObj.systemHeaderObj.copy()
112 112
113 113 self.dataOutObj.dataType = self.dataInObj.dataType
114 114 self.dataOutObj.nPairs = self.nPairs
115 115 self.dataOutObj.nChannels = self.nChannels
116 116 self.dataOutObj.nProfiles = self.nFFTPoints
117 117 self.dataOutObj.nHeights = self.nHeights
118 118 self.dataOutObj.nFFTPoints = self.nFFTPoints
119 119 #self.dataOutObj.data = None
120 120
121 self.dataOutObj.m_SystemHeader.numChannels = self.nChannels
122 self.dataOutObj.m_SystemHeader.nProfiles = self.nFFTPoints
121 self.dataOutObj.systemHeaderObj.numChannels = self.nChannels
122 self.dataOutObj.systemHeaderObj.nProfiles = self.nFFTPoints
123 123
124 124 self.dataOutObj.m_ProcessingHeader.totalSpectra = self.nChannels + self.nPairs
125 125 self.dataOutObj.m_ProcessingHeader.profilesPerBlock = self.nFFTPoints
126 126 self.dataOutObj.m_ProcessingHeader.numHeights = self.nHeights
127 127 self.dataOutObj.m_ProcessingHeader.shif_fft = True
128 128
129 129 spectraComb = numpy.zeros( (self.nChannels+self.nPairs)*2,numpy.dtype('u1'))
130 130 k = 0
131 131 for i in range( 0,self.nChannels*2,2 ):
132 132 spectraComb[i] = k
133 133 spectraComb[i+1] = k
134 134 k += 1
135 135
136 136 k *= 2
137 137
138 138 if self.pairList != None:
139 139
140 140 for pair in self.pairList:
141 141 spectraComb[k] = pair[0]
142 142 spectraComb[k+1] = pair[1]
143 143 k += 2
144 144
145 145 self.dataOutObj.m_ProcessingHeader.spectraComb = spectraComb
146 146
147 147 return self.dataOutObj
148 148
149 149 def init(self):
150 150
151 151 self.nHeights = self.dataInObj.nHeights
152 152 self.dataOutObj.nHeights = self.nHeights
153 153 self.dataOutObj.heightList = self.dataInObj.heightList
154 154
155 155 self.integratorObjIndex = 0
156 156 self.decoderObjIndex = 0
157 157 self.writerObjIndex = 0
158 158 self.plotterObjIndex = 0
159 159
160 160 if self.dataInObj.type == "Voltage":
161 161
162 162 if self.buffer == None:
163 163 self.buffer = numpy.zeros((self.nChannels,
164 164 self.nFFTPoints,
165 165 self.dataInObj.nHeights),
166 166 dtype='complex')
167 167
168 168 self.buffer[:,self.profIndex,:] = self.dataInObj.data
169 169 self.profIndex += 1
170 170
171 171 if self.profIndex == self.nFFTPoints:
172 172 self.__getFft()
173 173 self.dataOutObj.flagNoData = False
174 174
175 175 self.buffer = None
176 176 self.profIndex = 0
177 177 return
178 178
179 179 self.dataOutObj.flagNoData = True
180 180
181 181 return
182 182
183 183 #Other kind of data
184 184 if self.dataInObj.type == "Spectra":
185 185 self.dataOutObj.copy(self.dataInObj)
186 186 self.dataOutObj.flagNoData = False
187 187 return
188 188
189 189 raise ValueError, "The datatype is not valid"
190 190
191 191 def __getFft(self):
192 192 """
193 193 Convierte valores de Voltaje a Spectra
194 194
195 195 Affected:
196 196 self.dataOutObj.data_spc
197 197 self.dataOutObj.data_cspc
198 198 self.dataOutObj.data_dc
199 199 self.dataOutObj.heightList
200 200 self.dataOutObj.m_BasicHeader
201 201 self.dataOutObj.m_ProcessingHeader
202 self.dataOutObj.m_RadarControllerHeader
203 self.dataOutObj.m_SystemHeader
202 self.dataOutObj.radarControllerHeaderObj
203 self.dataOutObj.systemHeaderObj
204 204 self.profIndex
205 205 self.buffer
206 206 self.dataOutObj.flagNoData
207 207 self.dataOutObj.dataType
208 208 self.dataOutObj.nPairs
209 209 self.dataOutObj.nChannels
210 210 self.dataOutObj.nProfiles
211 self.dataOutObj.m_SystemHeader.numChannels
211 self.dataOutObj.systemHeaderObj.numChannels
212 212 self.dataOutObj.m_ProcessingHeader.totalSpectra
213 213 self.dataOutObj.m_ProcessingHeader.profilesPerBlock
214 214 self.dataOutObj.m_ProcessingHeader.numHeights
215 215 self.dataOutObj.m_ProcessingHeader.spectraComb
216 216 self.dataOutObj.m_ProcessingHeader.shif_fft
217 217 """
218 218
219 219 if self.dataInObj.flagNoData:
220 220 return 0
221 221
222 222 fft_volt = numpy.fft.fft(self.buffer,axis=1)
223 223 dc = fft_volt[:,0,:]
224 224
225 225 #calculo de self-spectra
226 226 fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,))
227 227 spc = fft_volt * numpy.conjugate(fft_volt)
228 228 spc = spc.real
229 229
230 230 blocksize = 0
231 231 blocksize += dc.size
232 232 blocksize += spc.size
233 233
234 234 cspc = None
235 235 pairIndex = 0
236 236 if self.pairList != None:
237 237 #calculo de cross-spectra
238 238 cspc = numpy.zeros((self.nPairs, self.nFFTPoints, self.nHeights), dtype='complex')
239 239 for pair in self.pairList:
240 240 cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:]))
241 241 pairIndex += 1
242 242 blocksize += cspc.size
243 243
244 244 self.dataOutObj.data_spc = spc
245 245 self.dataOutObj.data_cspc = cspc
246 246 self.dataOutObj.data_dc = dc
247 247 self.dataOutObj.m_ProcessingHeader.blockSize = blocksize
248 248 self.dataOutObj.m_BasicHeader.utc = self.dataInObj.m_BasicHeader.utc
249 249
250 250 # self.getNoise()
251 251
252 252 def addWriter(self,wrpath):
253 253 objWriter = SpectraWriter(self.dataOutObj)
254 254 objWriter.setup(wrpath)
255 255 self.writerObjList.append(objWriter)
256 256
257 257 def addPlotter(self,index=None):
258 258 if index==None:
259 259 index = self.plotterObjIndex
260 260
261 261 plotObj = Spectrum(self.dataOutObj, index)
262 262 self.plotterObjList.append(plotObj)
263 263
264 264 def addIntegrator(self,N,timeInterval):
265 265
266 266 objIncohInt = IncoherentIntegration(N,timeInterval)
267 267 self.integratorObjList.append(objIncohInt)
268 268
269 269 def writeData(self, wrpath):
270 270 if self.dataOutObj.flagNoData:
271 271 return 0
272 272
273 273 if len(self.writerObjList) <= self.writerObjIndex:
274 274 self.addWriter(wrpath)
275 275
276 276 self.writerObjList[self.writerObjIndex].putData()
277 277
278 278 self.writerObjIndex += 1
279 279
280 280 def plotData(self,
281 281 xmin=None,
282 282 xmax=None,
283 283 ymin=None,
284 284 ymax=None,
285 285 zmin=None,
286 286 zmax=None,
287 287 titleList=None,
288 288 xlabelList=None,
289 289 ylabelList=None,
290 290 winTitle='',
291 291 colormap="br_green",
292 292 showColorbar=False,
293 293 showPowerProfile=False,
294 294 XAxisAsTime=False,
295 295 save=False,
296 296 index=None,
297 297 channelList=[]):
298 298
299 299 if self.dataOutObj.flagNoData:
300 300 return 0
301 301
302 302 if len(self.plotterObjList) <= self.plotterObjIndex:
303 303 self.addPlotter(index)
304 304
305 305 self.plotterObjList[self.plotterObjIndex].plotData(xmin,
306 306 xmax,
307 307 ymin,
308 308 ymax,
309 309 zmin,
310 310 zmax,
311 311 titleList,
312 312 xlabelList,
313 313 ylabelList,
314 314 winTitle,
315 315 colormap,
316 316 showColorbar,
317 317 showPowerProfile,
318 318 XAxisAsTime,
319 319 save,
320 320 channelList)
321 321
322 322 self.plotterObjIndex += 1
323 323
324 324 def integrator(self, N=None, timeInterval=None):
325 325
326 326 if self.dataOutObj.flagNoData:
327 327 return 0
328 328
329 329 if len(self.integratorObjList) <= self.integratorObjIndex:
330 330 self.addIntegrator(N,timeInterval)
331 331
332 332 myIncohIntObj = self.integratorObjList[self.integratorObjIndex]
333 333 myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc)
334 334
335 335 if myIncohIntObj.isReady:
336 336 self.dataOutObj.data_spc = myIncohIntObj.data
337 337 self.dataOutObj.nAvg = myIncohIntObj.navg
338 338 self.dataOutObj.m_ProcessingHeader.incoherentInt = self.dataInObj.m_ProcessingHeader.incoherentInt*myIncohIntObj.navg
339 339 #print "myIncohIntObj.navg: ",myIncohIntObj.navg
340 340 self.dataOutObj.flagNoData = False
341 341
342 342 """Calcular el ruido"""
343 343 self.getNoise()
344 344 else:
345 345 self.dataOutObj.flagNoData = True
346 346
347 347 self.integratorObjIndex += 1
348 348
349 349
350 350
351 351 def removeDC(self, type):
352 352
353 353 if self.dataOutObj.flagNoData:
354 354 return 0
355 355
356 356 def removeInterference(self):
357 357
358 358 if self.dataOutObj.flagNoData:
359 359 return 0
360 360
361 361 def removeSatellites(self):
362 362
363 363 if self.dataOutObj.flagNoData:
364 364 return 0
365 365
366 366 def getNoise(self, type="hildebrand", parm=None):
367 367
368 368 if parm == None:
369 369 parm =self.dataOutObj.m_ProcessingHeader.incoherentInt
370 370
371 371 self.noiseObj.setNoise(self.dataOutObj.data_spc)
372 372
373 373 if type == "hildebrand":
374 374 noise = self.noiseObj.byHildebrand(parm)
375 375
376 376 if type == "window":
377 377 noise = self.noiseObj.byWindow(parm)
378 378
379 379 if type == "sort":
380 380 noise = self.noiseObj.bySort(parm)
381 381
382 382 self.dataOutObj.noise = noise
383 383 # print 10*numpy.log10(noise)
384 384
385 385 def selectChannels(self, channelList, pairList=[]):
386 386
387 387 channelIndexList = []
388 388
389 389 for channel in channelList:
390 390 if channel in self.dataOutObj.channelList:
391 391 index = self.dataOutObj.channelList.index(channel)
392 392 channelIndexList.append(index)
393 393
394 394 pairIndexList = []
395 395
396 396 for pair in pairList:
397 397 if pair in self.dataOutObj.pairList:
398 398 index = self.dataOutObj.pairList.index(pair)
399 399 pairIndexList.append(index)
400 400
401 401 self.selectChannelsByIndex(channelIndexList, pairIndexList)
402 402
403 403 def selectChannelsByIndex(self, channelIndexList, pairIndexList=[]):
404 404 """
405 405 Selecciona un bloque de datos en base a canales y pares segun el
406 406 channelIndexList y el pairIndexList
407 407
408 408 Input:
409 409 channelIndexList : lista de indices de los canales a seleccionar por ej.
410 410
411 411 Si tenemos los canales
412 412
413 413 self.channelList = (2,3,5,7)
414 414
415 415 y deseamos escoger los canales (3,7)
416 416 entonces colocaremos el parametro
417 417
418 418 channelndexList = (1,3)
419 419
420 420 pairIndexList : tupla de indice depares que se desea selecionar por ej.
421 421
422 422 Si tenemos los pares :
423 423
424 424 ( (0,1), (0,2), (1,3), (2,5) )
425 425
426 426 y deseamos seleccionar los pares ((0,2), (2,5))
427 427 entonces colocaremos el parametro
428 428
429 429 pairIndexList = (1,3)
430 430
431 431 Affected:
432 432 self.dataOutObj.data_spc
433 433 self.dataOutObj.data_cspc
434 434 self.dataOutObj.data_dc
435 435 self.dataOutObj.nChannels
436 436 self.dataOutObj.nPairs
437 437 self.dataOutObj.m_ProcessingHeader.spectraComb
438 self.dataOutObj.m_SystemHeader.numChannels
438 self.dataOutObj.systemHeaderObj.numChannels
439 439
440 440 self.dataOutObj.noise
441 441 Return:
442 442 None
443 443 """
444 444
445 445 if self.dataOutObj.flagNoData:
446 446 return 0
447 447
448 448 if pairIndexList == []:
449 449 pairIndexList = numpy.arange(len(self.dataOutObj.pairList))
450 450
451 451 nChannels = len(channelIndexList)
452 452 nPairs = len(pairIndexList)
453 453
454 454 blocksize = 0
455 455 #self spectra
456 456 spc = self.dataOutObj.data_spc[channelIndexList,:,:]
457 457 blocksize += spc.size
458 458
459 459 cspc = None
460 460 if pairIndexList != []:
461 461 cspc = self.dataOutObj.data_cspc[pairIndexList,:,:]
462 462 blocksize += cspc.size
463 463
464 464 #DC channel
465 465 dc = None
466 466 if self.dataOutObj.m_ProcessingHeader.flag_dc:
467 467 dc = self.dataOutObj.data_dc[channelIndexList,:]
468 468 blocksize += dc.size
469 469
470 470 #Almacenar las combinaciones de canales y cros espectros
471 471
472 472 spectraComb = numpy.zeros( (nChannels+nPairs)*2,numpy.dtype('u1'))
473 473 i = 0
474 474 for spcChannel in channelIndexList:
475 475 spectraComb[i] = spcChannel
476 476 spectraComb[i+1] = spcChannel
477 477 i += 2
478 478
479 479 if pairList != None:
480 480 for pair in pairList:
481 481 spectraComb[i] = pair[0]
482 482 spectraComb[i+1] = pair[1]
483 483 i += 2
484 484
485 485 #######
486 486
487 487 self.dataOutObj.data_spc = spc
488 488 self.dataOutObj.data_cspc = cspc
489 489 self.dataOutObj.data_dc = dc
490 490 self.dataOutObj.nChannels = nChannels
491 491 self.dataOutObj.nPairs = nPairs
492 492
493 493 self.dataOutObj.channelIndexList = channelIndexList
494 494
495 495 self.dataOutObj.m_ProcessingHeader.spectraComb = spectraComb
496 496 self.dataOutObj.m_ProcessingHeader.totalSpectra = nChannels + nPairs
497 self.dataOutObj.m_SystemHeader.numChannels = nChannels
497 self.dataOutObj.systemHeaderObj.numChannels = nChannels
498 498 self.dataOutObj.nChannels = nChannels
499 499 self.dataOutObj.m_ProcessingHeader.blockSize = blocksize
500 500
501 501 if cspc == None:
502 502 self.dataOutObj.m_ProcessingHeader.flag_dc = False
503 503 if dc == None:
504 504 self.dataOutObj.m_ProcessingHeader.flag_cpsc = False
505 505
506 506 def selectHeightsByValue(self, minHei, maxHei):
507 507 """
508 508 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
509 509 minHei <= height <= maxHei
510 510
511 511 Input:
512 512 minHei : valor minimo de altura a considerar
513 513 maxHei : valor maximo de altura a considerar
514 514
515 515 Affected:
516 516 Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex
517 517
518 518 Return:
519 519 None
520 520 """
521 521
522 522 if self.dataOutObj.flagNoData:
523 523 return 0
524 524
525 525 if (minHei < self.dataOutObj.heightList[0]) or (minHei > maxHei):
526 526 raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
527 527
528 528 if (maxHei > self.dataOutObj.heightList[-1]):
529 529 raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
530 530
531 531 minIndex = 0
532 532 maxIndex = 0
533 533 data = self.dataOutObj.heightList
534 534
535 535 for i,val in enumerate(data):
536 536 if val < minHei:
537 537 continue
538 538 else:
539 539 minIndex = i;
540 540 break
541 541
542 542 for i,val in enumerate(data):
543 543 if val <= maxHei:
544 544 maxIndex = i;
545 545 else:
546 546 break
547 547
548 548 self.selectHeightsByIndex(minIndex, maxIndex)
549 549
550 550 def selectHeightsByIndex(self, minIndex, maxIndex):
551 551 """
552 552 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
553 553 minIndex <= index <= maxIndex
554 554
555 555 Input:
556 556 minIndex : valor minimo de altura a considerar
557 557 maxIndex : valor maximo de altura a considerar
558 558
559 559 Affected:
560 560 self.dataOutObj.data_spc
561 561 self.dataOutObj.data_cspc
562 562 self.dataOutObj.data_dc
563 563 self.dataOutObj.heightList
564 564 self.dataOutObj.nHeights
565 565 self.dataOutObj.m_ProcessingHeader.numHeights
566 566 self.dataOutObj.m_ProcessingHeader.blockSize
567 567 self.dataOutObj.m_ProcessingHeader.firstHeight
568 self.dataOutObj.m_RadarControllerHeader.numHeights
568 self.dataOutObj.radarControllerHeaderObj.numHeights
569 569
570 570 Return:
571 571 None
572 572 """
573 573
574 574 if self.dataOutObj.flagNoData:
575 575 return 0
576 576
577 577 if (minIndex < 0) or (minIndex > maxIndex):
578 578 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
579 579
580 580 if (maxIndex >= self.dataOutObj.nHeights):
581 581 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
582 582
583 583 nChannels = self.dataOutObj.nChannels
584 584 nPairs = self.dataOutObj.nPairs
585 585 nProfiles = self.dataOutObj.nProfiles
586 586 dataType = self.dataOutObj.dataType
587 587 nHeights = maxIndex - minIndex + 1
588 588 blockSize = 0
589 589
590 590 #self spectra
591 591 spc = self.dataOutObj.data_spc[:,:,minIndex:maxIndex+1]
592 592 blockSize += spc.size
593 593
594 594 #cross spectra
595 595 cspc = None
596 596 if self.dataOutObj.data_cspc != None:
597 597 cspc = self.dataOutObj.data_cspc[:,:,minIndex:maxIndex+1]
598 598 blockSize += cspc.size
599 599
600 600 #DC channel
601 601 dc = self.dataOutObj.data_dc[:,minIndex:maxIndex+1]
602 602 blockSize += dc.size
603 603
604 604 self.dataOutObj.data_spc = spc
605 605 if cspc != None:
606 606 self.dataOutObj.data_cspc = cspc
607 607 self.dataOutObj.data_dc = dc
608 608
609 609 firstHeight = self.dataOutObj.heightList[minIndex]
610 610
611 611 self.dataOutObj.nHeights = nHeights
612 612 self.dataOutObj.m_ProcessingHeader.blockSize = blockSize
613 613 self.dataOutObj.m_ProcessingHeader.numHeights = nHeights
614 614 self.dataOutObj.m_ProcessingHeader.firstHeight = firstHeight
615 self.dataOutObj.m_RadarControllerHeader.numHeights = nHeights
615 self.dataOutObj.radarControllerHeaderObj.numHeights = nHeights
616 616
617 617 self.dataOutObj.heightList = self.dataOutObj.heightList[minIndex:maxIndex+1]
618 618
619 619
620 620 class IncoherentIntegration:
621 621
622 622 integ_counter = None
623 623 data = None
624 624 navg = None
625 625 buffer = None
626 626 nIncohInt = None
627 627
628 628 def __init__(self, N = None, timeInterval = None):
629 629 """
630 630 N
631 631 timeInterval - interval time [min], integer value
632 632 """
633 633
634 634 self.data = None
635 635 self.navg = None
636 636 self.buffer = None
637 637 self.timeOut = None
638 638 self.exitCondition = False
639 639 self.isReady = False
640 640 self.nIncohInt = N
641 641 self.integ_counter = 0
642 642 if timeInterval!=None:
643 643 self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line
644 644
645 645 if ((timeInterval==None) and (N==None)):
646 646 print 'N = None ; timeInterval = None'
647 647 sys.exit(0)
648 648 elif timeInterval == None:
649 649 self.timeFlag = False
650 650 else:
651 651 self.timeFlag = True
652 652
653 653
654 654 def exe(self,data,timeOfData):
655 655 """
656 656 data
657 657
658 658 timeOfData [seconds]
659 659 """
660 660
661 661 if self.timeFlag:
662 662 if self.timeOut == None:
663 663 self.timeOut = timeOfData + self.timeIntervalInSeconds
664 664
665 665 if timeOfData < self.timeOut:
666 666 if self.buffer == None:
667 667 self.buffer = data
668 668 else:
669 669 self.buffer = self.buffer + data
670 670 self.integ_counter += 1
671 671 else:
672 672 self.exitCondition = True
673 673
674 674 else:
675 675 if self.integ_counter < self.nIncohInt:
676 676 if self.buffer == None:
677 677 self.buffer = data
678 678 else:
679 679 self.buffer = self.buffer + data
680 680
681 681 self.integ_counter += 1
682 682
683 683 if self.integ_counter == self.nIncohInt:
684 684 self.exitCondition = True
685 685
686 686 if self.exitCondition:
687 687 self.data = self.buffer
688 688 self.navg = self.integ_counter
689 689 self.isReady = True
690 690 self.buffer = None
691 691 self.timeOut = None
692 692 self.integ_counter = 0
693 693 self.exitCondition = False
694 694
695 695 if self.timeFlag:
696 696 self.buffer = data
697 697 self.timeOut = timeOfData + self.timeIntervalInSeconds
698 698 else:
699 699 self.isReady = False
700 700 No newline at end of file
@@ -1,679 +1,679
1 1 '''
2 2 Created on Feb 7, 2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7
8 8 import os, sys
9 9 import numpy
10 10
11 11 path = os.path.split(os.getcwd())[0]
12 12 sys.path.append(path)
13 13
14 14 from Model.Voltage import Voltage
15 15 from IO.VoltageIO import VoltageWriter
16 16 from Graphics.VoltagePlot import Osciloscope
17 17 from Graphics.VoltagePlot import RTI
18 18
19 19 class VoltageProcessor:
20 20 '''
21 21 classdocs
22 22 '''
23 23
24 24 dataInObj = None
25 25 dataOutObj = None
26 26
27 27 integratorObjIndex = None
28 28 decoderObjIndex = None
29 29 profSelectorObjIndex = None
30 30 writerObjIndex = None
31 31 plotterObjIndex = None
32 32 flipIndex = None
33 33
34 34 integratorObjList = []
35 35 decoderObjList = []
36 36 profileSelectorObjList = []
37 37 writerObjList = []
38 38 plotterObjList = []
39 39 m_Voltage= Voltage()
40 40
41 41 def __init__(self):
42 42 '''
43 43 Constructor
44 44 '''
45 45
46 46 self.integratorObjIndex = None
47 47 self.decoderObjIndex = None
48 48 self.profSelectorObjIndex = None
49 49 self.writerObjIndex = None
50 50 self.plotterObjIndex = None
51 51 self.flipIndex = 1
52 52 self.integratorObjList = []
53 53 self.decoderObjList = []
54 54 self.profileSelectorObjList = []
55 55 self.writerObjList = []
56 56 self.plotterObjList = []
57 57
58 58 def setup(self, dataInObj=None, dataOutObj=None):
59 59
60 60 self.dataInObj = dataInObj
61 61
62 62 if dataOutObj == None:
63 63 dataOutObj = Voltage()
64 64
65 65 dataOutObj.copy(dataInObj)
66 66
67 67 self.dataOutObj = dataOutObj
68 68
69 69 return self.dataOutObj
70 70
71 71
72 72 def init(self):
73 73
74 74 self.integratorObjIndex = 0
75 75 self.decoderObjIndex = 0
76 76 self.profSelectorObjIndex = 0
77 77 self.writerObjIndex = 0
78 78 self.plotterObjIndex = 0
79 79 self.dataOutObj.copy(self.dataInObj)
80 80
81 81 if self.profSelectorObjIndex != None:
82 82 for profSelObj in self.profileSelectorObjList:
83 83 profSelObj.incIndex()
84 84
85 85 def addWriter(self, wrpath):
86 86 objWriter = VoltageWriter(self.dataOutObj)
87 87 objWriter.setup(wrpath)
88 88 self.writerObjList.append(objWriter)
89 89
90 90 def addRti(self,index=None):
91 91 if index==None:
92 92 index = self.plotterObjIndex
93 93
94 94 plotObj = RTI(self.dataOutObj, index)
95 95 self.plotterObjList.append(plotObj)
96 96
97 97 def addPlotter(self, index=None):
98 98 if index==None:
99 99 index = self.plotterObjIndex
100 100
101 101 plotObj = Osciloscope(self.dataOutObj, index)
102 102 self.plotterObjList.append(plotObj)
103 103
104 104 def addIntegrator(self, N,timeInterval):
105 105
106 106 objCohInt = CoherentIntegrator(N,timeInterval)
107 107 self.integratorObjList.append(objCohInt)
108 108
109 109 def addDecoder(self, code, ncode, nbaud):
110 110
111 111 objDecoder = Decoder(code,ncode,nbaud)
112 112 self.decoderObjList.append(objDecoder)
113 113
114 114 def addProfileSelector(self, nProfiles):
115 115
116 116 objProfSelector = ProfileSelector(nProfiles)
117 117 self.profileSelectorObjList.append(objProfSelector)
118 118
119 119 def writeData(self,wrpath):
120 120
121 121 if self.dataOutObj.flagNoData:
122 122 return 0
123 123
124 124 if len(self.writerObjList) <= self.writerObjIndex:
125 125 self.addWriter(wrpath)
126 126
127 127 self.writerObjList[self.writerObjIndex].putData()
128 128
129 129 self.writerObjIndex += 1
130 130
131 131 def addScope(self,index=None):
132 132 if index==None:
133 133 index = self.plotterObjIndex
134 134
135 135 plotObj = Osciloscope(self.dataOutObj, index)
136 136 self.plotterObjList.append(plotObj)
137 137
138 138 def plotScope(self,
139 139 xmin=None,
140 140 xmax=None,
141 141 ymin=None,
142 142 ymax=None,
143 143 titleList=None,
144 144 xlabelList=None,
145 145 ylabelList=None,
146 146 winTitle='',
147 147 type="power",
148 148 index=None):
149 149
150 150 if self.dataOutObj.flagNoData:
151 151 return 0
152 152
153 153 if len(self.plotterObjList) <= self.plotterObjIndex:
154 154 self.addScope(index)
155 155
156 156 self.plotterObjList[self.plotterObjIndex].plotData(xmin,
157 157 xmax,
158 158 ymin,
159 159 ymax,
160 160 titleList,
161 161 xlabelList,
162 162 ylabelList,
163 163 winTitle,
164 164 type)
165 165
166 166 self.plotterObjIndex += 1
167 167
168 168 def plotRti(self,
169 169 xmin=None,
170 170 xmax=None,
171 171 ymin=None,
172 172 ymax=None,
173 173 zmin=None,
174 174 zmax=None,
175 175 titleList=None,
176 176 xlabelList=None,
177 177 ylabelList=None,
178 178 winTitle='',
179 179 timezone='lt',
180 180 npoints=1000.0,
181 181 colormap="br_green",
182 182 showColorbar=True,
183 183 showPowerProfile=False,
184 184 XAxisAsTime=True,
185 185 save=False,
186 186 index=None):
187 187
188 188 if self.dataOutObj.flagNoData:
189 189 return 0
190 190
191 191 if len(self.plotterObjList) <= self.plotterObjIndex:
192 192 self.addRti(index)
193 193
194 194 self.plotterObjList[self.plotterObjIndex].plotData(xmin,
195 195 xmax,
196 196 ymin,
197 197 ymax,
198 198 zmin,
199 199 zmax,
200 200 titleList,
201 201 xlabelList,
202 202 ylabelList,
203 203 winTitle,
204 204 timezone,
205 205 npoints,
206 206 colormap,
207 207 showColorbar,
208 208 showPowerProfile,
209 209 XAxisAsTime,
210 210 save)
211 211
212 212 self.plotterObjIndex += 1
213 213
214 214
215 215 def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, type='iq', winTitle='', index=None):
216 216 if self.dataOutObj.flagNoData:
217 217 return 0
218 218
219 219 if len(self.plotterObjList) <= self.plotterObjIndex:
220 220 self.addPlotter(index)
221 221
222 222 self.plotterObjList[self.plotterObjIndex].plotData(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,type=type, winTitle=winTitle)
223 223
224 224 self.plotterObjIndex += 1
225 225
226 226 def integrator(self, N=None, timeInterval=None):
227 227
228 228 if self.dataOutObj.flagNoData:
229 229 return 0
230 230
231 231 if len(self.integratorObjList) <= self.integratorObjIndex:
232 232 self.addIntegrator(N,timeInterval)
233 233
234 234 myCohIntObj = self.integratorObjList[self.integratorObjIndex]
235 235 myCohIntObj.exe(data=self.dataOutObj.data,timeOfData=self.dataOutObj.m_BasicHeader.utc)
236 236
237 237 if myCohIntObj.isReady:
238 238 self.dataOutObj.data = myCohIntObj.data
239 239 self.dataOutObj.nAvg = myCohIntObj.navg
240 240 self.dataOutObj.m_ProcessingHeader.coherentInt *= myCohIntObj.navg
241 241 #print "myCohIntObj.navg: ",myCohIntObj.navg
242 242 self.dataOutObj.flagNoData = False
243 243
244 244 else:
245 245 self.dataOutObj.flagNoData = True
246 246
247 247 self.integratorObjIndex += 1
248 248
249 249 def decoder(self,code=None, mode = 0):
250 250
251 251 if self.dataOutObj.flagNoData:
252 252 return 0
253 253
254 254 if code == None:
255 code = self.dataOutObj.m_RadarControllerHeader.code
255 code = self.dataOutObj.radarControllerHeaderObj.code
256 256 ncode, nbaud = code.shape
257 257
258 258 if len(self.decoderObjList) <= self.decoderObjIndex:
259 259 self.addDecoder(code,ncode,nbaud)
260 260
261 261 myDecodObj = self.decoderObjList[self.decoderObjIndex]
262 262 data, ndata = myDecodObj.exe(data=self.dataOutObj.data,mode=mode)
263 263
264 264 self.dataOutObj.data = data
265 265 self.dataOutObj.nHeights = ndata
266 266 self.dataOutObj.heightList = self.dataInObj.heightList[:ndata]
267 267 self.dataOutObj.flagNoData = False
268 268
269 269 self.decoderObjIndex += 1
270 270
271 271
272 272 def filterByHei(self, window):
273 273 if window == None:
274 window = self.dataOutObj.m_RadarControllerHeader.txA / self.dataOutObj.m_ProcessingHeader.deltaHeight[0]
274 window = self.dataOutObj.radarControllerHeaderObj.txA / self.dataOutObj.m_ProcessingHeader.deltaHeight[0]
275 275
276 276 newdelta = self.dataOutObj.m_ProcessingHeader.deltaHeight[0] * window
277 277 dim1 = self.dataOutObj.data.shape[0]
278 278 dim2 = self.dataOutObj.data.shape[1]
279 279 r = dim2 % window
280 280
281 281 buffer = self.dataOutObj.data[:,0:dim2-r]
282 282 buffer = buffer.reshape(dim1,dim2/window,window)
283 283 buffer = numpy.sum(buffer,2)
284 284 self.dataOutObj.data = buffer
285 285
286 286 self.dataOutObj.m_ProcessingHeader.deltaHeight = newdelta
287 287 self.dataOutObj.m_ProcessingHeader.numHeights = buffer.shape[1]
288 288
289 289 self.dataOutObj.nHeights = self.dataOutObj.m_ProcessingHeader.numHeights
290 290
291 291 #self.dataOutObj.heightList es un numpy.array
292 292 self.dataOutObj.heightList = numpy.arange(self.dataOutObj.m_ProcessingHeader.firstHeight[0],newdelta*self.dataOutObj.nHeights,newdelta)
293 293
294 294 def deFlip(self):
295 295 self.dataOutObj.data *= self.flipIndex
296 296 self.flipIndex *= -1.
297 297
298 298 def selectChannels(self, channelList):
299 299 pass
300 300
301 301 def selectChannelsByIndex(self, channelIndexList):
302 302 """
303 303 Selecciona un bloque de datos en base a canales segun el channelIndexList
304 304
305 305 Input:
306 306 channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
307 307
308 308 Affected:
309 309 self.dataOutObj.data
310 310 self.dataOutObj.channelIndexList
311 311 self.dataOutObj.nChannels
312 312 self.dataOutObj.m_ProcessingHeader.totalSpectra
313 self.dataOutObj.m_SystemHeader.numChannels
313 self.dataOutObj.systemHeaderObj.numChannels
314 314 self.dataOutObj.m_ProcessingHeader.blockSize
315 315
316 316 Return:
317 317 None
318 318 """
319 319 if self.dataOutObj.flagNoData:
320 320 return 0
321 321
322 322 for channel in channelIndexList:
323 323 if channel not in self.dataOutObj.channelIndexList:
324 324 raise ValueError, "The value %d in channelIndexList is not valid" %channel
325 325
326 326 nChannels = len(channelIndexList)
327 327
328 328 data = self.dataOutObj.data[channelIndexList,:]
329 329
330 330 self.dataOutObj.data = data
331 331 self.dataOutObj.channelIndexList = channelIndexList
332 332 self.dataOutObj.nChannels = nChannels
333 333
334 334 self.dataOutObj.m_ProcessingHeader.totalSpectra = 0
335 self.dataOutObj.m_SystemHeader.numChannels = nChannels
335 self.dataOutObj.systemHeaderObj.numChannels = nChannels
336 336 self.dataOutObj.m_ProcessingHeader.blockSize = data.size
337 337 return 1
338 338
339 339
340 340 def selectHeightsByValue(self, minHei, maxHei):
341 341 """
342 342 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
343 343 minHei <= height <= maxHei
344 344
345 345 Input:
346 346 minHei : valor minimo de altura a considerar
347 347 maxHei : valor maximo de altura a considerar
348 348
349 349 Affected:
350 350 Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex
351 351
352 352 Return:
353 353 1 si el metodo se ejecuto con exito caso contrario devuelve 0
354 354 """
355 355 if self.dataOutObj.flagNoData:
356 356 return 0
357 357
358 358 if (minHei < self.dataOutObj.heightList[0]) or (minHei > maxHei):
359 359 raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
360 360
361 361 if (maxHei > self.dataOutObj.heightList[-1]):
362 362 raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
363 363
364 364 minIndex = 0
365 365 maxIndex = 0
366 366 data = self.dataOutObj.heightList
367 367
368 368 for i,val in enumerate(data):
369 369 if val < minHei:
370 370 continue
371 371 else:
372 372 minIndex = i;
373 373 break
374 374
375 375 for i,val in enumerate(data):
376 376 if val <= maxHei:
377 377 maxIndex = i;
378 378 else:
379 379 break
380 380
381 381 self.selectHeightsByIndex(minIndex, maxIndex)
382 382 return 1
383 383
384 384
385 385 def selectHeightsByIndex(self, minIndex, maxIndex):
386 386 """
387 387 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
388 388 minIndex <= index <= maxIndex
389 389
390 390 Input:
391 391 minIndex : valor de indice minimo de altura a considerar
392 392 maxIndex : valor de indice maximo de altura a considerar
393 393
394 394 Affected:
395 395 self.dataOutObj.data
396 396 self.dataOutObj.heightList
397 397 self.dataOutObj.nHeights
398 398 self.dataOutObj.m_ProcessingHeader.blockSize
399 399 self.dataOutObj.m_ProcessingHeader.numHeights
400 400 self.dataOutObj.m_ProcessingHeader.firstHeight
401 self.dataOutObj.m_RadarControllerHeader
401 self.dataOutObj.radarControllerHeaderObj
402 402
403 403 Return:
404 404 1 si el metodo se ejecuto con exito caso contrario devuelve 0
405 405 """
406 406 if self.dataOutObj.flagNoData:
407 407 return 0
408 408
409 409 if (minIndex < 0) or (minIndex > maxIndex):
410 410 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
411 411
412 412 if (maxIndex >= self.dataOutObj.nHeights):
413 413 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
414 414
415 415 nHeights = maxIndex - minIndex + 1
416 416
417 417 #voltage
418 418 data = self.dataOutObj.data[:,minIndex:maxIndex+1]
419 419
420 420 firstHeight = self.dataOutObj.heightList[minIndex]
421 421
422 422 self.dataOutObj.data = data
423 423 self.dataOutObj.heightList = self.dataOutObj.heightList[minIndex:maxIndex+1]
424 424 self.dataOutObj.nHeights = nHeights
425 425 self.dataOutObj.m_ProcessingHeader.blockSize = data.size
426 426 self.dataOutObj.m_ProcessingHeader.numHeights = nHeights
427 427 self.dataOutObj.m_ProcessingHeader.firstHeight = firstHeight
428 self.dataOutObj.m_RadarControllerHeader.numHeights = nHeights
428 self.dataOutObj.radarControllerHeaderObj.numHeights = nHeights
429 429 return 1
430 430
431 431 def selectProfilesByValue(self,indexList, nProfiles):
432 432 if self.dataOutObj.flagNoData:
433 433 return 0
434 434
435 435 if self.profSelectorObjIndex >= len(self.profileSelectorObjList):
436 436 self.addProfileSelector(nProfiles)
437 437
438 438 profileSelectorObj = self.profileSelectorObjList[self.profSelectorObjIndex]
439 439
440 440 if not(profileSelectorObj.isProfileInList(indexList)):
441 441 self.dataOutObj.flagNoData = True
442 442 self.profSelectorObjIndex += 1
443 443 return 0
444 444
445 445 self.dataOutObj.flagNoData = False
446 446 self.profSelectorObjIndex += 1
447 447
448 448 return 1
449 449
450 450
451 451 def selectProfilesByIndex(self, minIndex, maxIndex, nProfiles):
452 452 """
453 453 Selecciona un bloque de datos en base a un grupo indices de perfiles segun el rango
454 454 minIndex <= index <= maxIndex
455 455
456 456 Input:
457 457 minIndex : valor de indice minimo de perfil a considerar
458 458 maxIndex : valor de indice maximo de perfil a considerar
459 459 nProfiles : numero de profiles
460 460
461 461 Affected:
462 462 self.dataOutObj.flagNoData
463 463 self.profSelectorObjIndex
464 464
465 465 Return:
466 466 1 si el metodo se ejecuto con exito caso contrario devuelve 0
467 467 """
468 468
469 469 if self.dataOutObj.flagNoData:
470 470 return 0
471 471
472 472 if self.profSelectorObjIndex >= len(self.profileSelectorObjList):
473 473 self.addProfileSelector(nProfiles)
474 474
475 475 profileSelectorObj = self.profileSelectorObjList[self.profSelectorObjIndex]
476 476
477 477 if not(profileSelectorObj.isProfileInRange(minIndex, maxIndex)):
478 478 self.dataOutObj.flagNoData = True
479 479 self.profSelectorObjIndex += 1
480 480 return 0
481 481
482 482 self.dataOutObj.flagNoData = False
483 483 self.profSelectorObjIndex += 1
484 484
485 485 return 1
486 486
487 487 def selectNtxs(self, ntx):
488 488 pass
489 489
490 490
491 491 class Decoder:
492 492
493 493 data = None
494 494 profCounter = 1
495 495 nCode = None
496 496 nBaud = None
497 497 codeIndex = 0
498 498 code = None
499 499 flag = False
500 500
501 501 def __init__(self,code, ncode, nbaud):
502 502
503 503 self.data = None
504 504 self.ndata = None
505 505 self.profCounter = 1
506 506 self.nCode = ncode
507 507 self.nBaud = nbaud
508 508 self.codeIndex = 0
509 509 self.code = code #this is a List
510 510 self.flag = False
511 511
512 512 def exe(self, data, ndata=None, mode = 0):
513 513
514 514 if ndata == None: ndata = data.shape[1]
515 515
516 516 if mode == 0:
517 517 self.convolutionInFreq(data,ndata)
518 518
519 519 if mode == 1:
520 520 self.convolutionInTime(data, ndata)
521 521
522 522 self.ndata = ndata - self.nBaud + 1
523 523
524 524 return self.data, self.ndata
525 525
526 526 def convolutionInFreq(self,data, ndata):
527 527
528 528 newcode = numpy.zeros(ndata)
529 529 newcode[0:self.nBaud] = self.code[self.codeIndex]
530 530
531 531 self.codeIndex += 1
532 532
533 533 fft_data = numpy.fft.fft(data, axis=1)
534 534 fft_code = numpy.conj(numpy.fft.fft(newcode))
535 535 fft_code = fft_code.reshape(1,len(fft_code))
536 536
537 537 conv = fft_data.copy()
538 538 conv.fill(0)
539 539
540 540 conv = fft_data*fft_code
541 541
542 542 data = numpy.fft.ifft(conv,axis=1)
543 543 self.data = data[:,:-self.nBaud+1]
544 544 self.flag = True
545 545
546 546 if self.profCounter == self.nCode:
547 547 self.profCounter = 0
548 548 self.codeIndex = 0
549 549
550 550 self.profCounter += 1
551 551
552 552 def convolutionInTime(self, data, ndata):
553 553
554 554 nchannel = data.shape[1]
555 555 newcode = self.code[self.codeIndex]
556 556 self.codeIndex += 1
557 557 conv = data.copy()
558 558 for i in range(nchannel):
559 559 conv[i,:] = numpy.correlate(data[i,:], newcode)
560 560
561 561 self.data = conv
562 562 self.flag = True
563 563
564 564 if self.profCounter == self.nCode:
565 565 self.profCounter = 0
566 566 self.codeIndex = 0
567 567
568 568 self.profCounter += 1
569 569
570 570
571 571 class CoherentIntegrator:
572 572
573 573 integ_counter = None
574 574 data = None
575 575 navg = None
576 576 buffer = None
577 577 nCohInt = None
578 578
579 579 def __init__(self, N=None,timeInterval=None):
580 580
581 581 self.data = None
582 582 self.navg = None
583 583 self.buffer = None
584 584 self.timeOut = None
585 585 self.exitCondition = False
586 586 self.isReady = False
587 587 self.nCohInt = N
588 588 self.integ_counter = 0
589 589 if timeInterval!=None:
590 590 self.timeIntervalInSeconds = timeInterval * 60. #if (type(timeInterval)!=integer) -> change this line
591 591
592 592 if ((timeInterval==None) and (N==None)):
593 593 raise ValueError, "N = None ; timeInterval = None"
594 594
595 595 if timeInterval == None:
596 596 self.timeFlag = False
597 597 else:
598 598 self.timeFlag = True
599 599
600 600 def exe(self, data, timeOfData):
601 601
602 602 if self.timeFlag:
603 603 if self.timeOut == None:
604 604 self.timeOut = timeOfData + self.timeIntervalInSeconds
605 605
606 606 if timeOfData < self.timeOut:
607 607 if self.buffer == None:
608 608 self.buffer = data
609 609 else:
610 610 self.buffer = self.buffer + data
611 611 self.integ_counter += 1
612 612 else:
613 613 self.exitCondition = True
614 614
615 615 else:
616 616 if self.integ_counter < self.nCohInt:
617 617 if self.buffer == None:
618 618 self.buffer = data
619 619 else:
620 620 self.buffer = self.buffer + data
621 621
622 622 self.integ_counter += 1
623 623
624 624 if self.integ_counter == self.nCohInt:
625 625 self.exitCondition = True
626 626
627 627 if self.exitCondition:
628 628 self.data = self.buffer
629 629 self.navg = self.integ_counter
630 630 self.isReady = True
631 631 self.buffer = None
632 632 self.timeOut = None
633 633 self.integ_counter = 0
634 634 self.exitCondition = False
635 635
636 636 if self.timeFlag:
637 637 self.buffer = data
638 638 self.timeOut = timeOfData + self.timeIntervalInSeconds
639 639 else:
640 640 self.isReady = False
641 641
642 642
643 643
644 644 class ProfileSelector:
645 645
646 646 profileIndex = None
647 647 # Tamanho total de los perfiles
648 648 nProfiles = None
649 649
650 650 def __init__(self, nProfiles):
651 651
652 652 self.profileIndex = 0
653 653 self.nProfiles = nProfiles
654 654
655 655 def incIndex(self):
656 656 self.profileIndex += 1
657 657
658 658 if self.profileIndex >= self.nProfiles:
659 659 self.profileIndex = 0
660 660
661 661 def isProfileInRange(self, minIndex, maxIndex):
662 662
663 663 if self.profileIndex < minIndex:
664 664 return False
665 665
666 666 if self.profileIndex > maxIndex:
667 667 return False
668 668
669 669 return True
670 670
671 671 def isProfileInList(self, profileList):
672 672
673 673 if self.profileIndex not in profileList:
674 674 return False
675 675
676 676 return True
677 677
678 678
679 679 No newline at end of file
1 NO CONTENT: file renamed from schainpy/Processing/__init__.py to schainpy/old/Processing/__init__.py
1 NO CONTENT: file renamed from schainpy/Utilities/FtpServer.py to schainpy/old/Utilities/FtpServer.py
1 NO CONTENT: file renamed from schainpy/Utilities/FtpServerList.py to schainpy/old/Utilities/FtpServerList.py
1 NO CONTENT: file renamed from schainpy/Utilities/__init__.py to schainpy/old/Utilities/__init__.py
General Comments 0
You need to be logged in to leave comments. Login now