Skip to content

Commit

Permalink
Merge pull request #10334 from gem/nz_inits
Browse files Browse the repository at this point in the history
fix missing attributes when running NZ22 with disagg_by_src
  • Loading branch information
micheles authored Feb 11, 2025
2 parents 69aa375 + 8777374 commit 24990da
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 2 deletions.
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[Christopher Brooks]
* Another small bug fix for NZ 2022 inslab variants of the Kuehn et
al. (2020) GMM - the sigma_mu_model and sigma_mu_epsilon params
were sometimes missing from GSIM object + added a sensitivity test

[Marco Pagani, Michele Simionato]
* Added an `occurrence_rate` column in median_spectrum_disagg and fixed
the exporter to order the ruptures by ID
Expand Down
9 changes: 8 additions & 1 deletion openquake/calculators/tests/disagg_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from openquake.calculators.tests import CalculatorTestCase, strip_calc_id
from openquake.qa_tests_data.disagg import (
case_1, case_2, case_3, case_4, case_5, case_6, case_7, case_8, case_9,
case_10, case_11, case_12, case_13, case_14, case_15, case_master)
case_10, case_11, case_12, case_13, case_14, case_15, case_16, case_master)

aae = numpy.testing.assert_almost_equal

Expand Down Expand Up @@ -244,6 +244,13 @@ def test_case_15(self):
small50 = mrs50.array[mrs50.array < 2.]
numpy.testing.assert_allclose(small1, small50, rtol=1E-4)

def test_case_16(self):
# Check slab variant of NZ22 Kuehn 2020 GMM has required attributes
# which could (pre-fix) be sometimes missing (seemingly randomly)
# from the K20 GSIM object (test just checks execution not correctness
# of values)
self.run_calc(case_16.__file__, 'job_dsg.ini')

