@@ -347,6 +347,21 class VoltageProc(ProcessingUnit): | |||
|
347 | 347 | |
|
348 | 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 | ||
|
350 | 365 | |
|
351 | 366 | class CohInt(Operation): |
|
352 | 367 | |
@@ -972,4 +987,159 class IncohInt(Operation): | |||
|
972 | 987 | dataOut.utctime = avgdatatime |
|
973 | 988 | dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt * dataOut.nIncohInt * dataOut.nFFTPoints |
|
974 | 989 | dataOut.flagNoData = False |
|
975 | No newline at end of file | |
|
990 | ||
|
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