FREQCOR_functions.test_and_apply_denoising

FREQCOR_functions.test_and_apply_denoising(Rcos, Icos, freq, trafun, tfmin, tfmax, fit_Aslan21, bounds)[source]

Conditionally applies the denoising procedure described by Aslan et al. 2021 to spectral data.

The function:
  1. Determines a frequency threshold (3 Hz if max(freq) <= 5 Hz, else 5 Hz).

  2. Performs a linear regression on log-log(f * spectrum/variance) above the threshold.

  3. If the slope of the regression is > 0.2, applies the denoising fit using fit_Aslan21.

  4. Returns the denoising results and the (possibly denoised) transfer function.

Parameters:
  • Rcos (array-like or pd.Series) – Real (measured) (co)spectrum.

  • Icos (array-like or pd.Series) – Ideal (reference) (co)spectrum.

  • freq (array-like or pd.Series) – Frequency vector (Hz).

  • trafun (array-like or pd.Series) – Transfer function (real/ideal cospectra ratio).

  • tfmin (int) – Index for the lower bound of the fit frequency range.

  • tfmax (int) – Index for the upper bound of the fit frequency range.

  • fit_Aslan21 (callable) – Function to perform the Aslan et al. 2021 denoising fit.

  • bounds (tuple of lists) – Bounds for the fit parameters.

Returns:

  • denoising_out (dict) –

    Dictionary with denoising status and results. Contains keys:
    • ’active’: bool, True if denoising was performed.

    • ’sp_re_denoised’: array, denoised spectrum (if denoising performed).

    • ’x’: array, frequency vector used in denoising (if performed).

  • y_result (array or None) – The denoised transfer function if denoising was performed, otherwise None.

Notes

  • Denoising is only performed if the slope of the log-log regression is > 0.2.

  • If denoising fails, denoising_out[‘active’] is False and y_result is None.