#!/usr/bin/env python # encoding: utf-8 from glob import glob from plot_dsp import read_dsp, plot_all_map print "Plotting coverage using all dsp files for all events" periods = [20, 50, 100, 150] # get all the filenames dsp_files = glob('*/*.dsp') # create a list for all the files dsp_list = [] # loop over the files for fname in dsp_files: # read the dispersion dsp, dsp_dict = read_dsp(fname) # add the information to the list dsp_list.append((dsp, dsp_dict)) # plot the coverage map plot_all_map(dsp_list, coverage=True) for per in periods: print "Treating period %.1f" % per plot_all_map(dsp_list, coverage=True, period=per)
for sta in stations: events = event_array[station_array == sta, :] dsp_shortlist = dsp_array[station_array == sta] print sta, events.shape, dsp_shortlist.shape # cluster on events so as to compare dispersion curves for nearby # events brc = Birch(branching_factor=50, n_clusters=None, threshold=dist, compute_labels=True) brc.fit(events) labels = brc.predict(events) print np.max(labels) for lab in np.unique(labels): dsp_this_label_list = dsp_shortlist[labels == lab] cluster_name = os.path.join(dirname, "cluster_%s_%03d" % (sta, lab)) plot_all_dsp(dsp_this_label_list, legend=False, fname="%s_gvel.png" % cluster_name) plot_all_map(dsp_this_label_list, fname="%s_map.png" % cluster_name, legend=False) f = open("%s_info.txt" % cluster_name, "w") for (dsp, dsp_dict) in dsp_this_label_list: f.write( "%s %s %d %03d %02d %02d %.3f %.3f\n" % ( dsp_dict["STA"], dsp_dict["COMP"], dsp_dict["YEAR"], dsp_dict["JDAY"], dsp_dict["HOUR"], dsp_dict["MIN"], dsp_dict["EVLA"], dsp_dict["EVLO"], ) )
for sta in stations: events = event_array[station_array == sta, :] dsp_shortlist = dsp_array[station_array == sta] print sta, events.shape, dsp_shortlist.shape # cluster on events so as to compare dispersion curves for nearby # events brc = Birch(branching_factor=50, n_clusters=None, threshold=dist, compute_labels=True) brc.fit(events) labels = brc.predict(events) print np.max(labels) for lab in np.unique(labels): dsp_this_label_list = dsp_shortlist[labels == lab] cluster_name = os.path.join(dirname, 'cluster_%s_%03d' % (sta, lab)) plot_all_dsp(dsp_this_label_list, legend=False, fname='%s_gvel.png' % cluster_name) plot_all_map(dsp_this_label_list, fname='%s_map.png' % cluster_name, legend=False) f = open('%s_info.txt' % cluster_name, 'w') for (dsp, dsp_dict) in dsp_this_label_list: f.write('%s %s %d %03d %02d %02d %.3f %.3f\n' % (dsp_dict["STA"], dsp_dict["COMP"], dsp_dict["YEAR"], dsp_dict["JDAY"], dsp_dict["HOUR"], dsp_dict["MIN"], dsp_dict["EVLA"], dsp_dict["EVLO"])) f.close()
#!/usr/bin/env python # encoding: utf-8 from glob import glob from plot_dsp import read_dsp, plot_all_map print "Plotting coverage using all dsp files for all events" periods = [20, 50, 100, 150] # get all the filenames dsp_files = glob('*/*.dsp') # create a list for all the files dsp_list = [] # loop over the files for fname in dsp_files: # read the dispersion dsp, dsp_dict = read_dsp(fname) # add the information to the list dsp_list.append((dsp, dsp_dict)) # plot the coverage map plot_all_map(dsp_list, coverage=True) for per in periods: print "Treating period %.1f"%per plot_all_map(dsp_list, coverage=True, period=per)