plaid.utils.interpolation¶
Interpolation utilities for working with ordered lists and vectors.
Functions¶
|
Find the rank of the largest element smaller or equal to the given item in a sorted list. |
|
Vectorized binary search for multiple items in a sorted list (items is now a list or one-dimensional np.ndarray). |
|
Computes a item interpolation for temporal vectors defined either by item_indices and vectors at these indices. |
|
Computes a item interpolation for temporal vectors defined either by item_indices, some tags at these item indices (vectors_map), and vectors at those tags. |
piece_wise_linear_interpolation for more than one call (items is now a list or one-dimensional np.ndarray). |
|
piece_wise_linear_interpolation_with_map for more than one call (items is now a list or one-dimensional np.ndarray). |
Module Contents¶
- binary_search(ordered_list: list | numpy.ndarray, item: float | int) int[source]¶
Find the rank of the largest element smaller or equal to the given item in a sorted list.
- Inspects the sorted list “ordered_list” and returns:
0 if item <= ordered_list[0]
the rank of the largest element smaller or equal than item otherwise
- Parameters:
- Returns:
0 or the rank of the largest element smaller or equal than item in “ordered_list”.
- Return type:
- binary_search_vectorized(ordered_list: list | numpy.ndarray, items: list | numpy.ndarray) numpy.ndarray[source]¶
Vectorized binary search for multiple items in a sorted list (items is now a list or one-dimensional np.ndarray).
- piece_wise_linear_interpolation(item: float, item_indices: numpy.ndarray, vectors: numpy.ndarray | dict, tolerance: float = 0.0001) numpy.ndarray[source]¶
Computes a item interpolation for temporal vectors defined either by item_indices and vectors at these indices.
- Parameters:
item (float) – The input item at which the interpolation is required.
item_indices (np.ndarray) – The items where the available data is defined, of size (numberOfTimeIndices).
vectors (Union[np.ndarray, dict]) – The available data, of size (numberOfVectors, numberOfDofs).
tolerance (float) – Tolerance for deciding when using the closest timestep value instead of carrying out the linear interpolation, default to 1e-4.
- Returns:
Interpolated vector, of size (numberOfDofs).
- Return type:
np.ndarray
- piece_wise_linear_interpolation_with_map(item: float, item_indices: numpy.ndarray, vectors: numpy.ndarray | dict, vectors_map: list = None, tolerance: float = 0.0001) numpy.ndarray[source]¶
Computes a item interpolation for temporal vectors defined either by item_indices, some tags at these item indices (vectors_map), and vectors at those tags.
- Parameters:
item (float) – The input item at which the interpolation is required.
item_indices (np.ndarray) – The items where the available data is defined, of size (numberOfTimeIndices).
vectors (Union[np.ndarray, dict]) – The available data, of size (numberOfVectors, numberOfDofs).
vectors_map (list, optional) – List containing the mapping from the numberOfTimeIndices items indices to the numberOfVectors vectors, of size (numberOfTimeIndices,). Defaults to None.
tolerance (float, optional) – Tolerance for deciding when using the closest timestep value instead of carrying out the linear interpolation, default to 1e-4.
- Returns:
Interpolated vector, of size (numberOfDofs).
- Return type:
np.ndarray
- piece_wise_linear_interpolation_vectorized(items: list[float], item_indices: numpy.ndarray, vectors: numpy.ndarray | str) list[numpy.ndarray][source]¶
piece_wise_linear_interpolation for more than one call (items is now a list or one-dimensional np.ndarray).
- Parameters:
- Returns:
List of interpolated vectors, each of size (numberOfDofs).
- Return type:
list[np.ndarray]
- piece_wise_linear_interpolation_vectorized_with_map(items: list[float], item_indices: numpy.ndarray, vectors: numpy.ndarray | dict, vectors_map: list = None) list[numpy.ndarray][source]¶
piece_wise_linear_interpolation_with_map for more than one call (items is now a list or one-dimensional np.ndarray).
- Parameters:
items (list[float]) – The input items at which interpolations are required.
item_indices (np.ndarray) – The items where the available data is defined, of size (numberOfTimeIndices).
vectors (np.ndarray or dict) – The available data, of size (numberOfVectors, numberOfDofs).
vectors_map (list) – List containing the mapping from the numberOfTimeIndices items indices to the numberOfVectors vectors, of size (numberOfTimeIndices,). Default is None, in which case numberOfVectors = numberOfTimeIndices.
- Returns:
List of interpolated vectors, each of size (numberOfDofs).
- Return type:
list[np.ndarray]