def read(self,data): if self.type == 'float': c_rsf.sf_floatread(np.reshape(data,(data.size,)),self.file) elif self.type == 'complex': c_rsf.sf_complexread(np.reshape(data,(data.size)),self.file) else: raise TypeError, 'Unsupported file type %s' % self.type
def read(self, data=[], shape=None, datatype=None): if len(data) == 0: allocate = True if shape == None: shape = self.shape() if datatype == None: datatype = self.datatype data = np.zeros(shape, dtype=datatype) else: allocate = False shape = data.shape datacount = data.size if _swig_: if self.type == 'float': c_rsf.sf_floatread(np.reshape(data, (data.size, )), self.file) elif self.type == 'complex': c_rsf.sf_complexread(np.reshape(data, (data.size)), self.file) elif self.type == 'int': c_rsf.sf_intread(np.reshape(data, (data.size, )), self.file) else: raise TypeError('Unsupported file type %s' % self.type) else: if self.type == 'float': self.file.floatread(np.reshape(data, (data.size, ))) elif self.type == 'int': self.file.intread(np.reshape(data, (data.size, ))) else: raise TypeError('Unsupported file type %s' % self.type) if allocate: return data
def read(self,data): if self.type == 'float': c_rsf.sf_floatread(numpy.reshape(data,(data.size,)),self.file) elif self.type == 'complex': c_rsf.sf_complexread(numpy.reshape(data,(data.size)),self.file) else: raise TypeError, 'Unsupported file type %s' % self.type