Skip to content

Commit

Permalink
Make sure that noise window does not end at the P arrival time
Browse files Browse the repository at this point in the history
But only in case when the noise window length is not specified.
This ensures backward compatibility with the old behavior.
  • Loading branch information
claudiodsf committed Mar 29, 2024
1 parent 76cf8e0 commit 8a6d760
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion sourcespec/config_files/configspec.conf
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ p_arrival_tolerance = float(min=0, default=4.0)
s_arrival_tolerance = float(min=0, default=4.0)

# Start time (in seconds) of the noise window, respect to the P window
# If None, it will be set to the length of the signal (P or S) window
# If None, it will be set to the length of the signal (P or S) window plus
# the value of "signal_pre_time" (see below)
noise_pre_time = float(min=0.01, default=6.0)

# Start time (in seconds) of the signal window, respect to the P or S arrival
Expand Down
8 changes: 5 additions & 3 deletions sourcespec/ssp_process_traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,13 @@ def _define_signal_and_noise_windows(config, trace):
win_length = win_length_s
if config.variable_win_length_factor:
logger.info(f'{trace.id}: window length {win_length:.3f} seconds')
# use win_length if noise_pre_time is None
noise_pre_time = config.noise_pre_time or win_length
if config.noise_pre_time is None:
noise_pre_time = win_length + config.signal_pre_time
else:
noise_pre_time = config.noise_pre_time
t1 = max(
trace.stats.starttime,
p_arrival_time - noise_pre_time - config.signal_pre_time
p_arrival_time - noise_pre_time
)
t2 = t1 + win_length
if t2 > (p_arrival_time - config.signal_pre_time):
Expand Down

0 comments on commit 8a6d760

Please sign in to comment.