# -*- coding: utf-8 -*-# vim: tabstop=4 shiftwidth=4 softtabstop=4## Copyright (C) 2013-2025 GEM Foundation, Chung-Han Chan## 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:`Lin2009`"""importnumpyasnpfromopenquake.hazardlib.gsim.baseimportGMPE,CoeffsTablefromopenquake.hazardlibimportconstfromopenquake.hazardlib.imtimportPGA,SAdef_get_distance_term(C,mag,rrup):""" Returns the distance scaling term """return(C['C4']+C['C5']*(mag-6.3))*np.log(np.sqrt(rrup**2.+np.exp(C['H'])**2.))def_get_fault_type_dummy_variables(rake):""" Defines the fault type dummy variables for normal faulting (f_n) and reverse faulting (f_r) from rake. Classification based on that found in the original fortran code of Lin (2009) """f_n,f_r=np.zeros_like(rake),np.zeros_like(rake)f_n[(rake>=-120)&(rake<=-60)]=1.# normalf_r[(rake>=30)&(rake<=150)]=1.# reversereturnf_n,f_rdef_get_magnitude_term(C,mag):""" Returns the magnitude scaling term. """lny=C['C1']+C['C3']*(8.5-mag)**2.returnnp.where(mag>6.3,lny-C['H']*C['C5']*(mag-6.3),lny+C['C2']*(mag-6.3))def_get_site_response_term(C,vs30):""" Returns the site amplification term """returnC['C8']*np.log(vs30/1130.0)def_get_style_of_faulting_term(C,rake):""" Returns the style of faulting factor """f_n,f_r=_get_fault_type_dummy_variables(rake)returnC['C6']*f_n+C['C7']*f_r
[docs]classLin2009(GMPE):""" Implements GMPE developed by Po-Shen Lin and published as "Ground-motion attenuation relationship and path-effect study using Taiwan Data set" (Ph.D. dissertation of National Central University, Taiwan). This class implements the equations for 'crustal events'. """#: Supported tectonic region type is active shallow crust.DEFINED_FOR_TECTONIC_REGION_TYPE=const.TRT.ACTIVE_SHALLOW_CRUST#: Supported intensity measure types are spectral acceleration,#: and peak ground acceleration, see Table 4.1 in pages 48-49.DEFINED_FOR_INTENSITY_MEASURE_TYPES={PGA,SA}#: Supported intensity measure component is geometric mean#: of two horizontal components, see equation 4.1 page 46.DEFINED_FOR_INTENSITY_MEASURE_COMPONENT=const.IMC.GEOMETRIC_MEAN#: Supported standard deviation types is total, see equation 4.1 page 46.DEFINED_FOR_STANDARD_DEVIATION_TYPES={const.StdDev.TOTAL}#: Required site parameter is only Vs30 (used to distinguish rock).REQUIRES_SITES_PARAMETERS={'vs30'}#: Required rupture parameters are magnitude and rake see#: equation 4.1 page 46.REQUIRES_RUPTURE_PARAMETERS={'mag','rake'}#: Required distance measure is rupture distance, see equation 4.1#: page 46.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]=(_get_magnitude_term(C,ctx.mag)+_get_distance_term(C,ctx.mag,ctx.rrup)+_get_style_of_faulting_term(C,ctx.rake)+_get_site_response_term(C,ctx.vs30))sig[m]=C['sigma']