Skip to content
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

IndexError at short source-receiver distances #21

Open
bch0w opened this issue Jul 27, 2024 · 0 comments
Open

IndexError at short source-receiver distances #21

bch0w opened this issue Jul 27, 2024 · 0 comments

Comments

@bch0w
Copy link
Member

bch0w commented Jul 27, 2024

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.

@bch0w bch0w changed the title IndexError at very short source-receiver distances IndexError at short source-receiver distances Jul 27, 2024
bch0w added a commit that referenced this issue Jul 27, 2024
…hort source receiver distances, allowing for window selection rather than code crash, also added additional log messages for this preliminaries calculation. See related #21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant