Dear Forum,
I did a small script based on PhasePapy examples (it uses obspy).
The aim is to save data of picks of Z channels (a set of 10 waveforms Z channel) inside a CSV catalog and the compare with other seismic catalogs made manually.
After importing the necessary library I start processing:
file_list = glob.glob('*BO*BBO*Z*mseed')
print (file_list)
# data to trim
A = UTCDateTime("2020-11-10T13:09:00")
B = UTCDateTime("2020-11-10T13:09:00") + 148.
# Filter / picker parameters
picker = fbpicker.FBPicker(t_long=5, freqmin=1, mode='rms', t_ma=10,
nsigma=5, t_up=0.8, nr_len=2, nr_coeff=2, pol_len=10, pol_coeff=10,
uncert_coeff=3)
# Pick the waveforms
for wf_file in file_list:
st = read(wf_file)
#Here I pick all waveforms
for tr in st:
tr.detrend('linear')
tr_cut = tr.trim(A, B)
if tr_cut.stats.npts == 0: continue
scnl, picks, polarity, snr, uncert = picker.picks(tr_cut) # here is the picker
t_create = datetime.utcnow()
summary = fbpicker.FBSummary(picker, tr_cut) # here is the plot of picker
summary.plot_summary()
Here I try to save each pick information on a DataFrame
for i in range(len(picks)):
picks = pd.DataFrame({
'scnl' : [scnl] * len(picks),
'picks' : list([i.datetime for i in picks]),
'polarity' : polarity,
'snr' : snr,
'uncert' : uncert
})
picks.to_csv("out.csv")
Unfortunately I am not reaching the objective because only the last pick information is saved inside the out.csv file. An example of the output is:
,picks,polarity,scnl,snr,uncert
0,2020-11-10 13:10:07.620,C,BBOB.SHZ.BO.,8.9,0.04
How can I improve my for loop
for i in range(len(picks):
To allow saving all the picks inside of the DataFrame and then to CSV file.
Thanks a lot
Gonzalo