os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import argparse from tqdm import tqdm from multiprocessing import cpu_count import tensorflow as tf from seisnn.io import read_event_list, write_training_dataset, read_geom from seisnn.pick import get_pick_dict from seisnn.utils import get_config print(f'cpu counts: {cpu_count()} threads') ap = argparse.ArgumentParser() ap.add_argument('-c', '--catalog', required=True, help='catalog s-file dir', type=str) ap.add_argument('-g', '--geometry', required=True, help='geometry STATION0.HYP', type=str) ap.add_argument('-d', '--dataset', required=True, help='output dataset name', type=str) ap.add_argument('-p', '--pickset', required=True, help='output pickset name', type=str) args = ap.parse_args() config = get_config() geom = read_geom(args.geometry) events = read_event_list(args.catalog) pick_dict = get_pick_dict(events) pick_dict_keys = pick_dict.keys() for i, key in enumerate(pick_dict_keys): tqdm.write(f'station {key}, total: {i + 1}/{len(pick_dict_keys)}, pick counts: {len(pick_dict[key])}') with tf.device('/cpu:0'): write_training_dataset(pick_dict[key], geom, dataset=args.dataset, pickset=args.pickset)
import cartopy.crs as ccrs import cartopy.io.img_tiles as cimgt from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter from seisnn.io import read_hyp, read_event_list from seisnn.utils import get_config W, E, S, N = 119, 123, 21.5, 25.7 stamen_terrain = cimgt.Stamen('terrain-background') fig = plt.figure(figsize=(8, 10)) ax = fig.add_subplot(1, 1, 1, projection=stamen_terrain.crs) ax.set_extent([W, E, S, N], crs=ccrs.Geodetic()) ax.add_image(stamen_terrain, 11) events = read_event_list('HL201718') HL_eq = [] for event in events: HL_eq.append([event.origins[0].longitude, event.origins[0].latitude]) HL_eq = np.array(HL_eq).T ax.scatter(HL_eq[0], HL_eq[1], label='Earthquake', transform=ccrs.Geodetic(), color='#333333', edgecolors='k', linewidth=0.3, marker='o', s=0.5) events = read_event_list('MN2016')
import cartopy.crs as ccrs import cartopy.io.img_tiles as cimgt from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter from seisnn.io import read_hyp, read_event_list from seisnn.utils import get_config W, E, S, N = 121.3, 121.8, 23.5, 24.25 stamen_terrain = cimgt.Stamen('terrain-background') fig = plt.figure(figsize=(8, 11)) ax = fig.add_subplot(1, 1, 1, projection=stamen_terrain.crs) ax.set_extent([W, E, S, N], crs=ccrs.Geodetic()) ax.add_image(stamen_terrain, 11) events = read_event_list('HL201718') HL_eq = [] for event in events: HL_eq.append([event.origins[0].longitude, event.origins[0].latitude]) HL_eq = np.array(HL_eq).T ax.scatter(HL_eq[0], HL_eq[1], label='Earthquake', transform=ccrs.Geodetic(), color='#555555', edgecolors='k', linewidth=0.3, marker='o', s=10) geom = read_hyp('HL2017.HYP') HL_station = [] for k, station in geom.items(): HL_station.append([station['longitude'], station['latitude'], ]) HL_station = np.array(HL_station).T ax.scatter(HL_station[0], HL_station[1], label='HL 2017 station', transform=ccrs.Geodetic(), color='#b71c1c', edgecolors='k', marker='v', linewidth=0.5, s=60)
import cartopy.crs as ccrs import cartopy.io.img_tiles as cimgt from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter from seisnn.io import read_hyp, read_event_list from seisnn.utils import get_config W, E, S, N = 120.1, 120.85, 22.75, 23.25 stamen_terrain = cimgt.Stamen('terrain-background') fig = plt.figure(figsize=(8, 6)) ax = fig.add_subplot(1, 1, 1, projection=stamen_terrain.crs) ax.set_extent([W, E, S, N], crs=ccrs.Geodetic()) ax.add_image(stamen_terrain, 11) events = read_event_list('MN2016') MN_eq = [] for event in events: MN_eq.append([event.origins[0].longitude, event.origins[0].latitude]) MN_eq = np.array(MN_eq).T ax.scatter(MN_eq[0], MN_eq[1], label='Earthquake', transform=ccrs.Geodetic(), color='#555555', edgecolors='k', linewidth=0.3, marker='o', s=10) geom = read_hyp('MN2016.HYP')