Skip to content

Commit

Permalink
invoke format
Browse files Browse the repository at this point in the history
  • Loading branch information
keurfonluu committed Nov 2, 2022
1 parent cc09954 commit f990b63
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
21 changes: 16 additions & 5 deletions bruces/_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@


Earthquake = namedtuple(
"Earthquake", ["date", "latitude", "longitude", "easting", "northing", "depth", "magnitude"]
"Earthquake",
["date", "latitude", "longitude", "easting", "northing", "depth", "magnitude"],
)


Expand Down Expand Up @@ -90,8 +91,14 @@ def __init__(
"Initializing a catalog requires latitudes/longitudes or eastings/northings."
)

depths = depths if depths is not None else np.full(nev, np.nan, dtype=np.float64)
magnitudes = magnitudes if magnitudes is not None else np.full(nev, np.nan, dtype=np.float64)
depths = (
depths if depths is not None else np.full(nev, np.nan, dtype=np.float64)
)
magnitudes = (
magnitudes
if magnitudes is not None
else np.full(nev, np.nan, dtype=np.float64)
)

self._origin_times = np.asarray(origin_times)
self._latitudes = np.asarray(latitudes)
Expand All @@ -115,7 +122,11 @@ def __getitem__(self, islice):
z = self.depths[islice]
m = self.magnitudes[islice]

return Catalog(t, lat, lon, x, y, z, m) if np.ndim(t) > 0 else Earthquake(t, lat, lon, x, y, z, m)
return (
Catalog(t, lat, lon, x, y, z, m)
if np.ndim(t) > 0
else Earthquake(t, lat, lon, x, y, z, m)
)

def __iter__(self):
"""Iterate over earthquake in catalog as namedtuples."""
Expand Down Expand Up @@ -154,7 +165,7 @@ def decluster(self, algorithm="nearest-neighbor", return_indices=False, **kwargs
- 'gardner-knopoff': Gardner-Knopoff's method (after Gardner and Knopoff, 1974)
- 'nearest-neighbor': nearest-neighbor algorithm (after Zaliapin and Ben-Zion, 2020)
- 'reasenberg': Reasenberg's method (after Reasenberg, 1985)
return_indices : bool, optional, default False
If `True`, return indices of background events instead of declustered catalog.
Expand Down
6 changes: 1 addition & 5 deletions bruces/decluster/gardner_knopoff/_gardner_knopoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ def decluster(catalog, return_indices=False):

bg = _decluster(t, x, y, z, m)

return (
np.arange(len(catalog))[bg]
if return_indices
else catalog[bg]
)
return np.arange(len(catalog))[bg] if return_indices else catalog[bg]


@jitted
Expand Down
10 changes: 9 additions & 1 deletion bruces/decluster/nearest_neighbor/_nearest_neighbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@


def decluster(
catalog, return_indices=False, d=1.6, w=1.0, eta_0=None, alpha_0=1.5, use_depth=False, M=100, seed=None
catalog,
return_indices=False,
d=1.6,
w=1.0,
eta_0=None,
alpha_0=1.5,
use_depth=False,
M=100,
seed=None,
):
"""
Decluster earthquake catalog (after Zaliapin and Ben-Zion, 2020).
Expand Down
17 changes: 11 additions & 6 deletions bruces/decluster/reasenberg/_reasenberg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
from .._helpers import register


def decluster(catalog, return_indices=False, rfact=10, xmeff=None, xk=0.5, taumin=1.0, taumax=10.0, p=0.95):
def decluster(
catalog,
return_indices=False,
rfact=10,
xmeff=None,
xk=0.5,
taumin=1.0,
taumax=10.0,
p=0.95,
):
"""
Decluster earthquake catalog using Reasenberg's method.
Expand Down Expand Up @@ -48,11 +57,7 @@ def decluster(catalog, return_indices=False, rfact=10, xmeff=None, xk=0.5, taumi

bg = _decluster(t, x, y, z, m, rfact, xmeff, xk, taumin, taumax, p)

return (
np.arange(len(catalog))[bg]
if return_indices
else catalog[bg]
)
return np.arange(len(catalog))[bg] if return_indices else catalog[bg]


@jitted
Expand Down

0 comments on commit f990b63

Please sign in to comment.