A Magnitude Frequency Distribution (MFD) is a function that describes the rate (per year) of earthquakes across all magnitudes.
Package mfd contains the basic class for MFD – openquake.hazardlib.mfd.base.BaseMFD, and three actual implementations: openquake.hazardlib.mfd.evenly_discretized.EvenlyDiscretizedMFD openquake.hazardlib.mfd.truncated_gr.TruncatedGRMFD and openquake.hazardlib.mfd.youngs_coppersmith_1985.YoungsCoppersmith1985MFD.
Module openquake.hazardlib.mfd.evenly_discretized defines an evenly discretized MFD.
Evenly discretized MFD is defined as a precalculated histogram.
Parameters: 


Checks the following constraints:
Applies absolute modification of the MFD from the min_mag, bin_width and occurrence_rates modification.
Parameters: 


Module openquake.hazardlib.mfd.truncated_gr defines a Truncated GutenbergRichter MFD.
Truncated GutenbergRichter MFD is defined in a functional form.
The annual occurrence rate for a specific bin (magnitude band) is defined as
rate = 10 ** (a_val  b_val * mag_lo)  10 ** (a_val  b_val * mag_hi)
where
Parameters: 


Values for min_mag and max_mag don’t have to be aligned with respect to bin_width. They get rounded accordingly anyway so that both are divisible by bin_width just before converting a function to a histogram. See _get_min_mag_and_num_bins().
Estimate the number of bins in the histogram and return it along with the first bin center abscissa (magnitude) value.
Rounds min_mag and max_mag with respect to bin_width to make the distance between them include integer number of bins.
Returns:  A tuple of two items: first bin center and total number of bins. 

Calculate and return an annual occurrence rate for a specific bin.
Parameters:  mag – Magnitude value corresponding to the center of the bin of interest. 

Returns:  Float number, the annual occurrence rate calculated using formula described in TruncatedGRMFD. 
Calculate total moment rate (total energy released per unit time)
TMR = ((10**ai) / bi) * (10 ** (bi*max_mag)  10 ** (bi*min_mag))
where ai = a + log10(b) + 9.05 and bi = 1.5  b. In case of bi == 0 the following formula is applied:
TMR = (10 ** ai) * (max_mag  min_mag)
Returns:  Float, calculated TMR value in N * m / year (Newtonmeter per year). 

Recalculate an a value preserving a total moment rate tmr
a = (log10((tmr * bi) / (10 ** (bi*max_mag)  10 ** (bi*min_mag)))
 9.05  log10(b))
where bi = 1.5  b. If bi == 0 the following formula is used:
a = log10(tmr / (max_mag  min_mag))  9.05  log10(b)
Checks the following constraints:
Calculate and return the annual occurrence rates histogram.
The result histogram has only one bin if minimum and maximum magnitude values appear equal after rounding.
Returns:  See :meth: openquake.hazardlib.mfd.base.BaseMFD.get_annual_occurrence_rates. 

Apply relative bvalue modification.
Parameters:  value – A float value to add to b_val. 

After changing b_val the a_val is recalculated the same way as for modify_increment_max_mag() (with respect to TMR).
Apply relative maximum magnitude modification.
Parameters:  value – A float value to add to max_mag. 

The GutenbergRichter a value is recalculated with respect to old total moment rate.
Module openquake.hazardlib.mfd.youngs_coppersmith_1985 defines the Youngs and Coppersmith 1985 MFD.
Class implementing the MFD for the ‘Characteristic Earthquake Model’ as described in: “Implications of fault slip rates and earthquake recurrence models to probabilistic seismic hazard estimates”, by Robert R. Youngs and Kevin J. Coppersmith and published in Bulletin of the Seismological Society of America, Vol. 75, No. 4, pages 939964, 1985. The class implements the MFD under the following assumptions as reported at page 954:
Parameters: 


Values for min_mag and the maximum magnitude (char_mag + 0.25) don’t have to be aligned with respect to bin_width. They get rounded accordingly anyway so that both are divisible by bin_width just before converting a function to a histogram. See _get_min_mag_and_num_bins().
Estimate the number of bins in the histogram and return it along with the first bin center value.
Rounds min_mag and max_mag with respect to bin_width to make the distance between them include integer number of bins.
Returns:  A tuple of 2 items: first bin center, and total number of bins. 

