diff --git a/inputs/gutenberg_richter.data b/inputs/gutenberg_richter.data new file mode 100644 index 00000000..74909881 --- /dev/null +++ b/inputs/gutenberg_richter.data @@ -0,0 +1,53 @@ + 0 1.4 + 10 1.5 + 20 1.7 + 25 1.9 + 30 2.1 + 35 2.3 + 40 2.4 + 45 2.5 + 50 2.6 + 60 2.8 + 70 2.8 + 75 2.9 + 85 2.9 + 90 3.0 +100 3.0 +110 3.1 +120 3.1 +130 3.2 +140 3.2 +150 3.3 +160 3.3 +170 3.4 +180 3.4 +190 3.5 +200 3.5 +210 3.6 +230 3.7 +240 3.7 +250 3.8 +260 3.8 +270 3.9 +280 3.9 +290 4.0 +300 4.0 +310 4.1 +320 4.2 +330 4.2 +340 4.2 +350 4.3 +360 4.3 +370 4.3 +380 4.4 +390 4.4 +400 4.5 +430 4.6 +470 4.7 +510 4.8 +560 4.9 +600 5.1 +700 5.2 +800 5.4 +900 5.5 +1000 5.7 \ No newline at end of file diff --git a/pylot/core/analysis/magnitude.py b/pylot/core/analysis/magnitude.py index a772059f..3a430158 100644 --- a/pylot/core/analysis/magnitude.py +++ b/pylot/core/analysis/magnitude.py @@ -5,7 +5,7 @@ Created autumn/winter 2015. :author: Ludger Küperkoch / MAGS2 EP3 working group """ - +import os import matplotlib.pyplot as plt import numpy as np from obspy.core import Stream, UTCDateTime @@ -15,8 +15,14 @@ from scipy.optimize import curve_fit from scipy import integrate, signal from pylot.core.io.data import Data from pylot.core.util.dataprocessing import restitute_data, read_metadata -from pylot.core.util.utils import common_range +from pylot.core.util.utils import common_range, fit_curve +def gutenberg_richter_relation(delta): + relation = np.loadtxt(os.path.join(os.path.expanduser('~'), + '.pylot', 'gutenberg_richter.data')) + # prepare spline interpolation to calculate return value + func, params = fit_curve(relation[:,0], relation[:, 1]) + return func(delta, params) class Magnitude(object): '''