[merge] merged changes in QtPyLoT manually

This commit is contained in:
Marcel Paffrath 2017-07-17 11:38:50 +02:00
commit 7f0ab4dd94
19 changed files with 196580 additions and 98416 deletions

View File

@ -25,6 +25,7 @@ https://www.iconfinder.com/iconsets/flavour
import os import os
import sys import sys
import platform
import argparse import argparse
import matplotlib import matplotlib
@ -41,7 +42,7 @@ from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
QTreeView, QComboBox, QTabWidget, QPushButton, QGridLayout QTreeView, QComboBox, QTabWidget, QPushButton, QGridLayout
import numpy as np import numpy as np
from obspy import UTCDateTime from obspy import UTCDateTime
from obspy.core.event import Magnitude from obspy.core.event import Magnitude, Origin
from obspy.core.util import AttribDict from obspy.core.util import AttribDict
try: try:
@ -82,7 +83,13 @@ from pylot.core.util.map_projection import map_projection
from pylot.core.util.structure import DATASTRUCTURE from pylot.core.util.structure import DATASTRUCTURE
from pylot.core.util.thread import AutoPickThread, Thread from pylot.core.util.thread import AutoPickThread, Thread
from pylot.core.util.version import get_git_version as _getVersionString from pylot.core.util.version import get_git_version as _getVersionString
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.')
locateTool = dict(nll=nll) locateTool = dict(nll=nll)
@ -602,12 +609,10 @@ class MainWindow(QMainWindow):
def metadata(self): def metadata(self):
return self._metadata return self._metadata
@metadata.setter @metadata.setter
def metadata(self, value): def metadata(self, value):
self._metadata = value self._metadata = value
def updateFileMenu(self): def updateFileMenu(self):
self.fileMenu.clear() self.fileMenu.clear()
@ -711,7 +716,7 @@ class MainWindow(QMainWindow):
event = self.get_current_event() event = self.get_current_event()
data = Data(self, event) data = Data(self, event)
try: try:
data_new = Data(self, evtdata=fname) data_new = Data(self, evtdata=str(fname))
data += data_new data += data_new
except ValueError: except ValueError:
qmb = QMessageBox(self, icon=QMessageBox.Question, qmb = QMessageBox(self, icon=QMessageBox.Question,
@ -857,11 +862,21 @@ class MainWindow(QMainWindow):
# get path from first event in list and split them # get path from first event in list and split them
path = eventlist[0] path = eventlist[0]
try: try:
system_name = platform.system()
if system_name in ["Linux", "Darwin"]:
dirs = { dirs = {
'database': path.split('/')[-2], 'database': path.split('/')[-2],
'datapath': path.split('/')[-3], 'datapath': path.split('/')[-3],
'rootpath': '/' + os.path.join(*path.split('/')[:-3]) 'rootpath': '/' + os.path.join(*path.split('/')[:-3])
} }
elif system_name == "Windows":
rootpath = path.split('/')[:-3]
rootpath[0] += '/'
dirs = {
'database': path.split('/')[-2],
'datapath': path.split('/')[-3],
'rootpath': os.path.join(*rootpath)
}
except Exception as e: except Exception as e:
dirs = { dirs = {
'database': '', 'database': '',
@ -1059,17 +1074,6 @@ class MainWindow(QMainWindow):
filename = 'PyLoT_' + eventname filename = 'PyLoT_' + eventname
outpath = os.path.join(directory, filename) outpath = os.path.join(directory, filename)
title = 'Save pick data ...' title = 'Save pick data ...'
#if not outformat:
# outformat = settings.value('output/Format')
# outformat = outformat[0:4]
#else:
# selected_filter = "NonLinLoc observation file (*.obs)"
# fname = outpath
#if outformat == '.obs':
# file_filter = "NonLinLoc observation file (*.obs)"
#elif outformat == '.cnv':
# file_filter = "VELEST observation file format (*.cnv)"
#elif outformat == '.xml':
file_filter = "(*.xml *.obs *.cnv)" file_filter = "(*.xml *.obs *.cnv)"
if dlgflag == 1: if dlgflag == 1:
@ -1078,12 +1082,11 @@ class MainWindow(QMainWindow):
outpath, outpath,
file_filter) file_filter)
#fbasename, exform = os.path.splitext(fname) try:
fbasename = fname fbasename = fname
except:
fbasename = outpath
exform = ['.obs', '.xml', '.cnv'] exform = ['.obs', '.xml', '.cnv']
#if not exform and selected_filter or not exform in OUTPUTFORMATS:
# exform = selected_filter.split('*')[1][:-1]
# return fname, exform
return fbasename, exform return fbasename, exform
settings = QSettings() settings = QSettings()
@ -1225,7 +1228,8 @@ class MainWindow(QMainWindow):
def okToContinue(self): def okToContinue(self):
if self.dirty: if self.dirty:
qmb = QMessageBox(self, icon=QMessageBox.Question, text='Do you wish to save changes in the current project?') qmb = QMessageBox(self, icon=QMessageBox.Question,
text='Do you wish to save changes in the current project?')
qmb.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) qmb.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
qmb.setDefaultButton(QMessageBox.Save) qmb.setDefaultButton(QMessageBox.Save)
ret = qmb.exec_() ret = qmb.exec_()
@ -1351,13 +1355,13 @@ class MainWindow(QMainWindow):
call modal plot thread method when finished. call modal plot thread method when finished.
''' '''
if load: if load:
wfd_thread = Thread(self, self.loadWaveformData, self.wfd_thread = Thread(self, self.loadWaveformData,
progressText='Reading data input...') progressText='Reading data input...')
if load and plot: if load and plot:
wfd_thread.finished.connect(self.plotWaveformDataThread) self.wfd_thread.finished.connect(self.plotWaveformDataThread)
if load: if load:
wfd_thread.start() self.wfd_thread.start()
if plot and not load: if plot and not load:
self.plotWaveformDataThread() self.plotWaveformDataThread()
@ -1519,7 +1523,8 @@ class MainWindow(QMainWindow):
# wfst += self.get_data().getWFData().select(component=alter_comp) # wfst += self.get_data().getWFData().select(component=alter_comp)
plotWidget = self.getPlotWidget() plotWidget = self.getPlotWidget()
self.adjustPlotHeight() self.adjustPlotHeight()
plots = plotWidget.plotWFData(wfdata=wfst, title=title, mapping=False, component=comp, nth_sample=int(nth_sample)) plots = plotWidget.plotWFData(wfdata=wfst, title=title, mapping=False, component=comp,
nth_sample=int(nth_sample))
return plots return plots
def adjustPlotHeight(self): def adjustPlotHeight(self):
@ -1920,8 +1925,10 @@ class MainWindow(QMainWindow):
dashed = QtCore.Qt.DashLine dashed = QtCore.Qt.DashLine
dotted = QtCore.Qt.DotLine dotted = QtCore.Qt.DotLine
phase_col = { phase_col = {
'P': (pg.mkPen('c'), pg.mkPen((0, 255, 255, 100), style=dashed), pg.mkPen('b', style=dashed), pg.mkPen('b', style=dotted)), 'P': (pg.mkPen('c'), pg.mkPen((0, 255, 255, 100), style=dashed), pg.mkPen('b', style=dashed),
'S': (pg.mkPen('m'), pg.mkPen((255, 0, 255, 100), style=dashed), pg.mkPen('r', style=dashed), pg.mkPen('r', style=dotted)) pg.mkPen('b', style=dotted)),
'S': (pg.mkPen('m'), pg.mkPen((255, 0, 255, 100), style=dashed), pg.mkPen('r', style=dashed),
pg.mkPen('r', style=dotted))
} }
else: else:
phase_col = { phase_col = {
@ -1943,6 +1950,9 @@ class MainWindow(QMainWindow):
if picks['epp'] and picks['lpp']: if picks['epp'] and picks['lpp']:
epp = picks['epp'] - stime epp = picks['epp'] - stime
lpp = picks['lpp'] - stime lpp = picks['lpp'] - stime
else:
epp = None
lpp = None
spe = picks['spe'] spe = picks['spe']
if not spe and epp and lpp: if not spe and epp and lpp:
@ -1956,7 +1966,8 @@ class MainWindow(QMainWindow):
pw.plot([lpp, lpp], ylims, pw.plot([lpp, lpp], ylims,
alpha=.25, pen=colors[0], name='LPP') alpha=.25, pen=colors[0], name='LPP')
if spe: if spe:
spe_l = pg.PlotDataItem([mpp - spe, mpp - spe], ylims, pen=colors[1], name='{}-SPE'.format(phase)) spe_l = pg.PlotDataItem([mpp - spe, mpp - spe], ylims, pen=colors[1],
name='{}-SPE'.format(phase))
spe_r = pg.PlotDataItem([mpp + spe, mpp + spe], ylims, pen=colors[1]) spe_r = pg.PlotDataItem([mpp + spe, mpp + spe], ylims, pen=colors[1])
pw.addItem(spe_l) pw.addItem(spe_l)
pw.addItem(spe_r) pw.addItem(spe_r)
@ -2151,6 +2162,7 @@ class MainWindow(QMainWindow):
''' '''
Build and initiate event table (3rd tab [index=2]) containing information of every event. Build and initiate event table (3rd tab [index=2]) containing information of every event.
''' '''
def set_enabled(item, enabled=True, checkable=False): def set_enabled(item, enabled=True, checkable=False):
# modify item flags depending on case needed # modify item flags depending on case needed
if enabled and not checkable: if enabled and not checkable:
@ -2352,10 +2364,12 @@ class MainWindow(QMainWindow):
# if not rest_flag: # if not rest_flag:
# raise ProcessingError('Restitution of waveform data failed!') # raise ProcessingError('Restitution of waveform data failed!')
if type == 'ML': if type == 'ML':
local_mag = LocalMagnitude(corr_wf, self.get_data().get_evt_data(), self.inputs.get('sstop'), verbosity = True) local_mag = LocalMagnitude(corr_wf, self.get_data().get_evt_data(), self.inputs.get('sstop'),
verbosity=True)
return local_mag.updated_event() return local_mag.updated_event()
elif type == 'Mw': elif type == 'Mw':
moment_mag = MomentMagnitude(corr_wf, self.get_data().get_evt_data(), self.inputs.get('vp'), self.inputs.get('Qp'), self.inputs.get('rho'), verbosity = True) moment_mag = MomentMagnitude(corr_wf, self.get_data().get_evt_data(), self.inputs.get('vp'),
self.inputs.get('Qp'), self.inputs.get('rho'), verbosity=True)
return moment_mag.updated_event() return moment_mag.updated_event()
else: else:
return None return None
@ -2558,6 +2572,7 @@ class Project(object):
''' '''
Pickable class containing information of a QtPyLoT project, like event lists and file locations. Pickable class containing information of a QtPyLoT project, like event lists and file locations.
''' '''
def __init__(self): def __init__(self):
self.eventlist = [] self.eventlist = []
self.location = None self.location = None
@ -2610,13 +2625,17 @@ class Project(object):
print(e, datetime, filename) print(e, datetime, filename)
continue continue
for event in self.eventlist: for event in self.eventlist:
if not event.origins: if event.origins:
continue
origin = event.origins[0] # should have only one origin origin = event.origins[0] # should have only one origin
if origin.time == datetime: if origin.time == datetime:
origin.latitude = float(lat) origin.latitude = float(lat)
origin.longitude = float(lon) origin.longitude = float(lon)
origin.depth = float(depth) origin.depth = float(depth)
elif not event.origins:
origin = Origin(resource_id=event.resource_id,
time=datetime, latitude=float(lat),
longitude=float(lon), depth=float(depth))
event.origins.append(origin)
event.magnitudes.append(Magnitude(resource_id=event.resource_id, event.magnitudes.append(Magnitude(resource_id=event.resource_id,
mag=float(mag), mag=float(mag),
mag_type='M')) mag_type='M'))
@ -2704,6 +2723,7 @@ class getExistingDirectories(QFileDialog):
''' '''
File dialog with possibility to select multiple folders. File dialog with possibility to select multiple folders.
''' '''
def __init__(self, *args): def __init__(self, *args):
super(getExistingDirectories, self).__init__(*args) super(getExistingDirectories, self).__init__(*args)
self.setOption(self.DontUseNativeDialog, True) self.setOption(self.DontUseNativeDialog, True)

98097
icons_rc_3.py Normal file

File diff suppressed because it is too large Load Diff

1
pylot/RELEASE-VERSION Normal file
View File

@ -0,0 +1 @@
b286-dirty

View File

@ -39,7 +39,7 @@ class Data(object):
elif isinstance(evtdata, dict): elif isinstance(evtdata, dict):
evt = readPILOTEvent(**evtdata) evt = readPILOTEvent(**evtdata)
evtdata = evt evtdata = evt
elif isinstance(evtdata, basestring): elif isinstance(evtdata, str):
try: try:
cat = read_events(evtdata) cat = read_events(evtdata)
if len(cat) is not 1: if len(cat) is not 1:

View File

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from pylot.core.util.errors import ParameterError from pylot.core.util.errors import ParameterError
import default_parameters from pylot.core.io import default_parameters
class PylotParameter(object): class PylotParameter(object):
''' '''

View File

@ -253,8 +253,8 @@ def picks_from_picksdict(picks, creation_info=None):
lpp = phase['lpp'] lpp = phase['lpp']
pick.time_errors.lower_uncertainty = onset - epp pick.time_errors.lower_uncertainty = onset - epp
pick.time_errors.upper_uncertainty = lpp - onset pick.time_errors.upper_uncertainty = lpp - onset
except KeyError as e: except (KeyError, TypeError) as e:
warnings.warn(e.message, RuntimeWarning) warnings.warn(str(e), RuntimeWarning)
try: try:
picker = phase['picker'] picker = phase['picker']
except KeyError as e: except KeyError as e:
@ -274,7 +274,7 @@ def picks_from_picksdict(picks, creation_info=None):
else: else:
pick.polarity = 'undecidable' pick.polarity = 'undecidable'
except KeyError as e: 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 pass
else: else:
raise e 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('nfac{0}'.format(phase)),
default.get('tsnrz' if phase == 'P' else 'tsnrh'), default.get('tsnrz' if phase == 'P' else 'tsnrh'),
Pick1=rel_pick, Pick1=rel_pick,
iplot=None, iplot=0,
verbosity=0) verbosity=0)
if epp is None or lpp is None: if epp is None or lpp is None:
continue continue

View File

@ -307,7 +307,7 @@ class HOScf(CharacteristicFunction):
class ARZcf(CharacteristicFunction): class ARZcf(CharacteristicFunction):
def calcCF(self, data): 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()) x = self.getDataArray(self.getCut())
xnp = x[0].data xnp = x[0].data
nn = np.isnan(xnp) nn = np.isnan(xnp)
@ -430,7 +430,7 @@ class ARZcf(CharacteristicFunction):
class ARHcf(CharacteristicFunction): class ARHcf(CharacteristicFunction):
def calcCF(self, data): 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()) xnp = self.getDataArray(self.getCut())
n0 = np.isnan(xnp[0].data) n0 = np.isnan(xnp[0].data)
@ -567,7 +567,7 @@ class ARHcf(CharacteristicFunction):
class AR3Ccf(CharacteristicFunction): class AR3Ccf(CharacteristicFunction):
def calcCF(self, data): 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()) xnp = self.getDataArray(self.getCut())
n0 = np.isnan(xnp[0].data) n0 = np.isnan(xnp[0].data)

