Skip to content

Commit 7bf9864

Browse files
authored
Merge pull request #39 from krisvanneste/short_windows2
Fixes related to records with short signal windows
2 parents 3953a54 + 1cb9a30 commit 7bf9864

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ This release requires at least Python 3.7.
3434
instead of `s_arrival_tolerance` (see [#35])
3535
- Fix bug where signal and noise windows were plotted with the wrong length,
3636
under certain circumstances (see [#35])
37+
- Fixes related to records with short signal windows (see [#39])
3738
- Fix for beachball not plotted anymore with recent versions of Matplotlib.
3839
- Fix bug where traces ignored because of low spectral S/N ratio, where still
3940
plotted as if they were valid traces
@@ -566,4 +567,5 @@ Initial Python port.
566567
[#35]: https://github.com/SeismicSource/sourcespec/issues/35
567568
[#37]: https://github.com/SeismicSource/sourcespec/issues/37
568569
[#38]: https://github.com/SeismicSource/sourcespec/issues/38
570+
[#39]: https://github.com/SeismicSource/sourcespec/issues/39
569571
[#40]: https://github.com/SeismicSource/sourcespec/issues/40

sourcespec/ssp_build_spectra.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,8 @@ def _build_weight_from_inv_frequency(spec, pow=0.25):
417417
"""
418418
if pow >= 1:
419419
raise ValueError('pow must be < 1')
420-
# Note: weight.data is used for plotting, weight.data_log for actual weighting
420+
# Note: weight.data is used for plotting,
421+
# weight.data_log for actual weighting
421422
weight = spec.copy()
422423
freq = weight.get_freq()
423424
weight.data *= 0
@@ -455,7 +456,10 @@ def _build_weight_from_ratio(spec, specnoise, smooth_width_decades):
455456
weight.data /= np.max(weight.data)
456457
# slightly taper weight at low frequencies, to avoid overestimating
457458
# weight at low frequencies, in cases where noise is underestimated
458-
cosine_taper(weight.data, weight.stats.delta / 4, left_taper=True)
459+
cosine_taper(
460+
weight.data,
461+
min(0.25, weight.stats.delta / 4),
462+
left_taper=True)
459463
# Make sure weight is positive
460464
weight.data[weight.data <= 0] = 0.001
461465
return weight

sourcespec/ssp_process_traces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def _define_signal_and_noise_windows(config, trace):
274274
# Signal window for spectral analysis (P phase)
275275
t1 = p_arrival_time - config.signal_pre_time
276276
t1 = max(trace.stats.starttime, t1)
277-
t2 = t1 + min(config.win_length, s_minus_p)
277+
t2 = t1 + min(config.win_length, s_minus_p + s_pre_time)
278278
trace.stats.arrivals['P1'] = ('P1', t1)
279279
trace.stats.arrivals['P2'] = ('P2', t2)
280280
# Noise window for spectral analysis

0 commit comments

Comments
 (0)