Removed error in smoothing function
This commit is contained in:
parent
8912cb145c
commit
417c1bd3d8
@ -34,13 +34,14 @@ __all__ = ['SmoothingType', 'smoothSpectralData', 'SmoothingWidth']
|
|||||||
|
|
||||||
from enum import Enum, unique
|
from enum import Enum, unique
|
||||||
import bisect
|
import bisect
|
||||||
|
import copy
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
@unique
|
@unique
|
||||||
class SmoothingWidth(Enum):
|
class SmoothingWidth(Enum):
|
||||||
none = (0, 'No smoothing')
|
none = (0, 'No smoothing')
|
||||||
one = (1, '1/1stoctave smoothing')
|
one = (1, '1/1st octave smoothing')
|
||||||
two = (2, '1/2th octave smoothing')
|
two = (2, '1/2th octave smoothing')
|
||||||
three = (3, '1/3rd octave smoothing')
|
three = (3, '1/3rd octave smoothing')
|
||||||
six = (6, '1/6th 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
|
tr = 2 # truncate window after 2x std; shorter is faster and less accurate
|
||||||
|
|
||||||
# Safety
|
# Safety
|
||||||
|
MM = copy.deepcopy(M)
|
||||||
Noct = sw.value[0]
|
Noct = sw.value[0]
|
||||||
|
assert M, "Smoothing function: input array is empty"
|
||||||
assert Noct > 0, "'Noct' must be absolute positive"
|
assert Noct > 0, "'Noct' must be absolute positive"
|
||||||
if Noct < 1:
|
if Noct < 1:
|
||||||
raise Warning('Check if \'Noct\' is entered correctly')
|
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
|
L = M.shape[0] # number of data points
|
||||||
|
|
||||||
if st == SmoothingType.levels:
|
if st == SmoothingType.levels:
|
||||||
P = 10**(M/10) # magnitude [dB] --> power
|
P = 10**(MM/10) # magnitude [dB] --> power
|
||||||
else:
|
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
|
# TODO: This does not work due to complex numbers. Should be split up in
|
||||||
# magnitude and phase.
|
# magnitude and phase.
|
||||||
# elif st == SmoothingType.tf:
|
# elif st == SmoothingType.tf:
|
||||||
|
Loading…
Reference in New Issue
Block a user