In [4]:
%reset -f
%matplotlib notebook
%load_ext autoreload
%autoreload 1
%aimport functions
%qtconsole
import numpy as np
import acoustics
from functions import *
import matplotlib.pyplot as plt
import matplotlib as mpl
import seaborn as sns
mpl.rcParams['lines.linewidth']=0.5
In [5]:
%%capture c
import json
passby = json.load(open('Tabellen\passby.json','r+'))
fill_passby_with_signals(passby)
In [6]:
print('passby IDs:', list(passby.keys()))
In [7]:
E = passby['14']['Q4']
#
print('Signal ID(with corresponding .mat file):', E['ID'])
Signals = E['signals']
In [8]:
name='MIC'
f, ax = plt.subplots(1)
Signals[name].plot(ax = ax,label = name )
ax.legend()
Out[8]:
Wie in der obige Abbildung zu sehen ist hat der signal tieffrequentige Anteile (aufgrund vom Druckwelle der Vorbefahrt). Um diese Effekte zu kann man zwei neue Signale durch filterung erzeugen:
A-gewichtete
Signal
In [9]:
Signals['bandpass']= Signals['MIC'].bandpass(20,20000)
Signals['A']= Signals['bandpass'].weigh('A')
name='bandpass'
f, ax = plt.subplots(1)
Signals[name].plot(ax = ax,label = name )
ax.legend()
Out[9]:
In [10]:
signals = [(sn,key) for key,sn in Signals.items() if not key== 'LS' ]
f,(ax1) = plt.subplots(1)
for (sn,name) in signals:
sn.plot_levels(ax = ax1, method = 'weighting', label = name,lw=3,alpha=0.9)
LAFi = np.array(E['LAF']['FAMOS'][1])
ti = np.array(E['LAF']['FAMOS'][0]) + Signals['MIC'].t0
ax1.plot(ti, LAFi ,'-o', label = 'FAMOS' )
_ = ax1.legend()
In [11]:
signals = [(sn,key) for key,sn in Signals.items() if key is not 'LS']
f,(ax1) = plt.subplots()
Bands = acoustics.signal.OctaveBand(fstart = 20,fstop=20000, fraction=3)
for sn,name in signals:
sn.plot_third_octaves(frequencies = Bands.nominal , ax = ax1, lw=3, label = name)
famosSpect = E['spektrum']['FAMOS']
ax1.plot(famosSpect[0],famosSpect[1] ,'-o', label ='FAMOS', lw = 2 )
_ = ax1.legend()
In [12]:
Bands = acoustics.signal.OctaveBand(fstart = 50,fstop=8000, fraction=3)
lev = {name:{} for name in Signals.keys() if not name =='LS'}
for (sn,name) in signals:
d = lev[name]
d['leq'] = sn.leq()
d['level'] = sn.levels( method = 'weighting')[1]
octB= sn.third_octaves(frequencies=Bands.nominal)
d['Loct'] = level_from_spect(octB[1].leq().T)
den modul acoustics weist gute übereinstimmungen mit FAMOS ein.
In [ ]: