Source code for openquake.hazardlib.gsim.campbell_2003
# -*- coding: utf-8 -*-# vim: tabstop=4 shiftwidth=4 softtabstop=4## Copyright (C) 2012-2023 GEM Foundation## OpenQuake is free software: you can redistribute it and/or modify it# under the terms of the GNU Affero General Public License as published# by the Free Software Foundation, either version 3 of the License, or# (at your option) any later version.## OpenQuake is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU Affero General Public License for more details.## You should have received a copy of the GNU Affero General Public License# along with OpenQuake. If not, see <http://www.gnu.org/licenses/>."""Module exports :class:`Campbell2003`, :class:`Campbell2003SHARE`,:class:`Campbell2003MblgAB1987NSHMP2008`,:class:`Campbell2003MblgJ1996NSHMP2008`,:class:`Campbell2003MwNSHMP2008`"""importnumpyasnpfromopenquake.baselib.generalimportCallableDictfromopenquake.hazardlib.gsim.baseimportCoeffsTable,GMPEfromopenquake.hazardlib.gsim.utilsimport(mblg_to_mw_atkinson_boore_87,mblg_to_mw_johnston_96,clip_mean)fromopenquake.hazardlibimportconstfromopenquake.hazardlib.imtimportPGA,SA_compute_mean=CallableDict()@_compute_mean.add("base")def_compute_mean_1(kind,C,mag,rrup):""" Compute mean value according to equation 30, page 1021. """mean=(C['c1']+_compute_term1(C,mag)+_compute_term2(C,mag,rrup)+_compute_term3(C,rrup))returnmean@_compute_mean.add("Mblg87","Mblg96","Mw")def_compute_mean_2(kind,C,mag,rrup):""" Compute mean value (Equation 30 in USGS report) """mean=np.zeros_like(rrup)mean+=C['c1']+C['c2']*mag+C['c3']*(8.5-mag)**2idx=rrup>70.mean[idx]+=C['c7']*(np.log(rrup[idx])-np.log(70.))idx=rrup>130.mean[idx]+=C['c8']*(np.log(rrup[idx])-np.log(130.))R=np.sqrt(rrup**2+(C['c5']*np.exp(C['c6']*mag))**2)mean+=C['c4']*np.log(R)+(C['c9']+C['c10']*mag)*rrupreturnmeandef_compute_term1(C,mag):""" This computes the term f1 in equation 31, page 1021 """return(C['c2']*mag)+C['c3']*(8.5-mag)**2def_compute_term2(C,mag,rrup):""" This computes the term f2 in equation 32, page 1021 """c78_factor=(C['c7']*np.exp(C['c8']*mag))**2R=np.sqrt(rrup**2+c78_factor)returnC['c4']*np.log(R)+(C['c5']+C['c6']*mag)*rrupdef_compute_term3(C,rrup):""" This computes the term f3 in equation 34, page 1021 but corrected according to the erratum. """f3=np.zeros_like(rrup)idx_between_70_130=(rrup>70)&(rrup<=130)idx_greater_130=rrup>130f3[idx_between_70_130]=(C['c9']*(np.log(rrup[idx_between_70_130])-np.log(70)))f3[idx_greater_130]=(C['c9']*(np.log(rrup[idx_greater_130])-np.log(70))+C['c10']*(np.log(rrup[idx_greater_130])-np.log(130)))returnf3_convert_magnitude=CallableDict()@_convert_magnitude.add("Mblg87")def_convert_magnitude_1(kind,mag):""" Convert magnitude from Mblg to Mw using Atkinson and Boore 1987 equation. """returnmblg_to_mw_atkinson_boore_87(mag)@_convert_magnitude.add("Mblg96")def_convert_magnitude_2(kind,mag):""" Convert magnitude from Mblg to Mw using Johnston 1996 equation. """returnmblg_to_mw_johnston_96(mag)@_convert_magnitude.add("Mw")def_convert_magnitude_3(kind,mag):""" Return magnitude value unchanged """returnmag
[docs]classCampbell2003(GMPE):""" Implements GMPE developed by K.W Campbell and published as "Prediction of Strong Ground Motion Using the Hybrid Empirical Method and Its Use in the Development of Ground Motion (Attenuation) Relations in Eastern North America" (Bulletting of the Seismological Society of America, Volume 93, Number 3, pages 1012-1033, 2003). The class implements also the corrections given in the erratum (2004). """kind="base"#: Supported tectonic region type is stable continental crust given that#: the equations have been derived for Eastern North America.DEFINED_FOR_TECTONIC_REGION_TYPE=const.TRT.STABLE_CONTINENTAL#: Supported intensity measure types are spectral acceleration,#: and peak ground acceleration, see table 6, page 1022 (PGA is assumed#: to be equal to SA at 0.01 s)DEFINED_FOR_INTENSITY_MEASURE_TYPES={PGA,SA}#: Supported intensity measure component is the geometric mean of#: two horizontal components#: :attr:`~openquake.hazardlib.const.IMC.GEOMETRIC_MEAN`,DEFINED_FOR_INTENSITY_MEASURE_COMPONENT=const.IMC.GEOMETRIC_MEAN#: Supported standard deviation type is only total, see equation 35, page#: 1021DEFINED_FOR_STANDARD_DEVIATION_TYPES={const.StdDev.TOTAL}#: No site parameters are neededREQUIRES_SITES_PARAMETERS=set()#: Required rupture parameter is only magnitude, see equation 30 page#: 1021.REQUIRES_RUPTURE_PARAMETERS={'mag'}#: Required distance measure is closest distance to rupture, see equation#: 30 page 1021.REQUIRES_DISTANCES={'rrup'}
[docs]defcompute(self,ctx:np.recarray,imts,mean,sig,tau,phi):""" See :meth:`superclass method <.base.GroundShakingIntensityModel.compute>` for spec of input and result values. """form,imtinenumerate(imts):C=self.COEFFS[imt]mean[m]=_compute_mean(self.kind,C,ctx.mag,ctx.rrup)sig[m]=np.where(ctx.mag<7.16,C['c11']+C['c12']*ctx.mag,C['c13'])
[docs]classCampbell2003SHARE(Campbell2003):""" Extends :class:`~openquake.hazardlib.gsim.campbell_2003.Campbell2003` and introduces adjustments for style of faulting and default rock soil conditions as needed by the SHARE (http://www.share-eu.org/) project. """#: Required rupture parameters are magnitude and rakeREQUIRES_RUPTURE_PARAMETERS={'mag','rake'}#: Shear-wave velocity for reference soil conditions in [m s-1]DEFINED_FOR_REFERENCE_VELOCITY=800.
[docs]defcompute(self,ctx:np.recarray,imts,mean,sig,tau,phi):""" See :meth:`superclass method <.base.GroundShakingIntensityModel.compute>` for spec of input and result values. """super().compute(ctx,imts,mean,sig,tau,phi)form,imtinenumerate(imts):# extract faulting style and rock adjustment coefficients for the# given imtC_ADJ=self.COEFFS_FS_ROCK[imt]# apply faulting style and rock adjustment factor for mean and stdmean[m]=np.log(np.exp(mean[m])*_compute_faulting_style_term(C_ADJ['Frss'],self.CONSTS_FS['pR'],self.CONSTS_FS['Fnss'],self.CONSTS_FS['pN'],ctx.rake)*C_ADJ['AFrock'])
[docs]classCampbell2003MblgAB1987NSHMP2008(Campbell2003):""" Implement GMPE developed by Ken Campbell and described in "Development of semi-empirical attenuation relationships for the CEUS", U.S. Geological Survey, Award 01HQGR0011, final report. Document available at: http://earthquake.usgs.gov/research/external/reports/01HQGR0011.pdf This GMPE is used by the National Seismic Hazard Mapping Project (NSHMP) for the 2008 central and eastern US hazard model. This class replicates the algorithm as implemented in ``subroutine getCampCEUS`` in the ``hazgridXnga2.f`` Fortran code available at: http://earthquake.usgs.gov/hazards/products/conterminous/2008/software/ The class assumes rupture magnitude to be in Mblg scale (given that MFDs for central and eastern US are given in this scale). Mblg is converted to Mw using Atkinson and Boore 1987 conversion equation Coefficients are given for the B/C (firm rock) conditions. """kind="Mblg87"#: Shear-wave velocity for reference soil conditions in [m s-1]DEFINED_FOR_REFERENCE_VELOCITY=760.
[docs]defcompute(self,ctx:np.recarray,imts,mean,sig,tau,phi):""" See :meth:`superclass method <.base.GroundShakingIntensityModel.compute>` for spec of input and result values. """mag=_convert_magnitude(self.kind,ctx.mag)form,imtinenumerate(imts):C=self.COEFFS[imt]mean[m]=_compute_mean(self.kind,C,mag,ctx.rrup)mean[m]=clip_mean(imt,mean[m])sig[m]=np.where(mag<7.16,C['c11']+C['c12']*mag,C['c13'])
[docs]classCampbell2003MblgJ1996NSHMP2008(Campbell2003MblgAB1987NSHMP2008):""" Extend :class:`Campbell2003MblgAB1987NSHMP2008` but uses Johnston 1996 equation for converting Mblg to Mw """kind="Mblg96"
[docs]classCampbell2003MwNSHMP2008(Campbell2003MblgAB1987NSHMP2008):""" Extend :class:`Campbell2003MblgAB1987NSHMP2008` but assumes magnitude to be in Mw scale, so no converion is applied. """kind="Mw"