def _readDataGeneral(self,stepSlice=0,shotSlice=None,fileSlice=0,fieldName=None): fileSlice = tools.iterfy(fileSlice) stepSlice = tools.iterfy(stepSlice) #self.readTime(stepSlice,shotSlice,fileSlice) #if not self._existsInSelf("time"): #timeStampObj = memdata(self,"timestamp",fileSlice[0]) #self._addToSelf("time",timeStampObj) outS = [] # NB: Here is an issue, doesn't make sense like it is right now... for stepNum in stepSlice: # check if memory chached exists and the already read values contains what we need.. #print "TODO: add slice1 in slice2 ..., the current one does not work with None ..." #print "r1=range(5,100); r2=range(10,20); [idx for (idx,x) in zip(range(len(r1)),r1) if x in r2]" fileNum,FstepNum = self._getFileStep(stepNum) addr = address(fileNum,stepNum,"shotSlice") if (not self._existsInSelf(addr)) or (len(tools.iterDiff( self._getFromSelf(addr), shotSlice) )==0): path = self._paths["data"][FstepNum][0] path = getPath(path) #de=bug if (shotSlice is None): data = [h5r(self._h5s[fileNum],path)[...] % tt for tt in self.time[stepNum]] else: if isinstance(shotSlice,np.ndarray) and shotSlice.dtype is np.dtype(int): data = np.asarray([h5r(self._h5s[fileNum],path % self.time[stepNum][ts])[...] for ts in shotSlice]) #tshotSlice = np.zeros([data.len()],dtype=bool) #tshotSlice[shotSlice]=True #shotSlice=tshotSlice #data = data[shotSlice] else: data = self._getFromSelf(address(fileNum,stepNum,"_data")) # store is asked to use memory cache if (self._useMemoryCache): # save in .fileNum.stepNum._data self._addToSelf(address(fileNum,stepNum,"_data"),data) self._addToSelf(address(fileNum,stepNum,"shotSlice"),shotSlice) if (isinstance(data.dtype.names,tuple)): for fieldname in data.dtype.names: self._addToSelf(address(fileNum,stepNum,fieldname),data[fieldname]) if ( not (fieldname in self.__dict__) ): timeStampObj = memdata(self,"timestamp",fileNum) dataObj = memdata(self,fieldname,fileNum,timeStampObj) self._addToSelf(fieldname,dataObj) #else: #timeStampObj = memdata(self,"timestamp",fileNum) #dataObj = memdata(self,"_data",fileNum,timeStampObj) #tools.addToObj(self,"_data",dataObj) outS.append(data) return outS
def _readDataEVR(self,stepSlice=0,shotSlice=None,fileSlice=0): fileSlice = tools.iterfy(fileSlice) stepSlice = tools.iterfy(stepSlice) for fileNum in fileSlice: for stepNum in stepSlice: data= self._readDataGeneral(stepSlice=stepNum,shotSlice=shotSlice, fileSlice=fileSlice) timeStampObj = self._getFromSelf("time") addr = address(fileNum,stepNum,"shotSlice") addrCode = address(fileNum,stepNum,"code%d"%self.codes[0]) # if not read or we are asking shots outside the range of read values... if ( (not self._existsInSelf(addrCode)) or (len(tools.iterDiff( self._getFromSelf(addr), shotSlice) )==0) ): for code in self.codes: nshots = len(data) temp = np.zeros(nshots,dtype=np.bool) for nshot in range(nshots): if code in data[nshot][0]["eventCode"]: temp[nshot] = True addr = address(fileNum,stepNum,"code%d"%code) self._addToSelf(addr,temp) dataObj = memdata(self,"code%d"%code,fileNum,timeStampObj) self._addToSelf("code%d"%code,dataObj)
def _readDataIPM(self,stepSlice=0,shotSlice=None,fileSlice=0,fieldName=None): # further splits channels fileSlice = tools.iterfy(fileSlice) stepSlice = tools.iterfy(stepSlice) for fileNum in fileSlice: data= self._readDataGeneral(stepSlice=stepSlice,shotSlice=shotSlice, fileSlice=fileNum,fieldName=fieldName) timeStampObj = self._getFromSelf("time") for stepNum in stepSlice: addr = address(fileNum,stepNum,"shotSlice") addrChannel = address(fileNum,stepNum,"channel0") # if not read or we are asking shots outside the range of read values... if ( (not self._existsInSelf(addrChannel)) or (len(tools.iterDiff( self._getFromSelf(addr), shotSlice) )==0) ): # if only one step is read it does not return list ... if isinstance(data,list): channel_data = data[stepNum]["channel"] else: channel_data = data["channel"] for i in range(4): addr = address(fileNum,stepNum,"channel%d"%i) self._addToSelf(addr,channel_data[:,i]) dataObj = memdata(self,"channel%d"%i,fileNum,timeStampObj) self._addToSelf("channel%d"%i,dataObj)