View File

@ -480,7 +480,7 @@ def main():
Insheim = PDFstatistics(root_dir) Insheim = PDFstatistics(root_dir)
Insheim.curphase = 'p' Insheim.curphase = 'p'
qdlist = Insheim.get('qdf', 0.2) qdlist = Insheim.get('qdf', 0.2)
print qdlist print(qdlist)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -34,7 +34,7 @@ class AutoPicker(object):
warnings.simplefilter('ignore') 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 :param: cf, characteristic function, on which the picking algorithm is applied
:type: `~pylot.core.pick.CharFuns.CharacteristicFunction` object :type: `~pylot.core.pick.CharFuns.CharacteristicFunction` object

View File

@ -14,7 +14,7 @@ import numpy as np
from obspy.core import Stream, UTCDateTime 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) Function to derive earliest and latest possible pick after Diehl & Kissling (2009)
as reasonable uncertainties. Latest possible pick is based on noise level, 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 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. Function to derive first motion (polarity) of given phase onset Pick.
Calculation is based on zero crossings determined within time window pickwin 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) assert isinstance(X, Stream), "%s is not a stream object" % str(X)
SNR = None SNR = None
SNRdb = None SNRdB = None
noiselevel = None noiselevel = None
x = X[tracenum].data x = X[tracenum].data
@ -480,6 +480,7 @@ def getResolutionWindow(snr, extent):
'global': {'HRW': 40., 'MRW': 100., 'LRW': 200., 'VLRW': 300.} 'global': {'HRW': 40., 'MRW': 100., 'LRW': 200., 'VLRW': 300.}
} }
if snr:
if snr < 1.5: if snr < 1.5:
time_resolution = res_wins[extent]['VLRW'] time_resolution = res_wins[extent]['VLRW']
elif snr < 2.: elif snr < 2.:

