pub struct Interp2D<C1, C2, Z, S>where
S: Data<Elem = Z>,{ /* private fields */ }Expand description
Two dimensional bilinear interpolator for data on an irregular grid.
C1: Coordinate type of first axis.C2: Coordinate type of second axis.Z: Value type.S: Array representation ofZvalues.
Implementations§
Source§impl<C1, C2, Z, S> Interp2D<C1, C2, Z, S>where
S: Data<Elem = Z>,
impl<C1, C2, Z, S> Interp2D<C1, C2, Z, S>where
S: Data<Elem = Z>,
Sourcepub fn new(x: Vec<C1>, y: Vec<C2>, z: ArrayBase<S, Ix2>) -> Selfwhere
C1: PartialOrd,
C2: PartialOrd,
pub fn new(x: Vec<C1>, y: Vec<C2>, z: ArrayBase<S, Ix2>) -> Selfwhere
C1: PartialOrd,
C2: PartialOrd,
Create a new interpolation engine.
Interpolates values which are sampled on a rectangular grid.
§Parameters
x: The x-coordinates. Must be monotonic.y: The y-coordinates. Must be monotonic.z: The valuesz(x, y)for each grid point defined by thexandycoordinates.
§Panics
Panics when
- dimensions of x/y axis and z-values don’t match.
- one axis is empty.
xandyvalues are not monotonic.
Sourcepub fn bounds(&self) -> ((C1, C1), (C2, C2))
pub fn bounds(&self) -> ((C1, C1), (C2, C2))
Get the boundaries of the sample range
as ((x0, x1), (y0, y1)) tuple.
Sourcepub fn is_within_bounds(&self, (x, y): (C1, C2)) -> bool
pub fn is_within_bounds(&self, (x, y): (C1, C2)) -> bool
Check if the (x, y) coordinate lies within the defined sample range.
Sourcepub fn map_values<Z2>(
&self,
f: impl Fn(&Z) -> Z2,
) -> Interp2D<C1, C2, Z2, OwnedRepr<Z2>>
pub fn map_values<Z2>( &self, f: impl Fn(&Z) -> Z2, ) -> Interp2D<C1, C2, Z2, OwnedRepr<Z2>>
Create a new interpolated table by applying a function elementwise to the values.
Sourcepub fn map_x_axis<Xnew>(
self,
f: impl Fn(C1) -> Xnew,
) -> Interp2D<Xnew, C2, Z, S>where
Xnew: PartialOrd,
pub fn map_x_axis<Xnew>(
self,
f: impl Fn(C1) -> Xnew,
) -> Interp2D<Xnew, C2, Z, S>where
Xnew: PartialOrd,
Apply the function f to each x coordinate. Panics if the ordering of the coordinates
is not monotonic after applyint f.
Sourcepub fn map_y_axis<Ynew>(
self,
f: impl Fn(C2) -> Ynew,
) -> Interp2D<C1, Ynew, Z, S>where
Ynew: PartialOrd,
pub fn map_y_axis<Ynew>(
self,
f: impl Fn(C2) -> Ynew,
) -> Interp2D<C1, Ynew, Z, S>where
Ynew: PartialOrd,
Apply the function f to each y coordinate. Panics if the ordering of the coordinates
is not monotonic after applyint f.
Source§impl<C1, C2, Z, S> Interp2D<C1, C2, Z, S>where
C1: Copy + Sub<Output = C1> + Div + PartialOrd,
C2: Copy + Sub<Output = C2> + Div<Output = <C1 as Div>::Output> + PartialOrd,
Z: Copy + Mul<<C1 as Div>::Output, Output = Z> + Add<Output = Z> + Sub<Output = Z>,
<C1 as Div>::Output: Copy + Add<Output = <C1 as Div>::Output> + Sub<Output = <C1 as Div>::Output>,
S: Data<Elem = Z> + Clone,
impl<C1, C2, Z, S> Interp2D<C1, C2, Z, S>where
C1: Copy + Sub<Output = C1> + Div + PartialOrd,
C2: Copy + Sub<Output = C2> + Div<Output = <C1 as Div>::Output> + PartialOrd,
Z: Copy + Mul<<C1 as Div>::Output, Output = Z> + Add<Output = Z> + Sub<Output = Z>,
<C1 as Div>::Output: Copy + Add<Output = <C1 as Div>::Output> + Sub<Output = <C1 as Div>::Output>,
S: Data<Elem = Z> + Clone,
Sourcepub fn eval(&self, (x, y): (C1, C2)) -> Z
pub fn eval(&self, (x, y): (C1, C2)) -> Z
Evaluate the sampled function by interpolation at (x, y).
If (x, y) lies out of the sampled range then the function is silently extrapolated.
The boundaries of the sample range can be queried with bounds().
Sourcepub fn eval_no_extrapolation(&self, xy: (C1, C2)) -> Option<Z>
pub fn eval_no_extrapolation(&self, xy: (C1, C2)) -> Option<Z>
Returns the same value as eval() as long as (x, y) is within the
range of the samples. Otherwise None is returned instead of an extrapolation.