@@ -11,9 +11,9 import datetime | |||
|
11 | 11 | path = os.path.split(os.getcwd())[0] |
|
12 | 12 | sys.path.append(path) |
|
13 | 13 | |
|
14 | from Data.JROData import Spectra | |
|
14 | from Data.JROData import SpectraHeis | |
|
15 | 15 | from IO.SpectraIO import SpectraWriter |
|
16 | from Graphics.schainPlotTypes import SpcFigure | |
|
16 | #from Graphics.schainPlotTypes import SpcFigure | |
|
17 | 17 | #from JRONoise import Noise |
|
18 | 18 | |
|
19 | 19 | class SpectraProcessor: |
@@ -46,10 +46,10 class SpectraProcessor: | |||
|
46 | 46 | self.integratorObjIndex = None |
|
47 | 47 | self.writerObjIndex = None |
|
48 | 48 | self.plotObjIndex = None |
|
49 |
self.integratorO |
|
|
50 | self.writerObjList = [] | |
|
49 | self.integratorOst = [] | |
|
51 | 50 | self.plotObjList = [] |
|
52 |
self.noiseObj = |
|
|
51 | self.noiseObj = bjList = [] | |
|
52 | self.writerObjLiNone | |
|
53 | 53 | self.buffer = None |
|
54 | 54 | self.profIndex = 0 |
|
55 | 55 | |
@@ -285,7 +285,152 class SpectraProcessor: | |||
|
285 | 285 | |
|
286 | 286 | self.integratorObjIndex += 1 |
|
287 | 287 | |
|
288 | ||
|
289 | class SpectraHeisProcessor: | |
|
290 | def __init__(self): | |
|
291 | self.integratorObjIndex = None | |
|
292 | self.writerObjIndex = None | |
|
293 | self.plotterObjIndex = None | |
|
294 | self.integratorObjList = [] | |
|
295 | self.writerObjList = [] | |
|
296 | self.plotterObjList = [] | |
|
297 | #self.noiseObj = Noise() | |
|
298 | ||
|
299 | def setup(self,dataInObj=None, dataOutObj=None, nFFTPoints=None, pairList=None): | |
|
300 | if dataInObj == None: | |
|
301 | raise ValueError, "" | |
|
302 | ||
|
303 | if nFFTPoints == None: | |
|
304 | raise ValueError, "" | |
|
305 | ||
|
306 | self.dataInObj = dataInObj | |
|
307 | ||
|
308 | if dataOutObj == None: | |
|
309 | dataOutObj = SpectraHeis() | |
|
310 | ||
|
311 | self.dataOutObj = dataOutObj | |
|
312 | # self.noiseObj = Noise() | |
|
313 | ||
|
314 | ########################################## | |
|
315 | self.nFFTPoints = nFFTPoints | |
|
316 | self.nChannels = self.dataInObj.nChannels | |
|
317 | self.nHeights = self.dataInObj.nHeights | |
|
318 | self.pairList = pairList | |
|
319 | if pairList != None: | |
|
320 | self.nPairs = len(pairList) | |
|
321 | else: | |
|
322 | self.nPairs = 0 | |
|
323 | ||
|
324 | self.dataOutObj.heightList = self.dataInObj.heightList | |
|
325 | self.dataOutObj.channelIndexList = self.dataInObj.channelIndexList | |
|
326 | self.dataOutObj.m_RadarControllerHeader = self.dataInObj.m_RadarControllerHeader.copy() | |
|
327 | self.dataOutObj.m_SystemHeader = self.dataInObj.m_SystemHeader.copy() | |
|
328 | ||
|
329 | self.dataOutObj.dataType = self.dataInObj.dataType | |
|
330 | self.dataOutObj.nPairs = self.nPairs | |
|
331 | self.dataOutObj.nChannels = self.nChannels | |
|
332 | self.dataOutObj.nProfiles = self.nFFTPoints | |
|
333 | self.dataOutObj.nHeights = self.nHeights | |
|
334 | self.dataOutObj.nFFTPoints = self.nFFTPoints | |
|
335 | #self.dataOutObj.data = None | |
|
336 | ||
|
337 | self.dataOutObj.m_SystemHeader.numChannels = self.nChannels | |
|
338 | self.dataOutObj.m_SystemHeader.nProfiles = self.nFFTPoints | |
|
339 | ||
|
340 | self.dataOutObj.m_ProcessingHeader.totalSpectra = self.nChannels + self.nPairs | |
|
341 | self.dataOutObj.m_ProcessingHeader.profilesPerBlock = self.nFFTPoints | |
|
342 | self.dataOutObj.m_ProcessingHeader.numHeights = self.nHeights | |
|
343 | self.dataOutObj.m_ProcessingHeader.shif_fft = True | |
|
344 | ||
|
345 | spectraComb = numpy.zeros( (self.nChannels+self.nPairs)*2,numpy.dtype('u1')) | |
|
346 | k = 0 | |
|
347 | for i in range( 0,self.nChannels*2,2 ): | |
|
348 | spectraComb[i] = k | |
|
349 | spectraComb[i+1] = k | |
|
350 | k += 1 | |
|
351 | ||
|
352 | k *= 2 | |
|
353 | ||
|
354 | if self.pairList != None: | |
|
355 | ||
|
356 | for pair in self.pairList: | |
|
357 | spectraComb[k] = pair[0] | |
|
358 | spectraComb[k+1] = pair[1] | |
|
359 | k += 2 | |
|
360 | ||
|
361 | self.dataOutObj.m_ProcessingHeader.spectraComb = spectraComb | |
|
362 | ||
|
363 | return self.dataOutObj | |
|
364 | ||
|
365 | def init(self): | |
|
366 | self.integratorObjIndex = 0 | |
|
367 | self.writerObjIndex = 0 | |
|
368 | self.plotterObjIndex = 0 | |
|
288 | 369 | |
|
370 | if self.dataInObj.type == "Voltage": | |
|
371 | self.__getFft() | |
|
372 | self.dataOutObj.flagNoData = False | |
|
373 | return | |
|
374 | ||
|
375 | #Other kind of data | |
|
376 | if self.dataInObj.type == "SpectraHeis": | |
|
377 | self.dataOutObj.copy(self.dataInObj) | |
|
378 | self.dataOutObj.flagNoData = False | |
|
379 | return | |
|
380 | ||
|
381 | raise ValueError, "The datatype is not valid" | |
|
382 | ||
|
383 | def __getFft(self): | |
|
384 | if self.dataInObj.flagNoData: | |
|
385 | return 0 | |
|
386 | ||
|
387 | fft_volt = numpy.fft.fft(self.dataInObj.data, axis=1) | |
|
388 | #print fft_volt | |
|
389 | #calculo de self-spectra | |
|
390 | fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,)) | |
|
391 | ||
|
392 | spc = numpy.abs(fft_volt * numpy.conjugate(fft_volt)) | |
|
393 | self.dataOutObj.data_spc = spc | |
|
394 | #print spc | |
|
395 | ||
|
396 | def getSpectra(self): | |
|
397 | ||
|
398 | return self.dataOutObj.data_spc | |
|
399 | ||
|
400 | def getFrecuencies(self): | |
|
401 | ||
|
402 | print self.nFFTPoints | |
|
403 | return numpy.arange(int(self.nFFTPoints)) | |
|
404 | ||
|
405 | def addIntegrator(self,N,timeInterval): | |
|
406 | objIncohInt = IncoherentIntegration(N,timeInterval) | |
|
407 | self.integratorObjList.append(objIncohInt) | |
|
408 | ||
|
409 | def integrator(self, N=None, timeInterval=None): | |
|
410 | if self.dataOutObj.flagNoData: | |
|
411 | return 0 | |
|
412 | ||
|
413 | if len(self.integratorObjList) <= self.integratorObjIndex: | |
|
414 | self.addIntegrator(N,timeInterval) | |
|
415 | ||
|
416 | myIncohIntObj = self.integratorObjList[self.integratorObjIndex] | |
|
417 | myIncohIntObj.exe(data=self.dataOutObj.data_spc,timeOfData=self.dataOutObj.m_BasicHeader.utc) | |
|
418 | ||
|
419 | if myIncohIntObj.isReady: | |
|
420 | self.dataOutObj.data_spc = myIncohIntObj.data | |
|
421 | self.dataOutObj.nAvg = myIncohIntObj.navg | |
|
422 | self.dataOutObj.m_ProcessingHeader.incoherentInt *= myIncohIntObj.navg | |
|
423 | #print "myIncohIntObj.navg: ",myIncohIntObj.navg | |
|
424 | self.dataOutObj.flagNoData = False | |
|
425 | ||
|
426 | #self.getNoise(type="hildebrand",parm=myIncohIntObj.navg) | |
|
427 | # self.getNoise(type="sort", parm=16) | |
|
428 | ||
|
429 | else: | |
|
430 | self.dataOutObj.flagNoData = True | |
|
431 | ||
|
432 | self.integratorObjIndex += 1 | |
|
433 | ||
|
289 | 434 | |
|
290 | 435 | |
|
291 | 436 | class IncoherentIntegration: |
General Comments 0
You need to be logged in to leave comments.
Login now