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

This commit is contained in:
Ludger Küperkoch 2017-08-11 12:49:18 +02:00
commit 571b90e5b7
4 changed files with 82 additions and 18 deletions

View File

@ -73,7 +73,7 @@ from pylot.core.util.errors import FormatError, DatastructureError, \
from pylot.core.util.connection import checkurl from pylot.core.util.connection import checkurl
from pylot.core.util.dataprocessing import read_metadata, restitute_data from pylot.core.util.dataprocessing import read_metadata, restitute_data
from pylot.core.util.utils import fnConstructor, getLogin, \ from pylot.core.util.utils import fnConstructor, getLogin, \
full_range, readFilterInformation full_range, readFilterInformation, trim_station_components, check4gaps
from pylot.core.util.event import Event from pylot.core.util.event import Event
from pylot.core.io.location import create_creation_info, create_event from pylot.core.io.location import create_creation_info, create_event
from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \ from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
@ -1365,6 +1365,10 @@ class MainWindow(QMainWindow):
# ans = False # ans = False
self.fnames = self.getWFFnames_from_eventbox() self.fnames = self.getWFFnames_from_eventbox()
self.data.setWFData(self.fnames) self.data.setWFData(self.fnames)
wfdat = self.data.getWFData() # all available streams
check4gaps(wfdat)
# trim station components to same start value
trim_station_components(wfdat, trim_start=True, trim_end=False)
self._stime = full_range(self.get_data().getWFData())[0] self._stime = full_range(self.get_data().getWFData())[0]
def connectWFplotEvents(self): def connectWFplotEvents(self):
@ -1794,18 +1798,18 @@ class MainWindow(QMainWindow):
fig = Figure() fig = Figure()
self.fig_dict[key] = fig self.fig_dict[key] = fig
if not self.tap: #if not self.tap:
# init TuneAutopicker object # init TuneAutopicker object
self.tap = TuneAutopicker(self) self.tap = TuneAutopicker(self)
# first call of update to init tabs with empty canvas # first call of update to init tabs with empty canvas
self.update_autopicker() self.update_autopicker()
# connect update signal of TuneAutopicker with update function # connect update signal of TuneAutopicker with update function
# creating and filling figure canvas # creating and filling figure canvas
self.tap.update.connect(self.update_autopicker) self.tap.update.connect(self.update_autopicker)
self.tap.figure_tabs.setCurrentIndex(0) self.tap.figure_tabs.setCurrentIndex(0)
else: #else:
self.update_autopicker() # self.update_autopicker()
self.tap.fill_eventbox() # self.tap.fill_eventbox()
self.tap.show() self.tap.show()
def update_autopicker(self): def update_autopicker(self):

View File

@ -22,12 +22,11 @@ from pylot.core.analysis.magnitude import MomentMagnitude, LocalMagnitude
from pylot.core.io.data import Data from pylot.core.io.data import Data
from pylot.core.io.inputs import PylotParameter from pylot.core.io.inputs import PylotParameter
from pylot.core.pick.autopick import autopickevent, iteratepicker from pylot.core.pick.autopick import autopickevent, iteratepicker
from pylot.core.util.dataprocessing import restitute_data, read_metadata, \ from pylot.core.util.dataprocessing import restitute_data, read_metadata
remove_underscores
from pylot.core.util.defaults import SEPARATOR from pylot.core.util.defaults import SEPARATOR
from pylot.core.util.event import Event from pylot.core.util.event import Event
from pylot.core.util.structure import DATASTRUCTURE from pylot.core.util.structure import DATASTRUCTURE
from pylot.core.util.utils import real_None from pylot.core.util.utils import real_None, remove_underscores, trim_station_components, check4gaps
from pylot.core.util.version import get_git_version as _getVersionString from pylot.core.util.version import get_git_version as _getVersionString
__version__ = _getVersionString() __version__ = _getVersionString()
@ -239,9 +238,14 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
print('Could not find station {}. STOP!'.format(station)) print('Could not find station {}. STOP!'.format(station))
return return
wfdat = remove_underscores(wfdat) wfdat = remove_underscores(wfdat)
# trim components for each station to avoid problems with different trace starttimes for one station
wfdat = check4gaps(wfdat)
wfdat = trim_station_components(wfdat, trim_start=True, trim_end=False)
metadata = read_metadata(parameter.get('invdir')) metadata = read_metadata(parameter.get('invdir'))
print("Restitute data ...") corr_dat = None
corr_dat = restitute_data(wfdat.copy(), *metadata, ncores=ncores) if locflag:
print("Restitute data ...")
corr_dat = restitute_data(wfdat.copy(), *metadata, ncores=ncores)
if not corr_dat and locflag: if not corr_dat and locflag:
locflag = 2 locflag = 2
print('Working on event %s. Stations: %s' % (eventpath, station)) print('Working on event %s. Stations: %s' % (eventpath, station))

View File

@ -197,6 +197,7 @@ 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")
wfstart, wfend = full_range(wfstream) wfstart, wfend = full_range(wfstream)
if algoP == 'HOS' or algoP == 'ARZ' and zdat is not None: if algoP == 'HOS' or algoP == 'ARZ' and zdat is not None:

View File

@ -470,6 +470,61 @@ def remove_underscores(data):
return data return data
def trim_station_components(data, trim_start=True, trim_end=True):
'''
cut a stream so only the part common to all three traces is kept to avoid dealing with offsets
:param data: stream of seismic data
:type data: `obspy.core.stream.Stream`
:param trim_start: trim start of stream
:type trim_start: bool
:param trim_end: trim end of stream
:type trim_end: bool
:return: data stream
'''
starttime = {False: None}
endtime = {False: None}
stations = get_stations(data)
print('trim_station_components: Will trim stream for trim_start: {} and for '
'trim_end: {}.'.format(trim_start, trim_end))
for station in stations:
wf_station = data.select(station=station)
starttime[True] = max([trace.stats.starttime for trace in wf_station])
endtime[True] = min([trace.stats.endtime for trace in wf_station])
wf_station.trim(starttime=starttime[trim_start], endtime=endtime[trim_end])
return data
def check4gaps(data):
'''
check for gaps in Stream and remove them
:param data: stream of seismic data
:return: data stream
'''
stations = get_stations(data)
for station in stations:
wf_station = data.select(station=station)
if wf_station.get_gaps():
for trace in wf_station:
data.remove(trace)
print('check4gaps: Found gaps and removed station {} from waveform data.'.format(station))
return data
def get_stations(data):
stations = []
for tr in data:
station = tr.stats.station
if not station in stations:
stations.append(station)
return stations
def scaleWFData(data, factor=None, components='all'): def scaleWFData(data, factor=None, components='all'):
""" """
produce scaled waveforms from given waveform data and a scaling factor, produce scaled waveforms from given waveform data and a scaling factor,