From f35559e7c022d8b4e064fc64aaecce1bb7695494 Mon Sep 17 00:00:00 2001 From: Sebastianw Wehling-Benatelli Date: Thu, 22 Sep 2016 10:53:09 +0200 Subject: [PATCH] [new] added data file and a function that evaluates the Gutenberg-Richter relation for a given distance --- inputs/gutenberg_richter.data | 53 ++++++++++++++++++++++++++++++++ pylot/core/analysis/magnitude.py | 10 ++++-- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 inputs/gutenberg_richter.data 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 b65c9ab2..14af46a0 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): '''