[merge] merged changes in QtPyLoT manually
This commit is contained in:
commit
7f0ab4dd94
532
QtPyLoT.py
532
QtPyLoT.py
File diff suppressed because it is too large
Load Diff
24
autoPyLoT.py
24
autoPyLoT.py
@ -369,18 +369,18 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
|
||||
# HYPOSAT
|
||||
hyposatfile = '%s/PyLoT_%s_HYPOSAT_phases' % (event, evID)
|
||||
hyposat.export(picks, hyposatfile, parameter)
|
||||
# VELEST
|
||||
velestfile = '%s/PyLoT_%s_VELEST_phases.cnv' % (event, evID)
|
||||
velest.export(picks, velestfile, parameter, evt)
|
||||
# hypoDD
|
||||
hypoddfile = '%s/PyLoT_%s_hypoDD_phases.pha' % (event, evID)
|
||||
hypodd.export(picks, hypoddfile, parameter, evt)
|
||||
# FOCMEC
|
||||
focmecfile = '%s/PyLoT_%s_FOCMEC.in' % (event, evID)
|
||||
focmec.export(picks, focmecfile, parameter, evt)
|
||||
# HASH
|
||||
hashfile = '%s/PyLoT_%s_HASH' % (event, evID)
|
||||
hash.export(picks, hashfile, parameter, evt)
|
||||
# VELEST
|
||||
velestfile = '%s/PyLoT_%s_VELEST_phases.cnv' % (event, evID)
|
||||
velest.export(picks, velestfile, parameter, evt)
|
||||
# hypoDD
|
||||
hypoddfile = '%s/PyLoT_%s_hypoDD_phases.pha' % (event, evID)
|
||||
hypodd.export(picks, hypoddfile, parameter, evt)
|
||||
# FOCMEC
|
||||
focmecfile = '%s/PyLoT_%s_FOCMEC.in' % (event, evID)
|
||||
focmec.export(picks, focmecfile, parameter, evt)
|
||||
# HASH
|
||||
hashfile = '%s/PyLoT_%s_HASH' % (event, evID)
|
||||
hash.export(picks, hashfile, parameter, evt)
|
||||
|
||||
endsplash = '''------------------------------------------\n'
|
||||
-----Finished event %s!-----\n'
|
||||
|
196194
icons_rc.py → icons_rc_2.py
196194
icons_rc.py → icons_rc_2.py
File diff suppressed because it is too large
Load Diff
98097
icons_rc_3.py
Normal file
98097
icons_rc_3.py
Normal file
File diff suppressed because it is too large
Load Diff
1
pylot/RELEASE-VERSION
Normal file
1
pylot/RELEASE-VERSION
Normal file
@ -0,0 +1 @@
|
||||
b286-dirty
|
@ -39,7 +39,7 @@ class Data(object):
|
||||
elif isinstance(evtdata, dict):
|
||||
evt = readPILOTEvent(**evtdata)
|
||||
evtdata = evt
|
||||
elif isinstance(evtdata, basestring):
|
||||
elif isinstance(evtdata, str):
|
||||
try:
|
||||
cat = read_events(evtdata)
|
||||
if len(cat) is not 1:
|
||||
|
@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pylot.core.util.errors import ParameterError
|
||||
import default_parameters
|
||||
from pylot.core.io import default_parameters
|
||||
|
||||
class PylotParameter(object):
|
||||
'''
|
||||
|
@ -253,8 +253,8 @@ def picks_from_picksdict(picks, creation_info=None):
|
||||
lpp = phase['lpp']
|
||||
pick.time_errors.lower_uncertainty = onset - epp
|
||||
pick.time_errors.upper_uncertainty = lpp - onset
|
||||
except KeyError as e:
|
||||
warnings.warn(e.message, RuntimeWarning)
|
||||
except (KeyError, TypeError) as e:
|
||||
warnings.warn(str(e), RuntimeWarning)
|
||||
try:
|
||||
picker = phase['picker']
|
||||
except KeyError as e:
|
||||
@ -274,7 +274,7 @@ def picks_from_picksdict(picks, creation_info=None):
|
||||
else:
|
||||
pick.polarity = 'undecidable'
|
||||
except KeyError as e:
|
||||
if 'fm' in e.message: # no polarity information found for this phase
|
||||
if 'fm' in str(e): # no polarity information found for this phase
|
||||
pass
|
||||
else:
|
||||
raise e
|
||||
@ -360,7 +360,7 @@ def reassess_pilot_event(root_dir, db_dir, event_id, out_dir=None, fn_param=None
|
||||
default.get('nfac{0}'.format(phase)),
|
||||
default.get('tsnrz' if phase == 'P' else 'tsnrh'),
|
||||
Pick1=rel_pick,
|
||||
iplot=None,
|
||||
iplot=0,
|
||||
verbosity=0)
|
||||
if epp is None or lpp is None:
|
||||
continue
|
||||
|
@ -307,7 +307,7 @@ class HOScf(CharacteristicFunction):
|
||||
class ARZcf(CharacteristicFunction):
|
||||
def calcCF(self, data):
|
||||
|
||||
print 'Calculating AR-prediction error from single trace ...'
|
||||
print('Calculating AR-prediction error from single trace ...')
|
||||
x = self.getDataArray(self.getCut())
|
||||
xnp = x[0].data
|
||||
nn = np.isnan(xnp)
|
||||
@ -430,7 +430,7 @@ class ARZcf(CharacteristicFunction):
|
||||
class ARHcf(CharacteristicFunction):
|
||||
def calcCF(self, data):
|
||||
|
||||
print 'Calculating AR-prediction error from both horizontal traces ...'
|
||||
print('Calculating AR-prediction error from both horizontal traces ...')
|
||||
|
||||
xnp = self.getDataArray(self.getCut())
|
||||
n0 = np.isnan(xnp[0].data)
|
||||
@ -567,7 +567,7 @@ class ARHcf(CharacteristicFunction):
|
||||
class AR3Ccf(CharacteristicFunction):
|
||||
def calcCF(self, data):
|
||||
|
||||
print 'Calculating AR-prediction error from all 3 components ...'
|
||||
print('Calculating AR-prediction error from all 3 components ...')
|
||||
|
||||
xnp = self.getDataArray(self.getCut())
|
||||
n0 = np.isnan(xnp[0].data)
|
||||
|
@ -480,7 +480,7 @@ def main():
|
||||
Insheim = PDFstatistics(root_dir)
|
||||
Insheim.curphase = 'p'
|
||||
qdlist = Insheim.get('qdf', 0.2)
|
||||
print qdlist
|
||||
print(qdlist)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -34,7 +34,7 @@ class AutoPicker(object):
|
||||
|
||||
warnings.simplefilter('ignore')
|
||||
|
||||
def __init__(self, cf, TSNR, PickWindow, iplot=None, aus=None, Tsmooth=None, Pick1=None, fig=None):
|
||||
def __init__(self, cf, TSNR, PickWindow, iplot=0, aus=None, Tsmooth=None, Pick1=None, fig=None):
|
||||
'''
|
||||
:param: cf, characteristic function, on which the picking algorithm is applied
|
||||
:type: `~pylot.core.pick.CharFuns.CharacteristicFunction` object
|
||||
|
@ -14,7 +14,7 @@ import numpy as np
|
||||
from obspy.core import Stream, UTCDateTime
|
||||
|
||||
|
||||
def earllatepicker(X, nfac, TSNR, Pick1, iplot=None, verbosity=1, fig=None):
|
||||
def earllatepicker(X, nfac, TSNR, Pick1, iplot=0, verbosity=1, fig=None):
|
||||
'''
|
||||
Function to derive earliest and latest possible pick after Diehl & Kissling (2009)
|
||||
as reasonable uncertainties. Latest possible pick is based on noise level,
|
||||
@ -144,7 +144,7 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None, verbosity=1, fig=None):
|
||||
return EPick, LPick, PickError
|
||||
|
||||
|
||||
def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None, fig=None):
|
||||
def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=0, fig=None):
|
||||
'''
|
||||
Function to derive first motion (polarity) of given phase onset Pick.
|
||||
Calculation is based on zero crossings determined within time window pickwin
|
||||
@ -357,7 +357,7 @@ def getSNR(X, TSNR, t1, tracenum=0):
|
||||
assert isinstance(X, Stream), "%s is not a stream object" % str(X)
|
||||
|
||||
SNR = None
|
||||
SNRdb = None
|
||||
SNRdB = None
|
||||
noiselevel = None
|
||||
|
||||
x = X[tracenum].data
|
||||
@ -480,14 +480,15 @@ def getResolutionWindow(snr, extent):
|
||||
'global': {'HRW': 40., 'MRW': 100., 'LRW': 200., 'VLRW': 300.}
|
||||
}
|
||||
|
||||
if snr < 1.5:
|
||||
time_resolution = res_wins[extent]['VLRW']
|
||||
elif snr < 2.:
|
||||
time_resolution = res_wins[extent]['LRW']
|
||||
elif snr < 3.:
|
||||
time_resolution = res_wins[extent]['MRW']
|
||||
elif snr >3.:
|
||||
time_resolution = res_wins[extent]['HRW']
|
||||
if snr:
|
||||
if snr < 1.5:
|
||||
time_resolution = res_wins[extent]['VLRW']
|
||||
elif snr < 2.:
|
||||
time_resolution = res_wins[extent]['LRW']
|
||||
elif snr < 3.:
|
||||
time_resolution = res_wins[extent]['MRW']
|
||||
elif snr >3.:
|
||||
time_resolution = res_wins[extent]['HRW']
|
||||
else:
|
||||
time_resolution = res_wins[extent]['VLRW']
|
||||
|
||||
|
@ -15,7 +15,7 @@ from obspy.core import Stream, UTCDateTime
|
||||
import warnings
|
||||
|
||||
|
||||
def earllatepicker(X, nfac, TSNR, Pick1, iplot=None, stealthMode = False):
|
||||
def earllatepicker(X, nfac, TSNR, Pick1, iplot=0, stealthMode = False):
|
||||
'''
|
||||
Function to derive earliest and latest possible pick after Diehl & Kissling (2009)
|
||||
as reasonable uncertainties. Latest possible pick is based on noise level,
|
||||
@ -136,7 +136,7 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None, stealthMode = False):
|
||||
return EPick, LPick, PickError
|
||||
|
||||
|
||||
def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None):
|
||||
def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=0):
|
||||
'''
|
||||
Function to derive first motion (polarity) of given phase onset Pick.
|
||||
Calculation is based on zero crossings determined within time window pickwin
|
||||
|
@ -1,13 +1,16 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import urllib2
|
||||
try:
|
||||
from urllib2 import urlopen
|
||||
except:
|
||||
from urllib.request import urlopen
|
||||
|
||||
|
||||
def checkurl(url='https://ariadne.geophysik.rub.de/trac/PyLoT'):
|
||||
try:
|
||||
urllib2.urlopen(url, timeout=1)
|
||||
urlopen(url, timeout=1)
|
||||
return True
|
||||
except urllib2.URLError:
|
||||
except:
|
||||
pass
|
||||
return False
|
||||
|
@ -4,7 +4,6 @@
|
||||
import os
|
||||
import glob
|
||||
import sys
|
||||
from obspy.io.xseed import Parser
|
||||
|
||||
import numpy as np
|
||||
|
||||
@ -170,7 +169,7 @@ def read_metadata(path_to_inventory):
|
||||
invfile = list()
|
||||
respfile = list()
|
||||
# possible file extensions specified here:
|
||||
inv = dict(dless=dlfile, xml=invfile, resp=respfile, dseed=dlfile)
|
||||
inv = dict(dless=dlfile, xml=invfile, resp=respfile, dseed=dlfile[:])
|
||||
if os.path.isfile(path_to_inventory):
|
||||
ext = os.path.splitext(path_to_inventory)[1].split('.')[1]
|
||||
inv[ext] += [path_to_inventory]
|
||||
|
@ -19,6 +19,7 @@ class map_projection(QtGui.QWidget):
|
||||
'''
|
||||
QtGui.QWidget.__init__(self)
|
||||
self._parent = parent
|
||||
self.metadata = parent.metadata
|
||||
self.parser = parent.metadata[1]
|
||||
self.picks = None
|
||||
self.picks_dict = None
|
||||
|
@ -59,7 +59,7 @@ def exp_parameter(te, tm, tl, eta):
|
||||
return tm, sig1, sig2, a
|
||||
|
||||
|
||||
def gauss_branches(k, (mu, sig1, sig2, a1, a2)):
|
||||
def gauss_branches(k, param_tuple):
|
||||
'''
|
||||
function gauss_branches takes an axes x, a center value mu, two sigma
|
||||
values sig1 and sig2 and two scaling factors a1 and a2 and return a
|
||||
@ -79,6 +79,9 @@ def gauss_branches(k, (mu, sig1, sig2, a1, a2)):
|
||||
:returns fun_vals: list with function values along axes x
|
||||
'''
|
||||
|
||||
#python 3 workaround
|
||||
mu, sig1, sig2, a1, a2 = param_tuple
|
||||
|
||||
def _func(k, mu, sig1, sig2, a1, a2):
|
||||
if k < mu:
|
||||
rval = a1 * 1 / (np.sqrt(2 * np.pi) * sig1) * np.exp(-((k - mu) / sig1) ** 2 / 2)
|
||||
@ -93,7 +96,7 @@ def gauss_branches(k, (mu, sig1, sig2, a1, a2)):
|
||||
return _func(k, mu, sig1, sig2, a1, a2)
|
||||
|
||||
|
||||
def exp_branches(k, (mu, sig1, sig2, a)):
|
||||
def exp_branches(k, param_tuple):
|
||||
'''
|
||||
function exp_branches takes an axes x, a center value mu, two sigma
|
||||
values sig1 and sig2 and a scaling factor a and return a
|
||||
@ -107,6 +110,9 @@ def exp_branches(k, (mu, sig1, sig2, a)):
|
||||
:returns fun_vals: list with function values along axes x:
|
||||
'''
|
||||
|
||||
#python 3 workaround
|
||||
mu, sig1, sig2, a = param_tuple
|
||||
|
||||
def _func(k, mu, sig1, sig2, a):
|
||||
mu = float(mu)
|
||||
if k < mu:
|
||||
|
@ -5,7 +5,7 @@ import hashlib
|
||||
import numpy as np
|
||||
from scipy.interpolate import splrep, splev
|
||||
import os
|
||||
import pwd
|
||||
import platform
|
||||
import re
|
||||
import warnings
|
||||
import subprocess
|
||||
@ -258,7 +258,7 @@ def getLogin():
|
||||
returns the actual user's login ID
|
||||
:return: login ID
|
||||
'''
|
||||
return pwd.getpwuid(os.getuid())[0]
|
||||
return os.getlogin()
|
||||
|
||||
|
||||
def getOwner(fn):
|
||||
@ -268,7 +268,15 @@ def getOwner(fn):
|
||||
:type fn: str
|
||||
:return: login ID of the file's owner
|
||||
'''
|
||||
return pwd.getpwuid(os.stat(fn).st_uid).pw_name
|
||||
system_name = platform.system()
|
||||
if system_name in ["Linux", "Darwin"]:
|
||||
import pwd
|
||||
return pwd.getpwuid(os.stat(fn).st_uid).pw_name
|
||||
elif system_name == "Windows":
|
||||
import win32security
|
||||
f = win32security.GetFileSecurity(fn, win32security.OWNER_SECURITY_INFORMATION)
|
||||
(username, domain, sid_name_use) = win32security.LookupAccountSid(None, f.GetSecurityDescriptorOwner())
|
||||
return username
|
||||
|
||||
|
||||
def getPatternLine(fn, pattern):
|
||||
|
@ -6,6 +6,7 @@ Created on Wed Mar 19 11:27:35 2014
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import getpass
|
||||
import warnings
|
||||
import copy
|
||||
@ -47,7 +48,12 @@ from pylot.core.util.utils import prepTimeAxis, full_range, scaleWFData, \
|
||||
demeanTrace, isSorted, findComboBoxIndex, clims
|
||||
from autoPyLoT import autoPyLoT
|
||||
from pylot.core.util.thread import Thread
|
||||
import icons_rc
|
||||
if sys.version_info.major == 3:
|
||||
import icons_rc_3 as icons_rc
|
||||
elif sys.version_info.major == 2:
|
||||
import icons_rc_2 as icons_rc
|
||||
else:
|
||||
raise ImportError('Could not determine python version.')
|
||||
|
||||
if pg:
|
||||
pg.setConfigOption('background', 'w')
|
||||
@ -70,9 +76,9 @@ def plot_pdf(_axes, x, y, annotation, bbox_props, xlabel=None, ylabel=None,
|
||||
title=None):
|
||||
# try method or data
|
||||
try:
|
||||
_axes.plot(x, y()) # y provided as method
|
||||
_axes.plot(x, y()) # y provided as method
|
||||
except:
|
||||
_axes.plot(x, y) # y provided as data
|
||||
_axes.plot(x, y) # y provided as data
|
||||
|
||||
if title:
|
||||
_axes.set_title(title)
|
||||
@ -462,7 +468,7 @@ class WaveformWidgetPG(QtGui.QWidget):
|
||||
|
||||
def plotWFData(self, wfdata, title=None, zoomx=None, zoomy=None,
|
||||
noiselevel=None, scaleddata=False, mapping=True,
|
||||
component='*', nth_sample=1, iniPick=None):
|
||||
component='*', nth_sample=1, iniPick=None, verbosity=0):
|
||||
self.title = title
|
||||
self.clearPlotDict()
|
||||
wfstart, wfend = full_range(wfdata)
|
||||
@ -509,11 +515,12 @@ class WaveformWidgetPG(QtGui.QWidget):
|
||||
if n > nmax:
|
||||
nmax = n
|
||||
msg = 'plotting %s channel of station %s' % (channel, station)
|
||||
print(msg)
|
||||
if verbosity:
|
||||
print(msg)
|
||||
stime = trace.stats.starttime - wfstart
|
||||
time_ax = prepTimeAxis(stime, trace)
|
||||
if time_ax is not None:
|
||||
if not scaleddata:
|
||||
if not scaleddata:
|
||||
trace.detrend('constant')
|
||||
trace.normalize(np.max(np.abs(trace.data)) * 2)
|
||||
times = [time for index, time in enumerate(time_ax) if not index%nth_sample]
|
||||
@ -653,7 +660,7 @@ class WaveformWidget(FigureCanvas):
|
||||
stime = trace.stats.starttime - wfstart
|
||||
time_ax = prepTimeAxis(stime, trace)
|
||||
if time_ax is not None:
|
||||
if not scaleddata:
|
||||
if not scaleddata:
|
||||
trace.detrend('constant')
|
||||
trace.normalize(np.max(np.abs(trace.data)) * 2)
|
||||
times = [time for index, time in enumerate(time_ax) if not index%nth_sample]
|
||||
@ -696,7 +703,7 @@ class WaveformWidget(FigureCanvas):
|
||||
self.getAxes().set_ylim(lims)
|
||||
|
||||
def setYTickLabels(self, pos, labels):
|
||||
self.getAxes().set_yticks(pos)
|
||||
self.getAxes().set_yticks(list(pos))
|
||||
self.getAxes().set_yticklabels(labels)
|
||||
self.draw()
|
||||
|
||||
@ -822,7 +829,7 @@ class PickDlg(QDialog):
|
||||
self.drawArrivals()
|
||||
except Exception as e:
|
||||
print('Warning: Could not init expected picks from taup: {}'.format(e))
|
||||
|
||||
|
||||
def setupUi(self):
|
||||
menuBar = QtGui.QMenuBar(self)
|
||||
if not self._embedded:
|
||||
@ -865,7 +872,7 @@ class PickDlg(QDialog):
|
||||
tip='Delete current picks.')
|
||||
|
||||
# create other widget elements
|
||||
phaseitems = [None] + FILTERDEFAULTS.keys()
|
||||
phaseitems = [None] + list(FILTERDEFAULTS.keys())
|
||||
|
||||
# create buttons for P and S filter and picking
|
||||
self.p_button = QPushButton('P', self)
|
||||
@ -945,7 +952,11 @@ class PickDlg(QDialog):
|
||||
station_id = self.data.traces[0].get_id()
|
||||
parser = self.parent().metadata[1]
|
||||
station_coords = parser.get_coordinates(station_id)
|
||||
source_origin = self.parent().get_current_event().origins[0]
|
||||
origins = self.parent().get_current_event().origins
|
||||
if origins:
|
||||
source_origin = origins[0]
|
||||
else:
|
||||
raise ValueError('No source origin given.')
|
||||
arrivals = self.model.get_travel_times_geo(source_origin.depth,
|
||||
source_origin.latitude,
|
||||
source_origin.longitude,
|
||||
@ -1348,8 +1359,13 @@ class PickDlg(QDialog):
|
||||
phase = self.currentPhase
|
||||
filteroptions = self.getFilterOptions(phase[0]).parseFilterOptions()
|
||||
if filteroptions:
|
||||
data.filter(**filteroptions)
|
||||
wfdata.filter(**filteroptions)
|
||||
try:
|
||||
data.filter(**filteroptions)
|
||||
wfdata.filter(**filteroptions)
|
||||
except ValueError as e:
|
||||
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information,
|
||||
'Denied', 'setIniPickP: Could not filter waveform: {}'.format(e))
|
||||
self.qmb.show()
|
||||
|
||||
result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick-stime_diff, itrace)
|
||||
|
||||
@ -1401,8 +1417,13 @@ class PickDlg(QDialog):
|
||||
phase = self.currentPhase
|
||||
filteroptions = self.getFilterOptions(phase).parseFilterOptions()
|
||||
if filteroptions:
|
||||
data.filter(**filteroptions)
|
||||
wfdata.filter(**filteroptions)
|
||||
try:
|
||||
data.filter(**filteroptions)
|
||||
wfdata.filter(**filteroptions)
|
||||
except ValueError as e:
|
||||
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information,
|
||||
'Denied', 'setIniPickS: Could not filter waveform: {}'.format(e))
|
||||
self.qmb.show()
|
||||
|
||||
# determine SNR and noiselevel
|
||||
result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick-stime_diff)
|
||||
@ -1463,7 +1484,14 @@ class PickDlg(QDialog):
|
||||
# copy and filter data for earliest and latest possible picks
|
||||
wfdata = self.getWFData().copy().select(channel=channel)
|
||||
if filteroptions:
|
||||
wfdata.filter(**filteroptions)
|
||||
try:
|
||||
wfdata.filter(**filteroptions)
|
||||
except ValueError as e:
|
||||
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information,
|
||||
'Denied', 'setPick: Could not filter waveform: {}'.format(e))
|
||||
self.qmb.show()
|
||||
|
||||
|
||||
|
||||
# get earliest and latest possible pick and symmetric pick error
|
||||
if wfdata[0].stats.channel[2] == 'Z' or wfdata[0].stats.channel[2] == '3':
|
||||
@ -2736,7 +2764,7 @@ class InputsTab(PropTab):
|
||||
|
||||
from pylot.core.util.structure import DATASTRUCTURE
|
||||
|
||||
self.structureSelect.addItems(DATASTRUCTURE.keys())
|
||||
self.structureSelect.addItems(list(DATASTRUCTURE.keys()))
|
||||
|
||||
dsind = findComboBoxIndex(self.structureSelect, curstructure)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user