Skip to content

Commit 0692df4

Browse files
arkottkeclaude
andcommitted
Phase 3–8: remove SourceTheoryMotion/StaffordEtAl22Motion, add pygmm interop contracts
Deletes SourceTheoryMotion, StaffordEtAl22Motion, calc_stress_drop, calc_geometric_spreading from motions.py and the sea22-site_amp data file (now in pygmm.fourier_spectrum); adds _contracts.py with RvtMotion helpers; adds pygmm to dev requirements; updates CHANGELOG for 2.0.0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0753f7f commit 0692df4

11 files changed

Lines changed: 220 additions & 748 deletions

‎CHANGELOG.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## 2.0.0 (unreleased)
4+
5+
**Breaking changes**:
6+
7+
- Removed `SourceTheoryMotion` and `StaffordEtAl22Motion` — use
8+
`pygmm.fourier_spectrum.SourceTheoryModel` / `StaffordEtAl2022` instead.
9+
Pipe the result through `RvtMotion.from_fas(model)` to reproduce previous behaviour.
10+
- Removed `calc_stress_drop` and `calc_geometric_spreading` module-level helpers.
11+
- Removed `event_kwds` parameter from `CompatibleRvtMotion.__init__`; `duration` is
12+
now required. Use `CompatibleRvtMotion.from_response_spectrum(rs, duration)` or pass
13+
`duration` explicitly.
14+
15+
Added:
16+
17+
- `RvtMotion.from_fas(fas, peak_calculator=None)` — create a motion from any object
18+
with `.freqs`, `.fourier_amps`, `.duration` attributes.
19+
- `CompatibleRvtMotion.from_response_spectrum(rs, duration, **kw)` — create a
20+
compatible motion from any object with `.periods`, `.spec_accels`, `.damping`.
21+
- `RvtMotion.calc_pga()` and `.calc_pgv()`.
22+
323
## 0.8.0 (dev)
424

525
- Added Stafford et al. (2022) ground motion model.

‎examples/run_example_1.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
damping = 0.05
1515
method = "BJ84"
1616

17-
event_keys = ["magnitude", "distance", "region"]
18-
event_kwds = {key: event[key] for key in event_keys}
17+
calc_kwds = {key: event[key] for key in ["magnitude", "distance", "region"]}
1918

2019
for method in ["BJ84", "CLH56", "DK85", "LP99", "TM87", "V75"]:
2120
start = datetime.datetime.now()
@@ -24,8 +23,7 @@
2423
event["psa"],
2524
duration=event["duration"],
2625
osc_damping=damping,
27-
event_kwds=event_kwds,
28-
peak_calculator=pyrvt.tools.get_peak_calculator(method, event_kwds),
26+
peak_calculator=pyrvt.tools.get_peak_calculator(method, calc_kwds),
2927
)
3028
psa_calc = crm.calc_osc_accels(target_freqs, damping)
3129
duration = datetime.datetime.now() - start

‎requirements_dev.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pre-commit
99
pydocstyle
1010
pyexcel
1111
pyexcel-xlsx
12+
pygmm
1213
pystrata
1314
pytest>=3.5
1415
pytest-cov

‎src/pyrvt/_contracts.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Consumer-side data contracts for pyrvt ↔ pygmm interop.
2+
3+
Canonical definitions live in ``pygmm.contracts``; this file is a private
4+
~35-LOC duplicate so pyrvt has no runtime dependency on pygmm.
5+
"""
6+
7+
from __future__ import annotations
8+
9+
from dataclasses import dataclass
10+
from typing import Optional
11+
12+
import numpy as np
13+
import numpy.typing as npt
14+
15+
16+
@dataclass(frozen=True)
17+
class FourierSpectrum:
18+
"""One-sided Fourier amplitude spectrum of acceleration.
19+
20+
Field names match ``pygmm.contracts.FourierSpectrum``.
21+
"""
22+
23+
freqs: npt.NDArray[np.floating]
24+
fourier_amps: npt.NDArray[np.floating]
25+
duration: float
26+
27+
28+
@dataclass(frozen=True)
29+
class ResponseSpectrum:
30+
"""Pseudo-spectral acceleration response spectrum.
31+
32+
Field names match ``pygmm.contracts.ResponseSpectrum``.
33+
"""
34+
35+
periods: npt.NDArray[np.floating]
36+
spec_accels: npt.NDArray[np.floating]
37+
damping: float
38+
duration: Optional[float] = None

‎src/pyrvt/_version.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# file generated by vcs-versioning
2+
# don't change, don't track in version control
3+
from __future__ import annotations
4+
5+
__all__ = [
6+
"__version__",
7+
"__version_tuple__",
8+
"version",
9+
"version_tuple",
10+
"__commit_id__",
11+
"commit_id",
12+
]
13+
14+
version: str
15+
__version__: str
16+
__version_tuple__: tuple[int | str, ...]
17+
version_tuple: tuple[int | str, ...]
18+
commit_id: str | None
19+
__commit_id__: str | None
20+
21+
__version__ = version = '0.8.2.dev20+gdcab64e8f'
22+
__version_tuple__ = version_tuple = (0, 8, 2, 'dev20', 'gdcab64e8f')
23+
24+
__commit_id__ = commit_id = 'gdcab64e8f'
-2.51 KB
Binary file not shown.

0 commit comments

Comments
 (0)