Calculate and return the mean intensity for rock sites.

        Implements an equation from table 2.
438733
def _get_mean_rock(self, mag, _rake, rrup, is_reverse, imt):
        
        if mag <= self.NEAR_FIELD_SATURATION_MAG:
            C = self.COEFFS_ROCK_LOWMAG[imt]
        else:
            C = self.COEFFS_ROCK_HIMAG[imt]
        # clip mag if greater than 8.5. This is to avoid
        # ValueError: negative number cannot be raised to a fractional power
        mag = 8.5 if mag > 8.5 else mag
        mean = (
            C['c1'] + C['c2'] * mag + C['c3'] * ((8.5 - mag) ** 2.5)
            + C['c4'] * numpy.log(rrup + numpy.exp(C['c5'] + C['c6'] * mag))
            + C['c7'] * numpy.log(rrup + 2)
        )
        if is_reverse:
            # footnote in table 2 says that for reverse ruptures
            # the mean amplitude value should be multiplied by 1.2
            mean += 0.1823215567939546  # == log(1.2)
        return mean
1030233
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        C = self.COEFFS[imt]

        mean = (self._compute_magnitude_term(C, rup.mag) +
                self._compute_distance_term(C, dists.rhypo, rup.mag))
        stddevs = self._get_stddevs(C, dists.rhypo, stddev_types)
        return mean, stddevs
78208
def _compute_pga_rock(self, C_PGA, mag, rjb):
        
        return np.exp(self._compute_linear_magnitude_term(C_PGA, mag) +
                      self._compute_simple_distance_term(C_PGA, rjb))
86290
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        # pylint: disable=too-many-arguments
        

        # extract dictionary of coefficients specific to required
        # intensity measure type
        coeffs = self.COEFFS[imt]
        coeffs.update(self.CONSTS)

        # equation (1) is in terms of common logarithm
        log_mean = (self._compute_magnitude(rup, coeffs) +
                    self._compute_distance(dists, coeffs) +
                    self._get_site_amplification(sites, coeffs) +
                    self._get_mechanism(rup, coeffs))
        # so convert to g and thence to the natural logarithm
        mean = log_mean*np.log(10.0) - np.log(g)

        # convert standard deviations from common to natural logarithm
        log_stddevs = self._get_stddevs(coeffs, stddev_types, len(sites.vs30))
        stddevs = log_stddevs*np.log(10.0)

        return mean, stddevs
669975
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
                   for stddev_type in stddev_types)

        mean = np.zeros_like(sites.vs30)
        stddevs = [np.zeros_like(sites.vs30) for _ in stddev_types]

        idx_rock = sites.vs30 >= self.ROCK_VS30
        idx_soil = sites.vs30 < self.ROCK_VS30

        if idx_rock.any():
            C = self.COEFFS_ROCK[imt]
            self._compute_mean(C, self.CONSTS['A1_rock'],
                               self.CONSTS['A2_rock'], self.CONSTS['A3_rock'],
                               self.CONSTS['A4_rock'], self.CONSTS['A5_rock'],
                               self.CONSTS['A6_rock'], rup.mag, rup.hypo_depth,
                               dists.rrup, mean, idx_rock)
            self._compute_std(C, rup.mag, stddevs, idx_rock)

            if imt == SA(period=4.0, damping=5.0):
                mean = mean / 0.399

        if idx_soil.any():
            C = self.COEFFS_SOIL[imt]
            self._compute_mean(C, self.CONSTS['A1_soil'],
                               self.CONSTS['A2_soil'], self.CONSTS['A3_soil'],
                               self.CONSTS['A4_soil'], self.CONSTS['A5_soil'],
                               self.CONSTS['A6_soil'], rup.mag, rup.hypo_depth,
                               dists.rrup, mean, idx_soil)
            self._compute_std(C, rup.mag, stddevs, idx_soil)

        return mean, stddevs
1025464
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
                   for stddev_type in stddev_types)

        mean = np.zeros_like(sites.vs30)
        stddevs = [np.zeros_like(sites.vs30) for _ in stddev_types]

        idx_rock = sites.vs30 >= self.ROCK_VS30
        idx_soil = sites.vs30 < self.ROCK_VS30

        if idx_rock.any():
            C = self.COEFFS_ROCK[imt]
            self._compute_mean(C, rup.mag, dists.rhypo, rup.hypo_depth, mean,
                               idx_rock)
            self._compute_std(C, stddevs, idx_rock)

        if idx_soil.any():
            C = self.COEFFS_SOIL[imt]
            self._compute_mean(C, rup.mag, dists.rhypo, rup.hypo_depth, mean,
                               idx_soil)
            self._compute_std(C, stddevs, idx_soil)

        return mean, stddevs
1343512
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        C = self.COEFFS[imt]
        mean = (
            self._get_magnitude_term(C, rup.mag) +
            self._get_distance_term(C, rup.mag, dists.rrup) +
            self._get_style_of_faulting_term(C, rup.rake) +
            self._get_site_response_term(C, sites.vs30))

        stddevs = self._get_stddevs(C, stddev_types, len(sites.vs30))
        return mean, stddevs
