elif _is_quakeml(ev_catalog): print("reading QUAKEML catalog") else: print("warning error in reading ZMAP or QUAKEML") cat = read_events(ev_catalog) ncat = len(cat) print(cat.__str__(print_all=True)) for iev in range(start_itemp, stop_itemp): inplist = tempinp_dir + str( iev) + ".??" + "." + "*" + "..???" + "." + "mseed" print("inplist == ...", inplist) st.clear() for filename in glob.glob(inplist): csize = os.path.getsize(filename) if csize > 0: print("filename ..", filename) st += read(filename) nst = len(st) # print nst print(st.__str__(extended=True)) refT = min([tr.stats.starttime for tr in st]) Tshift = np.empty(nst) arrP = np.empty(nst) arrS = np.empty(nst)
prepick = 0.15, length = 4.6, swin = 'P', parallel = True) if len(template[0]) < 3: print('Skipping template -- %i picks & %i WF in template' % (n_picks[i], len(template[0]))) else: # stats = trace.Stats() template[0].sort(['starttime']) timestamp = template[0][0].stats.starttime end_template = template[0][0].stats.endtime # make plots stplot = std.copy() stplot = stplot.trim(starttime = timestamp - 5, endtime= end_template + 5) # stplot = stplot.detrend() # stplot = stplot.resample(25) stplot = stplot.filter('bandpass', freqmin= 3, freqmax = 10, corners = 4, zerophase = True) pretty_template_plot(template[0], background = stplot, picks = new_catalog[i].picks, save = True, savefile=os.path.join(os.getcwd() + "/Template_plots", "template_" + str(timestamp) + '-' + str(events_clust[i]) + ".png")) template[0].write(os.getcwd() + '/Templates_MSEED/template_' + str(timestamp) + '-'+ str(events_clust[i]) +'.ms', format='MSEED') template_names.append('template_' + str(timestamp) + '.ms') st.clear() std.clear() st_filter.clear() stplot.clear() print('Script took ', time.time() - init_time, ' s to complete.')
maxon_of=max(max_on_of,max_on_of1,max_on_of2) minon=int(minon_of/100) maxon=int(maxon_of/100) print minon_of,maxon_of if args.save_mseed: mseed_dir = os.path.join(args.output, "mseed") output_mseed = os.path.join(mseed_dir,mseed_files) threechannels.slice(t+minon, t+maxon).write(output_mseed, format="mseed") if args.plot: viz_dir = os.path.join(args.output, "viz") if not os.path.exists(viz_dir): os.makedirs(viz_dir) threechannels.slice(t+minon, t+maxon).plot(outfile=os.path.join(viz_dir, mseed_files.split(".mseed")[0]+'.png')) threechannels.clear() st1.clear() <<<<<<< HEAD ======= st2.clear() st3.clear() >>>>>>> cc97cd94a4e720f5b877dfefb44fa8ccb2fd3458 df = pd.DataFrame.from_dict(times_csv) print (df.shape[0]) output_catalog = os.path.join(args.output,'detection.csv') df.to_csv(output_catalog) # # writer = csv.DictWriter(csvfile, fieldnames=fieldnames) # writer.writeheader() # writer.writerow({k: str(v) for k, v in mdict.items()} )