w0fc: Plateau omega0 and corner frequency are are now taken as the median of previously calculated values from different functions synthsourcespek and fitSourceModel.

This commit is contained in:
Ludger Küperkoch 2015-11-30 13:27:08 +01:00
parent 957d2ccfe7
commit 466e0020a6

View File

@ -6,6 +6,7 @@ Created August/September 2015.
:author: Ludger Küperkoch / MAGS2 EP3 working group :author: Ludger Küperkoch / MAGS2 EP3 working group
""" """
import pdb
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
from obspy.core import Stream from obspy.core import Stream
@ -181,16 +182,14 @@ class w0fc(Magnitude):
# where spectral level reached 50% of flat level # where spectral level reached 50% of flat level
iin = np.where(YY >= 0.5 * w0in) iin = np.where(YY >= 0.5 * w0in)
Fcin = F[iin[0][np.size(iin) - 1]] Fcin = F[iin[0][np.size(iin) - 1]]
# use of implicit scipy function
# use of implicit scipy otimization function
fit = synthsourcespec(F, w0in, Fcin) fit = synthsourcespec(F, w0in, Fcin)
[optspecfit, pcov] = curve_fit(synthsourcespec, F, YY.real, [w0in, Fcin]) [optspecfit, pcov] = curve_fit(synthsourcespec, F, YY.real, [w0in, Fcin])
self.w01 = optspecfit[0] w01 = optspecfit[0]
self.fc1 = optspecfit[1] fc1 = optspecfit[1]
print ("w0fc: Determined w0-value: %e m/Hz, \n" print ("w0fc: Determined w0-value: %e m/Hz, \n"
"Determined corner frequency: %f Hz" % (self.w01, self.fc1)) "Determined corner frequency: %f Hz" % (w01, fc1))
# use of conventional fitting
[self.w02, self.fc2] = fitSourceModel(F, YY.real, Fcin, self.getiplot())
if self.getiplot() > 1: if self.getiplot() > 1:
f1 = plt.figure() f1 = plt.figure()
@ -216,6 +215,14 @@ class w0fc(Magnitude):
raw_input() raw_input()
plt.close(f1) plt.close(f1)
# use of conventional fitting
[w02, fc2] = fitSourceModel(F, YY.real, Fcin, self.getiplot())
# get w0 and fc as median
self.w0 = np.median([w01, w02])
self.fc = np.median([fc1, fc2])
print("w0fc: Using w0-value = %e m/Hz and fc = %f Hz" % (self.w0, self.fc))
def synthsourcespec(f, omega0, fcorner): def synthsourcespec(f, omega0, fcorner):
''' '''