-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature extraction update #2
base: main
Are you sure you want to change the base?
Conversation
tutorials/seis_feature.py
Outdated
env = compute_envelope(tr.data) | ||
|
||
if envfilter == True: | ||
sos = signal.butter(1, 0.01, 'lp', fs = tr.stats.sampling_rate, output = 'sos') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see here that the bounds of the filter are hardcoded in the function. would you consider moving these frequencies out of the function as argument? they could belong to a dictionary so that they remain specific to each function but also general enough that users can play with these frequency bands without having the change the functions
tutorials/seis_feature.py
Outdated
@@ -55,6 +77,8 @@ def compute_hibert(tr, env): | |||
auto = np.correlate(tr.data, tr.data, 'same') ## autocorrelation function | |||
|
|||
t = tr.times() | |||
|
|||
# family number 1: Based on waveforms. | |||
all_attr[0,0] = t[-1] - t[0] # Duration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this duration? that seems to be just the window length
tutorials/seis_feature.py
Outdated
sos_5_70 = signal.butter(N = 2, Wn= [3,10], btype = 'bp', fs=tr.stats.sampling_rate, output='sos') | ||
sos_50_100 = signal.butter(N = 2, Wn= [10,20], btype = 'bp', fs=tr.stats.sampling_rate, output='sos') | ||
sos_5_100 = signal.butter(N = 2, Wn= [20,50], btype = 'bp', fs=tr.stats.sampling_rate, output='sos') | ||
sos_0p1_1 = signal.butter(N = 2, Wn= [0.1,1], btype = 'bp', fs=tr.stats.sampling_rate, output='sos') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hardcoding frequency in these filters could be prone to bugs for other users.
tutorials/seis_feature.py
Outdated
|
||
ft = ft[0:len(ft)//2] | ||
ft = abs(np.fft.fft(tr.data)) ## Discrete Fast Fourtier Transform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could potentially save 50% of the calculation time by using the scipy fft. https://stackoverflow.com/questions/6363154/what-is-the-difference-between-numpy-fft-and-scipy-fftpack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few more changes but you have made lots of good progress!!
tutorials/seis_feature.py
Outdated
all_attr = np.empty((1,NATT), dtype = float) | ||
|
||
attributes = ['Duration', 'RappMaxMean', 'RappMaxMedian', 'AsDec','KurtoSig', 'KurtoEnv', 'SkewSig', | ||
attributes = ['Window_Length', 'RappMaxMean', 'RappMaxMedian', 'AsDec','KurtoSig', 'KurtoEnv', 'SkewSig', | ||
'SkewEnv', 'CorPeakNumber', 'Energy1/3Cor', 'Energy2/3Cor', 'int_ratio','E_0.1_1','E_1_3', | ||
'E_3_10', 'E_10_20','E_20_50','Kurt_0.1_1','Kurt_1_3','Kurt_3_10','Kurt_10_20','Kurt_20_50', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these have the hard coded frequency name, i forgot to notice that. it may feel less explanatory, but maybe using E_f1_f2, E_f2_f3, ... would work
tutorials/seis_feature.py
Outdated
starttime = tr.stats.starttime | ||
|
||
|
||
tr.trim(starttime, starttime + 239.95) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you trim after removing the instrumental response?
No description provided.