Skip to content

IndexError at short source-receiver distances #21

@bch0w

Description

@bch0w

I have noticed that at very short short-receiver distance D, where D is comparable to the longest wavelength of the signal, Pyflex throws an IndexError when trying to curtail the selected peaks/troughs using theoretical traveltimes. This often results in no window selection for these pairs, even if an analyst would have selected the window. Here is one example coming out of Pyatoa, where I would have expected a window,
Screenshot 2024-07-26 at 4 52 28 PM

But instead we get the error:

  File "/Users/chow/Repos/pyflex/pyflex/window_selector.py", line 316, in calculate_preliminiaries
    min_trough, max_trough = self.troughs[0], self.troughs[-1]
                             ~~~~~~~~~~~~^^^
IndexError: index 0 is out of bounds for axis 0 with size 0

The offending code block is here:

first_trough, last_trough = self.troughs[0], self.troughs[-1]
self.troughs = self.troughs[(self.troughs >= min_idx) &
(self.troughs <= max_idx)]
# If troughs have been removed, readd them add the boundaries.
if len(self.troughs):
if first_trough != self.troughs[0]:
self.troughs = np.concatenate([
np.array([min_idx], dtype=self.troughs.dtype),
self.troughs])
if last_trough != self.troughs[-1]:
self.troughs = np.concatenate([
self.troughs,
np.array([max_idx], dtype=self.troughs.dtype)])

This occurs because all troughs are excluded because they do not fall within the theoretically expected times where signal should be expected.

I think this also ties into two pass filtering that tends to smear signal before the event origin time, and the fact that we are at regional distances which complicates things over global waveform. Ultimately this should not result in an uncontrolled error, but rather a window accept/rejection.

I have a development branch where I'm testing out bypassing this check, which is somewhat optional anyway because it depends on having theoretical arrivals, which is not a prerequisite for window selection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions