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

This commit is contained in:
Ludger Küperkoch 2016-09-19 13:22:50 +02:00
commit aacfbf3bbb
7 changed files with 32 additions and 30 deletions

View File

@ -55,7 +55,7 @@ from pylot.core.util.errors import FormatError, DatastructureError, \
OverwriteError OverwriteError
from pylot.core.util.connection import checkurl from pylot.core.util.connection import checkurl
from pylot.core.util.utils import fnConstructor, getLogin, \ from pylot.core.util.utils import fnConstructor, getLogin, \
getGlobalTimes full_range
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, \
WaveformWidget, PropertiesDlg, HelpForm, createAction, PickDlg, \ WaveformWidget, PropertiesDlg, HelpForm, createAction, PickDlg, \
@ -660,7 +660,7 @@ class MainWindow(QMainWindow):
ans = self.data.setWFData(self.getWFFnames()) ans = self.data.setWFData(self.getWFFnames())
else: else:
ans = False ans = False
self._stime = getGlobalTimes(self.get_data().getWFData())[0] self._stime = full_range(self.get_data().getWFData())[0]
if ans: if ans:
self.plotWaveformData() self.plotWaveformData()
return ans return ans

View File

@ -740,11 +740,11 @@ class SeismicShot(object):
self._drawCFs(traceID, folm) self._drawCFs(traceID, folm)
def _drawStream(self, traceID, refresh=False, ax=None): def _drawStream(self, traceID, refresh=False, ax=None):
from pylot.core.util.utils import getGlobalTimes from pylot.core.util.utils import full_range
from pylot.core.util.utils import prepTimeAxis from pylot.core.util.utils import prepTimeAxis
stream = self.getSingleStream(traceID) stream = self.getSingleStream(traceID)
stime = getGlobalTimes(stream)[0] stime = full_range(stream)[0]
timeaxis = prepTimeAxis(stime, stream[0]) timeaxis = prepTimeAxis(stime, stream[0])
timeaxis -= stime timeaxis -= stime

View File

@ -15,6 +15,7 @@ from scipy.optimize import curve_fit
from scipy import integrate, signal from scipy import integrate, signal
from pylot.core.io.data import Data from pylot.core.io.data import Data
from pylot.core.util.dataprocessing import restitute_data from pylot.core.util.dataprocessing import restitute_data
from pylot.core.util.utils import common_range
class Magnitude(object): class Magnitude(object):
@ -360,25 +361,8 @@ def calcsourcespec(wfstream, onset, inventory, vp, delta, azimuth, incidence, qp
cordat_copy = cordat.copy() cordat_copy = cordat.copy()
# get equal time stamps and lengths of traces # get equal time stamps and lengths of traces
# necessary for rotation of traces # necessary for rotation of traces
tr0start = cordat_copy[0].stats.starttime trstart, trend = common_range(cordat_copy)
tr0start = tr0start.timestamp
tr0end = cordat_copy[0].stats.endtime
tr0end = tr0end.timestamp
tr1start = cordat_copy[1].stats.starttime
tr1start = tr1start.timestamp
tr1end = cordat_copy[1].stats.endtime
tr1end = tr1end.timestamp
tr2start = cordat_copy[2].stats.starttime
tr2start = tr2start.timestamp
tr2end = cordat_copy[0].stats.endtime
tr2end = tr2end.timestamp
trstart = UTCDateTime(max([tr0start, tr1start, tr2start]))
trend = UTCDateTime(min([tr0end, tr1end, tr2end]))
cordat_copy.trim(trstart, trend) cordat_copy.trim(trstart, trend)
minlen = min([len(cordat_copy[0]), len(cordat_copy[1]), len(cordat_copy[2])])
cordat_copy[0].data = cordat_copy[0].data[0:minlen]
cordat_copy[1].data = cordat_copy[1].data[0:minlen]
cordat_copy[2].data = cordat_copy[2].data[0:minlen]
try: try:
# rotate into LQT (ray-coordindate-) system using Obspy's rotate # rotate into LQT (ray-coordindate-) system using Obspy's rotate
# L: P-wave direction # L: P-wave direction

View File

@ -10,7 +10,7 @@ from obspy.core.event import Event
from pylot.core.io.phases import readPILOTEvent, picks_from_picksdict, \ from pylot.core.io.phases import readPILOTEvent, picks_from_picksdict, \
picksdict_from_pilot, merge_picks picksdict_from_pilot, merge_picks
from pylot.core.util.errors import FormatError, OverwriteError from pylot.core.util.errors import FormatError, OverwriteError
from pylot.core.util.utils import fnConstructor, getGlobalTimes from pylot.core.util.utils import fnConstructor, full_range
class Data(object): class Data(object):
@ -133,7 +133,7 @@ class Data(object):
""" """
self.cuttimes = getGlobalTimes(self.getWFData()) self.cuttimes = full_range(self.getWFData())
def getEventFileName(self): def getEventFileName(self):
""" """

View File

@ -12,7 +12,7 @@ from pylot.core.io.inputs import AutoPickParameter
from pylot.core.io.location import create_arrival, create_event, \ from pylot.core.io.location import create_arrival, create_event, \
create_magnitude, create_origin, create_pick create_magnitude, create_origin, create_pick
from pylot.core.pick.utils import select_for_phase from pylot.core.pick.utils import select_for_phase
from pylot.core.util.utils import getOwner, getGlobalTimes, four_digits from pylot.core.util.utils import getOwner, full_range, four_digits
def readPILOTEvent(phasfn=None, locfn=None, authority_id='RUB', **kwargs): def readPILOTEvent(phasfn=None, locfn=None, authority_id='RUB', **kwargs):
@ -325,7 +325,7 @@ def reassess_pilot_event(root_dir, db_dir, event_id, out_dir=None, fn_param=None
msg = 'no waveform data found for station {station}'.format(station=station) msg = 'no waveform data found for station {station}'.format(station=station)
warnings.warn(msg, RuntimeWarning) warnings.warn(msg, RuntimeWarning)
continue continue
stime, etime = getGlobalTimes(sel_st) stime, etime = full_range(sel_st)
rel_pick = mpp - stime rel_pick = mpp - stime
epp, lpp, spe = earllatepicker(sel_st, epp, lpp, spe = earllatepicker(sel_st,
default.get('nfac{0}'.format(phase)), default.get('nfac{0}'.format(phase)),

View File

@ -207,7 +207,25 @@ def four_digits(year):
return year return year
def getGlobalTimes(stream): def common_range(stream):
'''
takes a stream object and returns the earliest end and the latest start
time of all contained trace objects
:param stream: seismological data stream
:type stream: `~obspy.core.stream.Stream`
:return: maximum start time and minimum end time
'''
max_start = None
min_end = None
for trace in stream:
if max_start is None or trace.stats.starttime > max_start:
max_start = trace.stats.starttime
if min_end is None or trace.stats.endtime < min_end:
min_end = trace.stats.endtime
return max_start, min_end
def full_range(stream):
''' '''
takes a stream object and returns the latest end and the earliest start takes a stream object and returns the latest end and the earliest start
time of all contained trace objects time of all contained trace objects

View File

@ -32,7 +32,7 @@ from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin, \
from pylot.core.pick.compare import Comparison from pylot.core.pick.compare import Comparison
from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS, LOCTOOLS, \ from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS, LOCTOOLS, \
COMPPOSITION_MAP COMPPOSITION_MAP
from pylot.core.util.utils import prepTimeAxis, getGlobalTimes, scaleWFData, \ from pylot.core.util.utils import prepTimeAxis, full_range, scaleWFData, \
demeanTrace, isSorted, findComboBoxIndex, clims, find_horizontals demeanTrace, isSorted, findComboBoxIndex, clims, find_horizontals
@ -425,7 +425,7 @@ class WaveformWidget(FigureCanvas):
noiselevel=None, scaleddata=False, mapping=True): noiselevel=None, scaleddata=False, mapping=True):
self.getAxes().cla() self.getAxes().cla()
self.clearPlotDict() self.clearPlotDict()
wfstart, wfend = getGlobalTimes(wfdata) wfstart, wfend = full_range(wfdata)
nmax = 0 nmax = 0
for n, trace in enumerate(wfdata): for n, trace in enumerate(wfdata):
channel = trace.stats.channel channel = trace.stats.channel
@ -539,7 +539,7 @@ class PickDlg(QDialog):
else: else:
self.data = data self.data = data
self.stime, self.etime = getGlobalTimes(self.getWFData()) self.stime, self.etime = full_range(self.getWFData())
# initialize plotting widget # initialize plotting widget
self.multicompfig = WaveformWidget(self) self.multicompfig = WaveformWidget(self)