View File

@ -15,7 +15,7 @@ from obspy.core import Stream, UTCDateTime
import warnings 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) Function to derive earliest and latest possible pick after Diehl & Kissling (2009)
as reasonable uncertainties. Latest possible pick is based on noise level, 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 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. Function to derive first motion (polarity) of given phase onset Pick.
Calculation is based on zero crossings determined within time window pickwin Calculation is based on zero crossings determined within time window pickwin

View File

@ -1,13 +1,16 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- 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'): def checkurl(url='https://ariadne.geophysik.rub.de/trac/PyLoT'):
try: try:
urllib2.urlopen(url, timeout=1) urlopen(url, timeout=1)
return True return True
except urllib2.URLError: except:
pass pass
return False return False

View File

@ -4,7 +4,6 @@
import os import os
import glob import glob
import sys import sys
from obspy.io.xseed import Parser
import numpy as np import numpy as np
@ -170,7 +169,7 @@ def read_metadata(path_to_inventory):
invfile = list() invfile = list()
respfile = list() respfile = list()
# possible file extensions specified here: # 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): if os.path.isfile(path_to_inventory):
ext = os.path.splitext(path_to_inventory)[1].split('.')[1] ext = os.path.splitext(path_to_inventory)[1].split('.')[1]
inv[ext] += [path_to_inventory] inv[ext] += [path_to_inventory]

