Skip to content

Fixes related to records with short signal windows #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This release requires at least Python 3.7.
instead of `s_arrival_tolerance` (see [#35])
- Fix bug where signal and noise windows were plotted with the wrong length,
under certain circumstances (see [#35])
- Fixes related to records with short signal windows (see [#39])
- Fix for beachball not plotted anymore with recent versions of Matplotlib.
- Fix bug where traces ignored because of low spectral S/N ratio, where still
plotted as if they were valid traces
Expand Down Expand Up @@ -566,4 +567,5 @@ Initial Python port.
[#35]: https://github.com/SeismicSource/sourcespec/issues/35
[#37]: https://github.com/SeismicSource/sourcespec/issues/37
[#38]: https://github.com/SeismicSource/sourcespec/issues/38
[#39]: https://github.com/SeismicSource/sourcespec/issues/39
[#40]: https://github.com/SeismicSource/sourcespec/issues/40
8 changes: 6 additions & 2 deletions sourcespec/ssp_build_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ def _build_weight_from_inv_frequency(spec, pow=0.25):
"""
if pow >= 1:
raise ValueError('pow must be < 1')
# Note: weight.data is used for plotting, weight.data_log for actual weighting
# Note: weight.data is used for plotting,
# weight.data_log for actual weighting
weight = spec.copy()
freq = weight.get_freq()
weight.data *= 0
Expand Down Expand Up @@ -455,7 +456,10 @@ def _build_weight_from_ratio(spec, specnoise, smooth_width_decades):
weight.data /= np.max(weight.data)
# slightly taper weight at low frequencies, to avoid overestimating
# weight at low frequencies, in cases where noise is underestimated
cosine_taper(weight.data, weight.stats.delta / 4, left_taper=True)
cosine_taper(
weight.data,
min(0.25, weight.stats.delta / 4),
left_taper=True)
# Make sure weight is positive
weight.data[weight.data <= 0] = 0.001
return weight
Expand Down
2 changes: 1 addition & 1 deletion sourcespec/ssp_process_traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def _define_signal_and_noise_windows(config, trace):
# Signal window for spectral analysis (P phase)
t1 = p_arrival_time - config.signal_pre_time
t1 = max(trace.stats.starttime, t1)
t2 = t1 + min(config.win_length, s_minus_p)
t2 = t1 + min(config.win_length, s_minus_p + s_pre_time)
trace.stats.arrivals['P1'] = ('P1', t1)
trace.stats.arrivals['P2'] = ('P2', t2)
# Noise window for spectral analysis
Expand Down