Skip to content

Commit

Permalink
bem.base: rename get_source_magnitudes to get_derived_parameters also…
Browse files Browse the repository at this point in the history
… avg slips
  • Loading branch information
hvasbath committed May 2, 2024
1 parent c484729 commit 413d49e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion beat/apps/beat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ def setup(parser):
response = composite.engine.process(
sources=composite.sources, targets=composite.targets
)
derived = response.get_source_magnitudes(
derived = response.get_derived_parameters(
composite.engine.config.shear_modulus
)

Expand Down
24 changes: 19 additions & 5 deletions beat/bem/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pyrocko.gf import StaticResult
from pyrocko.guts import List, Object
from pyrocko.guts_array import Array
from pyrocko.moment_tensor import symmat6, moment_to_magnitude
from pyrocko.moment_tensor import moment_to_magnitude, symmat6

from .sources import DiscretizedBEMSource, check_intersection, slip_comp_to_idx

Expand Down Expand Up @@ -85,16 +85,30 @@ def source_slips(self) -> list[num.ndarray]:
slips.append(None)
return slips

def get_source_magnitudes(self, shear_modulus):
def get_derived_parameters(self, shear_modulus: float) -> list[num.ndarray]:
"""
Calculate derived source parameters magnitude[Mw]
and average slip amplitude[m]
Parameters
----------
shear_modulus: float
Returns
-------
list of derived parameters, each entry is for each source
"""
inverted_slips = self.source_slips()
total_slips = [num.linalg.norm(slips, axis=1) for slips in inverted_slips]

magnitudes = []
derived = []
for source, slips in zip(self.discretized_sources, total_slips):
moments = source.get_areas_triangles() * slips * shear_modulus
magnitudes.append(moment_to_magnitude(moments.sum()))
derived.append(
num.hstack([moment_to_magnitude(moments.sum()), slips.sum()])
)

return magnitudes
return derived


class BEMEngine(object):
Expand Down

0 comments on commit 413d49e

Please sign in to comment.