def test_cumulative_value(self): ''' Tests the calculation of the cumulative rate M > Mref Data and tests taken from Bungum (2007). Current parameters should reproduce Model 4 line in Figure 1 of Bungum (2007) ''' self.model = YoungsCoppersmithExponential() self.config = {'MFD_spacing': 0.1, 'Maximum_Magnitude': 8.0, 'Maximum_Magnitude_Uncertainty': None, 'Minimum_Magnitude': 5.0, 'Model_Weight': 1.0, 'b_value': [1.0, 0.1]} # Test case 1 - Fault of 120 km length and 60 km width (7200 km ** 2 area) # b-value 1, slip = 1 mm/yr self.model.setUp(self.config) self.model.get_mmax(self.config, self.msr, 0., 7200.) moment_rate = (30. * 1E9) * (7200. * 1E6) * (1.0 / 1000.) momax = _scale_moment(self.model.mmax, in_nm=True) beta = log(10.) expected_result = YC_EXP_DATA[:, 1] mags = np.arange(5.0, 8.1, 0.1) for iloc, mag in enumerate(mags): self.assertAlmostEqual( expected_result[iloc], self.model.cumulative_value(mag, moment_rate, beta, momax))
def get_mfd(self, slip, area, shear_modulus=30.0): ''' Calculates activity rate on the fault :param float slip: Slip rate in mm/yr :param fault_width: Width of the fault (km) :param float disp_length_ratio: Displacement to length ratio (dimensionless) :param float shear_modulus: Shear modulus of the fault (GPa) :returns: * Minimum Magnitude (float) * Bin width (float) * Occurrence Rates (numpy.ndarray) ''' # Working in Nm so convert: shear_modulus - GPa -> Nm # area - km ** 2. -> m ** 2. # slip - mm/yr -> m/yr moment_rate = (shear_modulus * 1.E9) * (area * 1.E6) * (slip / 1000.) moment_mag = _scale_moment(self.mmax, in_nm=True) characteristic_rate = moment_rate / moment_mag if self.sigma and (fabs(self.sigma) > 1E-5): self.mmin = self.mmax + (self.lower_bound * self.sigma) mag_upper = self.mmax + (self.upper_bound * self.sigma) mag_range = np.arange(self.mmin, mag_upper + self.bin_width, self.bin_width) self.occurrence_rate = characteristic_rate * (truncnorm.cdf( mag_range + (self.bin_width / 2.), self.lower_bound, self.upper_bound, loc=self.mmax, scale=self.sigma) - truncnorm.cdf(mag_range - (self.bin_width / 2.), self.lower_bound, self.upper_bound, loc=self.mmax, scale=self.sigma)) else: # Returns only a single rate self.mmin = self.mmax self.occurrence_rate = np.array([characteristic_rate], dtype=float) return self.mmin, self.bin_width, self.occurrence_rate
def get_mfd(self, slip, area, shear_modulus=30.0): ''' Calculates activity rate on the fault :param float slip: Slip rate in mm/yr :param fault_width: Width of the fault (km) :param float disp_length_ratio: Displacement to length ratio (dimensionless) :param float shear_modulus: Shear modulus of the fault (GPa) :returns: * Minimum Magnitude (float) * Bin width (float) * Occurrence Rates (numpy.ndarray) ''' # Working in Nm so convert: shear_modulus - GPa -> Nm # area - km ** 2. -> m ** 2. # slip - mm/yr -> m/yr moment_rate = (shear_modulus * 1.E9) * (area * 1.E6) * (slip / 1000.) moment_mag = _scale_moment(self.mmax, in_nm=True) characteristic_rate = moment_rate / moment_mag if self.sigma and (fabs(self.sigma) > 1E-5): self.mmin = self.mmax + (self.lower_bound * self.sigma) mag_upper = self.mmax + (self.upper_bound * self.sigma) mag_range = np.arange(self.mmin, mag_upper + self.bin_width, self.bin_width) self.occurrence_rate = characteristic_rate * ( truncnorm.cdf(mag_range + (self.bin_width / 2.), self.lower_bound, self.upper_bound, loc=self.mmax, scale=self.sigma) - truncnorm.cdf(mag_range - (self.bin_width / 2.), self.lower_bound, self.upper_bound, loc=self.mmax, scale=self.sigma)) else: # Returns only a single rate self.mmin = self.mmax self.occurrence_rate = np.array([characteristic_rate], dtype=float) return self.mmin, self.bin_width, self.occurrence_rate
def cumulative_value(self, slip_moment, mmax, mag_value, bbar, dbar): ''' Returns the rate of events with M > mag_value :param float slip_moment: :param float slip_moment: Product of slip (cm/yr) * Area (cm ^ 2) * shear_modulus (dyne-cm) :param float mmax: Maximum magnitude :param float mag_value: Magnitude value :param float bbar: \bar{b} parameter (effectively = b * log(10.)) :param float dbar: \bar{d} parameter ''' moment_ratio = slip_moment / _scale_moment(mmax) delta_m = mmax - mag_value return ((dbar - bbar) / dbar) * moment_ratio * np.exp(bbar * (delta_m))
def get_mfd(self, slip, area, shear_modulus=30.0): ''' Calculates activity rate on the fault :param float slip: Slip rate in mm/yr :param area: Width of the fault (km) :param float shear_modulus: Shear modulus of the fault (GPa) :returns: * Minimum Magnitude (float) * Bin width (float) * Occurrence Rates (numpy.ndarray) ''' # Working in Nm so convert: shear_modulus - GPa -> Nm # area - km ** 2. -> m ** 2. # slip - mm/yr -> m/yr moment_rate = (shear_modulus * 1.E9) * (area * 1.E6) * (slip / 1000.) moment_mag = _scale_moment(self.mmax, in_nm=True) beta = self.b_value * log(10.) mag = np.arange(self.mmin - (self.bin_width / 2.), self.mmax + self.bin_width, self.bin_width) if self.b_value > 1.5: print ('b-value larger than 1.5 will produce invalid results in ' 'Anderson & Luco models') self.occurrence_rate = np.nan * np.ones(len(mag) - 1) return self.mmin, self.bin_width, self.occurrence_rate self.occurrence_rate = np.zeros(len(mag) - 1, dtype=float) for ival in range(0, len(mag) - 1): self.occurrence_rate[ival] = ( self.cumulative_value(mag[ival], moment_rate, beta, moment_mag) - self.cumulative_value( mag[ival + 1], moment_rate, beta, moment_mag)) return self.mmin, self.bin_width, self.occurrence_rate
def _get_a3(bbar, dbar, slip_moment, mmax): """ Returns the A3 term (III.4 in Table 4) """ return ((dbar * (dbar - bbar)) / (bbar**2.)) * (slip_moment / _scale_moment(mmax))
def _get_a2(bbar, dbar, slip_moment, mmax): """ Returns the A2 value defined in II.4 of Table 2 """ return ((dbar - bbar) / bbar) * (slip_moment / _scale_moment(mmax))
def _get_a1(bbar, dbar, slip_moment, mmax): """ Returns the A1 term (I.4 of Table 2 in Anderson & Luco) """ return ((dbar - bbar) / dbar) * (slip_moment / _scale_moment(mmax))
def _get_a3(bbar, dbar, slip_moment, mmax): """ Returns the A3 term (III.4 in Table 4) """ return ((dbar * (dbar - bbar)) / (bbar ** 2.)) * (slip_moment / _scale_moment(mmax))