def interp1d(x, y, xnew, kind='linear', fill_value=np.nan, **kws): """interpolate x, y array onto new x values, using one of linear, quadratic, or cubic interpolation > ynew = interp1d(x, y, xnew, kind='linear') Arguments --------- x original x values y original y values xnew new x values for values to be interpolated to kind method to use: one of 'linear', 'quadratic', 'cubic' fill_value value to use to fill values for out-of-range x values Notes ----- unlike interp, this version will not extrapolate for values of `xnew` that are outside the range of `x` -- it will use NaN or `fill_value`. this is a bare-bones wrapping of scipy.interpolate.interp1d. see also: interp """ if '_larch' in kws: kws.pop('_larch') kwargs = { 'kind': kind.lower(), 'fill_value': fill_value, 'copy': False, 'bounds_error': False } kwargs.update(kws) return scipy_interp1d(x, y, **kwargs)(xnew)
def interp1d(x, y, xnew, kind='linear', fill_value=np.nan, **kws): """interpolate x, y array onto new x values, using one of linear, quadratic, or cubic interpolation > ynew = interp1d(x, y, xnew, kind='linear') Arguments --------- x original x values y original y values xnew new x values for values to be interpolated to kind method to use: one of 'linear', 'quadratic', 'cubic' fill_value value to use to fill values for out-of-range x values Notes ----- unlike interp, this version will not extrapolate for values of `xnew` that are outside the range of `x` -- it will use NaN or `fill_value`. this is a bare-bones wrapping of scipy.interpolate.interp1d. see also: interp """ if '_larch' in kws: kws.pop('_larch') kwargs = {'kind': kind.lower(), 'fill_value': fill_value, 'copy': False, 'bounds_error': False} kwargs.update(kws) return scipy_interp1d(x, y, **kwargs)(xnew)
def interp1d(y, n=101, dtype=None, kind='linear', axis=-1, copy=True, bounds_error=True, fill_value=np.nan): t0 = np.arange(y.shape[0]) t1 = np.linspace(0, y.shape[0]-1, n) f = scipy_interp1d(t0, y, kind, axis, copy, bounds_error, fill_value) y1 = f(t1) if dtype != None: y1 = np.asarray(y1, dtype=dtype) return y1
def interp1d(y, n=101, dtype=None, kind='linear', axis=-1, copy=True, bounds_error=True, fill_value=np.nan): t0 = np.arange(y.shape[0]) t1 = np.linspace(0, y.shape[0] - 1, n) f = scipy_interp1d(t0, y, kind, axis, copy, bounds_error, fill_value) y1 = f(t1) if dtype != None: y1 = np.asarray(y1, dtype=dtype) return y1