Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion acoustics/_signal.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ class Signal(numpy.ndarray):
* xlim
* ylim
* clim
* pref (default to 1, set pref=20e-6 for SPL)
.. note:: This method only works for a single channel.

"""
Expand All @@ -659,6 +660,7 @@ class Signal(numpy.ndarray):
'xlim' : None,
'ylim' : None,
'clim' : None,
'pref' : 1,
'NFFT' : 4096,
'noverlap' : 128,
'title': 'Spectrogram',
Expand All @@ -676,7 +678,7 @@ class Signal(numpy.ndarray):
ax0 = params.get('ax', plt.figure().add_subplot(111))
ax0.set_title(params['title'])

data = np.squeeze(self)
data = np.squeeze(self) / pref
try:
_, _, _, im = ax0.specgram(data, Fs=self.fs, noverlap=params['noverlap'], NFFT=params['NFFT'], mode='magnitude', scale_by_freq=False)
except AttributeError:
Expand Down
5 changes: 3 additions & 2 deletions acoustics/standards/iec_61672_1_2013.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ def integrate(data, sample_frequency, integration_time):
integration_time = np.asarray(integration_time)
sample_frequency = np.asarray(sample_frequency)
samples = data.shape[-1]
b, a = zpk2tf([1.0], [1.0, integration_time], [1.0])
b, a = bilinear(b, a, fs=sample_frequency)
b_analog = np.poly1d([1])
a_analog = np.poly1d([integration_time, 1])
b, a = bilinear(b_analog, a_analog, fs=sample_frequency)
#b, a = bilinear([1.0], [1.0, integration_time], fs=sample_frequency) # Bilinear: Analog to Digital filter.
n = np.floor(integration_time * sample_frequency).astype(int)
data = data[..., 0:n*(samples//n)]
Expand Down