[WIP] Initial implementation of logic trees for site models - #11654
Closed
CB-quakemodel wants to merge 101 commits into
Closed
[WIP] Initial implementation of logic trees for site models#11654CB-quakemodel wants to merge 101 commits into
CB-quakemodel wants to merge 101 commits into
Conversation
2 tasks
2 tasks
2 tasks
Contributor
Author
|
Upon some reflection, I think given the specifics of each site-response methodology that the desired outcome can still be obtained (explicitly) either within ModifiableGMPE-based branchs in the GMM LT (given we are literally modifying the input reference ground-motion), or (less ideally) through the introduction of similar functions within the specific GMMs which we use in these PSHA studies. For now given this, I will close this PR; if we introduce the site model logic trees into the classical calculator, we will also need to spend considerable time extending the capability into the event-based and scenario calculators, potentially for minimal benefit in terms of real applications given the focus is really for site-specific studies. |
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.
This PR adds the ability to specify site model logic trees using the regular NRML XML logic. The user can specify a site model XML file for the
site_model_filekey in the .ini within which each branch points to a different site model (either CSV or XML version). The site models must have identical lon/lat (and elevation if present), although the site IDs can vary (useful for tracking site param diffs at same locations) and share all site parameters (but of course the values for each parameter within each site model can differ).Full enumeration and sampling of site branches are supported. Under full enumeration realizations become the product of
R_SSC × R_GMM × R_SITE; when sampling all three legs are drawnnum_samplestimes independently (the site leg uses the samelt.random/lt.samplemethods as the SSC and GSIM parts so bothearly_weightsandlate_weightsare supported).The approach of specifying different site model files rather than branches with absolute or relative uncertainties for parameters like vs30 is suitable because then we can 1) still specify many epistemic uncertainties in the case of site-specific or "few" sites calculations and 2) within a larger calculation we can incorporate epistemic uncertainties through using different regional Vs30 models.
A new hazardlib module
site_lt.pyhandles the site-model logic tree through two containers:SiteModelLogicTree(parses and validates the site model LT XML) andSiteModelsEpistemic(holds the loaded per-branch site model arrays and usesget_realizations()for full enumeration andsample()for sampling). Therefore everything is handled explicitly in a containerised approach, unlike in my initial implementation using ModifiableGMPE and representing epistemic uncertainty in the site params in the GMM logic tree (see #11650).We can use the containerised approach in combination with published site-specific methodologies applied through (to be added as needed)
ModifiableGMPEfunctions to explicitly represent the epistemic uncertainties in the site response within a logic tree with a dedicated site model component. An example would be the amplification factors per branch as described in the Rodriguez-Marek et al. (2021) site model logic tree-focused paper - we could specify them in the site model logic tree, and then the application of the factors themselves could be handled in a dedicatedModifiableGMPEcapability if passed as site parameters in the context arrays.QA tests are added for a site model logic tree with a rock site model and a softer soil site model (
logictree/case_24and subtests) in a test with 2 sources and 2 GMMs to ensure the logic tree is sufficiently complex:use_rates=trueandindividual_rlzs=false)use_rates=trueandindividual_rlzs=false)__fromh5___into a disagg calcNB: Both
early_weightsandlate_weightssampling methods are tested in these QA tests.NB: Most of the files changed in this PR are from these extensive unit tests.
NB: The existing
override_vs30.ini option (viaSiteCollection.multiply()) also produces multiple hazard results at the same location, but it clones each site once per vs30 value as an unweighted set of contexts (the curves are never combined and remain as separate results) - the site-model LT in this PR instead adds a weighted third leg to the logic tree so all site params (not just vs30) vary per branch and contribute tohcurves-stats/meanand to sampling.Extensive unit tests are also added for the new
site_lt.pyhazardlib module which test:SiteModelLogicTreeXML parser accepts both flat and<logicTreeBranchingLevel>-wrapped NRML nestingsSiteModelLogicTreeXML parser rejects non-siteModelbranchsetsSiteModelLogicTreeXML parser rejects weights that don't sum to 1SiteModelLogicTreeXML parser rejects duplicatebranchIDs within a branchsetSiteModelLogicTreeXML parser rejects a<logicTree>with nositeModelbranchsetSiteModelsEpistemiccontainer rejects branches with mismatched site coordinatesSiteModelsEpistemiccontainer rejects branches with mismatched depth valuesSiteModelsEpistemiccontainer rejects branches with differing site-parameter field sets (e.g. one branch declaresz1pt0, another does not)SiteModelsEpistemiccontainer assigns every branch a unique BASE183 short characterlogictree.reduce_fullpreserves the surviving branch when a cluster uses only one site branchlogictree.reduce_fullleaves the tree alone when a cluster spans both site branchesFullLogicTree.__toh5__/__fromh5__roundtrip preserves the site LT metadataFullLogicTree.get_realizationsunder full enumeration builds the SSC × GMM × SITE outer product with correctly multiplied weightsFullLogicTree.get_realizationsunderearly_weightssampling gives uniform1/num_samplesweightsFullLogicTree.get_realizationsunderlate_weightssampling draws branches by weight and keeps each rlz's tree weight product (rescaled to sum to 1)Documentation is added for this feature.
It is not yet supported outside of classical and disaggregation — an error is intentionally raised to warn the user that site model logic trees are only supported in classical and disagg.