diff --git a/lasp/tools/tools.py b/lasp/tools/tools.py index 47173bb..5f145a2 100644 --- a/lasp/tools/tools.py +++ b/lasp/tools/tools.py @@ -34,13 +34,14 @@ __all__ = ['SmoothingType', 'smoothSpectralData', 'SmoothingWidth'] from enum import Enum, unique import bisect +import copy import numpy as np @unique class SmoothingWidth(Enum): none = (0, 'No smoothing') - one = (1, '1/1stoctave smoothing') + one = (1, '1/1st octave smoothing') two = (2, '1/2th octave smoothing') three = (3, '1/3rd octave smoothing') six = (6, '1/6th octave smoothing') @@ -105,7 +106,9 @@ def smoothSpectralData(freq, M, sw: SmoothingWidth, tr = 2 # truncate window after 2x std; shorter is faster and less accurate # Safety + MM = copy.deepcopy(M) Noct = sw.value[0] + assert M, "Smoothing function: input array is empty" assert Noct > 0, "'Noct' must be absolute positive" if Noct < 1: raise Warning('Check if \'Noct\' is entered correctly') @@ -120,9 +123,9 @@ def smoothSpectralData(freq, M, sw: SmoothingWidth, L = M.shape[0] # number of data points if st == SmoothingType.levels: - P = 10**(M/10) # magnitude [dB] --> power + P = 10**(MM/10) # magnitude [dB] --> power else: - P = M # data already given as power + P = MM # data already given as power # TODO: This does not work due to complex numbers. Should be split up in # magnitude and phase. # elif st == SmoothingType.tf: