Commit b1524eeb authored by Dave Flogeras's avatar Dave Flogeras
Browse files

Added the ability to high-pass filter data prior to segmenting.

We have noticed that some data contained considerable low frequency
energy.  This option allows us to experiment with high-pass filters in
the testing script.
parent c1c142b3
......@@ -12,10 +12,15 @@ parser = ArgumentParser( description='Process and segment a file using modified
parser.add_argument( 'input', help='Wave file to process', metavar='wavfile' )
parser.add_argument( '-f', '--filter', type=int,
parser.add_argument( '-l', '--lowpass-filter', type=int,
help='Optionally apply a low-pass at the specified cutoff frequency in Hz',
metavar='cutoff-hz' )
parser.add_argument( '-H', '--highpass-filter', type=int,
help='Optionally apply a highpass at the specified cutoff frequency in Hz',
metavar='cutoff-hz' )
parser.add_argument( '-g', '--global-km-window-seconds', type=float,
help='Global KM window size in seconds [default=0.25s]',
default=0.25,
......@@ -41,9 +46,12 @@ ax1.margins( x=0 )
ax1.plot( time, y )
ax1.title.set_text( 'Timeseries' )
if args.filter:
nyquist = fs/2
b,a = scipy.signal.butter( 3, args.filter / nyquist )
if args.lowpass_filter:
b,a = scipy.signal.butter( 3, args.lowpass_filter, fs=fs )
y = scipy.signal.filtfilt( b, a, y )
if args.highpass_filter:
b,a = scipy.signal.butter( 3, args.highpass_filter, btype='high', fs=fs )
y = scipy.signal.filtfilt( b, a, y )
f,t,spec = scipy.signal.spectrogram( y, fs,
......@@ -59,7 +67,8 @@ envelope = abs( z )
max_envelope_time = envelope.argmax()/fs
# Ignore edge effects of filter, if used
if args.filter: max_envelope_time = envelope[30:-30].argmax()/fs
if args.lowpass_filter or args.highpass_filter:
max_envelope_time = envelope[30:-30].argmax()/fs
Fattack, Fdecay = segment.kliewer_mertins( y**2, N=int(fs*args.global_km_window_seconds ))
max_attack_time = Fattack.argmax()/fs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment