##// END OF EJS Templates
Bugs fixed:...
Miguel Valdez -
r660:5880e83e7e4e
parent child
Show More
@@ -200,7 +200,7 class VoltageProc(ProcessingUnit):
200 """
200 """
201 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
201 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
202 """
202 """
203 data = self.dataOut.data[:,minIndex:maxIndex,:]
203 data = self.dataOut.data[:,:, minIndex:maxIndex]
204 else:
204 else:
205 data = self.dataOut.data[:,minIndex:maxIndex]
205 data = self.dataOut.data[:, minIndex:maxIndex]
206
206
@@ -566,6 +566,13 class Decoder(Operation):
566 print 'IOError: Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
566 print 'IOError: Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
567 raise IOError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
567 raise IOError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
568
568
569 #Frequency
570 __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex)
571
572 __codeBuffer[:,0:self.nBaud] = self.code
573
574 self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1))
575
569 if dataOut.flagDataAsBlock:
576 if dataOut.flagDataAsBlock:
570
577
571 self.ndatadec = self.__nHeis #- self.nBaud + 1
578 self.ndatadec = self.__nHeis #- self.nBaud + 1
@@ -574,17 +581,12 class Decoder(Operation):
574
581
575 else:
582 else:
576
583
577 __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex)
584 #Time
578
579 __codeBuffer[:,0:self.nBaud] = self.code
580
581 self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1))
582
583 self.ndatadec = self.__nHeis #- self.nBaud + 1
585 self.ndatadec = self.__nHeis #- self.nBaud + 1
584
586
585 self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex)
587 self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex)
586
588
587 def convolutionInFreq(self, data):
589 def __convolutionInFreq(self, data):
588
590
589 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
591 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
590
592
@@ -594,11 +596,9 class Decoder(Operation):
594
596
595 data = numpy.fft.ifft(conv,axis=1)
597 data = numpy.fft.ifft(conv,axis=1)
596
598
597 datadec = data#[:,:]
599 return data
598
599 return datadec
600
600
601 def convolutionInFreqOpt(self, data):
601 def __convolutionInFreqOpt(self, data):
602
602
603 raise NotImplementedError
603 raise NotImplementedError
604
604
@@ -610,7 +610,7 class Decoder(Operation):
610 #
610 #
611 # return datadec
611 # return datadec
612
612
613 def convolutionInTime(self, data):
613 def __convolutionInTime(self, data):
614
614
615 code = self.code[self.__profIndex]
615 code = self.code[self.__profIndex]
616
616
@@ -619,7 +619,7 class Decoder(Operation):
619
619
620 return self.datadecTime
620 return self.datadecTime
621
621
622 def convolutionByBlockInTime(self, data):
622 def __convolutionByBlockInTime(self, data):
623
623
624 repetitions = self.__nProfiles / self.nCode
624 repetitions = self.__nProfiles / self.nCode
625
625
@@ -629,10 +629,22 class Decoder(Operation):
629
629
630 for i in range(self.__nChannels):
630 for i in range(self.__nChannels):
631 for j in range(self.__nProfiles):
631 for j in range(self.__nProfiles):
632 self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='same')
632 self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:]
633
633
634 return self.datadecTime
634 return self.datadecTime
635
635
636 def __convolutionByBlockInFreq(self, data):
637
638 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
639
640 fft_data = numpy.fft.fft(data, axis=2)
641
642 conv = fft_data*fft_code
643
644 data = numpy.fft.ifft(conv,axis=2)
645
646 return data
647
636 def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None):
648 def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None):
637
649
638 if dataOut.flagDecodeData:
650 if dataOut.flagDecodeData:
@@ -653,24 +665,31 class Decoder(Operation):
653 print "Fail decoding: Code is not defined."
665 print "Fail decoding: Code is not defined."
654 return
666 return
655
667
668 datadec = None
669
656 if dataOut.flagDataAsBlock:
670 if dataOut.flagDataAsBlock:
657 """
671 """
658 Decoding when data have been read as block,
672 Decoding when data have been read as block,
659 """
673 """
660 datadec = self.convolutionByBlockInTime(dataOut.data)
674 if mode == 0:
661
675 datadec = self.__convolutionByBlockInTime(dataOut.data)
676 if mode == 1:
677 datadec = self.__convolutionByBlockInFreq(dataOut.data)
662 else:
678 else:
663 """
679 """
664 Decoding when data have been read profile by profile
680 Decoding when data have been read profile by profile
665 """
681 """
666 if mode == 0:
682 if mode == 0:
667 datadec = self.convolutionInTime(dataOut.data)
683 datadec = self.__convolutionInTime(dataOut.data)
668
684
669 if mode == 1:
685 if mode == 1:
670 datadec = self.convolutionInFreq(dataOut.data)
686 datadec = self.__convolutionInFreq(dataOut.data)
671
687
672 if mode == 2:
688 if mode == 2:
673 datadec = self.convolutionInFreqOpt(dataOut.data)
689 datadec = self.__convolutionInFreqOpt(dataOut.data)
690
691 if datadec is None:
692 raise ValueError, "Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode
674
693
675 dataOut.code = self.code
694 dataOut.code = self.code
676 dataOut.nCode = self.nCode
695 dataOut.nCode = self.nCode
@@ -678,7 +697,7 class Decoder(Operation):
678
697
679 dataOut.data = datadec
698 dataOut.data = datadec
680
699
681 dataOut.heightList = dataOut.heightList[0:self.ndatadec]
700 dataOut.heightList = dataOut.heightList[0:datadec.shape[-1]]
682
701
683 dataOut.flagDecodeData = True #asumo q la data esta decodificada
702 dataOut.flagDecodeData = True #asumo q la data esta decodificada
684
703
@@ -794,11 +813,6 class ProfileSelector(Operation):
794
813
795 dataOut.flagNoData = True
814 dataOut.flagNoData = True
796
815
797 if nProfiles:
798 self.nProfiles = dataOut.nProfiles
799 else:
800 self.nProfiles = nProfiles
801
802 if dataOut.flagDataAsBlock:
816 if dataOut.flagDataAsBlock:
803 """
817 """
804 data dimension = [nChannels, nProfiles, nHeis]
818 data dimension = [nChannels, nProfiles, nHeis]
@@ -823,11 +837,15 class ProfileSelector(Operation):
823
837
824 return True
838 return True
825
839
826 else:
827 """
840 """
828 data dimension = [nChannels, nHeis]
841 data dimension = [nChannels, nHeis]
829
830 """
842 """
843
844 if nProfiles:
845 self.nProfiles = nProfiles
846 else:
847 self.nProfiles = dataOut.nProfiles
848
831 if profileList != None:
849 if profileList != None:
832
850
833 dataOut.nProfiles = len(profileList)
851 dataOut.nProfiles = len(profileList)
@@ -839,7 +857,6 class ProfileSelector(Operation):
839 self.incIndex()
857 self.incIndex()
840 return True
858 return True
841
859
842
843 if profileRangeList != None:
860 if profileRangeList != None:
844
861
845 minIndex = profileRangeList[0]
862 minIndex = profileRangeList[0]
@@ -889,11 +906,12 class ProfileSelector(Operation):
889 dataOut.profileIndex = self.profileIndex
906 dataOut.profileIndex = self.profileIndex
890
907
891 self.incIndex()
908 self.incIndex()
892 return 1
909
910 return True
893
911
894 raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter"
912 raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter"
895
913
896 return 0
914 return False
897
915
898
916
899
917
General Comments 0
You need to be logged in to leave comments. Login now