Merge branch 'develop' of ariadne.geophysik.rub.de:/data/git/pylot into develop

This commit is contained in:
Ludger Küperkoch 2017-08-11 16:59:26 +02:00
commit a48bb60809
4 changed files with 49 additions and 18 deletions

View File

@ -68,6 +68,7 @@ def autopickevent(data, param, iplot=0, fig_dict=None, ncores=0, metadata=None,
pool.close() pool.close()
for pick in result: for pick in result:
if pick:
station = pick['station'] station = pick['station']
pick.pop('station') pick.pop('station')
all_onsets[station] = pick all_onsets[station] = pick
@ -87,6 +88,15 @@ def call_autopickstation(input_tuple):
return autopickstation(wfstream, pickparam, verbose, iplot=0, metadata=metadata, origin=origin) return autopickstation(wfstream, pickparam, verbose, iplot=0, metadata=metadata, origin=origin)
def get_source_coords(parser, station_id):
station_coords = None
try:
station_coords = parser.get_coordinates(station_id)
except Exception as e:
print('Could not get source coordinates for station {}: {}'.format(station_id, e))
return station_coords
def autopickstation(wfstream, pickparam, verbose=False, def autopickstation(wfstream, pickparam, verbose=False,
iplot=0, fig_dict=None, metadata=None, origin=None): iplot=0, fig_dict=None, metadata=None, origin=None):
""" """
@ -197,13 +207,14 @@ def autopickstation(wfstream, pickparam, verbose=False,
if len(ndat) == 0: # check for other components if len(ndat) == 0: # check for other components
ndat = wfstream.select(component="1") ndat = wfstream.select(component="1")
if not zdat:
wfstart, wfend = full_range(wfstream) print('No z-component found for station {}. STOP'.format(wfstream[0].stats.station))
return
if algoP == 'HOS' or algoP == 'ARZ' and zdat is not None: if algoP == 'HOS' or algoP == 'ARZ' and zdat is not None:
msg = '##################################################\nautopickstation:' \ msg = '##################################################\nautopickstation:' \
' Working on P onset of station {station}\nFiltering vertical ' \ ' Working on P onset of station {station}\nFiltering vertical ' \
'trace ...\n{data}'.format(station=zdat[0].stats.station, 'trace ...\n{data}'.format(station=wfstream[0].stats.station,
data=str(zdat)) data=str(zdat))
if verbose: print(msg) if verbose: print(msg)
z_copy = zdat.copy() z_copy = zdat.copy()
@ -224,11 +235,11 @@ def autopickstation(wfstream, pickparam, verbose=False,
if not metadata[1]: if not metadata[1]:
print('Warning: Could not use TauPy to estimate onsets as there are no metadata given.') print('Warning: Could not use TauPy to estimate onsets as there are no metadata given.')
else: else:
if origin:
source_origin = origin[0]
station_id = wfstream[0].get_id() station_id = wfstream[0].get_id()
parser = metadata[1] parser = metadata[1]
station_coords = parser.get_coordinates(station_id) station_coords = get_source_coords(parser, station_id)
if station_coords and origin:
source_origin = origin[0]
model = TauPyModel(taup_model) model = TauPyModel(taup_model)
arrivals = model.get_travel_times_geo( arrivals = model.get_travel_times_geo(
source_origin.depth, source_origin.depth,
@ -254,9 +265,8 @@ def autopickstation(wfstream, pickparam, verbose=False,
Lc = pstop - pstart Lc = pstop - pstart
print('autopick: CF calculation times respectively:' print('autopick: CF calculation times respectively:'
' pstart: {} s, pstop: {} s'.format(pstart, pstop)) ' pstart: {} s, pstop: {} s'.format(pstart, pstop))
else: elif not origin:
print('No source origins given!') print('No source origins given!')
else: else:
Lc = pstop - pstart Lc = pstop - pstart
Lwf = zdat[0].stats.endtime - zdat[0].stats.starttime Lwf = zdat[0].stats.endtime - zdat[0].stats.starttime
@ -964,14 +974,16 @@ def autopickstation(wfstream, pickparam, verbose=False,
else: else:
# dummy values (start of seismic trace) in order to derive # dummy values (start of seismic trace) in order to derive
# theoretical onset times for iteratve picking # theoretical onset times for iteratve picking
try: if edat:
lpickS = edat[0].stats.starttime + timeerrorsS[3] lpickS = edat[0].stats.starttime + timeerrorsS[3]
epickS = edat[0].stats.starttime - timeerrorsS[3] epickS = edat[0].stats.starttime - timeerrorsS[3]
mpickS = edat[0].stats.starttime mpickS = edat[0].stats.starttime
except: elif ndat:
lpickS = ndat[0].stats.starttime + timeerrorsS[3] lpickS = ndat[0].stats.starttime + timeerrorsS[3]
epickS = ndat[0].stats.starttime - timeerrorsS[3] epickS = ndat[0].stats.starttime - timeerrorsS[3]
mpickS = ndat[0].stats.starttime mpickS = ndat[0].stats.starttime
else:
return
# create dictionary # create dictionary
# for P phase # for P phase

View File

@ -219,11 +219,13 @@ class AICPicker(AutoPicker):
# check, if these are counts or m/s, important for slope estimation! # check, if these are counts or m/s, important for slope estimation!
# this is quick and dirty, better solution? # this is quick and dirty, better solution?
if max(self.Data[0].data < 1e-3) and max(self.Data[0].data >= 1e-6): if max(self.Data[0].data < 1e-3) and max(self.Data[0].data >= 1e-6):
self.Data[0].data = self.Data[0].data * 1000000 self.Data[0].data = self.Data[0].data * 1000000.
elif max(self.Data[0].data < 1e-6): elif max(self.Data[0].data < 1e-6):
self.Data[0].data = self.Data[0].data * 1e13 self.Data[0].data = self.Data[0].data * 1e13
# get signal window # get signal window
isignal = getsignalwin(self.Tcf, self.Pick, self.TSNR[2]) isignal = getsignalwin(self.Tcf, self.Pick, self.TSNR[2])
if len(isignal) == 0:
return
ii = min([isignal[len(isignal) - 1], len(self.Tcf)]) ii = min([isignal[len(isignal) - 1], len(self.Tcf)])
isignal = isignal[0:ii] isignal = isignal[0:ii]
try: try:
@ -242,7 +244,11 @@ class AICPicker(AutoPicker):
& (self.Tcf >= self.Pick)) & (self.Tcf >= self.Pick))
# find maximum within slope determination window # find maximum within slope determination window
# 'cause slope should be calculated up to first local minimum only! # 'cause slope should be calculated up to first local minimum only!
imax = np.argmax(self.Data[0].data[islope[0][0]:islope[0][len(islope[0])-1]]) dataslope = self.Data[0].data[islope[0][0]:islope[0][len(islope[0]) - 1]]
if len(dataslope) < 1:
print('No data in slope window found!')
return
imax = np.argmax(dataslope)
iislope = islope[0][0:imax+1] iislope = islope[0][0:imax+1]
if len(iislope) <= 2: if len(iislope) <= 2:
# calculate slope from initial onset to maximum of AIC function # calculate slope from initial onset to maximum of AIC function
@ -395,8 +401,14 @@ class PragPicker(AutoPicker):
# prominent trend: decrease aus # prominent trend: decrease aus
# flat: use given aus # flat: use given aus
cfdiff = np.diff(cfipick) cfdiff = np.diff(cfipick)
if len(cfdiff)<20:
print('PragPicker: Very few samples for CF. Check LTA window dimensions!')
i0diff = np.where(cfdiff > 0) i0diff = np.where(cfdiff > 0)
cfdiff = cfdiff[i0diff] cfdiff = cfdiff[i0diff]
if len(cfdiff)<1:
print('PragPicker: Negative slope for CF. Check LTA window dimensions! STOP')
self.Pick = None
return
minaus = min(cfdiff * (1 + self.aus)) minaus = min(cfdiff * (1 + self.aus))
aus1 = max([minaus, self.aus]) aus1 = max([minaus, self.aus])

View File

@ -228,6 +228,10 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=0, fig=None):
if len(zc1) == 3: if len(zc1) == 3:
break break
if len(zc1) < 3:
print('fmpicker: Could not determine zero crossings!')
return
# if time difference betweeen 1st and 2cnd zero crossing # if time difference betweeen 1st and 2cnd zero crossing
# is too short, get time difference between 1st and 3rd # is too short, get time difference between 1st and 3rd
# to derive maximum # to derive maximum

View File

@ -21,7 +21,7 @@ except:
pg = None pg = None
from matplotlib.figure import Figure from matplotlib.figure import Figure
from pylot.core.util.utils import find_horizontals, identifyPhase, loopIdentifyPhase from pylot.core.util.utils import find_horizontals, identifyPhase, loopIdentifyPhase, trim_station_components
try: try:
from matplotlib.backends.backend_qt4agg import FigureCanvas from matplotlib.backends.backend_qt4agg import FigureCanvas
@ -2058,6 +2058,9 @@ class TuneAutopicker(QWidget):
def fill_stationbox(self): def fill_stationbox(self):
fnames = self.parent.getWFFnames_from_eventbox(eventbox=self.eventBox) fnames = self.parent.getWFFnames_from_eventbox(eventbox=self.eventBox)
self.data.setWFData(fnames) self.data.setWFData(fnames)
wfdat = self.data.getWFData() # all available streams
# trim station components to same start value
trim_station_components(wfdat, trim_start=True, trim_end=False)
self.stationBox.clear() self.stationBox.clear()
stations = [] stations = []
for trace in self.data.getWFData(): for trace in self.data.getWFData():
@ -2248,7 +2251,7 @@ class TuneAutopicker(QWidget):
else: else:
self.disable_autopickTabs() self.disable_autopickTabs()
try: try:
main_fig.tight_layout() self.fig_dict['main_fig'].tight_layout()
except: except:
pass pass
self.figure_tabs.setCurrentIndex(0) self.figure_tabs.setCurrentIndex(0)