670889
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        # extracting dictionary of coefficients specific to required
        # intensity measure type.
        C = self.COEFFS[imt]
        # Implements mean model (equation 12)
        mean = (self._compute_magnitude(rup, C) +
                self._compute_distance(dists, C) +
                self._get_site_amplification(sites, rup, C) +
                self._get_mechanism(rup, C))

        stddevs = self._get_stddevs(rup, np.exp(mean), stddev_types, sites)

        return mean, stddevs
989778
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        # extracting dictionary of coefficients
        C = self.COEFFS[imt]

        mag = self._convert_magnitude(rup.mag)

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

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

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

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

        mean = self._clip_mean(imt, mean)

        # computing the total standard deviation
        stddevs = self._get_stddevs(C, stddev_types, num_sites=len(dists.rrup),
                                    mag=mag)

        return mean, stddevs
656512
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        C = self.COEFFS[imt]

        # clip rhypo at 10 (this is the minimum distance used in
        # deriving the equation), see page 22, this avoids singularity
        # in mean value equation
        rhypo = dists.rhypo.copy()
        rhypo[rhypo < 10] = 10

        # convert magnitude from Mblg to Mw
        mag = rup.mag * 0.98 - 0.39 if rup.mag <= 5.5 else \
              2.715 - 0.277 * rup.mag + 0.127 * rup.mag * rup.mag

        # functional form as explained in 'Youngs_fit_to_AB95lookup.doc'
        f1 = np.minimum(np.log(rhypo), np.log(70.))
        f2 = np.maximum(np.log(rhypo / 130.), 0)
        mean = (
            C['c1'] + C['c2'] * mag + C['c3'] * mag ** 2 +
            (C['c4'] + C['c5'] * mag) * f1 +
            (C['c6'] + C['c7'] * mag) * f2 +
            C['c8'] * rhypo
        )

        stddevs = self._get_stddevs(stddev_types,  dists.rhypo.shape[0])

        return mean, stddevs
1196411
def _get_mean(self, C, rup, dists, sites):
        
        return (self._get_magnitude_scaling_term(C, rup.mag) +
                self._get_distance_scaling_term(C, dists.rjb, rup.mag) +
                self._get_site_amplification_term(C, sites.vs30))
1243680
def _compute_site_class_term(self, C, vs30):
        
        # map vs30 value to site class, see table 2, p. 901.
        site_term = np.zeros(len(vs30))

        # hard rock
        site_term[vs30 > 1100.0] = C['CH']

        # rock
        site_term[(vs30 > 600) & (vs30 <= 1100)] = C['C1']

        # hard soil
        site_term[(vs30 > 300) & (vs30 <= 600)] = C['C2']

        # medium soil
        site_term[(vs30 > 200) & (vs30 <= 300)] = C['C3']

        # soft soil
        site_term[vs30 <= 200] = C['C4']

        return site_term
1214683
def Mean(self):
        
        mu = 0.0
        for x, p in self.d.iteritems():
            mu += p * x
        return mu
1021093
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        # get the necessary set of coefficients
        C = self.COEFFS[imt]
        # compute median sa on rock (vs30=1180m/s). Used for site response
        # term calculation
        sa1180 = np.exp(self._get_sa_at_1180(C, imt, sites, rup, dists))

        # get the mean value
        mean = (self._get_basic_term(C, rup, dists) +
                self._get_faulting_style_term(C, rup) +
                self._get_site_response_term(C, imt, sites.vs30, sa1180) +
                self._get_hanging_wall_term(C, dists, rup) +
                self._get_top_of_rupture_depth_term(C, imt, rup) +
                self._get_soil_depth_term(C, sites.z1pt0 / METRES_PER_KM,
                                          sites.vs30)
                )
        mean += self._get_regional_term(C, imt, sites.vs30, dists.rrup)
        # get standard deviations
        stddevs = self._get_stddevs(C, imt, rup, sites, stddev_types, sa1180,
                                    dists)
        return mean, stddevs
474681
def _compute_mean(self, C, g, mag, hypo_depth, dists, imt):
        

        delta = 0.00750 * 10 ** (0.507 * mag)

        # computing R for different values of mag
        if mag < 6.5:
            R = np.sqrt(dists.rhypo ** 2 + delta ** 2)
        else:
            R = np.sqrt(dists.rrup ** 2 + delta ** 2)

        mean = (
            # 1st term
            C['c1'] + C['c2'] * mag +
            # 2nd term
            C['c3'] * R -
            # 3rd term
            C['c4'] * np.log10(R) +
            # 4th term
            C['c5'] * hypo_depth
        )
        # convert from base 10 to base e
        if imt == PGV():
            mean = np.log(10 ** mean)
        else:
            # convert from cm/s**2 to g
            mean = np.log((10 ** mean) * 1e-2 / g)
        return mean
549469
def mean(self):
        
        return self._constructor(self.values.mean(axis=self.baseaxes, keepdims=True))
245561
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
                   for stddev_type in stddev_types)

        # extract dictionaries of coefficients specific to required
        # intensity measure type
        C = self.COEFFS[imt]

        # Deltas for Tectonic Region Type and rake angles
        delta_R, delta_S, delta_V, delta_I = self._get_deltas(rup.rake)

        mean = self._compute_mean(C, rup.mag, dists.rrup, rup.hypo_depth,
                                  delta_R, delta_S, delta_V, delta_I,
                                  sites.vs30)

        stddevs = self._get_stddevs(C, stddev_types, sites.vs30.size)

        return mean, stddevs