Skip to content

Commit 5471078

Browse files
committed
fix
1 parent 31fe4e6 commit 5471078

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

scripts/cut_templates_cc.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,9 @@ def extract_template_numpy(
158158
)
159159
traveltime_mask = np.memmap(traveltime_mask_fname, dtype=bool, mode="r+", shape=tuple(config["traveltime_shape"]))
160160

161-
waveforms_dict = {}
162161
for picks in picks_group:
163162

164-
# waveforms_dict = {}
163+
waveforms_dict = {}
165164
picks = picks.set_index(["idx_eve", "idx_sta", "phase_type"])
166165
picks_index = list(picks.index.unique())
167166

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

206-
if phase_type == "P" and ((idx_eve, idx_sta, "S") in picks.index):
205+
if phase_type == "P" and ((idx_eve, idx_sta, "S") in picks_index):
206+
207207
s_begin_time = (
208208
picks.loc[idx_eve, idx_sta, "S"]["phase_timestamp"] - trace_starttime - config[f"time_before_s"]
209209
)
@@ -226,12 +226,12 @@ def extract_template_numpy(
226226
trace_data = trace.data[begin_time_index:end_time_index].astype(np.float32)
227227
template_array[idx_pick, ic, 0, : len(trace_data)] = trace_data
228228

229-
if lock is not None:
230-
with lock:
231-
template_array.flush()
232-
traveltime_array.flush()
233-
traveltime_index_array.flush()
234-
traveltime_mask.flush()
229+
if lock is not None:
230+
with lock:
231+
template_array.flush()
232+
traveltime_array.flush()
233+
traveltime_index_array.flush()
234+
traveltime_mask.flush()
235235

236236
return
237237

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

559559
pbar = tqdm(total=nsplit, desc="Cutting templates")
560-
561560
ctx = mp.get_context("spawn")
562561

563562
with ctx.Manager() as manager:

0 commit comments

Comments
 (0)