##// END OF EJS Templates
Bugs fixed:...
Miguel Valdez -
r660:5880e83e7e4e
parent child
Show More
@@ -200,9 +200,9 class VoltageProc(ProcessingUnit):
200 200 """
201 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 204 else:
205 data = self.dataOut.data[:,minIndex:maxIndex]
205 data = self.dataOut.data[:, minIndex:maxIndex]
206 206
207 207 # firstHeight = self.dataOut.heightList[minIndex]
208 208
@@ -566,6 +566,13 class Decoder(Operation):
566 566 print 'IOError: Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
567 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 576 if dataOut.flagDataAsBlock:
570 577
571 578 self.ndatadec = self.__nHeis #- self.nBaud + 1
@@ -573,18 +580,13 class Decoder(Operation):
573 580 self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex)
574 581
575 582 else:
576
577 __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex)
578
579 __codeBuffer[:,0:self.nBaud] = self.code
580
581 self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1))
582 583
584 #Time
583 585 self.ndatadec = self.__nHeis #- self.nBaud + 1
584 586
585 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 591 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
590 592
@@ -594,11 +596,9 class Decoder(Operation):
594 596
595 597 data = numpy.fft.ifft(conv,axis=1)
596 598
597 datadec = data#[:,:]
599 return data
598 600
599 return datadec
600
601 def convolutionInFreqOpt(self, data):
601 def __convolutionInFreqOpt(self, data):
602 602
603 603 raise NotImplementedError
604 604
@@ -610,7 +610,7 class Decoder(Operation):
610 610 #
611 611 # return datadec
612 612
613 def convolutionInTime(self, data):
613 def __convolutionInTime(self, data):
614 614
615 615 code = self.code[self.__profIndex]
616 616
@@ -619,7 +619,7 class Decoder(Operation):
619 619
620 620 return self.datadecTime
621 621
622 def convolutionByBlockInTime(self, data):
622 def __convolutionByBlockInTime(self, data):
623 623
624 624 repetitions = self.__nProfiles / self.nCode
625 625
@@ -629,10 +629,22 class Decoder(Operation):
629 629
630 630 for i in range(self.__nChannels):
631 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 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 648 def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None):
637 649
638 650 if dataOut.flagDecodeData:
@@ -652,25 +664,32 class Decoder(Operation):
652 664 if self.code is None:
653 665 print "Fail decoding: Code is not defined."
654 666 return
655
667
668 datadec = None
669
656 670 if dataOut.flagDataAsBlock:
657 671 """
658 672 Decoding when data have been read as block,
659 673 """
660 datadec = self.convolutionByBlockInTime(dataOut.data)
661
674 if mode == 0:
675 datadec = self.__convolutionByBlockInTime(dataOut.data)
676 if mode == 1:
677 datadec = self.__convolutionByBlockInFreq(dataOut.data)
662 678 else:
663 679 """
664 680 Decoding when data have been read profile by profile
665 681 """
666 682 if mode == 0:
667 datadec = self.convolutionInTime(dataOut.data)
683 datadec = self.__convolutionInTime(dataOut.data)
668 684
669 685 if mode == 1:
670 datadec = self.convolutionInFreq(dataOut.data)
686 datadec = self.__convolutionInFreq(dataOut.data)
671 687
672 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 694 dataOut.code = self.code
676 695 dataOut.nCode = self.nCode
@@ -678,7 +697,7 class Decoder(Operation):
678 697
679 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 702 dataOut.flagDecodeData = True #asumo q la data esta decodificada
684 703
@@ -794,11 +813,6 class ProfileSelector(Operation):
794 813
795 814 dataOut.flagNoData = True
796 815
797 if nProfiles:
798 self.nProfiles = dataOut.nProfiles
799 else:
800 self.nProfiles = nProfiles
801
802 816 if dataOut.flagDataAsBlock:
803 817 """
804 818 data dimension = [nChannels, nProfiles, nHeis]
@@ -823,77 +837,81 class ProfileSelector(Operation):
823 837
824 838 return True
825 839
840 """
841 data dimension = [nChannels, nHeis]
842 """
843
844 if nProfiles:
845 self.nProfiles = nProfiles
826 846 else:
827 """
828 data dimension = [nChannels, nHeis]
847 self.nProfiles = dataOut.nProfiles
848
849 if profileList != None:
829 850
830 """
831 if profileList != None:
832
833 dataOut.nProfiles = len(profileList)
834
835 if self.isThisProfileInList(dataOut.profileIndex, profileList):
836 dataOut.flagNoData = False
837 dataOut.profileIndex = self.profileIndex
838
839 self.incIndex()
840 return True
841
851 dataOut.nProfiles = len(profileList)
842 852
843 if profileRangeList != None:
844
845 minIndex = profileRangeList[0]
846 maxIndex = profileRangeList[1]
847
848 dataOut.nProfiles = maxIndex - minIndex + 1
853 if self.isThisProfileInList(dataOut.profileIndex, profileList):
854 dataOut.flagNoData = False
855 dataOut.profileIndex = self.profileIndex
849 856
850 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
851 dataOut.flagNoData = False
852 dataOut.profileIndex = self.profileIndex
853
854 self.incIndex()
855 return True
857 self.incIndex()
858 return True
859
860 if profileRangeList != None:
856 861
857 if rangeList != None:
858
859 nProfiles = 0
860
861 for thisRange in rangeList:
862 minIndex = thisRange[0]
863 maxIndex = thisRange[1]
864
865 nProfiles += maxIndex - minIndex + 1
862 minIndex = profileRangeList[0]
863 maxIndex = profileRangeList[1]
864
865 dataOut.nProfiles = maxIndex - minIndex + 1
866
867 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
868 dataOut.flagNoData = False
869 dataOut.profileIndex = self.profileIndex
866 870
867 dataOut.nProfiles = nProfiles
871 self.incIndex()
872 return True
873
874 if rangeList != None:
875
876 nProfiles = 0
877
878 for thisRange in rangeList:
879 minIndex = thisRange[0]
880 maxIndex = thisRange[1]
881
882 nProfiles += maxIndex - minIndex + 1
883
884 dataOut.nProfiles = nProfiles
885
886 for thisRange in rangeList:
868 887
869 for thisRange in rangeList:
888 minIndex = thisRange[0]
889 maxIndex = thisRange[1]
890
891 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
870 892
871 minIndex = thisRange[0]
872 maxIndex = thisRange[1]
873
874 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
875
876 893 # print "profileIndex = ", dataOut.profileIndex
877
878 dataOut.flagNoData = False
879 dataOut.profileIndex = self.profileIndex
880
881 self.incIndex()
882 break
883 return True
884 894
885
886 if beam != None: #beam is only for AMISR data
887 if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]):
888 895 dataOut.flagNoData = False
889 896 dataOut.profileIndex = self.profileIndex
890 897
891 898 self.incIndex()
892 return 1
899 break
900 return True
901
902
903 if beam != None: #beam is only for AMISR data
904 if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]):
905 dataOut.flagNoData = False
906 dataOut.profileIndex = self.profileIndex
907
908 self.incIndex()
909
910 return True
893 911
894 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