Miscellaneous#

misc.py is a module containing a set of useful functions monalysa library.


monalysa.misc.gram_schmidt_orthogonalize(x: ndarray, y: ndarray) tuple[numpy.ndarray, numpy.ndarray]#

Perform the Gram-Schmidt orthogonalization.

Parameters:
  • x (np.ndarray) – 2D array of number corresponding to the x vector. The columns are the different components, while the rows are different x vectors.

  • y (np.ndarray) – 2D array of number corresponding to the y vector. The columns are the different components, while the rows are different y vectors.

Returns:

Returns the GS orthogonalized (x_norm, y_norm) vectors, with the rows corresponding to the different orthogonalized vectors, and the columns corresponding to the different components. The norm of the rows of x_norm and y_norm will 1. The dot product of the rows of the x_norm nad y_norm will be 0.

Return type:

tuple[np.ndarray, np.ndarray, np.ndarray]

monalysa.misc.is_binary_signal(sig: array, allownan=False) bool#

Indicates if the given input signal is a binary signal. Nan values can be allowed.

Parameters:
  • sig (np.array) – Input signal that is to be checked if it is a binary signal.

  • allownan (bool, optional) – Boolean to include if nans are to be allowed in the signal when testing it., by default False

Returns:

True if the signal is binary, else its False.

Return type:

bool

monalysa.misc.is_integer_num(num: Union[int, float]) bool#

Checks if the given number is an integer.

Parameters:

num (Union[int, float]) – The number that is to be checked if it is an integer.

Returns:

Bool indicating if the number is an integer. True if n is an integer, else its False

Return type:

bool

monalysa.misc.smoothed_derivative(data: array, tsamp: float, twin: float) array#

Compute first derivative for the given data. The derivative is computed using a Savitsky-Golay filter.

Parameters:
  • data (np.array) – Data with columns corresponding to different components, and rows corresponding to sampling instants.

  • tsamp (float) – Sampling time in seconds.

  • twin (float) – Window duration for the Savitsky-Golay (SG) filter used for filtering and computing the first derivative of the position data. This is used to determine the window length for the SG filter.

Returns:

First derivative of the given data.

Return type:

np.array