From be2477bb980465987e046d1bb4d16f7413ec1fc4 Mon Sep 17 00:00:00 2001 From: zhuwq Date: Fri, 2 Aug 2024 14:54:39 -0700 Subject: [PATCH] update --- adloc/utils.py | 2 +- docs/run_ransac.py | 4 ++-- docs/utils.py | 12 +++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/adloc/utils.py b/adloc/utils.py index a0f97e4..c8b78b1 100644 --- a/adloc/utils.py +++ b/adloc/utils.py @@ -172,7 +172,7 @@ def invert_location(picks, stations, config, estimator, events_init=None, iter=0 if "ncpu" in config: NCPU = config["ncpu"] else: - NCPU = mp.cpu_count() - 1 + NCPU = min(32, mp.cpu_count() - 1) jobs = [] events_inverted = [] diff --git a/docs/run_ransac.py b/docs/run_ransac.py index 11a0aca..e957550 100644 --- a/docs/run_ransac.py +++ b/docs/run_ransac.py @@ -61,8 +61,8 @@ events_init["depth_km"] = events_init["depth(m)"] / 1000.0 events_init["time"] = pd.to_datetime(events_init["time"]) - picks = picks[picks["phase_time"] < pd.to_datetime("2019-07-05 00:00:00")] - events_init = events_init[events_init["time"] < pd.to_datetime("2019-07-05 00:00:00")] + # picks = picks[picks["phase_time"] < pd.to_datetime("2019-07-05 00:00:00")] + # events_init = events_init[events_init["time"] < pd.to_datetime("2019-07-05 00:00:00")] stations = pd.read_csv(stations_file, sep="\t") stations.rename({"station": "station_id", "elevation(m)": "elevation_m"}, axis=1, inplace=True) diff --git a/docs/utils.py b/docs/utils.py index b9d8861..405deb2 100644 --- a/docs/utils.py +++ b/docs/utils.py @@ -195,11 +195,14 @@ def plotting_ransac(stations, figure_path, config, picks, events_init, events, i ax[1, 2].hist(picks[picks["mask"] == 1.0]["residual_amplitude"], bins=30, edgecolor="white") ax[1, 2].set_title("Pick residual (log10 cm/s)") plt.savefig(os.path.join(figure_path, f"hist_{iter}.png"), bbox_inches="tight", dpi=300) + plt.close(fig) xmin, xmax = config["xlim_km"] ymin, ymax = config["ylim_km"] zmin, zmax = config["zlim_km"] vmin, vmax = config["zlim_km"] + events = events.sort_values("time", ascending=True) + s = max(0.1, min(10, 5000 / len(events))) alpha = 0.8 fig, ax = plt.subplots(2, 3, figsize=(18, 8), gridspec_kw={"height_ratios": [2, 1]}) # fig, ax = plt.subplots(2, 3, figsize=(15, 8), gridspec_kw={"height_ratios": [2, 1]}) @@ -208,11 +211,12 @@ def plotting_ransac(stations, figure_path, config, picks, events_init, events, i events["y_km"], c=events["z_km"], cmap="viridis_r", - s=1, + s=s, marker="o", vmin=vmin, vmax=vmax, alpha=alpha, + linewidth=0., ) # set ratio 1:1 ax[0, 0].set_aspect("equal", "box") @@ -296,11 +300,12 @@ def plotting_ransac(stations, figure_path, config, picks, events_init, events, i events["z_km"], c=events["z_km"], cmap="viridis_r", - s=1, + s=s, marker="o", vmin=vmin, vmax=vmax, alpha=alpha, + linewidth=0., ) # ax[1, 0].set_aspect("equal", "box") ax[1, 0].set_xlim([xmin, xmax]) @@ -315,11 +320,12 @@ def plotting_ransac(stations, figure_path, config, picks, events_init, events, i events["z_km"], c=events["z_km"], cmap="viridis_r", - s=1, + s=s, marker="o", vmin=vmin, vmax=vmax, alpha=alpha, + linewidth=0., ) # ax[1, 1].set_aspect("equal", "box") ax[1, 1].set_xlim([ymin, ymax])