Optimized and cleaned fitSourceModel to speed it up.
This commit is contained in:
parent
bcde390d42
commit
42268cd3e9
@ -16,7 +16,6 @@ from pylot.core.pick.utils import getsignalwin, crossings_nonzero_all, \
|
|||||||
select_for_phase
|
select_for_phase
|
||||||
from pylot.core.util.utils import common_range, fit_curve
|
from pylot.core.util.utils import common_range, fit_curve
|
||||||
|
|
||||||
|
|
||||||
def richter_magnitude_scaling(delta):
|
def richter_magnitude_scaling(delta):
|
||||||
relation = np.loadtxt(os.path.join(os.path.expanduser('~'),
|
relation = np.loadtxt(os.path.join(os.path.expanduser('~'),
|
||||||
'.pylot', 'richter_scaling.data'))
|
'.pylot', 'richter_scaling.data'))
|
||||||
@ -530,7 +529,7 @@ def calcsourcespec(wfstream, onset, vp, delta, azimuth, incidence,
|
|||||||
fc1 = optspecfit[1]
|
fc1 = optspecfit[1]
|
||||||
if verbosity:
|
if verbosity:
|
||||||
print ("calcsourcespec: Determined w0-value: %e m/Hz, \n"
|
print ("calcsourcespec: Determined w0-value: %e m/Hz, \n"
|
||||||
"Determined corner frequency: %f Hz" % (w01, fc1))
|
"calcsourcespec: Determined corner frequency: %f Hz" % (w01, fc1))
|
||||||
|
|
||||||
# use of conventional fitting
|
# use of conventional fitting
|
||||||
[w02, fc2] = fitSourceModel(F, YYcor, Fcin, iplot, verbosity)
|
[w02, fc2] = fitSourceModel(F, YYcor, Fcin, iplot, verbosity)
|
||||||
@ -626,18 +625,25 @@ def fitSourceModel(f, S, fc0, iplot, verbosity=False):
|
|||||||
fc = []
|
fc = []
|
||||||
stdfc = []
|
stdfc = []
|
||||||
STD = []
|
STD = []
|
||||||
|
|
||||||
# get window around initial corner frequency for trials
|
# get window around initial corner frequency for trials
|
||||||
fcstopl = fc0 - max(1, len(f) / 10)
|
# left side of initial corner frequency
|
||||||
il = np.argmin(abs(f - fcstopl))
|
fcstopl = fc0 - max(1, fc0 / 2)
|
||||||
fcstopl = f[il]
|
il = np.where(f <= fcstopl)
|
||||||
fcstopr = fc0 + min(len(f), len(f) / 10)
|
il = il[0][np.size(il) - 1]
|
||||||
ir = np.argmin(abs(f - fcstopr))
|
# right side of initial corner frequency
|
||||||
fcstopr = f[ir]
|
fcstopr = fc0 + (fc0 / 2)
|
||||||
iF = np.where((f >= fcstopl) & (f <= fcstopr))
|
ir = np.where(f >= fcstopr)
|
||||||
|
# check, if fcstopr is available
|
||||||
|
if np.size(ir) == 0:
|
||||||
|
fcstopr = fc0
|
||||||
|
ir = len(f) - 1
|
||||||
|
else:
|
||||||
|
ir = ir[0][0]
|
||||||
|
|
||||||
# vary corner frequency around initial point
|
# vary corner frequency around initial point
|
||||||
for i in range(il, ir):
|
print("fitSourceModel: Varying corner frequency "
|
||||||
|
"around initial corner frequency ...")
|
||||||
|
for i in range(il, ir, 10):
|
||||||
FC = f[i]
|
FC = f[i]
|
||||||
indexdc = np.where((f > 0) & (f <= FC))
|
indexdc = np.where((f > 0) & (f <= FC))
|
||||||
dc = np.mean(S[indexdc])
|
dc = np.mean(S[indexdc])
|
||||||
|
Loading…
Reference in New Issue
Block a user