Ejemplo n.º 1
0
    def compute(self, ctx, imts, mean, sig, tau, phi):
        """
        See :meth:`superclass method
        <.base.GroundShakingIntensityModel.compute>`
        for spec of input and result values.
        """
        for m, imt in enumerate(imts):
            C = self.COEFFS[imt]

            if self.kind == 'Mblg':
                mag = mblg_to_mw_johnston_96(ctx.mag)
            elif self.kind == 'Mblg2008':
                mag = mblg_to_mw_atkinson_boore_87(ctx.mag)
            else:
                mag = ctx.mag

            # computing the magnitude term. Equation 19, page 2291
            f1 = _compute_magnitude_scaling_term(C, mag)

            # computing the geometrical spreading term. Equation 20, page 2291
            f2 = _compute_geometrical_spreading_term(C, ctx.rrup)

            # computing the anelastic attenuation term. Equation 21, page 2291
            f3 = _compute_anelastic_attenuation_term(C, ctx.rrup, mag)

            # computing the mean ln(IMT) using equation 18 at page 2290
            mean[m] = f1 + f2 + f3

            if self.kind != 'base':  # in subclasses
                mean[m] = clip_mean(imt, mean[m])

            # computing the total standard deviation
            sig[m] = (C['c14'] + C['c15'] * mag) if mag < 7.2 else C['c16']
Ejemplo n.º 2
0
    def _compute_mean(self, imt, mag, rhypo):
        """
        Compute mean value from lookup table.

        Lookup table defines log10(IMT) (in g) for combinations of Mw and
        log10(rhypo) values. ``mag`` is therefore converted from Mblg to Mw
        using Atkinson and Boore 1987 conversion equation. Mean value is
        finally converted from base 10 to base e.
        """
        mag = mblg_to_mw_atkinson_boore_87(mag)

        # to avoid run time warning in case rhypo is zero set minimum distance
        # to 10, which is anyhow the minimum distance allowed by the tables
        rhypo[rhypo < 10] = 10
        rhypo = np.log10(rhypo)

        # create lookup table and interpolate it at magnitude/distance values
        table = RectBivariateSpline(
            self.MAGS, self.DISTS, self.IMTS_TABLES[imt].T
        )
        mean = table(mag, rhypo)
        mean = mean.flatten()

        # convert mean from base 10 to base e
        return mean * np.log(10)
Ejemplo n.º 3
0
def _convert_magnitude(mag_eq, mag):
    """
    Convert magnitude from Mblg to Mw using various equations
    equation
    """
    if mag_eq == 'Mblg87':
        return mblg_to_mw_atkinson_boore_87(mag)
    elif mag_eq == 'Mblg96':
        return mblg_to_mw_johnston_96(mag)
    elif mag_eq == 'Mw':
        return mag
    def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        """
        See :meth:`superclass method
        <.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
        for spec of input and result values.
        """
        mag = mblg_to_mw_atkinson_boore_87(rup.mag)

        mean = self._get_mean(sites.vs30, mag, dists.rrup, imt, scale_fac=0)
        stddevs = self._get_stddevs(stddev_types, num_sites=sites.vs30.size)

        mean = clip_mean(imt, mean)

        return mean, stddevs
Ejemplo n.º 5
0
    def _compute_finite_fault_correction(self, mag):
        """
        Compute finite fault correction term as geometric mean of correction
        terms obtained from Mw values calculated with Johnston 1996 and
        Atkinson and Boore 1987 conversion equations.

        Implement equations as in lines 1653 - 1658 in hazgridXnga2.f
        """
        mw_j96 = mblg_to_mw_johnston_96(mag)
        mw_ab87 = mblg_to_mw_atkinson_boore_87(mag)

        t1 = np.exp(-1.25 + 0.227 * mw_j96)
        t2 = np.exp(-1.25 + 0.227 * mw_ab87)

        return np.sqrt(t1 * t2)
Ejemplo n.º 6
0
def _compute_finite_fault_correction_Mblg(kind, mag):
    """
    Compute finite fault correction term as geometric mean of correction
    terms obtained from Mw values calculated with Johnston 1996 and
    Atkinson and Boore 1987 conversion equations.

    Implement equations as in lines 1653 - 1658 in hazgridXnga2.f
    """
    mw_j96 = mblg_to_mw_johnston_96(mag)
    mw_ab87 = mblg_to_mw_atkinson_boore_87(mag)

    t1 = np.exp(-1.25 + 0.227 * mw_j96)
    t2 = np.exp(-1.25 + 0.227 * mw_ab87)

    return np.sqrt(t1 * t2)
Ejemplo n.º 7
0
    def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        """
        See :meth:`superclass method
        <.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
        for spec of input and result values.
        """
        assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
                   for stddev_type in stddev_types)

        C = self.COEFFS[imt]
        mag = mblg_to_mw_atkinson_boore_87(rup.mag)

        mean = (
            C['c1'] + C['c2'] * mag + C['c10'] * (mag - 6) ** 2 +
            (C['c6'] + C['c7'] * mag) * np.log(dists.rjb + np.exp(C['c4']))
        )
        mean = clip_mean(imt, mean)

        stddevs = self._compute_stddevs(C, dists.rjb.size, stddev_types)

        return mean, stddevs
Ejemplo n.º 8
0
 def _convert_magnitude(self, mag):
     """
     Convert magnitude from Mblg to Mw using Atkinson and Boore 1987
     equation
     """
     return mblg_to_mw_atkinson_boore_87(mag)
Ejemplo n.º 9
0
 def test_mblg_to_mw_atkinson_boore_87(self):
     mblg = 5
     mw = mblg_to_mw_atkinson_boore_87(mblg)
     self.assertAlmostEqual(mw, 4.5050)
Ejemplo n.º 10
0
 def _convert_magnitude(self, mag):
     """
     Convert magnitude from Mblg to Mw using Atkinson and Boore 1987
     equation
     """
     return mblg_to_mw_atkinson_boore_87(mag)
Ejemplo n.º 11
0
 def test_mblg_to_mw_atkinson_boore_87(self):
     mblg = 5
     mw = mblg_to_mw_atkinson_boore_87(mblg)
     self.assertAlmostEqual(mw, 4.5050)