lezargus.library.interpolate module#

Interpolation routines, across both multi-dimensional and multi-mode.

We have many interpolation functions for a wide variety of use cases. We store all of them here.

lezargus.library.interpolate.cubic_1d_interpolate_extrapolate_factory(x: ndarray, y: ndarray) Callable[[ndarray], ndarray][source]#

Return a wrapper function around Scipy’s Cubic interpolation.

We ignore NaN values for interpolation. Moreover, this function allows for extrapolation outside of the normal domain, though we still log it for debugging purposes.

Parameters:
  • x (ndarray) – The x data to interpolate over.

  • y (ndarray) – The y data to interpolate over.

Returns:

interpolate_function – The interpolation function of the data.

Return type:

Callable

lezargus.library.interpolate.cubic_1d_interpolate_factory(x: ndarray, y: ndarray) Callable[[ndarray], ndarray][source]#

Return a wrapper function around Scipy’s Cubic interpolation.

We ignore NaN values for interpolation. This is a simple wrapper, for other use cases, see the entire cubic_1d_interpolate_*_factory namespace.

Parameters:
  • x (ndarray) – The x data to interpolate over.

  • y (ndarray) – The y data to interpolate over.

Returns:

interpolate_function – The interpolation function of the data.

Return type:

Callable

lezargus.library.interpolate.cubic_1d_interpolate_gap_factory(x: ndarray, y: ndarray, gap_size: float | None = None) Callable[[ndarray], ndarray][source]#

Return a wrapper around Scipy’s Cubic interpolation, accounting for gaps.

Regions which are considered to have a gap are not interpolated. Should a request for data within a gap region be called, we return NaN. We also ignore NaN values for interpolation.

Parameters:
  • x (ndarray) – The x data to interpolate over.

  • y (ndarray) – The y data to interpolate over.

  • gap_size (float, default = None) – The maximum difference between two ordered x-coordinates before the region within the difference is considered to be a gap. If None, we assume that there are no gaps.

Returns:

interpolate_function – The interpolation function of the data.

Return type:

Callable

lezargus.library.interpolate.nearest_neighbor_1d_interpolate_factory(x: ndarray, y: ndarray) Callable[[ndarray], ndarray][source]#

Return a wrapper around Scipy’s interp1d interpolation.

This function exists so that in the event of the removal of Scipy’s interp1d function, we only need to fix it once here.

Parameters:
  • x (ndarray) – The x data to interpolate over.

  • y (ndarray) – The y data to interpolate over.

Returns:

interpolate_function – The interpolation function of the data.

Return type:

Callable