Logic trees for site amplification model - #11726
Open
CB-quakemodel wants to merge 3 commits into
Open
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 amplification model logic trees using the regular NRML XML logic. The user can specify an amplification LT XML file for the
amplification_csvkey in the .ini within which each branch points to a different amplification model CSV.Each branch must define AFs for all sitecol ampcodes and for all IMTs in
intensity_measure_types_and_levels, but beyond that all parameters (the actual AF and sigma values, the rock-IMLlevelgrid, and thefrom_mag/from_rrupgrids) are permitted to differ across branches so users can represent alternative discretisations and value sets as epistemic choices for site amplfication.Full enumeration and sampling of amp branches are supported. Under full enumeration realizations become the product of
R_SSC × R_GMM × R_amp; when sampling all three legs are drawnnum_samplestimes independently (the amp leg uses the samelt.random/lt.samplemethods as the SSC and GSIM parts so bothearly_weightsandlate_weightsare supported).Adding the ability to specify different amplification models per branch is important for supporting site response methodologies (e.g., Liou et al. 2024's BSSA methodologies) . The engine already supports the convolution approach with a single amplification model, so expanding this capability (as done so in this PR) to support epistemic uncertainty on the amplification model is a viable (and logical) option to support more advanced site response methodologies.
A new hazardlib module
amp_lt.pyhandles the amplification logic tree through two containers:AmpLogicTree(parses and validates the amp LT XML) andAmpFunctionsEpistemic(holds the loaded per-branch amplification dataframes and usesget_realizations()for full enumeration andsample()for sampling).QA tests are added (
logictree/case_26) for a 3-branch amp LT (low, med, high AF) covering 2 IMTs (PGA + SA(0.2)) each with 2 rock levels plusfrom_mag/from_rrupcolumns:Example of results for the classical with full enumeration:
NB: A pre-existing bug in
extract_disaggis also fixed as part of this PR:numpy.interpwas being called against the stored mean hazard curve usingoq.imtls[imt]asxp, but the stored curve is onoq.soil_intensitieslevels whenever amplification is active. This mismatch prevented any disagg calc which included an amplification model being applied from exported (regression test through logictree/case_26).Extensive unit tests are also added for the new
amp_lt.pyhazardlib module which test:AmpLogicTreeXML parser accepts both flat and<logicTreeBranchingLevel>-wrapped NRML nestingsAmpLogicTreeXML parser rejects non-amplificationModelbranchsetsAmpLogicTreeXML parser rejects weights that don't sum to 1AmpLogicTreeXML parser rejects duplicate branchIDs within a branchsetAmpLogicTreeXML parser rejects a<logicTree>with noamplificationModelbranchsetAmpLogicTree.is_amp_ltreturns True for a valid amplification LT XML and false for an invalid amplification LT XMLAmpFunctionsEpistemiccontainer assigns every branch a unique BASE183 short characterFullLogicTree.__toh5__/__fromh5__roundtrip preserves the amp LT metadataFullLogicTree.get_realizationsunder full enumeration builds theSSC × GMM × ampproduct with correctly multiplied weights and a three-leg pathFullLogicTree.get_realizationsunderearly_weightssampling gives uniform1/num_samplesweightsFullLogicTree.get_realizationsunderlate_weightssampling draws branches by weightDocumentation 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 amplification logic trees are currently only supported in these calculators. Support for other calc types will be added later.