Speed up spectral fit; take into account that in seldom cases not all

pick information in pick dictionary are available.
This commit is contained in:
Ludger Küperkoch 2020-07-30 10:37:39 +02:00
parent f49b9054b0
commit 6d81e4a132
2 changed files with 31 additions and 5 deletions

View File

@ -751,13 +751,16 @@ def fitSourceModel(f, S, fc0, iplot, verbosity=False):
# check difference of il and ir in order to # check difference of il and ir in order to
# keep calculation time acceptable # keep calculation time acceptable
idiff = ir - il idiff = ir - il
if idiff > 10000: print(idiff)
if idiff > 100000:
increment = 1000
elif idiff <= 100000 and idiff > 10000:
increment = 100 increment = 100
elif idiff <= 20: elif idiff <= 20:
increment = 1 increment = 1
else: else:
increment = 10 increment = 10
print(increment)
for i in range(il, ir, increment): for i in range(il, ir, increment):
FC = f[i] FC = f[i]
indexdc = np.where((f > 0) & (f <= FC)) indexdc = np.where((f > 0) & (f <= FC))

View File

@ -550,7 +550,6 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
if arrivals[key].has_key('S') and arrivals[key]['S']['mpp'] is not None: if arrivals[key].has_key('S') and arrivals[key]['S']['mpp'] is not None:
fm = '?' fm = '?'
onset = arrivals[key]['S']['mpp'] onset = arrivals[key]['S']['mpp']
print(onset)
year = onset.year year = onset.year
month = onset.month month = onset.month
day = onset.day day = onset.day
@ -660,7 +659,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
fid.write('%s, event %s \n' % (parameter.get('database'), parameter.get('eventID'))) fid.write('%s, event %s \n' % (parameter.get('database'), parameter.get('eventID')))
for key in arrivals: for key in arrivals:
# P onsets # P onsets
if arrivals[key].has_key('P'): if arrivals[key].has_key('P') and arrivals[key]['P']['mpp'] is not None:
if arrivals[key]['P']['weight'] < 4: if arrivals[key]['P']['weight'] < 4:
Ponset = arrivals[key]['P']['mpp'] Ponset = arrivals[key]['P']['mpp']
pyear = Ponset.year pyear = Ponset.year
@ -674,10 +673,22 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
# use symmetrized picking error as std # use symmetrized picking error as std
# (read the HYPOSAT manual) # (read the HYPOSAT manual)
pstd = arrivals[key]['P']['spe'] pstd = arrivals[key]['P']['spe']
if pstd is None:
errorsP = parameter.get('timeerrorsP')
if arrivals[key]['P']['weight'] == 0:
pstd = errorsP[0]
elif arrivals[key]['P']['weight'] == 1:
pstd = errorsP[1]
elif arrivals[key]['P']['weight'] == 2:
pstd = errorsP[2]
elif arrivals[key]['P']['weight'] == 3:
psrd = errorsP[3]
else:
pstd = errorsP[4]
fid.write('%-5s P1 %4.0f %02d %02d %02d %02d %05.02f %5.3f -999. 0.00 -999. 0.00\n' fid.write('%-5s P1 %4.0f %02d %02d %02d %02d %05.02f %5.3f -999. 0.00 -999. 0.00\n'
% (key, pyear, pmonth, pday, phh, pmm, Pss, pstd)) % (key, pyear, pmonth, pday, phh, pmm, Pss, pstd))
# S onsets # S onsets
if arrivals[key].has_key('S') and arrivals[key]['S']: if arrivals[key].has_key('S') and arrivals[key]['S']['mpp'] is not None:
if arrivals[key]['S']['weight'] < 4: if arrivals[key]['S']['weight'] < 4:
Sonset = arrivals[key]['S']['mpp'] Sonset = arrivals[key]['S']['mpp']
syear = Sonset.year syear = Sonset.year
@ -689,6 +700,18 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
sms = Sonset.microsecond sms = Sonset.microsecond
Sss = sss + sms / 1000000.0 Sss = sss + sms / 1000000.0
sstd = arrivals[key]['S']['spe'] sstd = arrivals[key]['S']['spe']
if pstd is None:
errorsS = parameter.get('timeerrorsS')
if arrivals[key]['S']['weight'] == 0:
pstd = errorsS[0]
elif arrivals[key]['S']['weight'] == 1:
pstd = errorsS[1]
elif arrivals[key]['S']['weight'] == 2:
pstd = errorsS[2]
elif arrivals[key]['S']['weight'] == 3:
psrd = errorsS[3]
else:
pstd = errorsP[4]
fid.write('%-5s S1 %4.0f %02d %02d %02d %02d %05.02f %5.3f -999. 0.00 -999. 0.00\n' fid.write('%-5s S1 %4.0f %02d %02d %02d %02d %05.02f %5.3f -999. 0.00 -999. 0.00\n'
% (key, syear, smonth, sday, shh, smm, Sss, sstd)) % (key, syear, smonth, sday, shh, smm, Sss, sstd))
fid.close() fid.close()