Calculate and return the annual occurrence rate for a specific bin.
Parameters:  mag – Magnitude value corresponding to the center of the bin of interest. 

Returns:  Float number, the annual occurrence rate for the :param mag value. 
Checks the following constraints:
minimum magnitude is positive.
b value is positive.
characteristic magnitude is positive
characteristic rate is positive
bin width is in the range (0, 0.5] to allow for at least one bin representing the characteristic distribution
characteristic magnitude minus 0.25 (that is the maximum magnitude of the GR distribution) is greater than the minimum magnitude by at least one magnitude bin.
rate of events at the characteristic magnitude is equal to the rate of events for magnitude equal to m_prime  1. This is done by asserting the equality (up to 7 digit precision)
10 ** (a_incr  b * (m'  1)) == char_rate / 0.5
where a_incr is the incremental a value obtained from the cumulative a value using the following formula
a_incr = a_val + log10(b_val * ln(10))
and m'  1 = char_mag  1.25
Define Youngs and Coppersmith 1985 MFD by constraing cumulative a value from characteristic rate. The cumulative a value is obtained by making use of the property that the rate of events at m’  1 must be equal to the rate at the characteristic magnitude, and therefore by first computing the incremental a value, using the following equation:
10 ** (a_incr  b_val * (m_prime  1)) == char_rate / 0.5
where m'  1 = char_mag  1.25. The cumulative a value is then obtained as
a_val = a_incr  log10(b_val * ln(10))
Parameters: 


Returns:  An instance of YoungsCoppersmith1985MFD. 
Values for min_mag and the maximum magnitude (char_mag + 0.25) don’t have to be aligned with respect to bin_width. They get rounded accordingly anyway so that both are divisible by bin_width just before converting a function to a histogram. See _get_min_mag_and_num_bins().
Define Youngs and Coppersmith 1985 MFD by constraing cumulative a value and characteristic rate from total moment rate. The cumulative a value and characteristic rate are obtained by solving equations (16) and (17), page 954, for the cumulative rate of events with magnitude greater than the minimum magnitude  N(min_mag)  and the cumulative rate of characteristic earthquakes  N(char_mag). The difference N(min_mag)  N(char_mag) represents the rate of noncharacteristic, exponentially distributed earthquakes and is used to derive the cumulative a value by solving the following equation
10 ** (a_val  b_val * min_mag) 
10 ** (a_val  b_val * (char_mag  0.25))
= N(min_mag)  N(char_mag)
which can be written as
a_val =
log10(N(min_mag)  N(char_mag)) /
(10 ** ( b_val * min_mag)  10 ** ( b_val * (char_mag  0.25))
In the calculation of N(min_mag) and N(char_mag), the Hanks and Kanamori (1979) formula
M0 = 10 ** (1.5 * Mw + 9.05)
is used to convert moment magnitude (Mw) to seismic moment (M0, Newton × m)
Parameters: 


Returns:  An instance of YoungsCoppersmith1985MFD. 
Values for min_mag and the maximum magnitude (char_mag + 0.25) don’t have to be aligned with respect to bin_width. They get rounded accordingly anyway so that both are divisible by bin_width just before converting a function to a histogram. See _get_min_mag_and_num_bins().
Module openquake.hazardlib.mfd.base defines base class for MFD – BaseMFD.
Abstract base class for MagnitudeFrequency Distribution function.
The set of modification type names that are supported by an MFD. Each modification should have a corresponding method named modify_modificationname() where the actual modification logic resides.
Check MFDspecific constraints and raise ValueError in case of violation.
This method must be implemented by subclasses.
Return an MFD annual occurrence rates histogram.
This method must be implemented by subclasses.
Returns:  The list of tuples, each tuple containing a pair (magnitude, occurrence_rate). Each pair represents a single bin of the histogram with magnitude being the center of the bin. Magnitude values are monotonically increasing by value of bin width. occurence_rate represents the number of events per year with magnitude that falls in between bin’s boundaries. 

Return the minimum and maximum magnitudes this MFD is defined for.
This method must be implemented by subclasses.
Returns:  Magnitude value, float number. 

Apply a single modification to an MFD parameters.
Reflects the modification method and calls it passing parameters as keyword arguments. See also MODIFICATIONS.
Modifications can be applied one on top of another. The logic of stacking modifications is up to a specific MFD implementation.
Parameters: 


Raises ValueError:  
If modification is missing from MODIFICATIONS. 