Commit e3d3bdab by Ben Farr

### Handle 1-D interpolation of complex functions

parent 7fdc3bb2
 ... ... @@ -14,6 +14,9 @@ class BoundedInterp1D(object): """A bounded 1-D interpolant that returns the specified value outside the input domain""" def __init__(self, x, y, low=None, high=None, outside_domain_val=np.inf): self._dtype = y.dtype self._complex = np.iscomplexobj(y) if low is not None and low > x.min(): self._low = low else: ... ... @@ -26,7 +29,9 @@ class BoundedInterp1D(object): self._outside_domain_val = outside_domain_val self._interp = interp1d(x, y) self._interp_re = interp1d(x, np.real(y)) if self._complex: self._interp_im = interp1d(x, np.imag(y)) @property def low(self): ... ... @@ -45,11 +50,13 @@ class BoundedInterp1D(object): def __call__(self, pts): pts = np.atleast_1d(pts) result = np.empty_like(pts) result = np.empty_like(pts, dtype=self._dtype) in_bounds = (pts > self.low) & (pts < self.high) result[~in_bounds] = self.outside_domain_val result[in_bounds] = self._interp(pts[in_bounds]) result[in_bounds] = self._interp_re(pts[in_bounds]) if self._complex: result[in_bounds] += 1j*self._interp_im(pts[in_bounds]) return result ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!