WALL-E: Einmal aufräumen und zurück!
This commit is contained in:
@@ -11,6 +11,7 @@ from pylot.core.loc import nll
|
||||
from pylot.core.loc import hsat
|
||||
from pylot.core.loc import velest
|
||||
|
||||
|
||||
def readFilterInformation(fname):
|
||||
def convert2FreqRange(*args):
|
||||
if len(args) > 1:
|
||||
@@ -18,6 +19,7 @@ def readFilterInformation(fname):
|
||||
elif len(args) == 1:
|
||||
return float(args[0])
|
||||
return None
|
||||
|
||||
filter_file = open(fname, 'r')
|
||||
filter_information = dict()
|
||||
for filter_line in filter_file.readlines():
|
||||
@@ -26,14 +28,14 @@ def readFilterInformation(fname):
|
||||
if pos == '\n':
|
||||
filter_line[n] = ''
|
||||
filter_information[filter_line[0]] = {'filtertype': filter_line[1]
|
||||
if filter_line[1]
|
||||
else None,
|
||||
if filter_line[1]
|
||||
else None,
|
||||
'order': int(filter_line[2])
|
||||
if filter_line[1]
|
||||
else None,
|
||||
if filter_line[1]
|
||||
else None,
|
||||
'freq': convert2FreqRange(*filter_line[3:])
|
||||
if filter_line[1]
|
||||
else None}
|
||||
if filter_line[1]
|
||||
else None}
|
||||
return filter_information
|
||||
|
||||
|
||||
@@ -41,15 +43,15 @@ FILTERDEFAULTS = readFilterInformation(os.path.join(os.path.expanduser('~'),
|
||||
'.pylot',
|
||||
'filter.in'))
|
||||
|
||||
OUTPUTFORMATS = {'.xml':'QUAKEML',
|
||||
'.cnv':'CNV',
|
||||
'.obs':'NLLOC_OBS'}
|
||||
OUTPUTFORMATS = {'.xml': 'QUAKEML',
|
||||
'.cnv': 'CNV',
|
||||
'.obs': 'NLLOC_OBS'}
|
||||
|
||||
LOCTOOLS = dict(nll = nll, hsat = hsat, velest = velest)
|
||||
LOCTOOLS = dict(nll=nll, hsat=hsat, velest=velest)
|
||||
|
||||
COMPPOSITION_MAP = dict(Z = 2, N = 1, E = 0)
|
||||
COMPPOSITION_MAP = dict(Z=2, N=1, E=0)
|
||||
COMPPOSITION_MAP['1'] = 1
|
||||
COMPPOSITION_MAP['2'] = 0
|
||||
COMPPOSITION_MAP['3'] = 2
|
||||
|
||||
COMPNAME_MAP = dict(Z = '3', N = '1', E = '2')
|
||||
COMPNAME_MAP = dict(Z='3', N='1', E='2')
|
||||
|
||||
@@ -21,5 +21,6 @@ class DatastructureError(Exception):
|
||||
class OverwriteError(IOError):
|
||||
pass
|
||||
|
||||
|
||||
class ParameterError(Exception):
|
||||
pass
|
||||
pass
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import sys
|
||||
from PySide.QtCore import QThread, Signal
|
||||
|
||||
|
||||
class AutoPickThread(QThread):
|
||||
message = Signal(str)
|
||||
finished = Signal()
|
||||
@@ -28,6 +29,5 @@ class AutoPickThread(QThread):
|
||||
sys.stdout = sys.__stdout__
|
||||
self.finished.emit()
|
||||
|
||||
|
||||
def write(self, text):
|
||||
self.message.emit(text)
|
||||
|
||||
@@ -10,6 +10,7 @@ import numpy as np
|
||||
from obspy.core import UTCDateTime
|
||||
import obspy.core.event as ope
|
||||
|
||||
|
||||
def createAmplitude(pickID, amp, unit, category, cinfo):
|
||||
'''
|
||||
|
||||
@@ -28,6 +29,7 @@ def createAmplitude(pickID, amp, unit, category, cinfo):
|
||||
amplitude.pick_id = pickID
|
||||
return amplitude
|
||||
|
||||
|
||||
def createArrival(pickresID, cinfo, phase, azimuth=None, dist=None):
|
||||
'''
|
||||
createArrival - function to create an Obspy Arrival
|
||||
@@ -56,6 +58,7 @@ def createArrival(pickresID, cinfo, phase, azimuth=None, dist=None):
|
||||
arrival.distance = dist
|
||||
return arrival
|
||||
|
||||
|
||||
def createCreationInfo(agency_id=None, creation_time=None, author=None):
|
||||
'''
|
||||
|
||||
@@ -71,6 +74,7 @@ def createCreationInfo(agency_id=None, creation_time=None, author=None):
|
||||
return ope.CreationInfo(agency_id=agency_id, author=author,
|
||||
creation_time=creation_time)
|
||||
|
||||
|
||||
def createEvent(origintime, cinfo, originloc=None, etype=None, resID=None,
|
||||
authority_id=None):
|
||||
'''
|
||||
@@ -115,6 +119,7 @@ def createEvent(origintime, cinfo, originloc=None, etype=None, resID=None,
|
||||
event.origins = [o]
|
||||
return event
|
||||
|
||||
|
||||
def createMagnitude(originID, cinfo):
|
||||
'''
|
||||
createMagnitude - function to create an ObsPy Magnitude object
|
||||
@@ -129,6 +134,7 @@ def createMagnitude(originID, cinfo):
|
||||
magnitude.origin_id = originID
|
||||
return magnitude
|
||||
|
||||
|
||||
def createOrigin(origintime, cinfo, latitude, longitude, depth):
|
||||
'''
|
||||
createOrigin - function to create an ObsPy Origin
|
||||
@@ -158,6 +164,7 @@ def createOrigin(origintime, cinfo, latitude, longitude, depth):
|
||||
origin.depth = depth
|
||||
return origin
|
||||
|
||||
|
||||
def createPick(origintime, picknum, picktime, eventnum, cinfo, phase, station,
|
||||
wfseedstr, authority_id):
|
||||
'''
|
||||
@@ -196,6 +203,7 @@ def createPick(origintime, picknum, picktime, eventnum, cinfo, phase, station,
|
||||
pick.waveform_id = ope.ResourceIdentifier(id=wfseedstr, prefix='file:/')
|
||||
return pick
|
||||
|
||||
|
||||
def createResourceID(timetohash, restype, authority_id=None, hrstr=None):
|
||||
'''
|
||||
|
||||
@@ -220,6 +228,7 @@ def createResourceID(timetohash, restype, authority_id=None, hrstr=None):
|
||||
resID.convertIDToQuakeMLURI(authority_id=authority_id)
|
||||
return resID
|
||||
|
||||
|
||||
def demeanTrace(trace, window):
|
||||
"""
|
||||
returns the DATA where each trace is demean by the average value within
|
||||
@@ -234,6 +243,7 @@ def demeanTrace(trace, window):
|
||||
trace.data -= trace.data[window].mean()
|
||||
return trace
|
||||
|
||||
|
||||
def findComboBoxIndex(combo_box, val):
|
||||
"""
|
||||
Function findComboBoxIndex takes a QComboBox object and a string and
|
||||
@@ -246,6 +256,7 @@ def findComboBoxIndex(combo_box, val):
|
||||
"""
|
||||
return combo_box.findText(val) if combo_box.findText(val) is not -1 else 0
|
||||
|
||||
|
||||
def find_nearest(array, value):
|
||||
'''
|
||||
Function find_nearest takes an array and a value and returns the
|
||||
@@ -254,7 +265,8 @@ def find_nearest(array, value):
|
||||
:param value:
|
||||
:return:
|
||||
'''
|
||||
return (np.abs(array-value)).argmin()
|
||||
return (np.abs(array - value)).argmin()
|
||||
|
||||
|
||||
def fnConstructor(s):
|
||||
'''
|
||||
@@ -277,6 +289,7 @@ def fnConstructor(s):
|
||||
fn = '_' + fn
|
||||
return fn
|
||||
|
||||
|
||||
def getGlobalTimes(stream):
|
||||
'''
|
||||
|
||||
@@ -293,6 +306,7 @@ def getGlobalTimes(stream):
|
||||
max_end = trace.stats.endtime
|
||||
return min_start, max_end
|
||||
|
||||
|
||||
def getHash(time):
|
||||
'''
|
||||
:param time: time object for which a hash should be calculated
|
||||
@@ -303,6 +317,7 @@ def getHash(time):
|
||||
hg.update(time.strftime('%Y-%m-%d %H:%M:%S.%f'))
|
||||
return hg.hexdigest()
|
||||
|
||||
|
||||
def getLogin():
|
||||
'''
|
||||
|
||||
@@ -310,6 +325,7 @@ def getLogin():
|
||||
'''
|
||||
return pwd.getpwuid(os.getuid())[0]
|
||||
|
||||
|
||||
def getOwner(fn):
|
||||
'''
|
||||
|
||||
@@ -319,6 +335,7 @@ def getOwner(fn):
|
||||
'''
|
||||
return pwd.getpwuid(os.stat(fn).st_uid).pw_name
|
||||
|
||||
|
||||
def getPatternLine(fn, pattern):
|
||||
"""
|
||||
Takes a file name and a pattern string to search for in the file and
|
||||
@@ -343,6 +360,7 @@ def getPatternLine(fn, pattern):
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def isSorted(iterable):
|
||||
'''
|
||||
|
||||
@@ -352,6 +370,7 @@ def isSorted(iterable):
|
||||
'''
|
||||
return sorted(iterable) == iterable
|
||||
|
||||
|
||||
def prepTimeAxis(stime, trace):
|
||||
'''
|
||||
|
||||
@@ -378,6 +397,7 @@ def prepTimeAxis(stime, trace):
|
||||
'delta: {2}'.format(nsamp, len(time_ax), tincr))
|
||||
return time_ax
|
||||
|
||||
|
||||
def scaleWFData(data, factor=None, components='all'):
|
||||
"""
|
||||
produce scaled waveforms from given waveform data and a scaling factor,
|
||||
@@ -409,6 +429,7 @@ def scaleWFData(data, factor=None, components='all'):
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def runProgram(cmd, parameter=None):
|
||||
"""
|
||||
run an external program specified by cmd with parameters input returning the
|
||||
@@ -427,8 +448,10 @@ def runProgram(cmd, parameter=None):
|
||||
cmd += ' %s 2>&1' % parameter
|
||||
|
||||
output = subprocess.check_output('{} | tee /dev/stderr'.format(cmd),
|
||||
shell = True)
|
||||
shell=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import doctest
|
||||
|
||||
doctest.testmod()
|
||||
|
||||
@@ -31,16 +31,19 @@
|
||||
#
|
||||
# include RELEASE-VERSION
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
__all__ = "get_git_version"
|
||||
|
||||
# NO IMPORTS FROM PYLOT IN THIS FILE! (file gets used at installation time)
|
||||
import os
|
||||
import inspect
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
# NO IMPORTS FROM PYLOT IN THIS FILE! (file gets used at installation time)
|
||||
|
||||
script_dir = os.path.abspath(os.path.dirname(inspect.getfile(
|
||||
inspect.currentframe())))
|
||||
inspect.currentframe())))
|
||||
PYLOT_ROOT = os.path.abspath(os.path.join(script_dir, os.pardir,
|
||||
os.pardir, os.pardir))
|
||||
VERSION_FILE = os.path.join(PYLOT_ROOT, "pylot", "RELEASE-VERSION")
|
||||
@@ -108,4 +111,4 @@ def get_git_version(abbrev=4):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print get_git_version()
|
||||
print(get_git_version())
|
||||
|
||||
@@ -9,6 +9,7 @@ import datetime
|
||||
import numpy as np
|
||||
|
||||
from matplotlib.figure import Figure
|
||||
|
||||
try:
|
||||
from matplotlib.backends.backend_qt4agg import FigureCanvas
|
||||
except ImportError:
|
||||
@@ -23,9 +24,9 @@ from PySide.QtCore import QSettings, Qt, QUrl, Signal, Slot
|
||||
from PySide.QtWebKit import QWebView
|
||||
from obspy import Stream, UTCDateTime
|
||||
from pylot.core.read.inputs import FilterOptions
|
||||
from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin,\
|
||||
from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin, \
|
||||
getResolutionWindow
|
||||
from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS, LOCTOOLS,\
|
||||
from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS, LOCTOOLS, \
|
||||
COMPPOSITION_MAP
|
||||
from pylot.core.util.utils import prepTimeAxis, getGlobalTimes, scaleWFData, \
|
||||
demeanTrace, isSorted, findComboBoxIndex
|
||||
@@ -164,9 +165,10 @@ class MPLWidget(FigureCanvas):
|
||||
def insertLabel(self, pos, text):
|
||||
pos = pos / max(self.getAxes().ylim)
|
||||
axann = self.getAxes().annotate(text, xy=(.03, pos),
|
||||
xycoords='axes fraction')
|
||||
xycoords='axes fraction')
|
||||
axann.set_bbox(dict(facecolor='lightgrey', alpha=.6))
|
||||
|
||||
|
||||
class PickDlg(QDialog):
|
||||
def __init__(self, parent=None, data=None, station=None, picks=None,
|
||||
rotate=False):
|
||||
@@ -263,8 +265,8 @@ class PickDlg(QDialog):
|
||||
tip='Zoom into waveform',
|
||||
checkable=True)
|
||||
self.resetZoomAction = createAction(parent=self, text='Home',
|
||||
slot=self.resetZoom, icon=home_icon,
|
||||
tip='Reset zoom to original limits')
|
||||
slot=self.resetZoom, icon=home_icon,
|
||||
tip='Reset zoom to original limits')
|
||||
self.resetPicksAction = createAction(parent=self, text='Delete Picks',
|
||||
slot=self.delPicks, icon=del_icon,
|
||||
tip='Delete current picks.')
|
||||
@@ -516,7 +518,6 @@ class PickDlg(QDialog):
|
||||
inoise = getnoisewin(t, ini_pick, noise_win, gap_win)
|
||||
trace = demeanTrace(trace=trace, window=inoise)
|
||||
|
||||
|
||||
self.setXLims([ini_pick - x_res, ini_pick + x_res])
|
||||
self.setYLims(np.array([-noiselevel * 2.5, noiselevel * 2.5]) +
|
||||
trace_number)
|
||||
@@ -575,8 +576,8 @@ class PickDlg(QDialog):
|
||||
traces = self.getTraceID(horiz_comp)
|
||||
traces.sort()
|
||||
self.setYLims(tuple(np.array([-0.5, +0.5]) +
|
||||
np.array(traces)))
|
||||
noiselevels = [trace + 1 / (2.5 * 2) for trace in traces] +\
|
||||
np.array(traces)))
|
||||
noiselevels = [trace + 1 / (2.5 * 2) for trace in traces] + \
|
||||
[trace - 1 / (2.5 * 2) for trace in traces]
|
||||
|
||||
self.getPlotWidget().plotWFData(wfdata=data,
|
||||
@@ -757,7 +758,6 @@ class PickDlg(QDialog):
|
||||
self.drawPicks()
|
||||
self.draw()
|
||||
|
||||
|
||||
def setPlotLabels(self):
|
||||
|
||||
# get channel labels
|
||||
@@ -1041,7 +1041,7 @@ class LocalisationTab(PropTab):
|
||||
self.binlabel.setText("{0} bin directory".format(curtool))
|
||||
|
||||
def selectDirectory(self, edit):
|
||||
selected_directory = QFileDialog.getExistingDirectory()
|
||||
selected_directory = QFileDialog.getExistingDirectory()
|
||||
edit.setText(selected_directory)
|
||||
|
||||
def getValues(self):
|
||||
@@ -1052,7 +1052,6 @@ class LocalisationTab(PropTab):
|
||||
return values
|
||||
|
||||
|
||||
|
||||
class NewEventDlg(QDialog):
|
||||
def __init__(self, parent=None, titleString="Create a new event"):
|
||||
"""
|
||||
@@ -1293,6 +1292,8 @@ class HelpForm(QDialog):
|
||||
def updatePageTitle(self):
|
||||
self.pageLabel.setText(self.webBrowser.documentTitle())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
|
||||
doctest.testmod()
|
||||
|
||||
Reference in New Issue
Block a user