@@ -147,9 +147,9 class JROData: | |||||
147 |
|
147 | |||
148 | code = None |
|
148 | code = None | |
149 |
|
149 | |||
150 |
flagDecodeData = |
|
150 | flagDecodeData = False #asumo q la data no esta decodificada | |
151 |
|
151 | |||
152 |
flagDeflipData = |
|
152 | flagDeflipData = False #asumo q la data no esta sin flip | |
153 |
|
153 | |||
154 | flagShiftFFT = False |
|
154 | flagShiftFFT = False | |
155 |
|
155 | |||
@@ -290,6 +290,13 class Voltage(JROData): | |||||
290 | self.nCohInt = None |
|
290 | self.nCohInt = None | |
291 |
|
291 | |||
292 | self.blocksize = None |
|
292 | self.blocksize = None | |
|
293 | ||||
|
294 | self.flagDecodeData = False #asumo q la data no esta decodificada | |||
|
295 | ||||
|
296 | self.flagDeflipData = False #asumo q la data no esta sin flip | |||
|
297 | ||||
|
298 | self.flagShiftFFT = False | |||
|
299 | ||||
293 |
|
300 | |||
294 | def getNoisebyHildebrand(self): |
|
301 | def getNoisebyHildebrand(self): | |
295 | """ |
|
302 | """ | |
@@ -379,6 +386,12 class Spectra(JROData): | |||||
379 | self.nFFTPoints = None |
|
386 | self.nFFTPoints = None | |
380 |
|
387 | |||
381 | self.wavelength = None |
|
388 | self.wavelength = None | |
|
389 | ||||
|
390 | self.flagDecodeData = False #asumo q la data no esta decodificada | |||
|
391 | ||||
|
392 | self.flagDeflipData = False #asumo q la data no esta sin flip | |||
|
393 | ||||
|
394 | self.flagShiftFFT = False | |||
382 |
|
395 | |||
383 | def getNoisebyHildebrand(self): |
|
396 | def getNoisebyHildebrand(self): | |
384 | """ |
|
397 | """ |
@@ -1399,6 +1399,7 class VoltageReader(JRODataReader): | |||||
1399 | self.dataOut.flagShiftFFT = False |
|
1399 | self.dataOut.flagShiftFFT = False | |
1400 |
|
1400 | |||
1401 | if self.processingHeaderObj.code != None: |
|
1401 | if self.processingHeaderObj.code != None: | |
|
1402 | ||||
1402 | self.dataOut.nCode = self.processingHeaderObj.nCode |
|
1403 | self.dataOut.nCode = self.processingHeaderObj.nCode | |
1403 |
|
1404 | |||
1404 | self.dataOut.nBaud = self.processingHeaderObj.nBaud |
|
1405 | self.dataOut.nBaud = self.processingHeaderObj.nBaud | |
@@ -1408,6 +1409,13 class VoltageReader(JRODataReader): | |||||
1408 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() |
|
1409 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() | |
1409 |
|
1410 | |||
1410 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() |
|
1411 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() | |
|
1412 | ||||
|
1413 | self.dataOut.flagDecodeData = False #asumo q la data no esta decodificada | |||
|
1414 | ||||
|
1415 | self.dataOut.flagDeflipData = False #asumo q la data no esta sin flip | |||
|
1416 | ||||
|
1417 | self.dataOut.flagShiftFFT = False | |||
|
1418 | ||||
1411 |
|
1419 | |||
1412 | # self.updateDataHeader() |
|
1420 | # self.updateDataHeader() | |
1413 |
|
1421 | |||
@@ -2059,13 +2067,18 class SpectraReader(JRODataReader): | |||||
2059 |
|
2067 | |||
2060 | self.dataOut.timeInterval = self.ippSeconds * self.processingHeaderObj.nCohInt * self.processingHeaderObj.nIncohInt * self.dataOut.nFFTPoints |
|
2068 | self.dataOut.timeInterval = self.ippSeconds * self.processingHeaderObj.nCohInt * self.processingHeaderObj.nIncohInt * self.dataOut.nFFTPoints | |
2061 |
|
2069 | |||
2062 | self.dataOut.flagShiftFFT = self.processingHeaderObj.shif_fft |
|
|||
2063 |
|
||||
2064 | # self.profileIndex += 1 |
|
2070 | # self.profileIndex += 1 | |
2065 |
|
2071 | |||
2066 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() |
|
2072 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() | |
2067 |
|
2073 | |||
2068 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() |
|
2074 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() | |
|
2075 | ||||
|
2076 | self.dataOut.flagShiftFFT = self.processingHeaderObj.shif_fft | |||
|
2077 | ||||
|
2078 | self.dataOut.flagDecodeData = True #asumo q la data no esta decodificada | |||
|
2079 | ||||
|
2080 | self.dataOut.flagDeflipData = True #asumo q la data no esta sin flip | |||
|
2081 | ||||
2069 |
|
2082 | |||
2070 | return self.dataOut.data_spc |
|
2083 | return self.dataOut.data_spc | |
2071 |
|
2084 |
@@ -369,7 +369,7 class ProcessingHeader(Header): | |||||
369 | self.profilesPerBlock = int(header['nProfilesperBlock'][0]) |
|
369 | self.profilesPerBlock = int(header['nProfilesperBlock'][0]) | |
370 | self.dataBlocksPerFile = int(header['nDataBlocksperFile'][0]) |
|
370 | self.dataBlocksPerFile = int(header['nDataBlocksperFile'][0]) | |
371 | self.nWindows = int(header['nNumWindows'][0]) |
|
371 | self.nWindows = int(header['nNumWindows'][0]) | |
372 |
self.processFlags = |
|
372 | self.processFlags = header['nProcessFlags'] | |
373 | self.nCohInt = int(header['nCoherentIntegrations'][0]) |
|
373 | self.nCohInt = int(header['nCoherentIntegrations'][0]) | |
374 | self.nIncohInt = int(header['nIncoherentIntegrations'][0]) |
|
374 | self.nIncohInt = int(header['nIncoherentIntegrations'][0]) | |
375 | self.totalSpectra = int(header['nTotalSpectra'][0]) |
|
375 | self.totalSpectra = int(header['nTotalSpectra'][0]) |
@@ -88,6 +88,7 class CrossSpectraPlot(Figure): | |||||
88 | x = dataOut.getFreqRange(1) |
|
88 | x = dataOut.getFreqRange(1) | |
89 | y = dataOut.getHeiRange() |
|
89 | y = dataOut.getHeiRange() | |
90 | z = 10.*numpy.log10(dataOut.data_spc[:,:,:]) |
|
90 | z = 10.*numpy.log10(dataOut.data_spc[:,:,:]) | |
|
91 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |||
91 | avg = numpy.average(numpy.abs(z), axis=1) |
|
92 | avg = numpy.average(numpy.abs(z), axis=1) | |
92 |
|
93 | |||
93 | noise = dataOut.getNoise() |
|
94 | noise = dataOut.getNoise() | |
@@ -265,10 +266,11 class RTIPlot(Figure): | |||||
265 | x = dataOut.getTimeRange() |
|
266 | x = dataOut.getTimeRange() | |
266 | y = dataOut.getHeiRange() |
|
267 | y = dataOut.getHeiRange() | |
267 | z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) |
|
268 | z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) | |
|
269 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |||
268 | avg = numpy.average(z, axis=1) |
|
270 | avg = numpy.average(z, axis=1) | |
269 |
|
271 | |||
270 | noise = dataOut.getNoise() |
|
272 | noise = dataOut.getNoise() | |
271 |
|
|
273 | ||
272 | if not self.__isConfig: |
|
274 | if not self.__isConfig: | |
273 |
|
275 | |||
274 | nplots = len(channelIndexList) |
|
276 | nplots = len(channelIndexList) | |
@@ -284,6 +286,7 class RTIPlot(Figure): | |||||
284 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 |
|
286 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 | |
285 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 |
|
287 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 | |
286 |
|
288 | |||
|
289 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |||
287 | self.__isConfig = True |
|
290 | self.__isConfig = True | |
288 |
|
291 | |||
289 | thisDatetime = dataOut.datatime |
|
292 | thisDatetime = dataOut.datatime | |
@@ -313,9 +316,9 class RTIPlot(Figure): | |||||
313 | self.draw() |
|
316 | self.draw() | |
314 |
|
317 | |||
315 | if save: |
|
318 | if save: | |
316 | date = thisDatetime.strftime("%Y%m%d") |
|
319 | ||
317 | if figfile == None: |
|
320 | if figfile == None: | |
318 |
figfile = self.getFilename(name = |
|
321 | figfile = self.getFilename(name = self.name) | |
319 |
|
322 | |||
320 | self.saveFigure(figpath, figfile) |
|
323 | self.saveFigure(figpath, figfile) | |
321 |
|
324 | |||
@@ -412,7 +415,9 class SpectraPlot(Figure): | |||||
412 |
|
415 | |||
413 | x = dataOut.getVelRange(1) |
|
416 | x = dataOut.getVelRange(1) | |
414 | y = dataOut.getHeiRange() |
|
417 | y = dataOut.getHeiRange() | |
|
418 | ||||
415 | z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) |
|
419 | z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) | |
|
420 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |||
416 | avg = numpy.average(z, axis=1) |
|
421 | avg = numpy.average(z, axis=1) | |
417 |
|
422 | |||
418 | noise = dataOut.getNoise() |
|
423 | noise = dataOut.getNoise() | |
@@ -485,6 +490,8 class Scope(Figure): | |||||
485 |
|
490 | |||
486 | def setup(self, idfigure, nplots, wintitle): |
|
491 | def setup(self, idfigure, nplots, wintitle): | |
487 |
|
492 | |||
|
493 | self.nplots = nplots | |||
|
494 | ||||
488 | self.createFigure(idfigure, wintitle) |
|
495 | self.createFigure(idfigure, wintitle) | |
489 |
|
496 | |||
490 | nrow,ncol = self.getSubplots() |
|
497 | nrow,ncol = self.getSubplots() | |
@@ -494,7 +501,7 class Scope(Figure): | |||||
494 | for i in range(nplots): |
|
501 | for i in range(nplots): | |
495 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
502 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) | |
496 |
|
503 | |||
497 | self.nplots = nplots |
|
504 | ||
498 |
|
505 | |||
499 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
506 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
500 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, filename=None): |
|
507 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, filename=None): | |
@@ -522,13 +529,11 class Scope(Figure): | |||||
522 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
529 | channelIndexList.append(dataOut.channelList.index(channel)) | |
523 |
|
530 | |||
524 | x = dataOut.heightList |
|
531 | x = dataOut.heightList | |
525 | y = dataOut.data[channelList,:] * numpy.conjugate(dataOut.data[channelList,:]) |
|
532 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
526 | y = y.real |
|
533 | y = y.real | |
527 |
|
534 | |||
528 | noise = dataOut.getNoise() |
|
|||
529 |
|
||||
530 | if not self.__isConfig: |
|
535 | if not self.__isConfig: | |
531 | nplots = len(channelList) |
|
536 | nplots = len(channelIndexList) | |
532 |
|
537 | |||
533 | self.setup(idfigure=idfigure, |
|
538 | self.setup(idfigure=idfigure, | |
534 | nplots=nplots, |
|
539 | nplots=nplots, | |
@@ -550,7 +555,7 class Scope(Figure): | |||||
550 | self.setWinTitle(title) |
|
555 | self.setWinTitle(title) | |
551 |
|
556 | |||
552 | for i in range(len(self.axesList)): |
|
557 | for i in range(len(self.axesList)): | |
553 |
title = "Channel %d |
|
558 | title = "Channel %d" %(i) | |
554 | axes = self.axesList[i] |
|
559 | axes = self.axesList[i] | |
555 | ychannel = y[i,:] |
|
560 | ychannel = y[i,:] | |
556 | axes.pline(x, ychannel, |
|
561 | axes.pline(x, ychannel, |
@@ -62,7 +62,7 class ProcessingUnit: | |||||
62 | def operation(self, **kwargs): |
|
62 | def operation(self, **kwargs): | |
63 |
|
63 | |||
64 | """ |
|
64 | """ | |
65 |
Operacion directa sobre la data (data |
|
65 | Operacion directa sobre la data (dataOut.data). Es necesario actualizar los valores de los | |
66 | atributos del objeto dataOut |
|
66 | atributos del objeto dataOut | |
67 |
|
67 | |||
68 | Input: |
|
68 | Input: | |
@@ -347,24 +347,11 class VoltageProc(ProcessingUnit): | |||||
347 |
|
347 | |||
348 | return 1 |
|
348 | return 1 | |
349 |
|
349 | |||
350 |
|
||||
351 | def filterByHeights(self, window): |
|
|||
352 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] |
|
|||
353 |
|
||||
354 | if window == None: |
|
|||
355 | window = self.dataOut.radarControllerHeaderObj.txA / deltaHeight |
|
|||
356 |
|
||||
357 | newdelta = deltaHeight * window |
|
|||
358 | r = self.dataOut.data.shape[1] % window |
|
|||
359 | buffer = self.dataOut.data[:,0:self.dataOut.data.shape[1]-r] |
|
|||
360 | buffer = buffer.reshape(self.dataOut.data.shape[0],self.dataOut.data.shape[1]/window,window) |
|
|||
361 | buffer = numpy.sum(buffer,2) |
|
|||
362 | self.dataOut.data = buffer |
|
|||
363 | self.dataOut.heightList = numpy.arange(self.dataOut.heightList[0],newdelta*self.dataOut.nHeights/window,newdelta) |
|
|||
364 |
|
||||
365 |
|
350 | |||
366 | class CohInt(Operation): |
|
351 | class CohInt(Operation): | |
367 |
|
352 | |||
|
353 | __isConfig = False | |||
|
354 | ||||
368 | __profIndex = 0 |
|
355 | __profIndex = 0 | |
369 | __withOverapping = False |
|
356 | __withOverapping = False | |
370 |
|
357 | |||
@@ -539,10 +526,10 class CohInt(Operation): | |||||
539 |
|
526 | |||
540 | return avgdata, avgdatatime |
|
527 | return avgdata, avgdatatime | |
541 |
|
528 | |||
542 | def run(self, dataOut, n=None, timeInterval=None, overlapping=False): |
|
529 | def run(self, dataOut, **kwargs): | |
543 |
|
530 | |||
544 | if not self.__isConfig: |
|
531 | if not self.__isConfig: | |
545 |
self.setup( |
|
532 | self.setup(**kwargs) | |
546 | self.__isConfig = True |
|
533 | self.__isConfig = True | |
547 |
|
534 | |||
548 | avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) |
|
535 | avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) | |
@@ -556,7 +543,102 class CohInt(Operation): | |||||
556 | dataOut.utctime = avgdatatime |
|
543 | dataOut.utctime = avgdatatime | |
557 | dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt |
|
544 | dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt | |
558 | dataOut.flagNoData = False |
|
545 | dataOut.flagNoData = False | |
|
546 | ||||
|
547 | class Decoder(Operation): | |||
|
548 | ||||
|
549 | __isConfig = False | |||
|
550 | __profIndex = 0 | |||
|
551 | ||||
|
552 | code = None | |||
|
553 | ||||
|
554 | nCode = None | |||
|
555 | nBaud = None | |||
|
556 | ||||
|
557 | def __init__(self): | |||
|
558 | ||||
|
559 | self.__isConfig = False | |||
|
560 | ||||
|
561 | def setup(self, code): | |||
|
562 | ||||
|
563 | self.__profIndex = 0 | |||
|
564 | ||||
|
565 | self.code = code | |||
|
566 | ||||
|
567 | self.nCode = len(code) | |||
|
568 | self.nBaud = len(code[0]) | |||
|
569 | ||||
|
570 | def convolutionInFreq(self, data): | |||
|
571 | ||||
|
572 | ndata = data.shape[1] | |||
|
573 | newcode = numpy.zeros(ndata) | |||
|
574 | newcode[0:self.nBaud] = self.code[self.__profIndex] | |||
|
575 | ||||
|
576 | fft_data = numpy.fft.fft(data, axis=1) | |||
|
577 | fft_code = numpy.conj(numpy.fft.fft(newcode)) | |||
|
578 | fft_code = fft_code.reshape(1,len(fft_code)) | |||
|
579 | ||||
|
580 | # conv = fft_data.copy() | |||
|
581 | # conv.fill(0) | |||
|
582 | ||||
|
583 | conv = fft_data*fft_code | |||
|
584 | ||||
|
585 | data = numpy.fft.ifft(conv,axis=1) | |||
|
586 | ||||
|
587 | datadec = data[:,:-self.nBaud+1] | |||
|
588 | ndatadec = ndata - self.nBaud + 1 | |||
|
589 | ||||
|
590 | if self.__profIndex == self.nCode: | |||
|
591 | self.__profIndex = 0 | |||
|
592 | ||||
|
593 | self.__profIndex += 1 | |||
|
594 | ||||
|
595 | return ndatadec, datadec | |||
|
596 | ||||
|
597 | ||||
|
598 | def convolutionInTime(self, data): | |||
|
599 | ||||
|
600 | nchannel = data.shape[1] | |||
|
601 | newcode = self.code[self.__profIndex] | |||
|
602 | ||||
|
603 | datadec = data.copy() | |||
|
604 | ||||
|
605 | for i in range(nchannel): | |||
|
606 | datadec[i,:] = numpy.correlate(data[i,:], newcode) | |||
|
607 | ||||
|
608 | ndatadec = ndata - self.nBaud + 1 | |||
|
609 | ||||
|
610 | if self.__profIndex == self.nCode: | |||
|
611 | self.__profIndex = 0 | |||
|
612 | ||||
|
613 | self.__profIndex += 1 | |||
|
614 | ||||
|
615 | return ndatadec, datadec | |||
|
616 | ||||
|
617 | def run(self, dataOut, code=None, mode = 0): | |||
|
618 | ||||
|
619 | if not self.__isConfig: | |||
559 |
|
620 | |||
|
621 | if code == None: | |||
|
622 | code = dataOut.code | |||
|
623 | ||||
|
624 | self.setup(code) | |||
|
625 | self.__isConfig = True | |||
|
626 | ||||
|
627 | if mode == 0: | |||
|
628 | ndatadec, datadec = self.convolutionInFreq(data) | |||
|
629 | ||||
|
630 | if mode == 1: | |||
|
631 | ndatadec, datadec = self.convolutionInTime(data) | |||
|
632 | ||||
|
633 | dataOut.data = datadec | |||
|
634 | ||||
|
635 | dataOut.heightList = dataOut.heightList[0:ndatadec+1] | |||
|
636 | ||||
|
637 | dataOut.flagDecodeData = True #asumo q la data no esta decodificada | |||
|
638 | ||||
|
639 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip | |||
|
640 | ||||
|
641 | ||||
560 |
|
642 | |||
561 | class SpectraProc(ProcessingUnit): |
|
643 | class SpectraProc(ProcessingUnit): | |
562 |
|
644 | |||
@@ -606,7 +688,7 class SpectraProc(ProcessingUnit): | |||||
606 | self.buffer |
|
688 | self.buffer | |
607 | self.dataOut.flagNoData |
|
689 | self.dataOut.flagNoData | |
608 | """ |
|
690 | """ | |
609 |
fft_volt = numpy.fft.fft(self.buffer,axis=1) |
|
691 | fft_volt = numpy.fft.fft(self.buffer,axis=1) | |
610 | dc = fft_volt[:,0,:] |
|
692 | dc = fft_volt[:,0,:] | |
611 |
|
693 | |||
612 | #calculo de self-spectra |
|
694 | #calculo de self-spectra | |
@@ -635,6 +717,8 class SpectraProc(ProcessingUnit): | |||||
635 |
|
717 | |||
636 | def init(self, nFFTPoints=None, pairsList=None): |
|
718 | def init(self, nFFTPoints=None, pairsList=None): | |
637 |
|
719 | |||
|
720 | self.dataOut.flagNoData = True | |||
|
721 | ||||
638 | if self.dataIn.type == "Spectra": |
|
722 | if self.dataIn.type == "Spectra": | |
639 | self.dataOut.copy(self.dataIn) |
|
723 | self.dataOut.copy(self.dataIn) | |
640 | return |
|
724 | return | |
@@ -660,7 +744,7 class SpectraProc(ProcessingUnit): | |||||
660 | dtype='complex') |
|
744 | dtype='complex') | |
661 |
|
745 | |||
662 |
|
746 | |||
663 | self.buffer[:,self.profIndex,:] = self.dataIn.data |
|
747 | self.buffer[:,self.profIndex,:] = self.dataIn.data.copy() | |
664 | self.profIndex += 1 |
|
748 | self.profIndex += 1 | |
665 |
|
749 | |||
666 | if self.firstdatatime == None: |
|
750 | if self.firstdatatime == None: | |
@@ -987,159 +1071,4 class IncohInt(Operation): | |||||
987 | dataOut.utctime = avgdatatime |
|
1071 | dataOut.utctime = avgdatatime | |
988 | dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt * dataOut.nIncohInt * dataOut.nFFTPoints |
|
1072 | dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt * dataOut.nIncohInt * dataOut.nFFTPoints | |
989 | dataOut.flagNoData = False |
|
1073 | dataOut.flagNoData = False | |
990 |
|
1074 | No newline at end of file | ||
991 |
|
||||
992 | class ProfileSelector(Operation): |
|
|||
993 |
|
||||
994 | profileIndex = None |
|
|||
995 | # Tamanho total de los perfiles |
|
|||
996 | nProfiles = None |
|
|||
997 |
|
||||
998 | def __init__(self): |
|
|||
999 |
|
||||
1000 | self.profileIndex = 0 |
|
|||
1001 |
|
||||
1002 | def incIndex(self): |
|
|||
1003 | self.profileIndex += 1 |
|
|||
1004 |
|
||||
1005 | if self.profileIndex >= self.nProfiles: |
|
|||
1006 | self.profileIndex = 0 |
|
|||
1007 |
|
||||
1008 | def isProfileInRange(self, minIndex, maxIndex): |
|
|||
1009 |
|
||||
1010 | if self.profileIndex < minIndex: |
|
|||
1011 | return False |
|
|||
1012 |
|
||||
1013 | if self.profileIndex > maxIndex: |
|
|||
1014 | return False |
|
|||
1015 |
|
||||
1016 | return True |
|
|||
1017 |
|
||||
1018 | def isProfileInList(self, profileList): |
|
|||
1019 |
|
||||
1020 | if self.profileIndex not in profileList: |
|
|||
1021 | return False |
|
|||
1022 |
|
||||
1023 | return True |
|
|||
1024 |
|
||||
1025 | def run(self, dataOut, profileList=None, profileRangeList=None): |
|
|||
1026 |
|
||||
1027 | self.nProfiles = dataOut.nProfiles |
|
|||
1028 |
|
||||
1029 | if profileList != None: |
|
|||
1030 | if not(self.isProfileInList(profileList)): |
|
|||
1031 | dataOut.flagNoData = True |
|
|||
1032 | else: |
|
|||
1033 | dataOut.flagNoData = False |
|
|||
1034 | self.incIndex() |
|
|||
1035 | return 1 |
|
|||
1036 |
|
||||
1037 |
|
||||
1038 | elif profileRangeList != None: |
|
|||
1039 | minIndex = profileRangeList[0] |
|
|||
1040 | maxIndex = profileRangeList[1] |
|
|||
1041 | if not(self.isProfileInRange(minIndex, maxIndex)): |
|
|||
1042 | dataOut.flagNoData = True |
|
|||
1043 | else: |
|
|||
1044 | dataOut.flagNoData = False |
|
|||
1045 | self.incIndex() |
|
|||
1046 | return 1 |
|
|||
1047 | else: |
|
|||
1048 | raise ValueError, "ProfileSelector needs profileList or profileRangeList" |
|
|||
1049 |
|
||||
1050 | return 0 |
|
|||
1051 |
|
||||
1052 | class Decoder: |
|
|||
1053 |
|
||||
1054 | data = None |
|
|||
1055 | profCounter = None |
|
|||
1056 | code = None |
|
|||
1057 | ncode = None |
|
|||
1058 | nbaud = None |
|
|||
1059 | codeIndex = None |
|
|||
1060 | flag = False |
|
|||
1061 |
|
||||
1062 | def __init__(self): |
|
|||
1063 |
|
||||
1064 | self.data = None |
|
|||
1065 | self.ndata = None |
|
|||
1066 | self.profCounter = 1 |
|
|||
1067 | self.codeIndex = 0 |
|
|||
1068 | self.flag = False |
|
|||
1069 | self.code = None |
|
|||
1070 | self.ncode = None |
|
|||
1071 | self.nbaud = None |
|
|||
1072 | self.__isConfig = False |
|
|||
1073 |
|
||||
1074 | def convolutionInFreq(self, data, ndata): |
|
|||
1075 |
|
||||
1076 | newcode = numpy.zeros(ndata) |
|
|||
1077 | newcode[0:self.nbaud] = self.code[self.codeIndex] |
|
|||
1078 |
|
||||
1079 | self.codeIndex += 1 |
|
|||
1080 |
|
||||
1081 | fft_data = numpy.fft.fft(data, axis=1) |
|
|||
1082 | fft_code = numpy.conj(numpy.fft.fft(newcode)) |
|
|||
1083 | fft_code = fft_code.reshape(1,len(fft_code)) |
|
|||
1084 |
|
||||
1085 | conv = fft_data.copy() |
|
|||
1086 | conv.fill(0) |
|
|||
1087 |
|
||||
1088 | conv = fft_data*fft_code |
|
|||
1089 |
|
||||
1090 | data = numpy.fft.ifft(conv,axis=1) |
|
|||
1091 | self.data = data[:,:-self.nbaud+1] |
|
|||
1092 | self.flag = True |
|
|||
1093 |
|
||||
1094 | if self.profCounter == self.ncode: |
|
|||
1095 | self.profCounter = 0 |
|
|||
1096 | self.codeIndex = 0 |
|
|||
1097 |
|
||||
1098 | self.profCounter += 1 |
|
|||
1099 |
|
||||
1100 | def convolutionInTime(self, data, ndata): |
|
|||
1101 |
|
||||
1102 | nchannel = data.shape[1] |
|
|||
1103 | newcode = self.code[self.codeIndex] |
|
|||
1104 | self.codeIndex += 1 |
|
|||
1105 | conv = data.copy() |
|
|||
1106 | for i in range(nchannel): |
|
|||
1107 | conv[i,:] = numpy.correlate(data[i,:], newcode) |
|
|||
1108 |
|
||||
1109 | self.data = conv |
|
|||
1110 | self.flag = True |
|
|||
1111 |
|
||||
1112 | if self.profCounter == self.ncode: |
|
|||
1113 | self.profCounter = 0 |
|
|||
1114 | self.codeIndex = 0 |
|
|||
1115 |
|
||||
1116 | self.profCounter += 1 |
|
|||
1117 |
|
||||
1118 | def run(self, dataOut, code=None, mode = 0): |
|
|||
1119 |
|
||||
1120 | if not(self.__isConfig): |
|
|||
1121 | if code == None: |
|
|||
1122 | code = dataOut.radarControllerHeaderObj.code |
|
|||
1123 | # code = dataOut.code |
|
|||
1124 |
|
||||
1125 | ncode, nbaud = code.shape |
|
|||
1126 | self.code = code |
|
|||
1127 | self.ncode = ncode |
|
|||
1128 | self.nbaud = nbaud |
|
|||
1129 | self.__isConfig = True |
|
|||
1130 |
|
||||
1131 | ndata = dataOut.data.shape[1] |
|
|||
1132 |
|
||||
1133 | if mode == 0: |
|
|||
1134 | self.convolutionInFreq(dataOut.data, ndata) |
|
|||
1135 |
|
||||
1136 | if mode == 1: |
|
|||
1137 | self.convolutionInTime(dataOut.data, ndata) |
|
|||
1138 |
|
||||
1139 | self.ndata = ndata - self.nbaud + 1 |
|
|||
1140 |
|
||||
1141 | dataOut.data = self.data |
|
|||
1142 |
|
||||
1143 | dataOut.heightList = dataOut.heightList[:self.ndata] |
|
|||
1144 |
|
||||
1145 | dataOut.flagNoData = False No newline at end of file |
|
General Comments 0
You need to be logged in to leave comments.
Login now