Skip to content

Commit 13b465a

Browse files
committed
Raise error if trace contains only zeros in from_obspy_trace method of Spectrum class.
1 parent d423d55 commit 13b465a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sourcespec/spectrum.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ def from_obspy_trace(self, trace):
626626
raise TypeError('Only ObsPy Trace objects are supported')
627627
if len(trace.data) < 10:
628628
raise ValueError('The trace must have at least 10 samples')
629+
if np.all(trace.data == 0):
630+
raise ValueError('Trace is all zeros')
629631
signal = trace.data
630632
delta = trace.stats.delta
631633
amp, freq = signal_fft(signal, delta)

0 commit comments

Comments
 (0)