Browse Source

bugfixes relative timeshifts to array mean

master
asteinbe 2 years ago
parent
commit
513f28ae92
3 changed files with 42 additions and 27 deletions
  1. +22
    -15
      src/process/main.py
  2. +10
    -9
      src/process/sembCalc.py
  3. +10
    -3
      src/tools/config.py

+ 22
- 15
src/process/main.py View File

@ -87,12 +87,18 @@ def processLoop(traces=None, stations=None, cluster=None):
for argv in sys.argv:
if argv[-7:] == '--force':
force = True
if argv[-12:] == '--force-move':
evpath_emps = evpath_emp[:-7]
elif argv[-12:] == '--force-move':
force = False
move = True
evpath_emps = evpath_emp[:-12]
else:
evpath_emps = evpath_emp
if force is False:
check_is_empty(evpath, move=move)
C = config.Config(evpath, eventpath_emp=evpath_emp)
C = config.Config(evpath, eventpath_emp=evpath_emps)
Origin = C.parseConfig('origin')
flag_rpe = False
@ -255,9 +261,10 @@ def processLoop(traces=None, stations=None, cluster=None):
fobjreferenceshiftname = newFreq + '_' + filtername + '.refpkl'
rp = os.path.join(Folder['semb'], fobjreferenceshiftname)
fobjreferenceshiftnameemp = newFreq + '_' + filtername + 'emp' + '.refpkl'
rpe = os.path.join(Folder['semb'], fobjreferenceshiftnameemp)
rpe = os.path.join(Folder['semb'], fobjreferenceshiftnameemp) + '.shift'
fobjpickleshiftname = newFreq + '_' + filtername + '.xcorrpkl'
ps = os.path.join(Folder['semb'], fobjpickleshiftname)
refshift = 0
SL = {}
for i in xcorrnetworks:
@ -603,17 +610,17 @@ def processLoop(traces=None, stations=None, cluster=None):
else:
Wd_emp = waveform.readWaveformsPyrocko(FilterMeta,
tw_emp,
evpath_emp,
evpath_emps,
ev_emp,
desired)
elif cfg.colesseo_input() is True:
Wd_emp = waveform.readWaveforms_colesseo(FilterMeta,
tw_emp,
evpath_emp,
evpath_emps,
ev_emp, C)
else:
Wd_emp = waveform.readWaveforms(FilterMeta, tw_emp,
evpath_emp, ev_emp)
evpath_emps, ev_emp)
if cfg.Bool('correct_shifts_empirical_synthetic') is True\
or cfg.Bool('dynamic_filter') is True:
Wdf_emp = waveform.processdummyWaveforms(Wd_emp, Config,
@ -627,9 +634,9 @@ def processLoop(traces=None, stations=None, cluster=None):
ff2 = filter.fhi()
switchs = "l0"
else:
f1 = str('ff1 = filter.flo%s()'%filterindex+1)
f1 = str('filter.flo%s()'% str(filterindex+1))
ff1 = eval(f1)
f2 = str('ff2 = filter.fhi%s()'%filterindex+1)
f2 = str('filter.fhi%s()'% str(filterindex+1))
ff2 = eval(f2)
switchs = "h1"
ps_wdf_emp = os.path.join(Folder['semb'],
@ -783,17 +790,17 @@ def processLoop(traces=None, stations=None, cluster=None):
else:
Wd_emp = waveform.readWaveformsPyrocko(FilterMeta,
tw_emp,
evpath_emp,
evpath_emps,
ev_emp,
desired)
elif cfg.colesseo_input() is True:
Wd_emp = waveform.readWaveforms_colesseo(FilterMeta,
tw_emp,
evpath_emp,
evpath_emps,
ev_emp, C)
else:
Wd_emp = waveform.readWaveforms(FilterMeta, tw_emp,
evpath_emp, ev_emp)
evpath_emps, ev_emp)
flag_rpe = True
nstats = stations_per_array
if switch == 0:
@ -937,9 +944,9 @@ def processLoop(traces=None, stations=None, cluster=None):
ff2 = filter.fhi()
switchs = "l0"
else:
f1 = str('filter.flo%s()'%filterindex+1)
f1 = str('filter.flo%s()'% str(filterindex+1))
ff1 = eval(f1)
f2 = str('filter.fhi%s()'%filterindex+1)
f2 = str('filter.fhi%s()'% str(filterindex+1))
ff2 = eval(f2)
switchs = "h1"
ps_wdf = os.path.join(Folder['semb'],
@ -975,9 +982,9 @@ def processLoop(traces=None, stations=None, cluster=None):
ff2 = filter.fhi()
switchs = "l0"
else:
f1 = str('filter.flo%s()'%filterindex+1)
f1 = str('filter.flo%s()'% str(filterindex+1))
ff1 = eval(f1)
f2 = str('ff2 = filter.fhi%s()'%filterindex+1)
f2 = str('ff2 = filter.fhi%s()'% str(filterindex+1))
ff2 = eval(f2)
switchs = "h1"
if cfg.Bool('bootstrap_array_weights') is False:


+ 10
- 9
src/process/sembCalc.py View File

@ -85,14 +85,15 @@ def optimization_timeshifts(*params, **args):
def solve_timeshifts(maxp, nostat, nsamp, ntimes, nstep, dimX, dimY, Gmint,
new_frequence, minSampleCount, latv, lonv, traveltimes,
traces, calcStreamMap, timeev, Config, Origin, refshifts,cfg):
traces, calcStreamMap, timeev, Config, Origin, refshifts,
cfg):
t = time.time() # start timing
# bounds given as (min,max)
bounds = []
max_semb = 0.
low = -1.*cfg.Float('shift_max')
high = cfg.Float('shift_max')
low = -1*cfg.Int('shift_max')
high = cfg.Int('shift_max')
for i in range(low, high):
bounds = []
if cfg.Bool('correct_shifts_empirical_station_wise') is False:
bounds = [(i-1., i+1.)]
else:
@ -114,11 +115,11 @@ def solve_timeshifts(maxp, nostat, nsamp, ntimes, nstep, dimX, dimY, Gmint,
elapsed = time.time() - t # get the processing time
print("shifts:", result.x)
if result.func > max_semb:
max_semb = result.func
add_factor = i
return result.x+add_factor
print("shifts:", result.x, "semblance:", 1./result.fun)
if 1./result.fun > max_semb:
max_semb = result.fun
shifts = result.x
return shifts
def make_bayesian_weights(narrays, nbootstrap=100,
type='bayesian', rstate=None):


+ 10
- 3
src/tools/config.py View File

@ -99,11 +99,18 @@ class Config(object):
'''
cDict = {}
if suffix == "origin_emp":
files = glob.glob(os.path.join(self.eventpath_emp, '*.'+'origin'))
try:
files = glob.glob(os.path.join(self.eventpath_emp, '*.'+'origin'))
parser = SafeConfigParser()
parser.read(files[0])
except:
files = glob.glob(os.path.join(self.eventpath_emp, '*.'+'origin_emp'))
parser = SafeConfigParser()
parser.read(files[0])
else:
files = glob.glob(os.path.join(self.eventpath, '*.'+suffix))
parser = SafeConfigParser()
parser.read(files[0])
parser = SafeConfigParser()
parser.read(files[0])
for section_name in parser.sections():
for name, value in parser.items(section_name):


Loading…
Cancel
Save