@@ -596,73 +596,60 class Decoder(Operation): | |||
|
596 | 596 | |
|
597 | 597 | self.__nChannels, self.__nHeis = shape |
|
598 | 598 | |
|
599 |
|
|
|
599 | __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.float32) | |
|
600 | 600 | |
|
601 |
|
|
|
601 | __codeBuffer[:,0:self.nBaud] = self.code | |
|
602 | 602 | |
|
603 |
self.fft_code = numpy.conj(numpy.fft.fft( |
|
|
603 | self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1)) | |
|
604 | 604 | |
|
605 | self.ndatadec = __nHeis - nBaud + 1 | |
|
606 | ||
|
607 | self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex) | |
|
605 | 608 | |
|
606 | 609 | def convolutionInFreq(self, data): |
|
607 | 610 | |
|
611 | ini = time.time() | |
|
612 | ||
|
608 | 613 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) |
|
609 | 614 | |
|
610 | 615 | fft_data = numpy.fft.fft(data, axis=1) |
|
611 | 616 | |
|
612 | ||
|
613 | # conv = fft_data.copy() | |
|
614 | # conv.fill(0) | |
|
615 | ||
|
616 | 617 | conv = fft_data*fft_code |
|
617 | 618 | |
|
618 | 619 | data = numpy.fft.ifft(conv,axis=1) |
|
619 | 620 | |
|
620 | 621 | datadec = data[:,:-self.nBaud+1] |
|
621 | ndatadec = self.__nHeis - self.nBaud + 1 | |
|
622 | 622 | |
|
623 | if self.__profIndex == self.nCode-1: | |
|
624 | self.__profIndex = 0 | |
|
625 | return ndatadec, datadec | |
|
626 | ||
|
627 | self.__profIndex += 1 | |
|
623 | print "Freq ", time.time() - ini | |
|
628 | 624 | |
|
629 |
return |
|
|
625 | return datadec | |
|
630 | 626 | |
|
631 | 627 | def convolutionInFreqOpt(self, data): |
|
632 | 628 | |
|
629 | ini = time.time() | |
|
630 | ||
|
633 | 631 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) |
|
634 | 632 | |
|
635 | 633 | data = cfunctions.decoder(fft_code, data) |
|
636 | 634 | |
|
637 | 635 | datadec = data[:,:-self.nBaud+1] |
|
638 | ndatadec = self.__nHeis - self.nBaud + 1 | |
|
639 | 636 | |
|
640 | if self.__profIndex == self.nCode-1: | |
|
641 | self.__profIndex = 0 | |
|
642 | return ndatadec, datadec | |
|
643 | ||
|
644 | self.__profIndex += 1 | |
|
637 | print "OptFreq ", time.time() - ini | |
|
645 | 638 | |
|
646 |
return |
|
|
639 | return datadec | |
|
647 | 640 | |
|
648 | 641 | def convolutionInTime(self, data): |
|
649 | 642 | |
|
650 | self.__nChannels, self.__nHeis = data.shape | |
|
651 | self.__codeBuffer = self.code[self.__profIndex] | |
|
652 | ndatadec = self.__nHeis - self.nBaud + 1 | |
|
653 | ||
|
654 | datadec = numpy.zeros((self.__nChannels, ndatadec)) | |
|
643 | ini = time.time() | |
|
655 | 644 | |
|
656 | for i in range(self.__nChannels): | |
|
657 | datadec[i,:] = numpy.correlate(data[i,:], self.__codeBuffer) | |
|
645 | code = self.code[self.__profIndex].reshape(1,-1) | |
|
658 | 646 | |
|
659 | if self.__profIndex == self.nCode-1: | |
|
660 | self.__profIndex = 0 | |
|
661 | return ndatadec, datadec | |
|
647 | for i in range(__nChannels): | |
|
648 | self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='valid') | |
|
662 | 649 | |
|
663 | self.__profIndex += 1 | |
|
650 | print "Time ", time.time() - ini | |
|
664 | 651 | |
|
665 |
return |
|
|
652 | return self.datadecTime | |
|
666 | 653 | |
|
667 | 654 | def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0): |
|
668 | 655 | ini = time.time() |
@@ -691,7 +678,9 class Decoder(Operation): | |||
|
691 | 678 | |
|
692 | 679 | if mode == 2: |
|
693 | 680 | ndatadec, datadec = self.convolutionInFreqOpt(dataOut.data) |
|
694 |
|
|
|
681 | ||
|
682 | ||
|
683 | ||
|
695 | 684 | dataOut.data = datadec |
|
696 | 685 | |
|
697 | 686 | dataOut.heightList = dataOut.heightList[0:ndatadec] |
@@ -699,8 +688,17 class Decoder(Operation): | |||
|
699 | 688 | dataOut.flagDecodeData = True #asumo q la data no esta decodificada |
|
700 | 689 | |
|
701 | 690 | print time.time() - ini, "prof = %d, nCode=%d" %(self.__profIndex, self.nCode) |
|
702 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip | |
|
691 | ||
|
692 | if self.__profIndex == self.nCode-1: | |
|
693 | self.__profIndex = 0 | |
|
694 | return 1 | |
|
695 | ||
|
696 | self.__profIndex += 1 | |
|
703 | 697 | |
|
698 | return 1 | |
|
699 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip | |
|
700 | ||
|
701 | ||
|
704 | 702 | |
|
705 | 703 | class SpectraProc(ProcessingUnit): |
|
706 | 704 |
General Comments 0
You need to be logged in to leave comments.
Login now