LASP 1.0
Library for Acoustic Signal Processing
Loading...
Searching...
No Matches
lasp.tools.tools Namespace Reference

Author: T. More...

Classes

class  SmoothingType
 
class  SmoothingWidth
 
class  sw
 

Functions

 intHann (x1, x2)
 Calculate integral of (part of) Hann window.
 
 smoothCalcMatrix (freq, SmoothingWidth sw)
 Args: freq: array of frequencies of data points [Hz] - equally spaced sw: SmoothingWidth.
 
 smoothSpectralData (freq, M, SmoothingWidth sw, SmoothingType st=SmoothingType.levels)
 Apply fractional octave smoothing to data in the frequency domain.
 

Variables

int Noct = 2
 
int fmin = 1e3
 
int fmax = 24e3
 
int Ndata = 200
 
 freq = np.linspace(fmin, fmax, Ndata)
 
float M = abs(0.4*np.random.normal(size=(len(freq),)))+0.01
 
 st
 
 Msm = smoothSpectralData(freq, M, sw, st)
 
 fsm = freq
 

Detailed Description

Author: T.

Hekman, C. Jansen, J.A. de Jong - ASCEE V.O.F.

Smooth data in the frequency domain.

TODO: This function is rather slow as it uses [for loops] in Python. Speed up. NOTE: function requires lin frequency spaced input data TODO: accept input data that is not lin spaced in frequency TODO: it makes more sense to output data that is log spaced in frequency TODO: Make SmoothSpectralData() multi-dimensional array aware. TODO: Smoothing does not work due to complex numbers. Is it reasonable to smooth complex data? If so, the data could be split in magnitude and phase.

Function Documentation

◆ intHann()

lasp.tools.tools.intHann (   x1,
  x2 
)

Calculate integral of (part of) Hann window.

If the args are vectors, the return value will match those.

Args: x1: lower bound [-0.5, 0.5] x2: upper bound [-0.5, 0.5] Return: Integral of Hann window between x1 and x2

Definition at line 65 of file tools.py.

◆ smoothCalcMatrix()

lasp.tools.tools.smoothCalcMatrix (   freq,
SmoothingWidth  sw 
)

Args: freq: array of frequencies of data points [Hz] - equally spaced sw: SmoothingWidth.

Returns: freq: array frequencies of data points [Hz] Q: matrix to smooth, power: {fsm} = [Q] * {fraw}

Warning: this method does not work on levels (dB)

According to Tylka_JAES_SmoothingWeights.pdf "A Generalized Method for Fractional-Octave Smoothing of Transfer Functions that Preserves Log-Frequency Symmetry" https://doi.org/10.17743/jaes.2016.0053 par 1.3 eq. 16

Definition at line 81 of file tools.py.

◆ smoothSpectralData()

lasp.tools.tools.smoothSpectralData (   freq,
  M,
SmoothingWidth  sw,
SmoothingType   st = SmoothingType.levels 
)

Apply fractional octave smoothing to data in the frequency domain.

Args: freq: array of frequencies of data points [Hz] - equally spaced M: array of data, either power or dB the smoothing type st, the smoothing is applied. sw: smoothing width st: smoothing type = data type of input data

Returns: freq : array frequencies of data points [Hz] Msm : float smoothed magnitude of data points

Definition at line 155 of file tools.py.

Variable Documentation

◆ fmax

int lasp.tools.tools.fmax = 24e3

Definition at line 237 of file tools.py.

◆ fmin

int lasp.tools.tools.fmin = 1e3

Definition at line 236 of file tools.py.

◆ freq

lasp.tools.tools.freq = np.linspace(fmin, fmax, Ndata)

Definition at line 239 of file tools.py.

◆ fsm

lasp.tools.tools.fsm = freq

Definition at line 261 of file tools.py.

◆ M

int lasp.tools.tools.M = abs(0.4*np.random.normal(size=(len(freq),)))+0.01

Definition at line 241 of file tools.py.

◆ Msm

lasp.tools.tools.Msm = smoothSpectralData(freq, M, sw, st)

Definition at line 260 of file tools.py.

◆ Ndata

int lasp.tools.tools.Ndata = 200

Definition at line 238 of file tools.py.

◆ Noct

int lasp.tools.tools.Noct = 2

Definition at line 233 of file tools.py.

◆ st

lasp.tools.tools.st

Definition at line 256 of file tools.py.