Skip to content

Commit

Permalink
Minor comments
Browse files Browse the repository at this point in the history
  • Loading branch information
geojunky committed Apr 6, 2022
1 parent 8a0aea3 commit 45e0ef7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions seismic/extract_event_traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,9 @@ def extract_data(catalog, inventory, waveform_getter, event_trace_datafile,
phase_map = defaultdict(str) # seconds
phase_map['P'] = 'P'
phase_map['S'] = 'S'
phase_map['SW'] = 'P' # for surface-waves we use P-onset time within iter_event_data
# for surface-waves we use the default phase (P), but internally, safe_iter_event_data
# extracts data around event origin time
phase_map['SW'] = 'P'

# initialize event distance-range dict
distance_range = defaultdict(tuple) # arc degrees
Expand Down Expand Up @@ -420,6 +422,7 @@ def extract_data(catalog, inventory, waveform_getter, event_trace_datafile,
nproc = comm.Get_size()
rank = comm.Get_rank()

# data extraction is parallelized over stations
nsl_dict = None
if(rank==0):
nsl_dict = []
Expand All @@ -431,7 +434,9 @@ def extract_data(catalog, inventory, waveform_getter, event_trace_datafile,
temp_dict['.'.join(tokens[:3])] = tokens[-1]
# end for

njob = len(temp_dict)
njob = len(temp_dict) # total number of stations
# Add made up entries to ensure MPI-barrier calls are balanced across all
# processors
nbogus = np.int(np.ceil(njob/float(nproc)))*nproc - njob
for i in np.arange(nbogus): temp_dict['%i.%i.%i'%(i, i, i)] = '-1'

Expand All @@ -446,6 +451,8 @@ def extract_data(catalog, inventory, waveform_getter, event_trace_datafile,

for nsl, cha in nsl_dict.items():
if(cha == '-1'):
# Nothing to do for made up entries, which exist for the sole purpose of balancing
# MPI-barrier calls across all processors
for irank in np.arange(nproc):
comm.Barrier()
# end for
Expand Down

0 comments on commit 45e0ef7

Please sign in to comment.