@@ -109,6 +109,7 class SpectraProc(ProcessingUnit): | |||||
109 |
|
109 | |||
110 | if self.dataIn.type == "Spectra": |
|
110 | if self.dataIn.type == "Spectra": | |
111 | self.dataOut.copy(self.dataIn) |
|
111 | self.dataOut.copy(self.dataIn) | |
|
112 | # self.__selectPairs(pairsList) | |||
112 | return True |
|
113 | return True | |
113 |
|
114 | |||
114 | if self.dataIn.type == "Voltage": |
|
115 | if self.dataIn.type == "Voltage": | |
@@ -136,7 +137,7 class SpectraProc(ProcessingUnit): | |||||
136 | if self.dataIn.flagDataAsBlock: |
|
137 | if self.dataIn.flagDataAsBlock: | |
137 | #data dimension: [nChannels, nProfiles, nSamples] |
|
138 | #data dimension: [nChannels, nProfiles, nSamples] | |
138 | nVoltProfiles = self.dataIn.data.shape[1] |
|
139 | nVoltProfiles = self.dataIn.data.shape[1] | |
139 | nVoltProfiles = self.dataIn.nProfiles |
|
140 | # nVoltProfiles = self.dataIn.nProfiles | |
140 |
|
141 | |||
141 | if nVoltProfiles == nProfiles: |
|
142 | if nVoltProfiles == nProfiles: | |
142 | self.buffer = self.dataIn.data.copy() |
|
143 | self.buffer = self.dataIn.data.copy() | |
@@ -175,7 +176,33 class SpectraProc(ProcessingUnit): | |||||
175 |
|
176 | |||
176 | raise ValueError, "The type of input object '%s' is not valid"%(self.dataIn.type) |
|
177 | raise ValueError, "The type of input object '%s' is not valid"%(self.dataIn.type) | |
177 |
|
178 | |||
178 |
def __selectPairs(self, |
|
179 | def __selectPairs(self, pairsList): | |
|
180 | ||||
|
181 | if channelList == None: | |||
|
182 | return | |||
|
183 | ||||
|
184 | pairsIndexListSelected = [] | |||
|
185 | ||||
|
186 | for thisPair in pairsList: | |||
|
187 | ||||
|
188 | if thisPair not in self.dataOut.pairsList: | |||
|
189 | continue | |||
|
190 | ||||
|
191 | pairIndex = self.dataOut.pairsList.index(thisPair) | |||
|
192 | ||||
|
193 | pairsIndexListSelected.append(pairIndex) | |||
|
194 | ||||
|
195 | if not pairsIndexListSelected: | |||
|
196 | self.dataOut.data_cspc = None | |||
|
197 | self.dataOut.pairsList = [] | |||
|
198 | return | |||
|
199 | ||||
|
200 | self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected] | |||
|
201 | self.dataOut.pairsList = [self.dataOut.pairsList[i] for i in pairsIndexListSelected] | |||
|
202 | ||||
|
203 | return | |||
|
204 | ||||
|
205 | def __selectPairsByChannel(self, channelList=None): | |||
179 |
|
206 | |||
180 | if channelList == None: |
|
207 | if channelList == None: | |
181 | return |
|
208 | return | |
@@ -207,7 +234,7 class SpectraProc(ProcessingUnit): | |||||
207 |
|
234 | |||
208 | for channel in channelList: |
|
235 | for channel in channelList: | |
209 | if channel not in self.dataOut.channelList: |
|
236 | if channel not in self.dataOut.channelList: | |
210 |
raise ValueError, "Error selecting channels |
|
237 | raise ValueError, "Error selecting channels, Channel %d is not valid.\nAvailable channels = %s" %(channel, str(self.dataOut.channelList)) | |
211 |
|
238 | |||
212 | index = self.dataOut.channelList.index(channel) |
|
239 | index = self.dataOut.channelList.index(channel) | |
213 | channelIndexList.append(index) |
|
240 | channelIndexList.append(index) | |
@@ -245,7 +272,7 class SpectraProc(ProcessingUnit): | |||||
245 | self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] |
|
272 | self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] | |
246 | # self.dataOut.nChannels = nChannels |
|
273 | # self.dataOut.nChannels = nChannels | |
247 |
|
274 | |||
248 | self.__selectPairs(self.dataOut.channelList) |
|
275 | self.__selectPairsByChannel(self.dataOut.channelList) | |
249 |
|
276 | |||
250 | return 1 |
|
277 | return 1 | |
251 |
|
278 | |||
@@ -355,7 +382,7 class SpectraProc(ProcessingUnit): | |||||
355 | """ |
|
382 | """ | |
356 |
|
383 | |||
357 | if (minIndex < 0) or (minIndex > maxIndex): |
|
384 | if (minIndex < 0) or (minIndex > maxIndex): | |
358 |
raise ValueError, "Error selecting heights |
|
385 | raise ValueError, "Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex) | |
359 |
|
386 | |||
360 | if (maxIndex >= self.dataOut.nHeights): |
|
387 | if (maxIndex >= self.dataOut.nHeights): | |
361 | maxIndex = self.dataOut.nHeights-1 |
|
388 | maxIndex = self.dataOut.nHeights-1 |
General Comments 0
You need to be logged in to leave comments.
Login now