aerosandbox.numpy.interpolate
#
Module Contents#
Functions#
|
One-dimensional linear interpolation, analogous to numpy.interp(). |
|
Determines if the shapes of a given dataset are consistent with "structured" (i.e. gridded) data. |
|
Performs multidimensional interpolation on regular grids. Analogue to scipy.interpolate.interpn(). |
- aerosandbox.numpy.interpolate.interp(x, xp, fp, left=None, right=None, period=None)[source]#
One-dimensional linear interpolation, analogous to numpy.interp().
Returns the one-dimensional piecewise linear interpolant to a function with given discrete data points (xp, fp), evaluated at x.
See syntax here: https://numpy.org/doc/stable/reference/generated/numpy.interp.html
Specific notes: xp is assumed to be sorted.
- aerosandbox.numpy.interpolate.is_data_structured(x_data_coordinates, y_data_structured)[source]#
Determines if the shapes of a given dataset are consistent with “structured” (i.e. gridded) data.
For this to evaluate True, the inputs should be:
x_data_coordinates: A tuple or list of 1D ndarrays that represent coordinates along each axis of a N-dimensional hypercube.
y_data_structured: The values of some scalar defined on that N-dimensional hypercube, expressed as an N-dimesional array. In other words, y_data_structured is evaluated at np.meshgrid(*x_data_coordinates, indexing=”ij”).
Returns: Boolean of whether the above description is true.
- Parameters:
x_data_coordinates (Tuple[numpy.ndarray]) –
y_data_structured (numpy.ndarray) –
- Return type:
bool
- aerosandbox.numpy.interpolate.interpn(points, values, xi, method='linear', bounds_error=True, fill_value=_onp.nan)[source]#
Performs multidimensional interpolation on regular grids. Analogue to scipy.interpolate.interpn().
See syntax here: https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interpn.html
- Parameters:
points (Tuple[numpy.ndarray]) – The points defining the regular grid in n dimensions. Tuple of coordinates of each axis. Shapes (m1,
) (mn,) –
... (mn,) –
values (numpy.ndarray) –
xi (numpy.ndarray) –
method (str) –
- Return type:
numpy.ndarray
:param : :type : mn, :param values: The data on the regular grid in n dimensions. Shape (m1, …, mn) :param xi: The coordinates to sample the gridded data at. (…, ndim) :param method: The method of interpolation to perform. one of:
“bspline” (Note: differentiable and suitable for optimization - made of piecewise-cubics. For other
applications, other interpolators may be faster. Not monotonicity-preserving - may overshoot.)
“linear” (Note: differentiable, but not suitable for use in optimization w/o subgradient treatment due
to C1-discontinuity)
“nearest” (Note: NOT differentiable, don’t use in optimization. Fast.)
- Parameters:
bounds_error – If True, when interpolated values are requested outside of the domain of the input data,
False (a ValueError is raised. If) –
used. (then fill_value is) –
fill_value – If provided, the value to use for points outside of the interpolation domain. If None,
extrapolated. (values outside the domain are) –
points (Tuple[numpy.ndarray]) –
values (numpy.ndarray) –
xi (numpy.ndarray) –
method (str) –
- Return type:
numpy.ndarray
Returns: Interpolated values at input coordinates.