def __call__(self, xi):
"""Interpolate at the given coordinate.
Parameters
----------
xi : numpy.array
The coordinates to evaluate, with shape (..., ndim)
Returns
-------
val : numpy.array
The interpolated values at the given coordinates.
"""
ext = self._ext
ndim = self.ndim
xi = self._normalize_inputs(xi)
ans_shape = xi.shape[:-1]
xi = xi.reshape(-1, ndim)
ext_idx_vec = False
for idx in range(self.ndim):
ext_idx_vec = ext_idx_vec | (xi[:, idx] < ext) | (xi[:, idx] > self._max[idx])
int_idx_vec = ~ext_idx_vec
xi_ext = xi[ext_idx_vec, :]
xi_int = xi[int_idx_vec, :]
ans = np.empty(xi.shape[0])
ans[int_idx_vec] = imag_interp.map_coordinates(self._filt_values, xi_int.T, mode='nearest', prefilter=False)
if xi_ext.size > 0:
if not self._extrapolate:
raise ValueError('some inputs are out of bounds.')
ans[ext_idx_vec] = self._extfun(xi_ext)
if ans.size == 1:
return ans[0]
return ans.reshape(ans_shape)
评论列表
文章目录