interp3d

emg3d.maps.interp3d(points, values, new_points, method, fill_value, mode)[source]

Interpolate values in 3D either linearly or with a cubic spline.

Return values corresponding to a regular 3D grid defined by points on new_points.

This is a modified version of scipy.interpolate.interpn(), using scipy.interpolate.RegularGridInterpolator if method='linear' and a custom-wrapped version of scipy.ndimage.map_coordinates() if method='cubic'. If speed is important then choose ‘linear’, as it can be significantly faster.

Parameters:
points : tuple of ndarray of float, with shapes ((nx, ), (ny, ) (nz, ))

The points defining the regular grid in three dimensions.

values : array_like, shape (nx, ny, nz)

The data on the regular grid in three dimensions.

new_points : tuple (rec_x, rec_y, rec_z)

Coordinates (x, y, z) of new points.

method : {‘cubic’, ‘linear’}, optional

The method of interpolation to perform, ‘linear’ or ‘cubic’. Default is ‘cubic’ (forced to ‘linear’ if there are less than 3 points in any direction).

fill_value : float or None

Passed to scipy.interpolate.RegularGridInterpolator if method='linear': The value to use for points outside of the interpolation domain. If None, values outside the domain are extrapolated.

mode : {‘constant’, ‘nearest’, ‘mirror’, ‘reflect’, ‘wrap’}

Passed to scipy.ndimage.map_coordinates() if method='cubic': Determines how the input array is extended beyond its boundaries.

Returns:
new_values : ndarray

Values corresponding to new_points.