View File

@ -19,6 +19,7 @@ class map_projection(QtGui.QWidget):
''' '''
QtGui.QWidget.__init__(self) QtGui.QWidget.__init__(self)
self._parent = parent self._parent = parent
self.metadata = parent.metadata
self.parser = parent.metadata[1] self.parser = parent.metadata[1]
self.picks = None self.picks = None
self.picks_dict = None self.picks_dict = None

View File

@ -59,7 +59,7 @@ def exp_parameter(te, tm, tl, eta):
return tm, sig1, sig2, a 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 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 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 :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): def _func(k, mu, sig1, sig2, a1, a2):
if k < mu: if k < mu:
rval = a1 * 1 / (np.sqrt(2 * np.pi) * sig1) * np.exp(-((k - mu) / sig1) ** 2 / 2) 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) 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 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 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: :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): def _func(k, mu, sig1, sig2, a):
mu = float(mu) mu = float(mu)
if k < mu: if k < mu:

View File

@ -5,7 +5,7 @@ import hashlib
import numpy as np import numpy as np
from scipy.interpolate import splrep, splev from scipy.interpolate import splrep, splev
import os import os
import pwd import platform
import re import re
import warnings import warnings
import subprocess import subprocess
@ -258,7 +258,7 @@ def getLogin():
returns the actual user's login ID returns the actual user's login ID
:return: login ID :return: login ID
''' '''
return pwd.getpwuid(os.getuid())[0] return os.getlogin()
def getOwner(fn): def getOwner(fn):
@ -268,7 +268,15 @@ def getOwner(fn):
:type fn: str :type fn: str
:return: login ID of the file's owner :return: login ID of the file's owner
''' '''
system_name = platform.system()
if system_name in ["Linux", "Darwin"]:
import pwd
return pwd.getpwuid(os.stat(fn).st_uid).pw_name 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): def getPatternLine(fn, pattern):

