5.2.8.1.2. eqcorrscan.utils.mag_calc.calc_b_value¶
- eqcorrscan.utils.mag_calc.calc_b_value(magnitudes, completeness, max_mag=None, plotvar=True)[source]¶
Calculate the b-value for a range of completeness magnitudes.
Calculates a power-law fit to given magnitudes for each completeness magnitude. Plots the b-values and residuals for the fitted catalogue against the completeness values. Computes fits using numpy.polyfit, which uses a least-squares technique.
- Parameters:
- Return type:
list
- Returns:
List of tuples of (completeness, b-value, residual, number of magnitudes used)
Note
High “residuals” indicate better fit. Residuals are calculated according to the Wiemer & Wyss 2000, Minimum Magnitude of Completeness in Earthquake Catalogs: Examples from Alaska, the Western United States, and Japan, BSSA.
Example
>>> from obspy.clients.fdsn import Client >>> from obspy import UTCDateTime >>> from eqcorrscan.utils.mag_calc import calc_b_value >>> client = Client('IRIS') >>> t1 = UTCDateTime('2012-03-26T00:00:00') >>> t2 = t1 + (3 * 86400) >>> catalog = client.get_events(starttime=t1, endtime=t2, minmagnitude=3) >>> magnitudes = [event.magnitudes[0].mag for event in catalog] >>> b_values = calc_b_value(magnitudes, completeness=np.arange(3, 7, 0.2), ... plotvar=False) >>> round(b_values[4][1], 1) 1.0 >>> # We can set a maximum magnitude: >>> b_values = calc_b_value(magnitudes, completeness=np.arange(3, 7, 0.2), ... plotvar=False, max_mag=5) >>> round(b_values[4][1], 1) 1.0