Skip to content

Commit

Permalink
Merge pull request #10233 from gem/fix_k20
Browse files Browse the repository at this point in the history
Fix K20 site param bug
  • Loading branch information
micheles authored Dec 21, 2024
2 parents b0f57d1 + a40ceb1 commit 56cdb12
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
38 changes: 18 additions & 20 deletions openquake/hazardlib/gsim/kuehn_2020.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
:class:`KuehnEtAl2020SSlabNewZealand`,
:class:`KuehnEtAl2020SSlabSouthAmerica`,
:class:`KuehnEtAl2020SSlabTaiwan`,
:class:`KuehnEtAl2020SSSlabCascadiaSeattleBasin`,
:class:`KuehnEtAl2020SSlabCascadiaSeattleBasin`,
"""
import numpy as np
import os
Expand All @@ -54,11 +54,11 @@
# Path to the model coefficients
KUEHN_COEFFS = os.path.join(os.path.dirname(__file__), "kuehn_2020_coeffs.csv")

# Regions: Global (GLO), Alaska (ALU), Cascadia (CAS), Seattle (Sea)
# Regions: Global (GLO), Alaska (ALU), Cascadia (CAS), Seattle (SEA)
# Central America & Mexico (CAM), Japan (JPN - ISO 3-letter code),
# New Zealand (NZL), South America (SAM), Taiwan (TWN)
SUPPORTED_REGIONS = ["GLO",
"USA-AK", "CAS", "Sea",
"USA-AK", "CAS", "SEA",
"CAM", "JPN", "NZL", "SAM", "TWN"]

# Define inputs according to 3-letter codes
Expand Down Expand Up @@ -136,7 +136,7 @@
"file_unc": "kuehn2020_uncertainty_if_Taiwan.hdf5",
},
# Seattle (same as Cascadia but we use theta_c11_Sea for basin term)
"Sea": {
"SEA": {
"c1": "c_1_if_reg_Ca",
"c6": "c_6_2_reg_Ca",
"c7": "c_7_reg_Ca",
Expand Down Expand Up @@ -222,7 +222,7 @@
"file_unc": "kuehn2020_uncertainty_slab_Taiwan.hdf5",
},
# Seattle (same as Cascadia but we use theta_c11_Sea for basin term)
"Sea": {
"SEA": {
"c1": "c_1_slab_reg_Ca",
"c6": "c_6_2_reg_Ca",
"c7": "c_7_reg_Ca",
Expand Down Expand Up @@ -434,11 +434,11 @@ def _get_basin_term(C, ctx, region):
"""
# Basin term only defined for the four regions: Cascadia, Japan,
# New Zealand and Taiwan
assert region in ("CAS", "JPN", "NZL", "TWN", "Sea")
assert region in ("CAS", "JPN", "NZL", "TWN", "SEA")

# If region is Seattle retrieve theta_11 as basin term (this coeff
# is imt-dependent but are the same for interface and inslab)
if region == "Sea":
if region == "SEA":
theta_11 = C[REGION_TERMS_IF[region]["theta_11"]]
return np.full_like(ctx.vs30, theta_11)

