Struct Interp2D

Source
pub struct Interp2D<Sd, Sx, Sy, D, Strat>
where Sd: Data, Sd::Elem: Num + PartialOrd + NumCast + Copy + Debug + Sub + Send, Sx: Data<Elem = Sd::Elem>, Sy: Data<Elem = Sd::Elem>, D: Dimension,
{ /* private fields */ }
Expand description

Two dimensional interpolator

Implementations§

Source§

impl<Sd, D> Interp2D<Sd, OwnedRepr<Sd::Elem>, OwnedRepr<Sd::Elem>, D, Bilinear>
where Sd: Data, Sd::Elem: Num + PartialOrd + NumCast + Copy + Debug + Sub + Send, D: Dimension,

Source

pub fn builder( data: ArrayBase<Sd, D>, ) -> Interp2DBuilder<Sd, OwnedRepr<Sd::Elem>, OwnedRepr<Sd::Elem>, D, Bilinear>

Source§

impl<Sd, Sx, Sy, Strat> Interp2D<Sd, Sx, Sy, Ix2, Strat>
where Sd: Data, Sd::Elem: Num + PartialOrd + NumCast + Copy + Debug + Sub + Send, 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 + Send, 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 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_into( &self, x: Sx::Elem, y: Sy::Elem, buffer: ArrayViewMut<'_, Sd::Elem, <D::Smaller as Dimension>::Smaller>, ) -> Result<(), InterpolateError>

Calculate the interpolated values at (x, y). and stores the result into the provided buffer

The provided buffer must have the same shape as the interpolation data with the first two axes removed.

This can improve performance compared to interp because it does not allocate any memory for the result

§Panics

When the provided buffer is too small or has the wrong shape

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> + 'static, <Dq as DimAdd<<D::Smaller as Dimension>::Smaller>>::Output: DimExtension,

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

See interp_array_into for dimension information

§panics

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

Source

pub fn interp_array_into<Sqx, Sqy, Dq>( &self, xs: &ArrayBase<Sqx, Dq>, ys: &ArrayBase<Sqy, Dq>, buffer: ArrayViewMut<'_, Sd::Elem, <Dq as DimAdd<<D::Smaller as Dimension>::Smaller>>::Output>, ) -> Result<(), InterpolateError>
where Sqx: Data<Elem = Sd::Elem>, Sqy: Data<Elem = Sy::Elem>, Dq: Dimension + DimAdd<<D::Smaller as Dimension>::Smaller> + 'static, <Dq as DimAdd<<D::Smaller as Dimension>::Smaller>>::Output: DimExtension,

Calculate the interpolated values at all points in (xs, ys) and stores the result into the provided buffer

This can improve performance compared to interp_array because it does not allocate any memory for the result

§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() or when the provided buffer is too small or has the wrong shape

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 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 + Send, 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

Auto Trait Implementations§

§

impl<Sd, Sx, Sy, D, Strat> Freeze for Interp2D<Sd, Sx, Sy, D, Strat>
where <Sd as RawData>::Elem: Sized, Strat: Freeze, Sx: Freeze, Sy: Freeze, Sd: Freeze, D: Freeze,

§

impl<Sd, Sx, Sy, D, Strat> RefUnwindSafe for Interp2D<Sd, Sx, Sy, D, Strat>

§

impl<Sd, Sx, Sy, D, Strat> Send for Interp2D<Sd, Sx, Sy, D, Strat>
where <Sd as RawData>::Elem: Sized, Strat: Send, Sx: Send, Sy: Send, Sd: Send,

§

impl<Sd, Sx, Sy, D, Strat> Sync for Interp2D<Sd, Sx, Sy, D, Strat>
where <Sd as RawData>::Elem: Sized, Strat: Sync, Sx: Sync, Sy: Sync, Sd: Sync,

§

impl<Sd, Sx, Sy, D, Strat> Unpin for Interp2D<Sd, Sx, Sy, D, Strat>
where <Sd as RawData>::Elem: Sized, Strat: Unpin, Sx: Unpin, Sy: Unpin, Sd: Unpin, D: Unpin,

§

impl<Sd, Sx, Sy, D, Strat> UnwindSafe for Interp2D<Sd, Sx, Sy, D, Strat>
where <Sd as RawData>::Elem: Sized + RefUnwindSafe, Strat: UnwindSafe, Sx: UnwindSafe, Sy: UnwindSafe, Sd: UnwindSafe, D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.