<commit_before># -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright (C) 2015-2019 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/>.

"""
Created on Mon August 24, 2021
Authors: <EMAIL>, <EMAIL>


Module exports: `ManeaEtAl2021`

"""

import numpy as np
from openquake.hazardlib.gsim.base import GMPE, CoeffsTable, add_alias
from openquake.hazardlib import const
from openquake.hazardlib.imt import PGA, SA
from scipy.constants import g


def _compute_magnitude_term(C, mag):
    """
    Compute magnitude term
    """
    term01 = (mag - 5.7)
    mag_term = C['phi0'] + C['phi1'] * term01 + C['phi2']*term01**2
    return mag_term


def _compute_distance_term(C, rhypo, backarc):
    """
    Compute distance term and regional term
    """
    term = (C['phi3'] * np.log(rhypo) +
            +_compute_arc_regional_term(C, backarc) * rhypo)
    return term


def _compute_arc_regional_term(C, backarc):
    """
    Compute regional term - location with respect to the arc:
    back-arc sites (0 used in the paper/ 1 in OQ),
    fore-arc sites (2 used in the paper paper / 0 in OQ),
    along-arc sites (1 used in the paper / 2 in OQ)
    """
    term = np.zeros(len(backarc))
    #fore-arc sites
    idx = (backarc == 0)
    term[idx] = C['phi7']
    #along-arc sites
    idx = (backarc == 2)
    term[idx] = C['phi5']
    # back-arc sites
    idx = (backarc == 1)
    term[idx] = C['phi6']
    return term


def _compute_depth_term(C, hypo_depth):
    return C['phi4']*hypo_depth


def _get_site_amplification(C, sites):
    """
    Compute site terms - dummy terms + amplif
    """
    ssa, ssb, ssc = _get_site_type_dummy_variables(sites)

    return ((ssc*C['phi11'] + ssb*C['phi10'] +
            + ssa*C['phi9']) * np.ones(len(sites.vs30)) +
            + _compute_site_amplif(C, sites))


def _get_site_type_dummy_variables(sites):<commit_msg>Cleanup [ci skip]<commit_after># -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright (C) 2015-2019 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/>.

"""
Created on Mon August 24, 2021
Authors: <EMAIL>, <EMAIL>

Module exports: `ManeaEtAl2021`
"""

import numpy as np
from openquake.hazardlib.gsim.base import GMPE, CoeffsTable
from openquake.hazardlib import const
from openquake.hazardlib.imt import PGA, SA
from scipy.constants import g


def _compute_magnitude_term(C, mag):
    """
    Compute magnitude term
    """
    term01 = (mag - 5.7)
    mag_term = C['phi0'] + C['phi1'] * term01 + C['phi2']*term01**2
    return mag_term


def _compute_distance_term(C, rhypo, backarc):
    """
    Compute distance term and regional term
    """
    term = (C['phi3'] * np.log(rhypo) +
            +_compute_arc_regional_term(C, backarc) * rhypo)
    return term


def _compute_arc_regional_term(C, backarc):
    """
    Compute regional term - location with respect to the arc:
    fore-arc sites (2 used in the paper / 0 in OQ),
    back-arc sites (0 used in the paper/ 1 in OQ),
    along-arc sites (1 used in the paper / 2 in OQ)
    """
    term = np.zeros(len(backarc))
    # fore-arc sites
    term[backarc == 0] = C['phi7']
    # back-arc sites
    term[backarc == 1] = C['phi6']
    # along-arc sites
    term[backarc == 2] = C['phi5']
    return term


def _compute_depth_term(C, hypo_depth):
    return C['phi4']*hypo_depth


def _get_site_amplification(C, sites):
    """
    Compute site terms - dummy terms + amplif
    """
    ssa, ssb, ssc = _get_site_type_dummy_variables(sites)

    return ((ssc*C['phi11'] + ssb*C['phi10'] +
            + ssa*C['phi9']) * np.ones(len(sites.vs30)) +
            + _compute_site_amplif(C, sites))


def _get_site_type_dummy_variables(sites):
{'fraction_non_alphanumeric': 0.1133915870757976, 'fraction_numerical': 0.02275960170697013, 'mean_word_length': 3.410394265232975, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3817030', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1647, 'n_words': 543}