Muscat.Helpers.Interpolation module¶
- BinarySearch(orderedArray: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], item: Any) int [source]¶
- Inspects the sorted list “ordered_list” and returns:
0 if item <= orderedList[0]
the rank of the largest element smaller or equal than item otherwise
- Parameters:
orderedArray (one-dimensional np.ndarray) – the data sorted in increasing order from which the previous rank is searched
item (float or int) – the item for which the previous rank is searched
- Returns:
0 or the rank of the largest element smaller or equal than item in “orderedList”
- Return type:
int
- BinarySearchVectorized(orderedList: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], items: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) array [source]¶
BinarySearch for more than one call (items is now a one-dimensional np.ndarray)
- PieceWiseLinearInterpolation(item: float64, itemIndices: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], vectors: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], tolerance: float64 = 0.0001)[source]¶
Computes a item interpolation for temporal vectors defined either by itemIndices and vectors at these indices
- Parameters:
item (float) – the input item at which the interpolation is required
itemIndices (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)
tolerance (float) – tolerance for deciding when using the closest timestep value instead of carrying out the linear interpolation
- Returns:
interpolated vector, of size (numberOfDofs)
- Return type:
np.ndarray
- PieceWiseLinearInterpolationVectorized(items: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], itemIndices, vectors) List[ndarray] [source]¶
PieceWiseLinearInterpolation for more than one call (items is now a one-dimensional np.ndarray)
- PieceWiseLinearInterpolationVectorizedWithMap(items, itemIndices, vectors, vectorsMap) List[ndarray] [source]¶
PieceWiseLinearInterpolation for more than one call (items is now a list or one-dimensional np.ndarray)
- PieceWiseLinearInterpolationWithMap(item: float64, itemIndices: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], vectors, vectorsMap: List[int64], tolerance=0.0001) ndarray [source]¶
Computes a item interpolation for temporal vectors defined either by itemIndices, some tags at these item indices (vectorsMap), and vectors at those tags.
- Parameters:
item (float) – the input item at which the interpolation is required
itemIndices (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)
vectorsMap (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.
tolerance (float) – tolerance for deciding when using the closest timestep value instead of carrying out the linear interpolation
- Returns:
interpolated vector, of size (numberOfDofs)
- Return type:
np.ndarray