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

Add option to pick from P pick #572

Merged
merged 7 commits into from
Jun 28, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions eqcorrscan/utils/mag_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@
winlen=0.9, pre_pick=0.2, pre_filt=True, lowcut=1.0,
highcut=20.0, corners=4, min_snr=1.0, plot=False,
remove_old=False, ps_multiplier=0.34, velocity=False,
water_level=0, iaspei_standard=False):
water_level=0, iaspei_standard=False, win_from_p=False):
"""
Pick amplitudes for local magnitude for a single event.

Expand Down Expand Up @@ -779,6 +779,9 @@
static amplification of 1), or AML with wood-anderson static
amplification of 2080. Note: Units are SI (and specified in the
amplitude)
:type win_from_p: bool
:param win_from_p:
Whether to start the picking window from the P-time or not.

Check failure on line 784 in eqcorrscan/utils/mag_calc.py

View workflow job for this annotation

GitHub Actions / flake8-linter

W291 trailing whitespace
calum-chamberlain marked this conversation as resolved.
Show resolved Hide resolved

:returns: Picked event
:rtype: :class:`obspy.core.event.Event`
Expand Down Expand Up @@ -891,7 +894,10 @@
raise NotImplementedError(
"No p or s picks - you should not have been able to "
"get here")
trim_start = s_time - pre_pick
if win_from_p:
trim_start = p_time - pre_pick

Check warning on line 898 in eqcorrscan/utils/mag_calc.py

View check run for this annotation

Codecov / codecov/patch

eqcorrscan/utils/mag_calc.py#L898

Added line #L898 was not covered by tests
else:
trim_start = s_time - pre_pick
trim_end = s_time + (s_time - p_time) * winlen
# Work out the window length based on p-s time or distance
else: # Fixed window-length
Expand All @@ -908,8 +914,14 @@
"No s-pick or hypocentral distance to predict "
f"s-arrival for station {sta}, skipping")
continue
trim_start = s_time - pre_pick
if win_from_p:
trim_start = p_time - pre_pick

Check warning on line 918 in eqcorrscan/utils/mag_calc.py

View check run for this annotation

Codecov / codecov/patch

eqcorrscan/utils/mag_calc.py#L918

Added line #L918 was not covered by tests
else:
trim_start = s_time - pre_pick
trim_end = s_time + winlen
if trim_end <= trim_start:
Logger.error(f"Trying to trim to negative length: {trim_start} -- {trim_end}. Skipping")

Check failure on line 923 in eqcorrscan/utils/mag_calc.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E501 line too long (104 > 80 characters)
calum-chamberlain marked this conversation as resolved.
Show resolved Hide resolved
continue

Check warning on line 924 in eqcorrscan/utils/mag_calc.py

View check run for this annotation

Codecov / codecov/patch

eqcorrscan/utils/mag_calc.py#L923-L924

Added lines #L923 - L924 were not covered by tests
tr = tr.trim(trim_start, trim_end)
if len(tr.data) <= 10:
Logger.warning(f'Insufficient data for {sta}')
Expand Down
Loading