resistics.common.math module

resistics.common.math.forwardFFT(data: numpy.ndarray, norm: bool = True)[source]

Forward real fourier transform

Parameters
datanp.ndarray

Time array to be transformed

normbool, optional

Normalisation option

Returns
fourierDatanp.ndarray

Fourier transformed data

resistics.common.math.getFrequencyArray(fs: float, samples: int) → numpy.ndarray[source]

Calculate the frequency array for a real fourier transform

Frequency array goes from 0Hz to Nyquist. Nyquist = fs/2

Parameters
fsfloat

Sampling frequency

samplesint

Number of samples

Returns
frequenciesnp.ndarray

Array of rfft frequencies

resistics.common.math.intdiv(nom: Union[int, float], div: Union[int, float]) → int[source]

Return an integer result of division

The division is expected to be exact and ensures an integer return rather than float. Code execution will exit if division is not exact

Parameters
nomint, float

Nominator

divint, float

Divisor

Returns
outint

Result of division

resistics.common.math.inverseFFT(data: numpy.ndarray, length: int, norm: bool = True)[source]

Inverse real fourier transform

Parameters
datanp.ndarray

Time array to be transformed

lengthint

Length of output time data (to remove padding)

normbool, optional

Normalisation option

Returns
timeDatanp.ndarray

Inverse fourier transformed data

resistics.common.math.padNextPower2(size: int) → int[source]

Calculate the amount of padding to next power of 2

Parameters
sizefloat

Size of array to be padded

Returns
padSizeint

Amout of extra padding required to increase to next power of 2