diff --git a/openquake/hazardlib/gsim/atkinson_macias_2009.py b/openquake/hazardlib/gsim/atkinson_macias_2009.py index 38430a87a5f..17a87b81275 100644 --- a/openquake/hazardlib/gsim/atkinson_macias_2009.py +++ b/openquake/hazardlib/gsim/atkinson_macias_2009.py @@ -25,6 +25,7 @@ from openquake.hazardlib.gsim.base import GMPE, CoeffsTable from openquake.hazardlib import const from openquake.hazardlib.imt import PGA, SA +from openquake.hazardlib.gsim.mgmpe.cb14_basin_term import _get_cb14_basin_term def _get_distance_term(C, rrup, mag): @@ -77,6 +78,12 @@ class AtkinsonMacias2009(GMPE): #: Required distance measure is rupture distance REQUIRES_DISTANCES = {'rrup'} + def __init__(self, cb14_basin_term=False): + if cb14_basin_term: + self.REQUIRES_SITES_PARAMETERS = frozenset( + self.REQUIRES_SITES_PARAMETERS | {'z2pt5'}) + self.cb14_basin_term = cb14_basin_term + def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi): """ See :meth:`superclass method @@ -89,7 +96,11 @@ def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi): _get_distance_term(C, ctx.rrup, ctx.mag)) # Convert mean from cm/s and cm/s/s and from common logarithm to # natural logarithm - mean[m] = np.log((10.0 ** (imean - 2.0)) / g) + ln_mean = np.log((10.0 ** (imean - 2.0)) / g) + # Apply CB14 basin term if specified + if self.cb14_basin_term: + ln_mean += _get_cb14_basin_term(imt, ctx) + mean[m] = ln_mean sig[m] = np.log(10.0 ** C["sigma"]) COEFFS = CoeffsTable(sa_damping=5, table=""" diff --git a/openquake/hazardlib/gsim/kuehn_2020.py b/openquake/hazardlib/gsim/kuehn_2020.py index 746ded0abd2..c734fbf6298 100644 --- a/openquake/hazardlib/gsim/kuehn_2020.py +++ b/openquake/hazardlib/gsim/kuehn_2020.py @@ -647,8 +647,7 @@ class KuehnEtAl2020SInter(GMPE): m_b: The magnitude scaling breakpoint. This term is defined for each region and tectonic region type, but this can also be over-ridden by the user - :param bool m9_basin_term: Apply the M9 basin term instead of the GMM's - native basin term + :param bool m9_basin_term: Apply the M9 basin adjustment :param bool usgs_basin_scaling: Scaling factor to be applied to basin term based on USGS basin model diff --git a/openquake/hazardlib/gsim/mgmpe/cb14_basin_term.py b/openquake/hazardlib/gsim/mgmpe/cb14_basin_term.py index acad2d59e72..9e0f71dbb33 100644 --- a/openquake/hazardlib/gsim/mgmpe/cb14_basin_term.py +++ b/openquake/hazardlib/gsim/mgmpe/cb14_basin_term.py @@ -25,7 +25,7 @@ from openquake.hazardlib.gsim.campbell_bozorgnia_2014 import CampbellBozorgnia2014 -def _get_cb14_basin_term(ctx, C, jpn_flag=False): +def _get_cb14_basin_term(imt, ctx, jpn_flag=False): """ Get the basin response term defined in equation 20 of the Campbell and Bozorgnia (2014) GMM paper. @@ -33,6 +33,7 @@ def _get_cb14_basin_term(ctx, C, jpn_flag=False): Currently the global basin term is provided (i.e. the Japan-regionalised basin term is for now turned off). """ + C = CampbellBozorgnia2014.COEFFS[imt] z2pt5 = ctx.z2pt5 fb = np.zeros(len(z2pt5)) idx = z2pt5 < 1.0 @@ -81,5 +82,4 @@ def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi): """ self.gmpe.compute(ctx, imts, mean, sig, tau, phi) for m, imt in enumerate(imts): - C = CampbellBozorgnia2014.COEFFS[imt] - mean[m] += _get_cb14_basin_term(ctx, C) \ No newline at end of file + mean[m] += _get_cb14_basin_term(ctx) \ No newline at end of file diff --git a/openquake/hazardlib/gsim/parker_2020.py b/openquake/hazardlib/gsim/parker_2020.py index 3313dadd920..b94c31a3d9b 100644 --- a/openquake/hazardlib/gsim/parker_2020.py +++ b/openquake/hazardlib/gsim/parker_2020.py @@ -375,8 +375,7 @@ class ParkerEtAl2020SInter(GMPE): "AK", "Cascadia", "CAM_S", "CAM_N", "JP_Pac", "JP_Phi", "SA_N", "SA_S", "TW_W", "TW_E") :param str basin: Choice of basin region ("Out" or "Seattle") - :param bool m9_basin_term: Apply the M9 basin term instead of the GMM's - native basin term + :param bool m9_basin_term: Apply the M9 basin term adjustment :param bool usgs_basin_scaling: Scaling factor to be applied to basin term based on USGS basin model :param float sigma_mu_epsilon: Number of standard deviations to multiply @@ -406,6 +405,8 @@ class ParkerEtAl2020SInter(GMPE): #: Required distance measure is closest distance to rupture, for #: interface events REQUIRES_DISTANCES = {'rrup'} + + # Other required attributes REQUIRES_ATTRIBUTES = {'region', 'saturation_region', 'basin', 'm9_basin_term' 'usgs_basin_scaling', 'sigma_mu_epsilon'} @@ -477,8 +478,14 @@ def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi): if self.m9_basin_term and imt != PGV: if imt.period >= 1.9: m9_adj = _get_adjusted_m9_basin_term(C, ctx.z2pt5) - fb[ctx.z2pt5 >= 6.0] += m9_adj[ctx.z2pt5 >= 6.0] - + if fb != 0.0: + fb[ctx.z2pt5 >= 6.0] += m9_adj[ctx.z2pt5 >= 6.0] + else: + fb = m9_adj # fb is zero if no region (no basin) thus + # just take the adjusted m9 term instead + # for the basin amplification given has + # been specified by user + # Now get the mean with basin term added mean[m] = pre_baf_mean + (fb * usgs_baf)