suboptimumg.log_analysis.utils#

suboptimumg.log_analysis.utils.safe_gradient(signal, dt)[source]#

Compute a time derivative that is robust to zero-width time steps, so that duplicate timestamps do not produce inf or NaN values.

Parameters:
  • signal (npt.NDArray[np.float64]) – The signal to differentiate.

  • dt (npt.NDArray[np.float64]) – Time step array. Must be the same length as signal.

Returns:

d(signal)/dt with NaNs from zero-width steps filled by linear interpolation between the nearest valid neighbours.

Return type:

npt.NDArray[np.float64]