Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuwq0 committed Aug 16, 2024
1 parent f9bb413 commit c232215
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions adloc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def is_data_valid(X, y):
)
t0 = X["phase_time"].min()

if event_init is not None:
event_init = np.array([[event_init[0], event_init[1], event_init[2], (event_init[3] - t0).total_seconds()]])
else:
if (event_init is None) or len(X) == 0:
event_init = np.array([[np.median(X["x_km"]), np.median(X["y_km"]), 5.0, 0.0]])
else:
event_init = np.array([[event_init[0], event_init[1], event_init[2], (event_init[3] - t0).total_seconds()]])

# xstd = np.std(X["x_km"])
# ystd = np.std(X["y_km"])
Expand Down Expand Up @@ -202,9 +202,11 @@ def invert_location(picks, stations, config, estimator, events_init=None, iter=0
for idx_eve, picks_by_event in picks.groupby("idx_eve"):
if events_init is not None:
event_init = events_init[events_init["idx_eve"] == idx_eve]
if len(event_init) == 1:
if len(event_init) == 0:
event_init = None
elif len(event_init) == 1:
event_init = event_init[["x_km", "y_km", "z_km", "time"]].values[0]
elif len(event_init) > 1:
else:
event_init = event_init[["x_km", "y_km", "z_km", "time"]].values[0]
print(f"Multiple initial locations for event_index {idx_eve}.")
else:
Expand Down
2 changes: 1 addition & 1 deletion docs/run_ransac.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@

for iter in range(MAX_SST_ITER):
# picks, events = invert_location_iter(picks, stations, config, estimator, events_init=events_init, iter=iter)
picks, events = invert_location(picks, stations, config, estimator, events_init=events, iter=iter)
picks, events = invert_location(picks, stations, config, estimator, events_init=events_init, iter=iter)
# station_term = picks[picks["mask"] == 1.0].groupby("idx_sta").agg({"residual_time": "mean"}).reset_index()
station_term_time = picks[picks["mask"] == 1.0].groupby("idx_sta").agg({"residual_time": "mean"}).reset_index()
station_term_amp = (
Expand Down

0 comments on commit c232215

Please sign in to comment.