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

Redundant check in calculate_preliminiaries #12

Open
wjlei1990 opened this issue Nov 7, 2016 · 7 comments
Open

Redundant check in calculate_preliminiaries #12

wjlei1990 opened this issue Nov 7, 2016 · 7 comments

Comments

@wjlei1990
Copy link

wjlei1990 commented Nov 7, 2016

Hi Lion,

I am revisiting the pyflex code and found that in the calculate_preliminiaries , you have such checks:

if self.ttimes:
            offset = self.event.origin_time - self.observed.stats.starttime
            min_time = self.ttimes[0]["time"] - \
                self.config.max_time_before_first_arrival + offset
            min_idx = int(min_time / self.observed.stats.delta)

            dist_in_km = geodetics.calcVincentyInverse(
                self.station.latitude, self.station.longitude,
                self.event.latitude, self.event.longitude)[0] / 1000.0
            max_time = dist_in_km / self.config.min_surface_wave_velocity + \
                offset + self.config.max_period
            max_idx = int(max_time / self.observed.stats.delta)

            # Reject all peaks and troughs before the minimal allowed start
            # time and after the maximum allowed end time.
            first_trough, last_trough = self.troughs[0], self.troughs[-1]
            self.troughs = self.troughs[(self.troughs >= min_idx) &
                                        (self.troughs <= max_idx)]

Which I think for current design of pyflex, this part shouldn't be here, because it works the same as function reject_on_traveltimes. It is also very limited since it reject all the windows after surface waves.

@krischer
Copy link
Collaborator

krischer commented Nov 7, 2016

Hmm...I think it has to stay there but you are partially right: It should be moved into a common routine that can be shared with reject_on_traveltimes().

I think that removing this might slow down the code down quite a bit as this here actually removes peaks and troughs before the windows are selected. The next steps creates windows as (if I remember correctly) full permutations of peaks and troughs so removing only a subset of peaks and troughs has the potential to eliminate a crazy amount of windows before they are even created.

@wjlei1990
Copy link
Author

Suppose you want to select ScS phases(close to event, which means it come after surface waves), you won't be able to do so since it is already rejected...

@wjlei1990
Copy link
Author

wjlei1990 commented Nov 7, 2016

If you are concerned about the speed issues, I think we may put the noise_end_index check here instead of putting a specific arrival time check.

For example, the window should be in signal region instead of noise region. If we check so, we can reject quite a lot of windows at the beginning of the seismograms. But users still have the flexibility to customize it...

@krischer
Copy link
Collaborator

krischer commented Nov 7, 2016

True but the reject_on_traveltimes() method will also reject these. Thus reconciling both methods to share a common core has the potential to fix both while still retaining all advantages.

The current logic as actually not particularly good for picking reflected phases for stations close to event precisely for the reason you mentioned. This could be solved by making the shared core for both methods a bit smarter. Instead of just relying on first arrival and a minimal surface wave velocity it could rely on first arrival (for beginning of allowed time window) and max(some core reflected phase time, min surface wave velocity). This should work for almost every case I believe.

@krischer
Copy link
Collaborator

krischer commented Nov 7, 2016

This smarter version could also replace the whole noise index stuff. It would just create a signal start and a signal end index. Everything before the signal start index will be considered noise.

@wjlei1990
Copy link
Author

Not so in my code. In my code, I replace the reject_on_traveltime with reject_on_selection_mode, and there are now 5 choices: 1) body_waves; 2) suface_waves; 3) body_and_surface_waves;...

I agree with your opinion that the travel time should be used in a smarter way. I will think about and let you know later...

@wjlei1990
Copy link
Author

Oh, I got one more question for you, just to make sure...

In this line

                self.config.noise_end_index = \
                    int(self.ttimes[0]["time"] - self.config.min_period)

We should consider offset right? Otherwise, the noise_end_index is the index starting from the event origin time, not the trace starttime.

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

2 participants