##// END OF EJS Templates
fix diferent blocks per file size at the end,-> resize arrays
joabAM -
r1555:73660288fffc
parent child
Show More
@@ -196,6 +196,7 class MergeH5(object):
196
196
197 self.fill_dataIn(data, self.ch_dataIn[ch])
197 self.fill_dataIn(data, self.ch_dataIn[ch])
198
198
199
199 return
200 return
200
201
201
202
@@ -235,14 +236,33 class MergeH5(object):
235 if data[attr].ndim == 1:
236 if data[attr].ndim == 1:
236 setattr(dataIn, attr, data[attr][:])
237 setattr(dataIn, attr, data[attr][:])
237 else:
238 else:
238 setattr(dataIn, attr, data[attr][:,:])
239 setattr(dataIn, attr, numpy.squeeze(data[attr][:,:]))
239 #print("shape in", dataIn.data_spc.shape, len(dataIn.data_spc))
240 #print("shape in", dataIn.data_spc.shape, len(dataIn.data_spc))
240 if dataIn.data_spc.ndim > 3:
241 if dataIn.data_spc.ndim > 3:
241 dataIn.data_spc = dataIn.data_spc[0]
242 dataIn.data_spc = dataIn.data_spc[0]
242 #print("shape in", dataIn.data_spc.shape)
243 #print("shape in", dataIn.data_spc.shape)
243 if self.blocksPerFile == None:
244
244 self.blocksPerFile = len(dataIn.data_spc) #blocks, ch, fft, hei
245
245 print("blocks per file: ", self.blocksPerFile)
246
247 def getBlocksPerFile(self):
248 b = numpy.zeros(self.nChannels)
249 for i in range(self.nChannels):
250 b[i] = self.ch_dataIn[i].data_spc.shape[0] #number of blocks
251
252 self.blocksPerFile = int(b.min())
253 iresh_ch = numpy.where(b > self.blocksPerFile)[0]
254 if len(iresh_ch) > 0:
255 for ich in iresh_ch:
256 for i in range(len(self.dataList)):
257 if hasattr(self.ch_dataIn[ich], self.dataList[i]):
258 # print("reshaping ", self.dataList[i])
259 # print(getattr(self.ch_dataIn[ich], self.dataList[i]).shape)
260 dataAux = getattr(self.ch_dataIn[ich], self.dataList[i])
261 setattr(self.ch_dataIn[ich], self.dataList[i], None)
262 setattr(self.ch_dataIn[ich], self.dataList[i], dataAux[0:self.blocksPerFile])
263 # print(getattr(self.ch_dataIn[ich], self.dataList[i]).shape)
264 else:
265 return
246
266
247
267
248 def getLabel(self, name, x=None):
268 def getLabel(self, name, x=None):
@@ -317,7 +337,6 class MergeH5(object):
317 ints = [data.nIncohInt for data in self.ch_dataIn]
337 ints = [data.nIncohInt for data in self.ch_dataIn]
318 self.dataOut.nIncohInt = numpy.stack(ints, axis=1)
338 self.dataOut.nIncohInt = numpy.stack(ints, axis=1)
319
339
320 print("nIncohInt 1: ",self.dataOut.nIncohInt.shape)
321
340
322 if self.dataOut.nIncohInt.ndim > 3:
341 if self.dataOut.nIncohInt.ndim > 3:
323 aux = self.dataOut.nIncohInt
342 aux = self.dataOut.nIncohInt
@@ -334,7 +353,6 class MergeH5(object):
334 if (self.dataOut.nIncohInt.shape)[0]==self.nChannels: ## ch,blocks, hei
353 if (self.dataOut.nIncohInt.shape)[0]==self.nChannels: ## ch,blocks, hei
335 self.dataOut.nIncohInt = numpy.swapaxes(self.dataOut.nIncohInt, 0, 1) ## blocks,ch, hei
354 self.dataOut.nIncohInt = numpy.swapaxes(self.dataOut.nIncohInt, 0, 1) ## blocks,ch, hei
336
355
337 print("nIncohInt 2: ", self.dataOut.nIncohInt.shape)
338 #print("utcTime: ", time.shape)
356 #print("utcTime: ", time.shape)
339 #print("data_spc ",self.dataOut.data_spc.shape)
357 #print("data_spc ",self.dataOut.data_spc.shape)
340 pairsList = [pair for pair in itertools.combinations(self.channelList, 2)]
358 pairsList = [pair for pair in itertools.combinations(self.channelList, 2)]
@@ -487,6 +505,11 class MergeH5(object):
487 #print("Opening file: ",filename)
505 #print("Opening file: ",filename)
488 self.readFile(fp,ch)
506 self.readFile(fp,ch)
489 fp.close()
507 fp.close()
508
509 if self.blocksPerFile == None:
510 self.getBlocksPerFile()
511 print("blocks per file: ", self.blocksPerFile)
512
490 self.getDataOut()
513 self.getDataOut()
491 name = name[-16:]
514 name = name[-16:]
492 #print("Final name out: ", name)
515 #print("Final name out: ", name)
@@ -2120,8 +2120,12 class IncohInt(Operation):
2120 dataOut.data_spc,
2120 dataOut.data_spc,
2121 dataOut.data_cspc,
2121 dataOut.data_cspc,
2122 dataOut.data_dc)
2122 dataOut.data_dc)
2123
2123 self.incohInt += dataOut.nIncohInt
2124 self.incohInt += dataOut.nIncohInt
2124 self.nOutliers += dataOut.data_outlier
2125
2126 if isinstance(dataOut.data_outlier,numpy.ndarray) or isinstance(dataOut.data_outlier,int) or isinstance(dataOut.data_outlier, float):
2127 self.nOutliers += dataOut.data_outlier
2128
2125 if self.__dataReady:
2129 if self.__dataReady:
2126 #print("prof: ",dataOut.max_nIncohInt,self.__profIndex)
2130 #print("prof: ",dataOut.max_nIncohInt,self.__profIndex)
2127 dataOut.data_spc = avgdata_spc
2131 dataOut.data_spc = avgdata_spc
General Comments 0
You need to be logged in to leave comments. Login now