Added offset_t option to SLM(); removed trailing spaces

This commit is contained in:
Casper Jansen 2022-11-10 11:39:44 +01:00
parent e405ab8eea
commit fbb14f475c

View File

@ -27,7 +27,6 @@ class SLM:
Multi-channel Sound Level Meter. Input data: time data with a certain Multi-channel Sound Level Meter. Input data: time data with a certain
sampling frequency. Output: time-weighted (fast/slow) sound pressure sampling frequency. Output: time-weighted (fast/slow) sound pressure
levels in dB(A/C/Z). Possibly in octave bands. levels in dB(A/C/Z). Possibly in octave bands.
""" """
def __init__(self, def __init__(self,
@ -38,7 +37,8 @@ class SLM:
xmin = None, xmin = None,
xmax = None, xmax = None,
include_overall=True, include_overall=True,
level_ref_value=P_REF): level_ref_value=P_REF,
offset_t=0):
""" """
Initialize a sound level meter object. Initialize a sound level meter object.
@ -55,7 +55,7 @@ class SLM:
include_overall: If true, a non-functioning filter is added which include_overall: If true, a non-functioning filter is added which
is used to compute the overall level. is used to compute the overall level.
level_ref_value: Reference value for computing the levels in dB level_ref_value: Reference value for computing the levels in dB
offset_t: Offset to be added to output time data [s]
""" """
self.fbdesigner = fbdesigner self.fbdesigner = fbdesigner
@ -74,6 +74,7 @@ class SLM:
nfilters = len(self.xs) nfilters = len(self.xs)
if include_overall: nfilters +=1 if include_overall: nfilters +=1
self.include_overall = include_overall self.include_overall = include_overall
self.offset_t = offset_t
spld = SPLFilterDesigner(fs) spld = SPLFilterDesigner(fs)
if fw == FreqWeighting.A: if fw == FreqWeighting.A:
@ -153,7 +154,7 @@ class SLM:
Ncur = levels.shape[0] Ncur = levels.shape[0]
tend = tstart + Ncur / self.fs_slm tend = tstart + Ncur / self.fs_slm
t = np.linspace(tstart, tend, Ncur, endpoint=False) t = np.linspace(tstart, tend, Ncur, endpoint=False) + self.offset_t
self.N += Ncur self.N += Ncur
output = {} output = {}