@@ -580,7 +580,7 class Decoder(Operation): | |||||
580 |
|
580 | |||
581 | self.__isConfig = False |
|
581 | self.__isConfig = False | |
582 |
|
582 | |||
583 | def setup(self, code): |
|
583 | def setup(self, code, shape): | |
584 |
|
584 | |||
585 | self.__profIndex = 0 |
|
585 | self.__profIndex = 0 | |
586 |
|
586 | |||
@@ -589,15 +589,21 class Decoder(Operation): | |||||
589 | self.nCode = len(code) |
|
589 | self.nCode = len(code) | |
590 | self.nBaud = len(code[0]) |
|
590 | self.nBaud = len(code[0]) | |
591 |
|
591 | |||
|
592 | self.__nChannels, self.__nHeis = shape | |||
|
593 | ||||
|
594 | self.__codeBuffer = numpy.zeros(self.nCode, self.__nHeis) | |||
|
595 | ||||
|
596 | self.__codeBuffer[:,0:self.nBaud] = self.code[:,:] | |||
|
597 | ||||
|
598 | self.fft_code = numpy.conj(numpy.fft.fft(self.__codeBuffer, axis=1)) | |||
|
599 | ||||
|
600 | ||||
592 | def convolutionInFreq(self, data): |
|
601 | def convolutionInFreq(self, data): | |
593 |
|
602 | |||
594 | nchannel, ndata = data.shape |
|
603 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) | |
595 | newcode = numpy.zeros(ndata) |
|
|||
596 | newcode[0:self.nBaud] = self.code[self.__profIndex] |
|
|||
597 |
|
604 | |||
598 | fft_data = numpy.fft.fft(data, axis=1) |
|
605 | fft_data = numpy.fft.fft(data, axis=1) | |
599 | fft_code = numpy.conj(numpy.fft.fft(newcode)) |
|
606 | ||
600 | fft_code = fft_code.reshape(1,len(fft_code)) |
|
|||
601 |
|
607 | |||
602 | # conv = fft_data.copy() |
|
608 | # conv = fft_data.copy() | |
603 | # conv.fill(0) |
|
609 | # conv.fill(0) | |
@@ -607,7 +613,7 class Decoder(Operation): | |||||
607 | data = numpy.fft.ifft(conv,axis=1) |
|
613 | data = numpy.fft.ifft(conv,axis=1) | |
608 |
|
614 | |||
609 | datadec = data[:,:-self.nBaud+1] |
|
615 | datadec = data[:,:-self.nBaud+1] | |
610 |
ndatadec = |
|
616 | ndatadec = self.__nHeis - self.nBaud + 1 | |
611 |
|
617 | |||
612 | if self.__profIndex == self.nCode-1: |
|
618 | if self.__profIndex == self.nCode-1: | |
613 | self.__profIndex = 0 |
|
619 | self.__profIndex = 0 | |
@@ -620,14 +626,14 class Decoder(Operation): | |||||
620 |
|
626 | |||
621 | def convolutionInTime(self, data): |
|
627 | def convolutionInTime(self, data): | |
622 |
|
628 | |||
623 |
|
|
629 | self.__nChannels, self.__nHeis = data.shape | |
624 |
|
|
630 | self.__codeBuffer = self.code[self.__profIndex] | |
625 |
ndatadec = |
|
631 | ndatadec = self.__nHeis - self.nBaud + 1 | |
626 |
|
632 | |||
627 |
datadec = numpy.zeros(( |
|
633 | datadec = numpy.zeros((self.__nChannels, ndatadec)) | |
628 |
|
634 | |||
629 |
for i in range( |
|
635 | for i in range(self.__nChannels): | |
630 |
datadec[i,:] = numpy.correlate(data[i,:], |
|
636 | datadec[i,:] = numpy.correlate(data[i,:], self.__codeBuffer) | |
631 |
|
637 | |||
632 | if self.__profIndex == self.nCode-1: |
|
638 | if self.__profIndex == self.nCode-1: | |
633 | self.__profIndex = 0 |
|
639 | self.__profIndex = 0 | |
@@ -650,7 +656,7 class Decoder(Operation): | |||||
650 | return 1 |
|
656 | return 1 | |
651 |
|
657 | |||
652 | if not self.__isConfig: |
|
658 | if not self.__isConfig: | |
653 | self.setup(code) |
|
659 | self.setup(code, data.shape) | |
654 | self.__isConfig = True |
|
660 | self.__isConfig = True | |
655 |
|
661 | |||
656 | if mode == 0: |
|
662 | if mode == 0: |
General Comments 0
You need to be logged in to leave comments.
Login now