Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuwq0 committed Dec 18, 2024
1 parent 31fe4e6 commit 5471078
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions scripts/cut_templates_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,9 @@ def extract_template_numpy(
)
traveltime_mask = np.memmap(traveltime_mask_fname, dtype=bool, mode="r+", shape=tuple(config["traveltime_shape"]))

waveforms_dict = {}
for picks in picks_group:

# waveforms_dict = {}
waveforms_dict = {}
picks = picks.set_index(["idx_eve", "idx_sta", "phase_type"])
picks_index = list(picks.index.unique())

Expand Down Expand Up @@ -203,7 +202,8 @@ def extract_template_numpy(
begin_time = phase_timestamp - trace_starttime - config[f"time_before_{phase_type.lower()}"]
end_time = phase_timestamp - trace_starttime + config[f"time_after_{phase_type.lower()}"]

if phase_type == "P" and ((idx_eve, idx_sta, "S") in picks.index):
if phase_type == "P" and ((idx_eve, idx_sta, "S") in picks_index):

s_begin_time = (
picks.loc[idx_eve, idx_sta, "S"]["phase_timestamp"] - trace_starttime - config[f"time_before_s"]
)
Expand All @@ -226,12 +226,12 @@ def extract_template_numpy(
trace_data = trace.data[begin_time_index:end_time_index].astype(np.float32)
template_array[idx_pick, ic, 0, : len(trace_data)] = trace_data

if lock is not None:
with lock:
template_array.flush()
traveltime_array.flush()
traveltime_index_array.flush()
traveltime_mask.flush()
if lock is not None:
with lock:
template_array.flush()
traveltime_array.flush()
traveltime_index_array.flush()
traveltime_mask.flush()

return

Expand Down Expand Up @@ -557,7 +557,6 @@ def parse_key(key):
print(f"Using {ncpu} cores")

pbar = tqdm(total=nsplit, desc="Cutting templates")

ctx = mp.get_context("spawn")

with ctx.Manager() as manager:
Expand Down

0 comments on commit 5471078

Please sign in to comment.