Skip to content
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
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,13 @@ import dataclasses

import numpy as np

from rupture_generator import SegmentContext, SlipField, gaussian_anamorphosis
from rupture_generator import (
STATIONARY,
SegmentContext,
SlipField,
embed,
gaussian_anamorphosis,
)


@dataclasses.dataclass(frozen=True, eq=False)
Expand All @@ -191,9 +197,9 @@ class GivenSlip:
return SlipField(
slip_m=self.slip_m,
latent=gaussian_anamorphosis(self.slip_m, context.geometry.occupied),
# The scores have no covariance of their own; the source's is the
# The scores have no noise of their own; the stationary one is the
# nearest, and it is what the other models' draws use.
latent_covariance=context.source.covariance,
sampler=embed(STATIONARY, context.geometry, context.source.magnitude),
)
```

Expand Down
6 changes: 3 additions & 3 deletions benchmarks/test_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
eikonal_solve,
synthesise_pulses,
)
from rupture_generator.rupture.source import segment_source
from rupture_generator.sampling import Grid
from rupture_generator.rupture.source import MAI_BEROZA
from rupture_generator.sampling import Covariance, Grid, VonKarman
from rupture_generator.sampling.field import _embed

SPACING_KM = 0.1
Expand All @@ -34,7 +34,7 @@ def grid():

@pytest.fixture(scope="module", params=MAGNITUDES, ids=lambda m: f"Mw{m}")
def covariance(request):
return segment_source(request.param, 90.0).covariance
return Covariance(VonKarman(), MAI_BEROZA.lengths_km(request.param))


def test_embed(benchmark, grid, covariance):
Expand Down
6 changes: 0 additions & 6 deletions examples/alpine_hope.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ Kelly = 180.0
"Te Rapa 1" = 160.0
"Te Rapa 2" = 135.0

[source.correlation]
strike_exponent = 0.5
strike_offset = 2.5
dip_exponent = 0.3333333333333333
dip_offset = 1.5

[propagation]
type = "predetermined"

Expand Down
6 changes: 0 additions & 6 deletions examples/beavan.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ Charing_Cross = 66.5
Fault_NNW = 6.23
Fault_NE = 15.46

[source.correlation]
strike_exponent = 0.5
strike_offset = 2.5
dip_exponent = 0.3333333333333333
dip_offset = 1.5

[propagation]
type = "predetermined"

Expand Down
8 changes: 1 addition & 7 deletions examples/colombia.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# The parameters are not tuned to match the observations of this earthquake.
#
# The correlation relation is Mai & Beroza's, spelled out. The depth profiles' shallow
# The noise is the default, Mai & Beroza's lengths. The depth profiles' shallow
# ramps end at 8 km and their deep ramps start at 197.5 km, so they are flat across the
# fault.
#
Expand Down Expand Up @@ -102,12 +102,6 @@ type = "finite"
magnitude = 7.4
rake_deg = 50.54

[source.correlation]
strike_exponent = 0.5
strike_offset = 2.5
dip_exponent = 0.3333
dip_offset = 1.5

[slip]
coefficient_of_variation = 0.75
side_taper = 0.02
Expand Down
6 changes: 0 additions & 6 deletions examples/crustal.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ type = "finite"
magnitude = 6.2
rake_deg = 175.0

[source.correlation]
strike_exponent = 0.5
strike_offset = 2.5
dip_exponent = 0.3333333333333333
dip_offset = 1.5

[slip]
coefficient_of_variation = 0.9
side_taper = 0.02
Expand Down
6 changes: 0 additions & 6 deletions examples/landers.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ type = "per_fault"
"Homestead Valley" = 180.0
"Camp Rock - Emerson" = 180.0

[source.correlation]
strike_exponent = 0.5
strike_offset = 2.5
dip_exponent = 0.3333333333333333
dip_offset = 1.5

[propagation]
type = "predetermined"

Expand Down
6 changes: 0 additions & 6 deletions examples/northridge.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ type = "finite"
magnitude = 6.8
rake_deg = 102.2

[source.correlation]
strike_exponent = 0.5
strike_offset = 2.5
dip_exponent = 0.3333333333333333
dip_offset = 1.5

[slip]
coefficient_of_variation = 0.9
side_taper = 0.02
Expand Down
7 changes: 3 additions & 4 deletions examples/two_faults_segments.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# The two faults of two_faults.toml, with settings that differ on one segment.
# A [segments.<name>] table starts from the global table of the same name and
# replaces the keys it gives; [segments.<name>.correlation] does the same over the
# source's correlation table.
# replaces the keys it gives. A list such as a noise replaces the global one whole.
#
# The parameters are not tuned to match any observations: this is not a past earthquake.

Expand Down Expand Up @@ -41,5 +40,5 @@ coefficient_of_variation = 0.6
[segments.next.speed]
velocity_fraction = 0.7

[segments.next.correlation]
strike_offset = 2.2
[[segments.next.slip.noise]]
relation = { strike_offset = 2.2 }
6 changes: 0 additions & 6 deletions examples/venezuela.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ type = "predetermined"
[propagation.parents]
"Segment 2" = "Segment 1"

[source.correlation]
strike_exponent = 0.5
strike_offset = 2.5
dip_exponent = 0.3333333333333333
dip_offset = 1.5

[slip]
coefficient_of_variation = 0.9
side_taper = 0.02
Expand Down
14 changes: 11 additions & 3 deletions rupture_generator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
later.

:mod:`rupture_generator.config` builds the same inputs from a TOML file, and the
command line runs that file. :func:`rupture_generator.sampling.sampler` keeps the
last 64 covariance embeddings, two per segment, so drawing a fault system of up to
32 segments again reuses every one. ``sampler.cache_clear()`` releases them.
command line runs that file. :func:`embed` keeps the last 128 noise embeddings, two
or three per segment, so drawing a fault system again reuses every one.
``embed.cache_clear()`` releases them.
"""

from importlib.metadata import version
Expand Down Expand Up @@ -44,11 +44,13 @@
ramp_field,
)
from rupture_generator.rupture.models import (
STATIONARY,
CorrelatedPerturbation,
CorrelatedRise,
Drawn,
DrawnSlip,
GaussianRake,
NoiseFamily,
Perturbation,
PerturbationModel,
PulseSettings,
Expand All @@ -60,12 +62,14 @@
SlipField,
SlipModel,
SpeedModel,
embed,
gaussian_anamorphosis,
)
from rupture_generator.rupture.propagator import JumpModel, likeliest_path, sample_path
from rupture_generator.rupture.realisation import Hypocentre, Realisation
from rupture_generator.rupture.source import (
MAI_BEROZA,
SUZUKI_2022,
CorrelationRelation,
SegmentSource,
magnitude_from_moment,
Expand All @@ -79,6 +83,8 @@

__all__ = [
"MAI_BEROZA",
"STATIONARY",
"SUZUKI_2022",
"CorrelatedPerturbation",
"CorrelatedRise",
"CorrelationRelation",
Expand All @@ -92,6 +98,7 @@
"JumpSeed",
"Layers",
"Medium",
"NoiseFamily",
"Perturbation",
"PerturbationModel",
"PulseSettings",
Expand All @@ -110,6 +117,7 @@
"SpatialField",
"SpeedModel",
"constant_field",
"embed",
"first_arrival",
"gaussian_anamorphosis",
"generate",
Expand Down
Loading
Loading