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

Fix/b value testing #178

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion seismostats/analysis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# flake8: noqa

from seismostats.analysis.estimate_beta import (estimate_b_kijko_smit,
estimate_b_laplace,
estimate_b_positive,
estimate_b_classic,
estimate_b_utsu,
Expand Down
72 changes: 0 additions & 72 deletions seismostats/analysis/estimate_beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,24 +232,6 @@ def estimate_b_utsu(
return b


def differences(magnitudes: np.ndarray) -> np.ndarray:
"""returns all the differences between the magnitudes, only counting each
difference once

Args:
magnitudes: vector of magnitudes differences, sorted in time (first
entry is the earliest earthquake)

Returns: array of all differences of the elements of the input
"""
mag_diffs = np.array([])
for ii in range(1, len(magnitudes)):
loop_mag1 = magnitudes[ii:]
loop_mag2 = magnitudes[:-ii]
mag_diffs = np.append(mag_diffs, loop_mag1 - loop_mag2)
return mag_diffs


def estimate_b_positive(
magnitudes: np.ndarray,
delta_m: float = 0,
Expand Down Expand Up @@ -447,60 +429,6 @@ def make_more_incomplete(
return magnitudes, times


def estimate_b_laplace(
magnitudes: np.ndarray,
delta_m: float = 0,
b_parameter: str = "b_value",
return_std: bool = False,
return_n: bool = False,
) -> float | tuple[float, float]:
"""Return the b-value estimate calculated using
all the differences between magnitudes.
(This has a little less variance than the
:func:`seismostats.analysis.estimate_b_positive`
method.)

Source:
Van der Elst 2021 (J Geophysical Research: Solid Earth, Vol 126, Issue
2)

Args:
magnitudes: vector of magnitudes differences, sorted in time (first
entry is the earliest earthquake)
delta_m: discretization of magnitudes. default is no discretization
b_parameter:either 'b-value', then the corresponding value of the
Gutenberg-Richter law is returned, otherwise 'beta' from the
exponential distribution [p(M) = exp(-beta*(M-mc))]
return_std: if True the standard deviation of beta/b-value (see above)
is returned

Returns:
b: maximum likelihood beta or b-value, depending on value of
input variable 'b_parameter'. Note that the difference is just a
factor [b_value = beta * log10(e)]
std: Shi and Bolt estimate of the beta/b-value estimate
"""
mag_diffs = differences(magnitudes)
mag_diffs = abs(mag_diffs)
mag_diffs = mag_diffs[mag_diffs > 0]

out = estimate_b_classic(
mag_diffs,
mc=delta_m,
delta_m=delta_m,
b_parameter=b_parameter,
return_std=return_std,
)

if return_n:
if type(out) is tuple:
return out + tuple([len(mag_diffs)])
else:
return out, len(mag_diffs)
else:
return out


def estimate_b_weichert(
magnitudes: np.ndarray,
dates: list[np.datetime64],
Expand Down
Loading
Loading