def test_case_master(self):
# this tests exercise the case of a complex logic tree
self.run_calc(case_master.__file__, 'job.ini')
Expand Down
6 changes: 5 additions & 1 deletion openquake/hazardlib/gsim/nz22/nz_nshm2022_kuehn_2020.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def __init__(
if self.region in ("NZL"):
self.REQUIRES_SITES_PARAMETERS = \
self.__class__.REQUIRES_SITES_PARAMETERS


def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi):
"""
Expand Down Expand Up @@ -292,4 +293,7 @@ class NZNSHM2022_KuehnEtAl2020SSlab(NZNSHM2022_KuehnEtAl2020SInter):
DEFINED_FOR_TECTONIC_REGION_TYPE = const.TRT.SUBDUCTION_INTRASLAB

# Need vs30 + backarc also for inslab
REQUIRES_SITES_PARAMETERS = {"vs30", "backarc"}
REQUIRES_SITES_PARAMETERS = {"vs30", "backarc"}

# Other required params
REQUIRES_ATTRIBUTES = {'region', 'm_b', 'sigma_mu_model', 'sigma_mu_epsilon'}
1 change: 1 addition & 0 deletions openquake/qa_tests_data/disagg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
| case_10 | |
| case_11 | |
| case_12 | Source fragments and alternatives of fragments |
| case_16 | Check the NZ22 K20 GMM has required attributes |


Empty file.
18 changes: 18 additions & 0 deletions openquake/qa_tests_data/disagg/case_16/gmmLT.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<nrml xmlns:gml="http://www.opengis.net/gml"
xmlns="http://openquake.org/xmlns/nrml/0.4">
<logicTree logicTreeID='lt1'>
<logicTreeBranchSet uncertaintyType="gmpeModel" branchSetID="bs_slab"
applyToTectonicRegionType="Subduction Intraslab">
<logicTreeBranch branchID= "K20_test">
<uncertaintyModel>[NZNSHM2022_KuehnEtAl2020SSlab]
region = "GLO"
sigma_mu_epsilon = -1.28155
modified_sigma = "true"
</uncertaintyModel>
<uncertaintyWeight>1.0</uncertaintyWeight>
</logicTreeBranch>
</logicTreeBranchSet>
</logicTree>
</nrml>
54 changes: 54 additions & 0 deletions openquake/qa_tests_data/disagg/case_16/job_dsg.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[general]
description = dsg_nz22_test
random_seed = 25
calculation_mode = disaggregation

[logic_tree]
number_of_logic_tree_samples = 100

[erf]
rupture_mesh_spacing = 4
width_of_mfd_bin = 0.1
complex_fault_mesh_spacing = 10.0
area_source_discretization = 10.0

[site_params]
reference_vs30_type = measured
reference_vs30_value = 800.0
reference_depth_to_1pt0km_per_sec = 30.0
reference_depth_to_2pt5km_per_sec = 0.57

[calculation]
source_model_logic_tree_file = ssmLT.xml
gsim_logic_tree_file = gmmLT.xml
investigation_time = 1.0
maximum_distance = {'Subduction Intraslab': [(5.0, 0), (6.0, 200.0), (10, 500.0)]}
truncation_level = 5
intensity_measure_types_and_levels = {"PGA": logscale(0.005, 3.00, 25),
"SA(0.1)": logscale(0.005, 8.00, 25),
"SA(0.2)": logscale(0.005, 9.00, 25),
"SA(0.3)": logscale(0.005, 8.00, 25),
"SA(0.6)": logscale(0.005, 5.50, 25),
"SA(1.0)": logscale(0.005, 3.60, 25),
"SA(2.0)": logscale(0.005, 2.10, 25)}
horiz_comp_to_geom_mean = true
ps_grid_spacing = 0

[geometry]
sites_csv = sites_dsg.csv

[disaggregation]
poes_disagg = 0.002105 0.000404
mag_bin_width = 0.5
distance_bin_width = 25.0
coordinate_bin_width = 100
num_epsilon_bins = 10
num_rlzs_disagg = 0
disagg_outputs = Mag_Dist_Eps
epsilon_star = true
disagg_by_src = true

[output]
hazard_maps = true
export_dir = ../out/dsg
poes = 0.002105 0.000404
2 changes: 2 additions & 0 deletions openquake/qa_tests_data/disagg/case_16/sites_dsg.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lon,lat,vs30,z1pt0,z2pt5,backarc,custom_site_id
-178.9,-35.34,800,31.07,0.57,0,test
85 changes: 85 additions & 0 deletions openquake/qa_tests_data/disagg/case_16/ssm/slab_mps.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version='1.0' encoding='UTF-8'?>
<nrml xmlns:gml="http://www.opengis.net/gml" xmlns="http://openquake.org/xmlns/nrml/0.4">
<sourceModel name="NZL slab MPS ">
<pointSource id="slab_p1" name="point_1" tectonicRegion="Subduction Intraslab">
<pointGeometry>
<gml:Point>
<gml:pos>-178.9068 -35.3424</gml:pos>
</gml:Point>
<upperSeismoDepth>20</upperSeismoDepth>
<lowerSeismoDepth>80</lowerSeismoDepth>
</pointGeometry>
<hypoDepthDist>
<hypoDepth probability="1.0" depth="37.292"/>
</hypoDepthDist>
<magScaleRel>PointMSR</magScaleRel>
<ruptAspectRatio>1.0</ruptAspectRatio>
<truncGutenbergRichterMFD aValue="2.4977085037" bValue="1.06" minMag="5.0" maxMag="6.5"/>
<nodalPlaneDist>
<nodalPlane probability="0.32" strike="217" dip="57.0" rake="-84"/>
<nodalPlane probability="0.36" strike="230.0" dip="57.0" rake="-84"/>
<nodalPlane probability="0.32" strike="243" dip="57.0" rake="-84"/>
</nodalPlaneDist>
</pointSource>
<pointSource id="slab_p2" name="point_2" tectonicRegion="Subduction Intraslab">
<pointGeometry>
<gml:Point>
<gml:pos>-178.9068 -35.3424</gml:pos>
</gml:Point>
<upperSeismoDepth>20</upperSeismoDepth>
<lowerSeismoDepth>80</lowerSeismoDepth>
</pointGeometry>
<hypoDepthDist>
<hypoDepth probability="1.0" depth="37.292"/>
</hypoDepthDist>
<magScaleRel>CScalingMSR.C=4.15</magScaleRel>
<ruptAspectRatio>1.3</ruptAspectRatio>
<truncGutenbergRichterMFD aValue="2.4977085037" bValue="1.06" minMag="6.6" maxMag="8.15"/>
<nodalPlaneDist>
<nodalPlane probability="0.32" strike="217" dip="57.0" rake="-84"/>
<nodalPlane probability="0.36" strike="230.0" dip="57.0" rake="-84"/>
<nodalPlane probability="0.32" strike="243" dip="57.0" rake="-84"/>
</nodalPlaneDist>
</pointSource>
<pointSource id="slab_3" name="point_3" tectonicRegion="Subduction Intraslab">
<pointGeometry>
<gml:Point>
<gml:pos>-179.0097 -35.2982</gml:pos>
</gml:Point>
<upperSeismoDepth>20</upperSeismoDepth>
<lowerSeismoDepth>80</lowerSeismoDepth>
</pointGeometry>
<hypoDepthDist>
<hypoDepth probability="1.0" depth="37.812"/>
</hypoDepthDist>
<magScaleRel>PointMSR</magScaleRel>
<ruptAspectRatio>1.0</ruptAspectRatio>
<truncGutenbergRichterMFD aValue="2.4977085037" bValue="1.06" minMag="5.0" maxMag="6.5"/>
<nodalPlaneDist>
<nodalPlane probability="0.32" strike="217" dip="57.0" rake="-84"/>
<nodalPlane probability="0.36" strike="230.0" dip="57.0" rake="-84"/>
<nodalPlane probability="0.32" strike="243" dip="57.0" rake="-84"/>
</nodalPlaneDist>
</pointSource>
<pointSource id="slab_4" name="point_4" tectonicRegion="Subduction Intraslab">
<pointGeometry>
<gml:Point>
<gml:pos>-179.0097 -35.2982</gml:pos>
</gml:Point>
<upperSeismoDepth>20</upperSeismoDepth>
<lowerSeismoDepth>80</lowerSeismoDepth>
</pointGeometry>
<hypoDepthDist>
<hypoDepth probability="1.0" depth="37.812"/>
</hypoDepthDist>
<magScaleRel>CScalingMSR.C=4.15</magScaleRel>
<ruptAspectRatio>1.3</ruptAspectRatio>
<truncGutenbergRichterMFD aValue="2.4977085037" bValue="1.06" minMag="6.6" maxMag="8.15"/>
<nodalPlaneDist>
<nodalPlane probability="0.32" strike="217" dip="57.0" rake="-84"/>
<nodalPlane probability="0.36" strike="230.0" dip="57.0" rake="-84"/>
<nodalPlane probability="0.32" strike="243" dip="57.0" rake="-84"/>
</nodalPlaneDist>
</pointSource>
</sourceModel>
</nrml>
10 changes: 10 additions & 0 deletions openquake/qa_tests_data/disagg/case_16/ssmLT.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<nrml xmlns="http://openquake.org/xmlns/nrml/0.5">
<logicTree>
<logicTreeBranchSet uncertaintyType="sourceModel" branchSetID="slab_sample">
<logicTreeBranch branchID="slab_sample">
<uncertaintyModel>ssm/slab_mps.xml </uncertaintyModel>
<uncertaintyWeight>1.0</uncertaintyWeight>
</logicTreeBranch>
</logicTreeBranchSet>
</logicTree>
</nrml>

0 comments on commit 24990da

Please sign in to comment.