BasicTools.Helpers.Interpolation module

BasicTools.Helpers.Interpolation.BinarySearch(orderedList, item)[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:
  • ordered_list (list or 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

BasicTools.Helpers.Interpolation.BinarySearchVectorized(orderedList, items)[source]

BinarySearch for more than one call (items is now a list or one-dimensional np.ndarray)

BasicTools.Helpers.Interpolation.CheckIntegrity(GUI=False)[source]
BasicTools.Helpers.Interpolation.PieceWiseLinearInterpolation(item, itemIndices, vectors, tolerance=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

BasicTools.Helpers.Interpolation.PieceWiseLinearInterpolationVectorized(items, itemIndices, vectors)[source]

PieceWiseLinearInterpolation for more than one call (items is now a list or one-dimensional np.ndarray)

BasicTools.Helpers.Interpolation.PieceWiseLinearInterpolationVectorizedWithMap(items, itemIndices, vectors, vectorsMap)[source]

PieceWiseLinearInterpolation for more than one call (items is now a list or one-dimensional np.ndarray)

BasicTools.Helpers.Interpolation.PieceWiseLinearInterpolationWithMap(item, itemIndices, vectors, vectorsMap, tolerance=0.0001)[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