Expand Down Expand Up @@ -492,10 +492,11 @@ def get_mean_values(C, region, imt, trt, m_b, ctx, a1100=None,

# For Cascadia, Japan, New Zealand and Taiwan a basin depth term
# is included
if a1100.any() and region in ("CAS", "JPN", "NZL", "TWN", "Sea"):
if a1100.any() and region in ("CAS", "JPN", "NZL", "TWN", "SEA"):

# Get USGS basin scaling factor if required (can only be for
# CAS region)
# Get USGS basin scaling factor if required (checks during
# init ensure can only be applied to the CAS or SEA regions
# which use z2pt5
if usgs_bs:
usgs_baf = _get_z2pt5_usgs_basin_scaling(ctx.z2pt5, imt.period)
else:
Expand All @@ -511,7 +512,7 @@ def get_mean_values(C, region, imt, trt, m_b, ctx, a1100=None,
if imt.period >= 1.9:
fb[ctx.z2pt5 >= 6.0] = np.log(2.0) # M9 term instead

# Now add the basin term to pre-basin amp mean
# Now add the basin term to pre-basin amp mean
mean += fb * usgs_baf

return mean
Expand Down Expand Up @@ -660,7 +661,7 @@ class KuehnEtAl2020SInter(GMPE):
- New Zealand (NZL)
- South America (SAM)
- Taiwan (TWN)
- Seattle (Sea)
- Seattle (SEA)
In the original model defined by the authors, three of the regions
(JPN, CAM, SAM) define a forearc/backarc dependent anelastic attenuation
Expand Down Expand Up @@ -737,22 +738,19 @@ def __init__(self, region="GLO", m_b=None, m9_basin_term=None,
self.region = region

# For some regions a basin depth term is defined
if self.region in ("CAS", "JPN"):
# If region is CAS or JPN then the GMPE needs Z2.5
self.REQUIRES_SITES_PARAMETERS = \
self.REQUIRES_SITES_PARAMETERS.union({"z2pt5", })
if self.region in ("CAS", "JPN", "SEA"):
# If region is CAS, JPN or SEA then the GMPE needs Z2.5
self.REQUIRES_SITES_PARAMETERS |= {"z2pt5"}
elif self.region in ("NZL", "TWN"):
# If region is NZL or TWN then the GMPE needs Z1.0
self.REQUIRES_SITES_PARAMETERS |= {"z1pt0"}
else:
pass # Seattle Basin uses imt-dependent fixed theta_c11_Sea

self.m9_basin_term = m9_basin_term
self.usgs_basin_scaling = usgs_basin_scaling
# USGS basin scaling and M9 basin term is only
# applied when the region param is set to Cascadia.
if self.usgs_basin_scaling or self.m9_basin_term:
if self.region not in ["CAS", "Sea"]:
if self.region not in ["CAS", "SEA"]:
raise ValueError('To apply the USGS basin scaling or the M9 '
'basin adjustment to KuehnEtAl2020 the '
'Cascadia region or the Seattle Basin '
Expand Down Expand Up @@ -867,7 +865,7 @@ class KuehnEtAl2020SSlab(KuehnEtAl2020SInter):
"NZL": "NewZealand",
"SAM": "SouthAmerica",
"TWN": "Taiwan",
"Sea": "CascadiaSeattleBasin",
"SEA": "CascadiaSeattleBasin",
}


Expand Down
16 changes: 4 additions & 12 deletions openquake/hazardlib/tests/gsim/utils_us23_basin_adj_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@
[-4.16121733, -5.82549419, -7.68603107],
[-4.94338881, -6.57681856, -8.15619706]],

[[-4.10630526, -6.53500941, -8.77537358],
[-3.95831828, -6.04455764, -7.85456617],
[-4.64245446, -6.83630271, -8.3485733 ]],

[[-4.1286112 , -6.50684706, -8.75325462],
[-4.39797433, -5.97346732, -7.68603107],
[-5.22574681, -6.75329231, -7.74540788]],
Expand Down Expand Up @@ -164,16 +160,14 @@
z06_def = valid.gsim('[ZhaoEtAl2006SInter]\ncb14_basin_term="true"')

# KuehnEtAl2020SInterSeattle vs KuehnEtAl2020SInterCascadia vs Seattle SInter Adj
k20_def_sea_int = valid.gsim('[KuehnEtAl2020SInter]\nregion="Sea"')
k20_def_cas_int = valid.gsim('[KuehnEtAl2020SInter]\nregion="CAS"')
k20_adj_sea_int = valid.gsim('[KuehnEtAl2020SInter]\nregion="Sea"\n'
k20_def_sea_int = valid.gsim('[KuehnEtAl2020SInter]\nregion="SEA"')
k20_adj_sea_int = valid.gsim('[KuehnEtAl2020SInter]\nregion="SEA"\n'
'm9_basin_term="true"\n'
'usgs_basin_scaling="true"')

# KuehnEtAl2020SSlabSeattle vs KuehnEtAl2020SSlabCascadia vs Seattle SSlab Adj
k20_def_sea_sslab = valid.gsim('[KuehnEtAl2020SSlab]\nregion="Sea"')
k20_def_cas_sslab = valid.gsim('[KuehnEtAl2020SSlab]\nregion="CAS"')
k20_adj_sea_sslab = valid.gsim('[KuehnEtAl2020SSlab]\nregion="Sea"\n'
k20_def_sea_sslab = valid.gsim('[KuehnEtAl2020SSlab]\nregion="SEA"')
k20_adj_sea_sslab = valid.gsim('[KuehnEtAl2020SSlab]\nregion="SEA"\n'
'm9_basin_term="true"\n'
'usgs_basin_scaling="true"')

Expand Down Expand Up @@ -217,10 +211,8 @@ def test_all(self):
a09_adj, a09_def,
z06_adj, z06_def,
k20_def_sea_int,
k20_def_cas_int,
k20_adj_sea_int,
k20_def_sea_sslab,
k20_def_cas_sslab,
k20_adj_sea_sslab,
ask14_adj, ask14_def,
bssa14_adj, bssa14_def,
Expand Down

0 comments on commit 56cdb12

Please sign in to comment.