Math module

Module with a few mathematical definitions

This module collects a few simple, mathematical functions to treat data smoothing or the handling of angles.

NX2.math.bearingdiff180(a, b)

Calculate the smallest difference between two bearings.

There are two complications here compared to the usual a-b:

  • The angle wraps around at 360 deg.
  • A-priory it’s not clear if the shortest difference between two bearings is clockwise or anti-clockwise.
Parameters:b (a,) – angles in degrees
Returns:out – smallest difference between a and b in the range [-180,180]
Return type:float
NX2.math.smooth_expdec(data, t_e)

smooth an array with an exponential decay

Parameters:
  • data (np.ndarray) – input array to be smoothed
  • t_e (int) – decay timescale of expoential in number of bins (for NX2 data, i.e. seconds)
Returns:

out – smoothed array

Return type:

np.ndarray

NX2.math.smooth_gauss(data, width)

smooth an array with a gauss

Parameters:
  • data (np.ndarray) – input array to be smoothed
  • t_e (int) – decay timescale of exponential in number of bins (for NX2 data, i.e. seconds)
Returns:

out – smoothed array

Return type:

np.ndarray