pub type Interp2DView<A, D, S> = Interp2D<ViewRepr<A>, ViewRepr<A>, ViewRepr<A>, D, S>;
Expand description

two-dimensional interpolant for data views and axis views

Aliased Type§

struct Interp2DView<A, D, S> { /* private fields */ }

Implementations§

source§

impl<Sd, Sx, Sy, Strat> Interp2D<Sd, Sx, Sy, Ix2, Strat>where Sd: Data, Sd::Elem: Num + PartialOrd + NumCast + Copy + Debug + Sub, Sx: Data<Elem = Sd::Elem>, Sy: Data<Elem = Sd::Elem>, Strat: Interp2DStrategy<Sd, Sx, Sy, Ix2>,

source

pub fn interp_scalar( &self, x: Sx::Elem, y: Sy::Elem ) -> Result<Sd::Elem, InterpolateError>

convinient interpolation function for interpolation at one point when the data dimension is Ix2

let data = array![
    [1.0, 2.0],
    [3.0, 4.0],
];
let (qx, qy) = (0.0, 0.5);
let expected = 1.5;

let interpolator = Interp2D::builder(data).build().unwrap();
let result = interpolator.interp_scalar(qx, qy).unwrap();
source§

impl<Sd, Sx, Sy, D, Strat> Interp2D<Sd, Sx, Sy, D, Strat>where Sd: Data, Sd::Elem: Num + PartialOrd + NumCast + Copy + Debug + Sub, Sx: Data<Elem = Sd::Elem>, Sy: Data<Elem = Sd::Elem>, D: Dimension + RemoveAxis, D::Smaller: RemoveAxis, Strat: Interp2DStrategy<Sd, Sx, Sy, D>,

source

pub fn new_unchecked( x: ArrayBase<Sx, Ix1>, y: ArrayBase<Sy, Ix1>, data: ArrayBase<Sd, D>, strategy: Strat ) -> Self

Create a interpolator without any data validation. This is fast and cheap.

Safety

The following data properties are assumed, but not checked:

  • x and y are stricktly monotonic rising
  • data.shape()[0] == x.len(), data.shape()[1] == y.len()
  • the strategy is porperly initialized with the data
source

pub fn interp( &self, x: Sx::Elem, y: Sy::Elem ) -> Result<Array<Sd::Elem, <D::Smaller as Dimension>::Smaller>, InterpolateError>

Calculate the interpolated values at (x, y). Returns the interpolated data in an array two dimensions smaller than the data dimension.

Concider using interp_scalar(x, y) when the data dimension is Ix2

source

pub fn interp_array<Sqx, Sqy, Dq>( &self, xs: &ArrayBase<Sqx, Dq>, ys: &ArrayBase<Sqy, Dq> ) -> Result<Array<Sd::Elem, <Dq as DimAdd<<D::Smaller as Dimension>::Smaller>>::Output>, InterpolateError>where Sqx: Data<Elem = Sd::Elem>, Sqy: Data<Elem = Sy::Elem>, Dq: Dimension + DimAdd<<D::Smaller as Dimension>::Smaller>,

Calculate the interpolated values at all points in (xs, ys)

Dimensions

given the data dimension N and the query dimension M the return array will have the dimension M + N - 2 where the fist M dimensions correspond to the query dimenions of xs and ys

Lets assume we hava a data dimension of N = (2, 3, 4, 5) and query this data with an array of dimension M = (10), the return dimension will be (10, 4, 5) given a multi dimensional qurey of M = (10, 20) the return will be (10, 20, 4, 5)

panics

when xs.shape() != ys.shape()

source

pub fn index_point( &self, x_idx: usize, y_idx: usize ) -> (Sx::Elem, Sx::Elem, ArrayView<'_, Sd::Elem, <D::Smaller as Dimension>::Smaller>)

get (x, y, data) coordinate at the given index

panics

when index out of bounds

source

pub fn get_index_left_of(&self, x: Sx::Elem, y: Sy::Elem) -> (usize, usize)

The index of a known value left of, or at x and y.

This will never return the right most index, so calling index_point(x_idx+1, y_idx+1) is always safe.

source

pub fn is_in_x_range(&self, x: Sx::Elem) -> bool

source

pub fn is_in_y_range(&self, y: Sy::Elem) -> bool

Trait Implementations§

source§

impl<Sd, Sx, Sy, D, Strat: Debug> Debug for Interp2D<Sd, Sx, Sy, D, Strat>where Sd: Data + Debug, Sd::Elem: Num + PartialOrd + NumCast + Copy + Debug + Sub, Sx: Data<Elem = Sd::Elem> + Debug, Sy: Data<Elem = Sd::Elem> + Debug, D: Dimension + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more