def __array__(self,context=None): 'numpy array' if _swig_: # danger: dangling open file descriptor if None == self.narray: if not hasattr(self,'file'): self.file = c_rsf.sf_input(self.tag) self.narray = c_rsf.rsf_array(self.file) return self.narray else: # gets only the real part of complex arrays val = os.popen('%s < %s' % (Filter('disfil')(number=False),self)).read() return map(lambda x: float(x.rstrip(',')),val.split())
def __array__(self,context=None): 'numpy array' if False and _swig_: #kls I broke path that uses c_rsf.sf_input if None == self.narray: if not hasattr(self,'f'): f = c_rsf.sf_input(self.tag) else: f = self.f self.narray = c_rsf.rsf_array(f) if not hasattr(self,'f'): c_rsf.sf_fileclose(f) return self.narray else: # gets only the real part of complex arrays # should be able to dp something like this, which is used in # class Input.read() #sys.stderr.write('in __array__\n') tempinput=Input(self.filename) #sys.stderr,write('call getall\n') return tempinput.getalldata()
def __array__(self,context=None): 'create narray' if [] == self.narray: if _swig_: if not hasattr(self,'file'): f = c_rsf.sf_input(self.tag) else: f = self.file self.narray = c_rsf.rsf_array(f) if not hasattr(self,'file'): c_rsf.sf_fileclose(f) else: # gets only the real part of complex arrays ##kls if not hasattr(self,'file'): f=Input(self.tag) else: f=self.file self.narray=np.memmap(f.string('in'),dtype=f.datatype, mode='r+', shape=f.shape()) return self.narray