Random sampling of NSHM rupture magnitude - #133
Open
lispandfound wants to merge 9 commits into
Open
Conversation
Contributor
Author
|
@claude review |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for sampling a random NSHM rupture magnitude when --magnitude-strategy is set to random, complementing the existing rupture propagation sampling strategy.
Changes:
- Introduces a
magnitude_strategyCLI option intended to control how total rupture magnitude is chosen (median vs random draw). - Extends
default_magnitude_estimationto request a random magnitude draw viamagnitude_scaling.area_to_magnitude(..., random=...). - Seeds Python’s
randomRNG alongside NumPy to support reproducible random sampling.
Suppressed comments (2)
workflow/scripts/nshm2022_to_realisation.py:82
default_magnitude_estimationadds a requiredstrategyparameter, but the docstring’s Parameters section doesn’t describe it, which makes it hard to understand what "maximising" vs "random" means for magnitude sampling.
components: "DisjointSet[str]",
avg_rake: float,
strategy: SamplingStrategy,
) -> dict[str, magnitude_scaling.BoldM]:
workflow/scripts/nshm2022_to_realisation.py:262
- The
magnitude_strategydocstring says that "random" will choose a random rupture propagation tree, but this option is for magnitude sampling. This is likely a copy/paste error and could confuse CLI users.
magnitude_strategy : SamplingStrategy, optional
The strategy to use when sampling total rupture magnitude. "maximising"
will choose the median rupture magnitude. "random" will choose a random
rupture propagation tree.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
321
to
325
| faults_info = db.get_rupture_fault_info(rupture_id) | ||
| seeds = Seeds.read_from_realisation_or_random(realisation_ffp) | ||
| np.random.seed(seed=seeds.nshm_to_realisation_seed) | ||
| random.seed(seeds.nshm_to_realisation_seed) | ||
| source_config = SourceConfig(faults) |
AndrewRidden-Harper
self-requested a review
August 28, 2026 02:30
AndrewRidden-Harper
left a comment
Contributor
There was a problem hiding this comment.
Copilot has some comments, so just check those if you haven't already. Otherwise, it looks good
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
… into magnitude_sampling_nshm
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
workflow/scripts/nshm2022_to_realisation.py:262
- The
magnitude_strategyparameter docstring incorrectly says the "random" option chooses a random rupture propagation tree; it should describe random sampling of rupture magnitude.
The strategy to use when sampling rupture propagation. "maximising" will
choose the maximally likely rupture propagation tree. "random" will
choose a random rupture propagation tree.
AndrewRidden-Harper
self-requested a review
August 28, 2026 04:36
AndrewRidden-Harper
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generates a random draw of the magnitude when
--magnitude-strategyis set torandom.