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:
Determines a frequency threshold (3 Hz if max(freq) <= 5 Hz, else 5 Hz).
Performs a linear regression on log-log(f * spectrum/variance) above the threshold.
If the slope of the regression is > 0.2, applies the denoising fit using fit_Aslan21.
Returns the denoising results and the (possibly denoised) transfer function.
- Parameters:
Rcos (
array-likeorpd.Series) – Real (measured) (co)spectrum.Icos (
array-likeorpd.Series) – Ideal (reference) (co)spectrum.freq (
array-likeorpd.Series) – Frequency vector (Hz).trafun (
array-likeorpd.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 (
tupleoflists) – 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 (
arrayorNone) – 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.