def __call__(self, x, y, mth="array"): """ Evaluate spline at positions x,y.""" if mth == "array": tx, ty, c = self.tck[:3] kx, ky = self.degrees z, ier = dfitpack.bispev(tx, ty, c, kx, ky, x, y) assert ier == 0, "Invalid input: ier=" + ` ier ` return z raise NotImplementedError
def __call__(self,x,y,mth='array'): """ Evaluate spline at positions x,y.""" if mth=='array': tx,ty,c = self.tck[:3] kx,ky = self.degrees z,ier = dfitpack.bispev(tx,ty,c,kx,ky,x,y) assert ier==0,'Invalid input: ier='+`ier` return z raise NotImplementedError
def __call__(self, x, y, mth='array'): """ Evaluate spline at positions x,y.""" x = np.asarray(x) y = np.asarray(y) # empty input yields empty output if (x.size == 0) and (y.size == 0): return array([]) if mth=='array': tx,ty,c = self.tck[:3] kx,ky = self.degrees z,ier = dfitpack.bispev(tx,ty,c,kx,ky,x,y) assert ier==0,'Invalid input: ier='+`ier` return z raise NotImplementedError
def __call__(self, x, y, mth='array'): """ Evaluate spline at positions x,y.""" x = np.asarray(x) y = np.asarray(y) # empty input yields empty output if (x.size == 0) and (y.size == 0): return array([]) if mth=='array': tx,ty,c = self.tck[:3] kx,ky = self.degrees z,ier = dfitpack.bispev(tx,ty,c,kx,ky,x,y) assert ier==0,'Invalid input: ier='+`ier` return z raise NotImplementedError('unknown method mth=%s' % mth)
def __call__(self, x, y, mth='array'): """ Evaluate spline at positions x,y.""" x = np.asarray(x) y = np.asarray(y) # empty input yields empty output if (x.size == 0) and (y.size == 0): return array([]) if mth=='array': tx,ty,c = self.tck[:3] kx,ky = self.degrees z,ier = dfitpack.bispev(tx,ty,c,kx,ky,x,y) if not ier == 0: raise ValueError("Error code returned by bispev: %s" % ier) return z raise NotImplementedError('unknown method mth=%s' % mth)
def bisplev(x,y,tck,dx=0,dy=0): """Evaluate a bivariate B-spline and its derivatives. Description: Return a rank-2 array of spline function values (or spline derivative values) at points given by the cross-product of the rank-1 arrays x and y. In special cases, return an array or just a float if either x or y or both are floats. Inputs: x, y -- Rank-1 arrays specifying the domain over which to evaluate the spline or its derivative. tck -- A sequence of length 5 returned by bisplrep containing the knot locations, the coefficients, and the degree of the spline: [tx, ty, c, kx, ky]. dx, dy -- The orders of the partial derivatives in x and y respectively. Outputs: (vals, ) vals -- The B-pline or its derivative evaluated over the set formed by the cross-product of x and y. Remarks: SEE bisprep to generate the tck representation. See also: splprep, splrep, splint, sproot, splev - evaluation, roots, integral UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions """ tx,ty,c,kx,ky=tck if not (0<=dx<kx): raise ValueError,"0<=dx=%d<kx=%d must hold"%(dx,kx) if not (0<=dy<ky): raise ValueError,"0<=dy=%d<ky=%d must hold"%(dy,ky) x,y=map(myasarray,[x,y]) if (len(x.shape) != 1) or (len(y.shape) != 1): raise ValueError, "First two entries should be rank-1 arrays." if (dx>0 or dy>0): z,ier=dfitpack.parder(tx,ty,c,kx,ky,dx,dy,x,y) else: z,ier=dfitpack.bispev(tx,ty,c,kx,ky,x,y) if ier==10: raise ValueError,"Invalid input data" if ier: raise TypeError,"An error occurred" z.shape=len(x),len(y) if len(z)>1: return z if len(z[0])>1: return z[0] return z[0][0]
def __call__(self, theta, phi): """ Evaluate the spline at the grid ponts defined by the coordinate arrays theta, phi. """ theta = np.asarray(theta) phi = np.asarray(phi) # empty input yields empty output if (theta.size == 0) and (phi.size == 0): return array([]) if theta.min() < 0. or theta.max() > np.pi: raise ValueError("requested theta out of bounds.") if phi.min() < 0. or phi.max() > 2. * np.pi: raise ValueError("requested phi out of bounds.") tx, ty, c = self.tck[:3] kx, ky = self.degrees z, ier = dfitpack.bispev(tx, ty, c, kx, ky, theta, phi) if not ier == 0: raise ValueError("Error code returned by bispev: %s" % ier) return z