View File

@ -6,6 +6,7 @@ Created on Wed Mar 19 11:27:35 2014
""" """
import os import os
import sys
import getpass import getpass
import warnings import warnings
import copy import copy
@ -47,7 +48,12 @@ from pylot.core.util.utils import prepTimeAxis, full_range, scaleWFData, \
demeanTrace, isSorted, findComboBoxIndex, clims demeanTrace, isSorted, findComboBoxIndex, clims
from autoPyLoT import autoPyLoT from autoPyLoT import autoPyLoT
from pylot.core.util.thread import Thread 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: if pg:
pg.setConfigOption('background', 'w') pg.setConfigOption('background', 'w')
@ -462,7 +468,7 @@ class WaveformWidgetPG(QtGui.QWidget):
def plotWFData(self, wfdata, title=None, zoomx=None, zoomy=None, def plotWFData(self, wfdata, title=None, zoomx=None, zoomy=None,
noiselevel=None, scaleddata=False, mapping=True, noiselevel=None, scaleddata=False, mapping=True,
component='*', nth_sample=1, iniPick=None): component='*', nth_sample=1, iniPick=None, verbosity=0):
self.title = title self.title = title
self.clearPlotDict() self.clearPlotDict()
wfstart, wfend = full_range(wfdata) wfstart, wfend = full_range(wfdata)
@ -509,6 +515,7 @@ class WaveformWidgetPG(QtGui.QWidget):
if n > nmax: if n > nmax:
nmax = n nmax = n
msg = 'plotting %s channel of station %s' % (channel, station) msg = 'plotting %s channel of station %s' % (channel, station)
if verbosity:
print(msg) print(msg)
stime = trace.stats.starttime - wfstart stime = trace.stats.starttime - wfstart
time_ax = prepTimeAxis(stime, trace) time_ax = prepTimeAxis(stime, trace)
@ -696,7 +703,7 @@ class WaveformWidget(FigureCanvas):
self.getAxes().set_ylim(lims) self.getAxes().set_ylim(lims)
def setYTickLabels(self, pos, labels): def setYTickLabels(self, pos, labels):
self.getAxes().set_yticks(pos) self.getAxes().set_yticks(list(pos))
self.getAxes().set_yticklabels(labels) self.getAxes().set_yticklabels(labels)
self.draw() self.draw()
@ -865,7 +872,7 @@ class PickDlg(QDialog):
tip='Delete current picks.') tip='Delete current picks.')
# create other widget elements # create other widget elements
phaseitems = [None] + FILTERDEFAULTS.keys() phaseitems = [None] + list(FILTERDEFAULTS.keys())
# create buttons for P and S filter and picking # create buttons for P and S filter and picking
self.p_button = QPushButton('P', self) self.p_button = QPushButton('P', self)
@ -945,7 +952,11 @@ class PickDlg(QDialog):
station_id = self.data.traces[0].get_id() station_id = self.data.traces[0].get_id()
parser = self.parent().metadata[1] parser = self.parent().metadata[1]
station_coords = parser.get_coordinates(station_id) 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, arrivals = self.model.get_travel_times_geo(source_origin.depth,
source_origin.latitude, source_origin.latitude,
source_origin.longitude, source_origin.longitude,
@ -1348,8 +1359,13 @@ class PickDlg(QDialog):
phase = self.currentPhase phase = self.currentPhase
filteroptions = self.getFilterOptions(phase[0]).parseFilterOptions() filteroptions = self.getFilterOptions(phase[0]).parseFilterOptions()
if filteroptions: if filteroptions:
try:
data.filter(**filteroptions) data.filter(**filteroptions)
wfdata.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) result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick-stime_diff, itrace)
@ -1401,8 +1417,13 @@ class PickDlg(QDialog):
phase = self.currentPhase phase = self.currentPhase
filteroptions = self.getFilterOptions(phase).parseFilterOptions() filteroptions = self.getFilterOptions(phase).parseFilterOptions()
if filteroptions: if filteroptions:
try:
data.filter(**filteroptions) data.filter(**filteroptions)
wfdata.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 # determine SNR and noiselevel
result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick-stime_diff) 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 # copy and filter data for earliest and latest possible picks
wfdata = self.getWFData().copy().select(channel=channel) wfdata = self.getWFData().copy().select(channel=channel)
if filteroptions: if filteroptions:
try:
wfdata.filter(**filteroptions) 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 # get earliest and latest possible pick and symmetric pick error
if wfdata[0].stats.channel[2] == 'Z' or wfdata[0].stats.channel[2] == '3': 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 from pylot.core.util.structure import DATASTRUCTURE
self.structureSelect.addItems(DATASTRUCTURE.keys()) self.structureSelect.addItems(list(DATASTRUCTURE.keys()))
dsind = findComboBoxIndex(self.structureSelect, curstructure) dsind = findComboBoxIndex(self.structureSelect, curstructure)