zooc.dsp.surface_extrapolator

2D-surface with interpolation and extrapolation.

class zooc.dsp.surface_extrapolator.SurfaceExtrapolator

Bases: ABC

Base class for 2D-surface extrapolators.

class zooc.dsp.surface_extrapolator.SurfaceExtrapolator1d(get_lin, a, z)

Bases: SurfaceExtrapolator

1D interpolator wrapper for surfaces where another dimension is collinear, while maintaining the 2d-surface interface.

Using interp1d for extrapolation.

Initialize with given X and Z data.

Parameters:
  • get_lin (Callable[[Any, Any], Any]) – Function to select the dimension from the input coordinates, e.g.: lambda x, y: x.

  • a (npt.NDArray[np.float64]) – X- or Y-data in order

  • z (Sequence[float]) – Z-data in order

class zooc.dsp.surface_extrapolator.SurfaceExtrapolator2d(xy, z)

Bases: SurfaceExtrapolator

2D-surface interpolator using LinearNDInterpolator and when outside hull, RegularGridInterpolator for extrapolation.

The interpolation works for any shaped input coordinates. However, the extrapolation works only when the convex hull defined by the input coordinates is rectangular.

Initialize with given XY and Z data.

Parameters:
get_bounds()

Get the XY-data bounds.

Returns:

Tuple of min and max bounds of the xy-data. [min_x, min_y], [max_x, max_y].

Return type:

tuple[ndarray[tuple[int, …], dtype[float64]], ndarray[tuple[int, …], dtype[float64]]]

property extrapolator: RegularGridInterpolator

Get the extrapolator for the data outside the xy-data range.

Returns:

Extrapolator object.

zooc.dsp.surface_extrapolator.create(xy, z)

Create a surface extrapolator based on the input XY and Z data.

Parameters:
Returns:

SurfaceExtrapolator object.

Raises:

ValueError – If the input points are collinear in both x and y dimensions, or if there are not enough data points.

Return type:

SurfaceExtrapolator

zooc.dsp.surface_extrapolator.get_non_collinear(points_2d)

Get non-collinear vectors, or None if the points are coplanar.

Checks if a set of 2D points are collinear (lie on the same line).

Parameters:

points_2d (ndarray[tuple[Any, ...], dtype[float64]]) – A 2D NumPy array of shape (N, 2) where N is the number of points.

Returns:

A tuple of two arrays (x, y) where:

  • x contains the x-coordinates of the points if they are not collinear in the x-dimension, otherwise None.

  • y contains the y-coordinates of the points if they are not collinear in the y-dimension, otherwise None.

Return type:

tuple[ndarray[tuple[Any, …], dtype[float64]] | None, ndarray[tuple[Any, …], dtype[float64]] | None]