Initial implementation of logic trees for site models - #11654
Open
CB-quakemodel wants to merge 66 commits into
Open
Initial implementation of logic trees for site models#11654CB-quakemodel wants to merge 66 commits into
CB-quakemodel wants to merge 66 commits into
Conversation
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 outer product
R_SSC × R_GMM × R_SITE; under sampling all three legs are Monte-Carlo 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 potentially evaluate the regional impact of using different Vs30 models that are available for a given region.
Example of how different site models could represent epistemic uncertainty in the site characterisation:
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 exposesget_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 site params in the GMM logic tree (see #11650)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.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.
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.