This class implements interpolation and extrapolation in n dimensions. More...
Public Member Functions | |
| None | __init__ (self, tuple basic_axes) |
| Instantiates an Ndpolator class. | |
| None | register (self, str name, tuple associated_axes, np.ndarray grid) |
| Registers an interpolation grid, along with any associated tables, with the ndpolator instance. | |
| tuple | import_query_pts (self, str name, np.ndarray query_pts) |
| Imports and processes query points (points of interest). | |
| np.ndarray | find_hypercubes (self, str name, np.ndarray normed_query_pts, np.ndarray indices, np.ndarray flags, tuple associated_axes=None) |
| Extracts and populates hypercubes for each query point based on the table reference, indices, flags and any associated axes. | |
| np.ndarray | distance (self, str name, np.ndarray query_pts) |
| Computes the squared Euclidean distance from each query point to the nearest hypercube in the interpolation grid. | |
| np.ndarray | ndpolate (self, str name, np.ndarray query_pts, str extrapolation_method='none', str search_algorithm='kdtree') |
| Performs n-dimensional interpolation or extrapolation. | |
Data Fields | |
| axes = basic_axes | |
| table = dict() | |
Properties | |
| tables = property | |
| Prints a list of tables attached to the ndpolator instance. | |
This class implements interpolation and extrapolation in n dimensions.
Ndpolator wraps around the C extension and provides a user-friendly interface from python.
| None __init__ | ( | self, | |
| tuple | basic_axes ) |
Instantiates an Ndpolator class.
The class relies on basic_axes to span the interpolation hypercubes. Only basic (spanning) axes should be passed here.
| None register | ( | self, | |
| str | name, | ||
| tuple | associated_axes, | ||
| np.ndarray | grid ) |
Registers an interpolation grid, along with any associated tables, with the ndpolator instance.
It is referenced by the provided table label. The list of tables is held in the top-level table dictionary. Each entry in the list has three elements: a tuple of associated axes, the interpolation grid, and a capsule (initially None) that stores a pointer to the initialized cndpolator structure for caching purposes.
TypeError if any of passed parameters have an incorrect type.
| tuple import_query_pts | ( | self, | |
| str | name, | ||
| np.ndarray | query_pts ) |
Imports and processes query points (points of interest).
This entails finding the enclosing (or adjacent, if at the boundary of the grid) hypercubes for each query point; per query point component flags (whether the component is on grid, on vertex, or out of bounds); and hypercube-normalized query points. Indices identify hypercubes by their superior corner; for example, a (3, 4, 5) x (2, 3, 4) x (1, 2) hypercube would be identified by the (5, 4, 2) corner. Thus, for N query points and M basic axes, all three arrays (indices, flags and hypercube-normalized query points are (N, M)-shaped.
A tuple with three elements: an ndarray of containing hypercube indices, an ndarray of per-component flags, and an ndarray of hypercube-normalized query points.
| np.ndarray find_hypercubes | ( | self, | |
| str | name, | ||
| np.ndarray | normed_query_pts, | ||
| np.ndarray | indices, | ||
| np.ndarray | flags, | ||
| tuple | associated_axes = None ) |
Extracts and populates hypercubes for each query point based on the table reference, indices, flags and any associated axes.
ndarray An (N, M, l(fv))-shaped array of containing (or adjacent, if on the grid boundary) hypercubes identified by their superior corners; N is the number of query points, M is the number of basic axes, and l(fv) is the length of the function values.
| np.ndarray distance | ( | self, | |
| str | name, | ||
| np.ndarray | query_pts ) |
Computes the squared Euclidean distance from each query point to the nearest hypercube in the interpolation grid.
Points inside the grid have distance 0, while points outside have distance equal to the squared distance to the nearest edge, face, or vertex of the grid.
This method is useful for:
ndarray An (N, 1)-shaped array of squared distances from each query point to the nearest hypercube. Distance is 0 for points inside the grid, and >0 for points outside the grid boundaries.
| np.ndarray ndpolate | ( | self, | |
| str | name, | ||
| np.ndarray | query_pts, | ||
| str | extrapolation_method = 'none', | ||
| str | search_algorithm = 'kdtree' ) |
Performs n-dimensional interpolation or extrapolation.
This is the main "workhorse" of the class and should be considered the default interface to the underlying C-based cndpolator extension. See the top-level README.md file for usage examples.
dict
ValueError
| axes = basic_axes |
| table = dict() |
|
static |
Prints a list of tables attached to the ndpolator instance.
Returns -------
table names (references) attached to the ndpolator