@@ -162,7 +162,8 @@ def extract_template_numpy(
162
162
waveforms_dict = {}
163
163
for i , station in stations .iterrows ():
164
164
station_id = station ["station_id" ]
165
- for c in station ["component" ]:
165
+ # for c in station["component"]:
166
+ for c in ["E" , "N" , "Z" , "1" , "2" , "3" ]:
166
167
mseed_name = f"{ mseed_path } /{ station_id } { c } .mseed"
167
168
if os .path .exists (mseed_name ):
168
169
try :
@@ -194,7 +195,8 @@ def extract_template_numpy(
194
195
station_id = station ["station_id" ]
195
196
event = events .loc [idx_eve ]
196
197
197
- for c in station ["component" ]:
198
+ # for c in station["component"]:
199
+ for c in ["E" , "N" , "Z" , "1" , "2" , "3" ]:
198
200
ic = config ["component_mapping" ][c ] # 012 for P, 345 for S
199
201
200
202
if f"{ station_id } { c } " in waveforms_dict :
@@ -291,7 +293,7 @@ def cut_templates(root_path, region, config):
291
293
# data_path = f"{region}/adloc"
292
294
# result_path = f"{region}/cctorch"
293
295
294
- data_path = f"{ region } /adloc_gamma "
296
+ data_path = f"{ region } /adloc "
295
297
result_path = f"{ region } /cctorch"
296
298
297
299
if not os .path .exists (f"{ root_path } /{ result_path } " ):
@@ -350,13 +352,13 @@ def cut_templates(root_path, region, config):
350
352
)
351
353
352
354
# %%
353
- stations = pd .read_csv (f"{ root_path } /{ data_path } /ransac_stations .csv" )
355
+ stations = pd .read_csv (f"{ root_path } /{ data_path } /adloc_stations .csv" )
354
356
stations .sort_values (by = ["latitude" , "longitude" ], inplace = True )
355
357
print (f"{ len (stations ) = } " )
356
358
print (stations .iloc [:5 ])
357
359
358
360
# %%
359
- events = pd .read_csv (f"{ root_path } /{ data_path } /ransac_events .csv" , parse_dates = ["time" ])
361
+ events = pd .read_csv (f"{ root_path } /{ data_path } /adloc_events .csv" , parse_dates = ["time" ])
360
362
events .rename (columns = {"time" : "event_time" }, inplace = True )
361
363
events ["event_time" ] = pd .to_datetime (events ["event_time" ], utc = True )
362
364
reference_t0 = events ["event_time" ].min ()
@@ -416,7 +418,7 @@ def cut_templates(root_path, region, config):
416
418
eikonal = init_eikonal2d (eikonal )
417
419
418
420
# %%
419
- picks = pd .read_csv (f"{ root_path } /{ data_path } /ransac_picks .csv" )
421
+ picks = pd .read_csv (f"{ root_path } /{ data_path } /adloc_picks .csv" )
420
422
picks = picks [picks ["adloc_mask" ] == 1 ]
421
423
picks ["phase_time" ] = pd .to_datetime (picks ["phase_time" ], utc = True )
422
424
min_phase_score = picks ["phase_score" ].min ()
@@ -514,7 +516,11 @@ def cut_templates(root_path, region, config):
514
516
515
517
picks .to_csv (f"{ root_path } /{ result_path } /cctorch_picks.csv" , index = False )
516
518
517
- dirs = sorted (glob (f"{ root_path } /{ region } /waveforms/????/???/??" ), reverse = True )
519
+ ## By hour
520
+ # dirs = sorted(glob(f"{root_path}/{region}/waveforms/????/???/??"), reverse=True)
521
+ ## By day
522
+ dirs = sorted (glob (f"{ root_path } /{ region } /waveforms/????/???" ), reverse = True )
523
+
518
524
ncpu = min (16 , mp .cpu_count ())
519
525
print (f"Using { ncpu } cores" )
520
526
@@ -529,8 +535,12 @@ def pbar_update(x):
529
535
530
536
ctx = mp .get_context ("spawn" )
531
537
picks_group = picks .copy ()
532
- picks_group ["year_jday_hour" ] = picks_group ["phase_time" ].dt .strftime ("%Y-%jT%H" )
533
- picks_group = picks_group .groupby ("year_jday_hour" )
538
+ ## By hour
539
+ # picks_group["year_jday_hour"] = picks_group["phase_time"].dt.strftime("%Y-%jT%H")
540
+ # picks_group = picks_group.groupby("year_jday_hour")
541
+ ## By day
542
+ picks_group ["year_jday" ] = picks_group ["phase_time" ].dt .strftime ("%Y-%j" )
543
+ picks_group = picks_group .groupby ("year_jday" )
534
544
535
545
with ctx .Manager () as manager :
536
546
lock = manager .Lock ()
@@ -539,12 +549,22 @@ def pbar_update(x):
539
549
for d in dirs :
540
550
541
551
tmp = d .split ("/" )
542
- year , jday , hour = tmp [- 3 :]
543
-
544
- if f"{ year } -{ jday } T{ hour } " not in picks_group .groups :
552
+ ## By hour
553
+ # year, jday, hour = tmp[-3:]
554
+ ## By day
555
+ year , jday = tmp [- 2 :]
556
+
557
+ ## By hour
558
+ # if f"{year}-{jday}T{hour}" not in picks_group.groups:
559
+ ## By day
560
+ if f"{ year } -{ jday } " not in picks_group .groups :
545
561
pbar_update (d )
546
562
continue
547
- picks_ = picks_group .get_group (f"{ year } -{ jday } T{ hour } " )
563
+
564
+ ## By hour
565
+ # picks_ = picks_group.get_group(f"{year}-{jday}T{hour}")
566
+ ## By day
567
+ picks_ = picks_group .get_group (f"{ year } -{ jday } " )
548
568
events_ = events .loc [picks_ ["idx_eve" ].unique ()]
549
569
picks_ = picks_ .set_index (["idx_eve" , "idx_sta" , "phase_type" ])
550
570
0 commit comments