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
35 changes: 35 additions & 0 deletions acoustics/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,38 @@ def _set_separator(ticklabels, separator):
decimal_number_format = item.replace('.', separator)
bands_sep.append(decimal_number_format)
return bands_sep

def plotDWTcoeff(signal,wavelet,fs):
"""
Plot Discrete Wavelet Transform Coefficients (Level 1)

:param signal: signal
:param fs: sample frequency
:param fwavelet : Wavelet to use in the transform

"""
[cA, cD] = pywt.wavedec(signal, wavelet, level= 1)

L = len(signal);
t= np.arange(0,(len(signal))/fs, 1/fs)
plt.figure(figsize=(30, 20));

plt.subplot(3, 1, 1)
plt.plot(t, signal, color='k');
plt.xlabel('Time');
plt.ylabel('S');
plt.title('Original Signal');

plt.subplot(3, 1, 2)
plt.plot(cA, color='r');
plt.xlabel('Samples');
plt.ylabel('cA');
plt.title('Approximation Coeff. (cA)');

plt.subplot(3, 1, 3)
plt.plot(cD, color='g');
plt.xlabel('Samples');
plt.ylabel('cD');
plt.title('Detailed Coeff. (cD)');

plt.show()
16 changes: 16 additions & 0 deletions acoustics/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import numpy as np
from scipy.sparse import spdiags
from scipy.signal import butter, lfilter, freqz, filtfilt, sosfilt
from scipy.integrate import simpson

import acoustics.octave
#from acoustics.octave import REFERENCE
Expand Down Expand Up @@ -1283,6 +1284,21 @@ def linear_phase(ntaps, steepness=1):
return np.exp(-1j * 2. * np.pi * f * alpha)



def transmitted_energy(signal, fs):
"""Compute the integration over time of the amplitude envelope in a time-domain input signal

:param signal: signal
:param fs: sample frequency

The transmitted energy is the signal feature used to compare the signal response to different impact energies.
"""
analytic_signal= hilbert(signal)
amplitude_envelope = np.abs(analytic_signal)
area = simpson(amplitude_envelope, dx=1/fs)
return area


__all__ = [
'bandpass',
'bandpass_frequencies',
Expand Down