[merge] merged changes in QtPyLoT manually
This commit is contained in:
commit
7f0ab4dd94
344
QtPyLoT.py
344
QtPyLoT.py
@ -25,6 +25,7 @@ https://www.iconfinder.com/iconsets/flavour
|
||||
|
||||
import os
|
||||
import sys
|
||||
import platform
|
||||
import argparse
|
||||
import matplotlib
|
||||
|
||||
@ -41,7 +42,7 @@ from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
|
||||
QTreeView, QComboBox, QTabWidget, QPushButton, QGridLayout
|
||||
import numpy as np
|
||||
from obspy import UTCDateTime
|
||||
from obspy.core.event import Magnitude
|
||||
from obspy.core.event import Magnitude, Origin
|
||||
from obspy.core.util import AttribDict
|
||||
|
||||
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.thread import AutoPickThread, Thread
|
||||
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)
|
||||
|
||||
@ -98,15 +105,15 @@ class MainWindow(QMainWindow):
|
||||
if not infile:
|
||||
infile = os.path.join(os.path.expanduser('~'), '.pylot', 'pylot.in')
|
||||
print('Using default input file {}'.format(infile))
|
||||
if os.path.isfile(infile)== False:
|
||||
if os.path.isfile(infile) == False:
|
||||
infile = QFileDialog().getOpenFileName(caption='Choose PyLoT-input file')
|
||||
if not os.path.exists(infile[0]):
|
||||
QMessageBox.warning(self, "PyLoT Warning",
|
||||
"No PyLoT-input file declared!")
|
||||
"No PyLoT-input file declared!")
|
||||
sys.exit(0)
|
||||
self.infile = infile[0]
|
||||
else:
|
||||
self.infile = infile
|
||||
self.infile = infile
|
||||
self._inputs = PylotParameter(infile)
|
||||
self._props = None
|
||||
|
||||
@ -122,8 +129,8 @@ class MainWindow(QMainWindow):
|
||||
self.poS_id = None
|
||||
self.ae_id = None
|
||||
self.scroll_id = None
|
||||
self._ctrl = False # control key pressed
|
||||
self._shift = False # shift key pressed
|
||||
self._ctrl = False # control key pressed
|
||||
self._shift = False # shift key pressed
|
||||
|
||||
# default factor for dataplot e.g. enabling/disabling scrollarea
|
||||
self.height_factor = 12
|
||||
@ -220,7 +227,7 @@ class MainWindow(QMainWindow):
|
||||
self._event_layout.addWidget(self.eventBox)
|
||||
self._event_layout.addWidget(self.ref_event_button)
|
||||
self._event_layout.addWidget(self.test_event_button)
|
||||
self._event_layout.setStretch(1,1) #set stretch of item 1 to 1
|
||||
self._event_layout.setStretch(1, 1) # set stretch of item 1 to 1
|
||||
self._main_layout.addLayout(self._event_layout)
|
||||
self.eventBox.activated.connect(self.refreshEvents)
|
||||
|
||||
@ -249,7 +256,7 @@ class MainWindow(QMainWindow):
|
||||
array_tab.setLayout(self.array_layout)
|
||||
events_tab.setLayout(self.events_layout)
|
||||
|
||||
#add tabs to main tab widget
|
||||
# add tabs to main tab widget
|
||||
self.tabs.addTab(wf_tab, 'Waveform Plot')
|
||||
self.tabs.addTab(array_tab, 'Array Map')
|
||||
self.tabs.addTab(events_tab, 'Eventlist')
|
||||
@ -478,25 +485,25 @@ class MainWindow(QMainWindow):
|
||||
componentGroup.setExclusive(True)
|
||||
|
||||
self.z_action = self.createAction(parent=componentGroup, text='Z',
|
||||
slot=self.plotZ, shortcut='Alt+Z',
|
||||
icon=z_icon, tip='Display the vertical (Z)'
|
||||
' component.',
|
||||
checkable=True)
|
||||
slot=self.plotZ, shortcut='Alt+Z',
|
||||
icon=z_icon, tip='Display the vertical (Z)'
|
||||
' component.',
|
||||
checkable=True)
|
||||
self.z_action.setChecked(True)
|
||||
self.z_action.setEnabled(False)
|
||||
|
||||
self.n_action = self.createAction(parent=componentGroup, text='N',
|
||||
slot=self.plotN, shortcut='Alt+N',
|
||||
icon=n_icon,
|
||||
tip='Display the north-south (N) '
|
||||
'component.', checkable=True)
|
||||
slot=self.plotN, shortcut='Alt+N',
|
||||
icon=n_icon,
|
||||
tip='Display the north-south (N) '
|
||||
'component.', checkable=True)
|
||||
self.n_action.setEnabled(False)
|
||||
|
||||
self.e_action = self.createAction(parent=componentGroup, text='E',
|
||||
slot=self.plotE, shortcut='Alt+E',
|
||||
icon=e_icon,
|
||||
tip='Display the east-west (E) component.',
|
||||
checkable=True)
|
||||
slot=self.plotE, shortcut='Alt+E',
|
||||
icon=e_icon,
|
||||
tip='Display the east-west (E) component.',
|
||||
checkable=True)
|
||||
self.e_action.setEnabled(False)
|
||||
|
||||
componentToolBar = self.addToolBar("ComponentSelection")
|
||||
@ -511,9 +518,9 @@ class MainWindow(QMainWindow):
|
||||
self.auto_tune.setEnabled(False)
|
||||
|
||||
self.auto_pick = self.createAction(parent=self, text='autoPick',
|
||||
slot=self.autoPick, shortcut='Alt+Ctrl+A',
|
||||
icon=autopylot_icon, tip='Automatically pick'
|
||||
' the displayed waveforms.')
|
||||
slot=self.autoPick, shortcut='Alt+Ctrl+A',
|
||||
icon=autopylot_icon, tip='Automatically pick'
|
||||
' the displayed waveforms.')
|
||||
self.auto_pick.setEnabled(False)
|
||||
|
||||
autoPickToolBar = self.addToolBar("autoPyLoT")
|
||||
@ -525,11 +532,11 @@ class MainWindow(QMainWindow):
|
||||
# pickToolBar.setObjectName("PickTools")
|
||||
# self.addActions(pickToolBar, pickToolActions)
|
||||
self.locateEvent = self.createAction(parent=self, text='locate the event',
|
||||
slot=self.locate_event,
|
||||
shortcut='Alt+Ctrl+L',
|
||||
icon=locate_icon,
|
||||
tip='Locate the event using '
|
||||
'the displayed manual arrivals.')
|
||||
slot=self.locate_event,
|
||||
shortcut='Alt+Ctrl+L',
|
||||
icon=locate_icon,
|
||||
tip='Locate the event using '
|
||||
'the displayed manual arrivals.')
|
||||
self.locateEvent.setEnabled(False)
|
||||
|
||||
locationToolBar = self.addToolBar("LocationTools")
|
||||
@ -552,7 +559,7 @@ class MainWindow(QMainWindow):
|
||||
def init_wfWidget(self):
|
||||
settings = QSettings()
|
||||
xlab = self.startTime.strftime('seconds since %Y/%m/%d %H:%M:%S (%Z)')
|
||||
plottitle = None#"Overview: {0} components ".format(self.getComponent())
|
||||
plottitle = None # "Overview: {0} components ".format(self.getComponent())
|
||||
self.disconnectWFplotEvents()
|
||||
if str(settings.value('pyqtgraphic')) == 'false' or not pg:
|
||||
self.pg = False
|
||||
@ -573,9 +580,9 @@ class MainWindow(QMainWindow):
|
||||
'''
|
||||
self.ref_event_button = QtGui.QPushButton('Ref')
|
||||
self.test_event_button = QtGui.QPushButton('Test')
|
||||
self.ref_event_button.setToolTip('Set manual picks of current '+
|
||||
self.ref_event_button.setToolTip('Set manual picks of current ' +
|
||||
'event as reference picks for autopicker tuning.')
|
||||
self.test_event_button.setToolTip('Set manual picks of current '+
|
||||
self.test_event_button.setToolTip('Set manual picks of current ' +
|
||||
'event as test picks for autopicker testing.')
|
||||
self.ref_event_button.setCheckable(True)
|
||||
self.test_event_button.setCheckable(True)
|
||||
@ -602,12 +609,10 @@ class MainWindow(QMainWindow):
|
||||
def metadata(self):
|
||||
return self._metadata
|
||||
|
||||
|
||||
@metadata.setter
|
||||
def metadata(self, value):
|
||||
self._metadata = value
|
||||
|
||||
|
||||
def updateFileMenu(self):
|
||||
|
||||
self.fileMenu.clear()
|
||||
@ -662,13 +667,13 @@ class MainWindow(QMainWindow):
|
||||
filt = "PILOT location files (*LOC*.mat)"
|
||||
caption = "Select PILOT location file"
|
||||
fn_loc = QFileDialog().getOpenFileName(self, caption=caption,
|
||||
filter=filt, dir=self.getRoot())
|
||||
filter=filt, dir=self.getRoot())
|
||||
fn_loc = fn_loc[0]
|
||||
loc_dir = os.path.split(fn_loc)[0]
|
||||
filt = "PILOT phases files (*PHASES*.mat)"
|
||||
caption = "Select PILOT phases file"
|
||||
fn_phases = QFileDialog().getOpenFileName(self, caption=caption,
|
||||
filter=filt, dir=loc_dir)
|
||||
filter=filt, dir=loc_dir)
|
||||
fn_phases = fn_phases[0]
|
||||
|
||||
type = getDataType(self)
|
||||
@ -679,16 +684,16 @@ class MainWindow(QMainWindow):
|
||||
def load_multiple_data(self, type='manual'):
|
||||
if not self.okToContinue():
|
||||
return
|
||||
refresh=False
|
||||
refresh = False
|
||||
events = self.project.eventlist
|
||||
fext = '.xml'
|
||||
for event in events:
|
||||
path = event.path
|
||||
eventname = path.split('/')[-1]
|
||||
filename = os.path.join(path, 'PyLoT_'+eventname+fext)
|
||||
filename = os.path.join(path, 'PyLoT_' + eventname + fext)
|
||||
if os.path.isfile(filename):
|
||||
self.load_data(filename, draw=False, event=event, overwrite=True)
|
||||
refresh=True
|
||||
refresh = True
|
||||
if not refresh:
|
||||
return
|
||||
if self.get_current_event().pylot_picks:
|
||||
@ -706,12 +711,12 @@ class MainWindow(QMainWindow):
|
||||
if not fname:
|
||||
return
|
||||
self.set_fname(fname, type)
|
||||
#data = dict(auto=self.autodata, manual=self.data)
|
||||
# data = dict(auto=self.autodata, manual=self.data)
|
||||
if not event:
|
||||
event = self.get_current_event()
|
||||
data = Data(self, event)
|
||||
try:
|
||||
data_new = Data(self, evtdata=fname)
|
||||
data_new = Data(self, evtdata=str(fname))
|
||||
data += data_new
|
||||
except ValueError:
|
||||
qmb = QMessageBox(self, icon=QMessageBox.Question,
|
||||
@ -740,7 +745,7 @@ class MainWindow(QMainWindow):
|
||||
def add_recentfile(self, event):
|
||||
self.recentfiles.insert(0, event)
|
||||
|
||||
def set_button_color(self, button, color = None):
|
||||
def set_button_color(self, button, color=None):
|
||||
'''
|
||||
Set background color of a button.
|
||||
button: type = QtGui.QAbstractButton
|
||||
@ -854,20 +859,30 @@ class MainWindow(QMainWindow):
|
||||
print('No project found.')
|
||||
return
|
||||
|
||||
#get path from first event in list and split them
|
||||
# get path from first event in list and split them
|
||||
path = eventlist[0]
|
||||
try:
|
||||
dirs = {
|
||||
'database': path.split('/')[-2],
|
||||
'datapath': path.split('/')[-3],
|
||||
'rootpath': '/'+os.path.join(*path.split('/')[:-3])
|
||||
}
|
||||
system_name = platform.system()
|
||||
if system_name in ["Linux", "Darwin"]:
|
||||
dirs = {
|
||||
'database': path.split('/')[-2],
|
||||
'datapath': 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:
|
||||
dirs = {
|
||||
'database': '',
|
||||
'datapath': '',
|
||||
'rootpath': ''
|
||||
}
|
||||
}
|
||||
print('Warning: Could not automatically init folder structure. ({})'.format(e))
|
||||
|
||||
settings = QSettings()
|
||||
@ -875,15 +890,15 @@ class MainWindow(QMainWindow):
|
||||
settings.sync()
|
||||
|
||||
if not self.project.eventlist:
|
||||
#init parameter object
|
||||
# init parameter object
|
||||
self.setParameter(show=False)
|
||||
#hide all parameter (show all needed parameter later)
|
||||
# hide all parameter (show all needed parameter later)
|
||||
self.paraBox.hide_parameter()
|
||||
for directory in dirs.keys():
|
||||
#set parameter
|
||||
# set parameter
|
||||
box = self.paraBox.boxes[directory]
|
||||
self.paraBox.setValue(box, dirs[directory])
|
||||
#show needed parameter in box
|
||||
# show needed parameter in box
|
||||
self.paraBox.show_parameter(directory)
|
||||
dirs_box = self.paraBox.get_groupbox_dialog('Directories')
|
||||
if not dirs_box.exec_():
|
||||
@ -896,7 +911,7 @@ class MainWindow(QMainWindow):
|
||||
'Rootpath missmatch to current project!')
|
||||
return
|
||||
else:
|
||||
self.project.rootpath = dirs['rootpath']
|
||||
self.project.rootpath = dirs['rootpath']
|
||||
|
||||
self.project.add_eventlist(eventlist)
|
||||
self.init_events()
|
||||
@ -943,8 +958,8 @@ class MainWindow(QMainWindow):
|
||||
'''
|
||||
if not eventBox:
|
||||
eventBox = self.eventBox
|
||||
index=eventBox.currentIndex()
|
||||
tv=QtGui.QTableView()
|
||||
index = eventBox.currentIndex()
|
||||
tv = QtGui.QTableView()
|
||||
header = tv.horizontalHeader()
|
||||
header.setResizeMode(QtGui.QHeaderView.ResizeToContents)
|
||||
header.setStretchLastSection(True)
|
||||
@ -955,12 +970,12 @@ class MainWindow(QMainWindow):
|
||||
eventBox.setView(tv)
|
||||
eventBox.clear()
|
||||
model = eventBox.model()
|
||||
plmax=0
|
||||
#set maximum length of path string
|
||||
plmax = 0
|
||||
# set maximum length of path string
|
||||
for event in self.project.eventlist:
|
||||
pl = len(event.path)
|
||||
if pl > plmax:
|
||||
plmax=pl
|
||||
plmax = pl
|
||||
|
||||
for id, event in enumerate(self.project.eventlist):
|
||||
event_path = event.path
|
||||
@ -984,8 +999,8 @@ class MainWindow(QMainWindow):
|
||||
item_nmp.setIcon(self.manupicksicon_small)
|
||||
item_nap = QtGui.QStandardItem(str(event_nautopicks))
|
||||
item_nap.setIcon(self.autopicksicon_small)
|
||||
item_ref = QtGui.QStandardItem()#str(event_ref))
|
||||
item_test = QtGui.QStandardItem()#str(event_test))
|
||||
item_ref = QtGui.QStandardItem() # str(event_ref))
|
||||
item_test = QtGui.QStandardItem() # str(event_test))
|
||||
if event_ref:
|
||||
item_ref.setBackground(self._colors['ref'])
|
||||
if event_test:
|
||||
@ -1015,8 +1030,8 @@ class MainWindow(QMainWindow):
|
||||
'{} unequal {}.'
|
||||
.format(event.path, self.eventBox.itemText(id)))
|
||||
raise ValueError(message)
|
||||
#not working with obspy events
|
||||
#eventBox.setItemData(id, event)
|
||||
# not working with obspy events
|
||||
# eventBox.setItemData(id, event)
|
||||
eventBox.setCurrentIndex(index)
|
||||
self.refreshRefTestButtons()
|
||||
|
||||
@ -1051,39 +1066,27 @@ class MainWindow(QMainWindow):
|
||||
def getSavePath(e, directory, outformat):
|
||||
print('warning: {0}'.format(e))
|
||||
if not directory:
|
||||
dlgflag = 1
|
||||
directory = self.get_current_event_path()
|
||||
dlgflag = 1
|
||||
directory = self.get_current_event_path()
|
||||
else:
|
||||
dlgflag = 0
|
||||
dlgflag = 0
|
||||
eventname = self.get_current_event_name()
|
||||
filename = 'PyLoT_'+eventname
|
||||
filename = 'PyLoT_' + eventname
|
||||
outpath = os.path.join(directory, filename)
|
||||
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)"
|
||||
|
||||
if dlgflag == 1:
|
||||
fname, selected_filter = QFileDialog.getSaveFileName(self,
|
||||
title,
|
||||
outpath,
|
||||
file_filter)
|
||||
fname, selected_filter = QFileDialog.getSaveFileName(self,
|
||||
title,
|
||||
outpath,
|
||||
file_filter)
|
||||
|
||||
#fbasename, exform = os.path.splitext(fname)
|
||||
fbasename = fname
|
||||
try:
|
||||
fbasename = fname
|
||||
except:
|
||||
fbasename = outpath
|
||||
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
|
||||
|
||||
settings = QSettings()
|
||||
@ -1094,20 +1097,20 @@ class MainWindow(QMainWindow):
|
||||
uppererrorS = self._inputs['timeerrorsS']
|
||||
|
||||
try:
|
||||
self.get_data().applyEVTData(self.get_current_event(), typ='event')#getPicks())
|
||||
self.get_data().applyEVTData(self.get_current_event(), typ='event') # getPicks())
|
||||
except OverwriteError:
|
||||
# msgBox = QMessageBox()
|
||||
# msgBox.setText("Picks have been modified!")
|
||||
# msgBox.setInformativeText(
|
||||
# "Do you want to save the changes and overwrite the picks?")
|
||||
# msgBox.setDetailedText(self.get_data().getPicksStr())
|
||||
# msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel)
|
||||
# msgBox.setDefaultButton(QMessageBox.Save)
|
||||
# ret = msgBox.exec_()
|
||||
# if ret == QMessageBox.Save:
|
||||
self.get_data().resetPicks()
|
||||
return self.saveData()
|
||||
# elif ret == QMessageBox.Cancel:
|
||||
# msgBox = QMessageBox()
|
||||
# msgBox.setText("Picks have been modified!")
|
||||
# msgBox.setInformativeText(
|
||||
# "Do you want to save the changes and overwrite the picks?")
|
||||
# msgBox.setDetailedText(self.get_data().getPicksStr())
|
||||
# msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel)
|
||||
# msgBox.setDefaultButton(QMessageBox.Save)
|
||||
# ret = msgBox.exec_()
|
||||
# if ret == QMessageBox.Save:
|
||||
self.get_data().resetPicks()
|
||||
return self.saveData()
|
||||
# elif ret == QMessageBox.Cancel:
|
||||
# return False
|
||||
# MP MP changed to suppress unnecessary user prompt
|
||||
try:
|
||||
@ -1176,8 +1179,8 @@ class MainWindow(QMainWindow):
|
||||
return self.get_current_event().getPicks()
|
||||
if type == 'auto':
|
||||
return self.get_current_event().getAutopicks()
|
||||
# rdict = dict(auto=self.pylot_autopicks, manual=self.pylot_picks)
|
||||
# return rdict[type]
|
||||
# rdict = dict(auto=self.pylot_autopicks, manual=self.pylot_picks)
|
||||
# return rdict[type]
|
||||
|
||||
def getPicksOnStation(self, station, type='manual'):
|
||||
try:
|
||||
@ -1225,7 +1228,8 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def okToContinue(self):
|
||||
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.setDefaultButton(QMessageBox.Save)
|
||||
ret = qmb.exec_()
|
||||
@ -1302,7 +1306,7 @@ class MainWindow(QMainWindow):
|
||||
# Loading an existing project from array_tab leads to two calls of newWF
|
||||
# which will read in data input twice. Therefore current tab is changed to 0
|
||||
# in loadProject before calling this function.
|
||||
plotted=False
|
||||
plotted = False
|
||||
# only refresh first/second tab when an event was changed.
|
||||
if self._eventChanged[0] or self._eventChanged[1]:
|
||||
event = self.get_current_event()
|
||||
@ -1324,7 +1328,7 @@ class MainWindow(QMainWindow):
|
||||
if len(self.project.eventlist) > 0:
|
||||
self.newWF()
|
||||
# keep track whether event was already plotted
|
||||
plotted=True
|
||||
plotted = True
|
||||
# if current tab is array_map-tab and the data in this tab was not yet refreshed
|
||||
if self.tabs.currentIndex() == 1:
|
||||
if self._eventChanged[1]:
|
||||
@ -1351,13 +1355,13 @@ class MainWindow(QMainWindow):
|
||||
call modal plot thread method when finished.
|
||||
'''
|
||||
if load:
|
||||
wfd_thread = Thread(self, self.loadWaveformData,
|
||||
progressText='Reading data input...')
|
||||
self.wfd_thread = Thread(self, self.loadWaveformData,
|
||||
progressText='Reading data input...')
|
||||
if load and plot:
|
||||
wfd_thread.finished.connect(self.plotWaveformDataThread)
|
||||
self.wfd_thread.finished.connect(self.plotWaveformDataThread)
|
||||
|
||||
if load:
|
||||
wfd_thread.start()
|
||||
self.wfd_thread.start()
|
||||
|
||||
if plot and not load:
|
||||
self.plotWaveformDataThread()
|
||||
@ -1445,7 +1449,7 @@ class MainWindow(QMainWindow):
|
||||
plotWidget = self.getPlotWidget()
|
||||
plotDict = plotWidget.getPlotDict()
|
||||
pos = plotDict.keys()
|
||||
labels = [plotDict[n][2]+'.'+plotDict[n][0] for n in pos]
|
||||
labels = [plotDict[n][2] + '.' + plotDict[n][0] for n in pos]
|
||||
plotWidget.setYTickLabels(pos, labels)
|
||||
try:
|
||||
plotWidget.figure.tight_layout()
|
||||
@ -1519,13 +1523,14 @@ class MainWindow(QMainWindow):
|
||||
# wfst += self.get_data().getWFData().select(component=alter_comp)
|
||||
plotWidget = self.getPlotWidget()
|
||||
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
|
||||
|
||||
def adjustPlotHeight(self):
|
||||
if self.pg:
|
||||
return
|
||||
height_need = len(self.data.getWFData())*self.height_factor
|
||||
height_need = len(self.data.getWFData()) * self.height_factor
|
||||
plotWidget = self.getPlotWidget()
|
||||
if self.tabs.widget(0).frameSize().height() < height_need:
|
||||
plotWidget.setMinimumHeight(height_need)
|
||||
@ -1601,7 +1606,7 @@ class MainWindow(QMainWindow):
|
||||
def getFilters(self):
|
||||
return self.filteroptions
|
||||
|
||||
def setFilterOptions(self, filterOptions):#, seismicPhase=None):
|
||||
def setFilterOptions(self, filterOptions): # , seismicPhase=None):
|
||||
# if seismicPhase is None:
|
||||
# self.getFilterOptions()[self.getSeismicPhase()] = filterOptions
|
||||
# else:
|
||||
@ -1650,7 +1655,7 @@ class MainWindow(QMainWindow):
|
||||
emsg.showMessage('Error: {0}'.format(e))
|
||||
else:
|
||||
self.update_status('Filter loaded ... '
|
||||
'[{0}: {1} Hz]'.format(
|
||||
'[{0}: {1} Hz]'.format(
|
||||
self.getFilterOptions().getFilterType(),
|
||||
self.getFilterOptions().getFreq()))
|
||||
if self.filterAction.isChecked():
|
||||
@ -1675,7 +1680,7 @@ class MainWindow(QMainWindow):
|
||||
def setSeismicPhase(self, phase):
|
||||
self.seismicPhase = self.seismicPhaseButtonGroup.getValue()
|
||||
self.update_status('Seismic phase changed to '
|
||||
'{0}'.format(self.getSeismicPhase()))
|
||||
'{0}'.format(self.getSeismicPhase()))
|
||||
|
||||
def scrollPlot(self, gui_event):
|
||||
'''
|
||||
@ -1694,12 +1699,12 @@ class MainWindow(QMainWindow):
|
||||
if vbar.maximum():
|
||||
vbar.setValue(vbar.value() + up_down[button])
|
||||
if self._ctrl:
|
||||
factor = {'up': 5./4.,
|
||||
'down': 4./5.}
|
||||
factor = {'up': 5. / 4.,
|
||||
'down': 4. / 5.}
|
||||
self.height_factor *= factor[button]
|
||||
self.adjustPlotHeight()
|
||||
if self._shift:
|
||||
factor = {'up': 1./2.,
|
||||
factor = {'up': 1. / 2.,
|
||||
'down': 2.}
|
||||
xlims = self.dataPlot.getXLims()
|
||||
xdiff = xlims[1] - xlims[0]
|
||||
@ -1824,9 +1829,9 @@ class MainWindow(QMainWindow):
|
||||
def autoPick(self):
|
||||
self.autosave = QFileDialog().getExistingDirectory(caption='Select autoPyLoT output')
|
||||
if not os.path.exists(self.autosave):
|
||||
QMessageBox.warning(self, "PyLoT Warning",
|
||||
"No autoPyLoT output declared!")
|
||||
return
|
||||
QMessageBox.warning(self, "PyLoT Warning",
|
||||
"No autoPyLoT output declared!")
|
||||
return
|
||||
self.listWidget = QListWidget()
|
||||
self.setDirty(True)
|
||||
self.logDockWidget = QDockWidget("AutoPickLog", self)
|
||||
@ -1836,13 +1841,13 @@ class MainWindow(QMainWindow):
|
||||
self.logDockWidget.setWidget(self.listWidget)
|
||||
self.addDockWidget(Qt.LeftDockWidgetArea, self.logDockWidget)
|
||||
self.addListItem('Loading default values from PyLoT-input file %s'
|
||||
% self.infile)
|
||||
% self.infile)
|
||||
autopick_parameter = self._inputs
|
||||
self.addListItem(str(autopick_parameter))
|
||||
receventid = self.get_current_event_path()
|
||||
self.thread = AutoPickThread(parent=self,
|
||||
func=autoPyLoT,
|
||||
infile = self.infile,
|
||||
infile=self.infile,
|
||||
fnames=self.fnames,
|
||||
eventid=receventid,
|
||||
savepath=self.autosave)
|
||||
@ -1861,7 +1866,7 @@ class MainWindow(QMainWindow):
|
||||
if not stat_picks:
|
||||
rval = False
|
||||
else:
|
||||
#set picks (ugly syntax?)
|
||||
# set picks (ugly syntax?)
|
||||
self.getPicks(type=type)[station] = picks
|
||||
rval = True
|
||||
return rval
|
||||
@ -1920,8 +1925,10 @@ class MainWindow(QMainWindow):
|
||||
dashed = QtCore.Qt.DashLine
|
||||
dotted = QtCore.Qt.DotLine
|
||||
phase_col = {
|
||||
'P': (pg.mkPen('c'), pg.mkPen((0, 255, 255, 100), style=dashed), pg.mkPen('b', style=dashed), 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))
|
||||
'P': (pg.mkPen('c'), pg.mkPen((0, 255, 255, 100), style=dashed), pg.mkPen('b', style=dashed),
|
||||
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:
|
||||
phase_col = {
|
||||
@ -1943,6 +1950,9 @@ class MainWindow(QMainWindow):
|
||||
if picks['epp'] and picks['lpp']:
|
||||
epp = picks['epp'] - stime
|
||||
lpp = picks['lpp'] - stime
|
||||
else:
|
||||
epp = None
|
||||
lpp = None
|
||||
spe = picks['spe']
|
||||
|
||||
if not spe and epp and lpp:
|
||||
@ -1956,7 +1966,8 @@ class MainWindow(QMainWindow):
|
||||
pw.plot([lpp, lpp], ylims,
|
||||
alpha=.25, pen=colors[0], name='LPP')
|
||||
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])
|
||||
pw.addItem(spe_l)
|
||||
pw.addItem(spe_r)
|
||||
@ -2040,7 +2051,7 @@ class MainWindow(QMainWindow):
|
||||
obsdir = os.path.join(locroot, 'obs')
|
||||
self.saveData(directory=obsdir, outformat='.obs')
|
||||
eventname = self.get_current_event_name()
|
||||
filename = 'PyLoT_'+eventname
|
||||
filename = 'PyLoT_' + eventname
|
||||
locpath = os.path.join(locroot, 'loc', filename)
|
||||
phasefile = os.path.join(obsdir, filename + '.obs')
|
||||
phasepath = os.path.join(locroot, 'obs', phasefile)
|
||||
@ -2053,7 +2064,7 @@ class MainWindow(QMainWindow):
|
||||
os.remove(phasepath)
|
||||
|
||||
self.get_data().applyEVTData(lt.read_location(locpath), typ='event')
|
||||
#self.get_data().applyEVTData(self.calc_magnitude(), typ='event')
|
||||
# self.get_data().applyEVTData(self.calc_magnitude(), typ='event')
|
||||
|
||||
def init_array_tab(self):
|
||||
'''
|
||||
@ -2108,7 +2119,7 @@ class MainWindow(QMainWindow):
|
||||
self.am_canvas = FigureCanvas(self.am_figure)
|
||||
self.am_toolbar = NavigationToolbar(self.am_canvas, self)
|
||||
self.array_map = map_projection(self)
|
||||
#self.array_map_thread()
|
||||
# self.array_map_thread()
|
||||
self.array_layout.addWidget(self.array_map)
|
||||
self.tabs.setCurrentIndex(index)
|
||||
self.refresh_array_map()
|
||||
@ -2128,8 +2139,8 @@ class MainWindow(QMainWindow):
|
||||
'''
|
||||
self.array_map = self.amt.data
|
||||
self.array_layout.addWidget(self.array_map)
|
||||
#self.tabs.setCurrentIndex(index)
|
||||
#self.refresh_array_map()
|
||||
# self.tabs.setCurrentIndex(index)
|
||||
# self.refresh_array_map()
|
||||
|
||||
def refresh_array_map(self):
|
||||
'''
|
||||
@ -2151,6 +2162,7 @@ class MainWindow(QMainWindow):
|
||||
'''
|
||||
Build and initiate event table (3rd tab [index=2]) containing information of every event.
|
||||
'''
|
||||
|
||||
def set_enabled(item, enabled=True, checkable=False):
|
||||
# modify item flags depending on case needed
|
||||
if enabled and not checkable:
|
||||
@ -2171,7 +2183,7 @@ class MainWindow(QMainWindow):
|
||||
table = self.project._table
|
||||
event = self.project.getEventFromPath(table[row][0].text())
|
||||
if column == 8 or column == 9:
|
||||
#toggle checked states (exclusive)
|
||||
# toggle checked states (exclusive)
|
||||
item_ref = table[row][8]
|
||||
item_test = table[row][9]
|
||||
if column == 8 and item_ref.checkState():
|
||||
@ -2186,7 +2198,7 @@ class MainWindow(QMainWindow):
|
||||
event.setTestEvent(False)
|
||||
self.fill_eventbox()
|
||||
elif column == 5:
|
||||
#update event notes
|
||||
# update event notes
|
||||
notes = table[row][5].text()
|
||||
event.addNotes(notes)
|
||||
self.fill_eventbox()
|
||||
@ -2270,8 +2282,8 @@ class MainWindow(QMainWindow):
|
||||
else:
|
||||
item_test.setCheckState(QtCore.Qt.Unchecked)
|
||||
|
||||
column=[item_path, item_time, item_lat, item_lon, item_depth, item_mag,
|
||||
item_nmp, item_nap, item_ref, item_test, item_notes]
|
||||
column = [item_path, item_time, item_lat, item_lon, item_depth, item_mag,
|
||||
item_nmp, item_nap, item_ref, item_test, item_notes]
|
||||
self.project._table.append(column)
|
||||
|
||||
for r_index, row in enumerate(self.project._table):
|
||||
@ -2352,10 +2364,12 @@ class MainWindow(QMainWindow):
|
||||
# if not rest_flag:
|
||||
# raise ProcessingError('Restitution of waveform data failed!')
|
||||
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()
|
||||
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()
|
||||
else:
|
||||
return None
|
||||
@ -2435,7 +2449,7 @@ class MainWindow(QMainWindow):
|
||||
self.project = Project()
|
||||
self.init_events(new=True)
|
||||
self.setDirty(False)
|
||||
self.project.parameter=self._inputs
|
||||
self.project.parameter = self._inputs
|
||||
self.saveProjectAsAction.setEnabled(True)
|
||||
self.update_status('Created new project...', duration=1000)
|
||||
return True
|
||||
@ -2457,7 +2471,7 @@ class MainWindow(QMainWindow):
|
||||
if hasattr(self.project, 'parameter'):
|
||||
if self.project.parameter:
|
||||
self._inputs = self.project.parameter
|
||||
self.tabs.setCurrentIndex(0) # implemented to prevent double-loading of waveform data
|
||||
self.tabs.setCurrentIndex(0) # implemented to prevent double-loading of waveform data
|
||||
self.init_events(new=True)
|
||||
self.setDirty(False)
|
||||
if hasattr(self.project, 'metadata'):
|
||||
@ -2477,7 +2491,7 @@ class MainWindow(QMainWindow):
|
||||
return False
|
||||
if not filename.split('.')[-1] == 'plp':
|
||||
filename = fnm[0] + '.plp'
|
||||
self.project.parameter=self._inputs
|
||||
self.project.parameter = self._inputs
|
||||
self.project.save(filename)
|
||||
self.setDirty(False)
|
||||
self.saveProjectAsAction.setEnabled(True)
|
||||
@ -2494,7 +2508,7 @@ class MainWindow(QMainWindow):
|
||||
self.setDirty(True)
|
||||
return False
|
||||
else:
|
||||
self.project.parameter=self._inputs
|
||||
self.project.parameter = self._inputs
|
||||
self.project.save()
|
||||
if not self.project.dirty:
|
||||
self.update_status('Saved back project to file:\n{}'.format(self.project.location), duration=5000)
|
||||
@ -2502,7 +2516,7 @@ class MainWindow(QMainWindow):
|
||||
return True
|
||||
else:
|
||||
# if still dirty because saving failed
|
||||
qmb = QMessageBox.warning(self,'Could not save project',
|
||||
qmb = QMessageBox.warning(self, 'Could not save project',
|
||||
'Could not save back to original file.\nChoose new file')
|
||||
self.setDirty(True)
|
||||
return self.saveProjectAs(exists=True)
|
||||
@ -2558,6 +2572,7 @@ class Project(object):
|
||||
'''
|
||||
Pickable class containing information of a QtPyLoT project, like event lists and file locations.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
self.eventlist = []
|
||||
self.location = None
|
||||
@ -2593,15 +2608,15 @@ class Project(object):
|
||||
'''
|
||||
infile = open(filename, 'r')
|
||||
for line in infile.readlines():
|
||||
event, date, time, mag, lat, lon, depth = line.split(separator)[:7]
|
||||
#skip first line
|
||||
event, date, time, mag, lat, lon, depth = line.split(separator)[:7]
|
||||
# skip first line
|
||||
try:
|
||||
month, day, year = date.split('/')
|
||||
except:
|
||||
continue
|
||||
year = int(year)
|
||||
#hardcoded, if year only consists of 2 digits (e.g. 16 instead of 2016)
|
||||
if year<100:
|
||||
# hardcoded, if year only consists of 2 digits (e.g. 16 instead of 2016)
|
||||
if year < 100:
|
||||
year += 2000
|
||||
datetime = '{}-{}-{}T{}'.format(year, month, day, time)
|
||||
try:
|
||||
@ -2610,16 +2625,20 @@ class Project(object):
|
||||
print(e, datetime, filename)
|
||||
continue
|
||||
for event in self.eventlist:
|
||||
if not event.origins:
|
||||
continue
|
||||
origin = event.origins[0] #should have only one origin
|
||||
if origin.time == datetime:
|
||||
origin.latitude = float(lat)
|
||||
origin.longitude = float(lon)
|
||||
origin.depth = float(depth)
|
||||
event.magnitudes.append(Magnitude(resource_id=event.resource_id,
|
||||
mag=float(mag),
|
||||
mag_type='M'))
|
||||
if event.origins:
|
||||
origin = event.origins[0] # should have only one origin
|
||||
if origin.time == datetime:
|
||||
origin.latitude = float(lat)
|
||||
origin.longitude = float(lon)
|
||||
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,
|
||||
mag=float(mag),
|
||||
mag_type='M'))
|
||||
|
||||
def search_eventfile_info(self):
|
||||
'''
|
||||
@ -2627,7 +2646,7 @@ class Project(object):
|
||||
and try to read event info from it
|
||||
'''
|
||||
datapaths = []
|
||||
fext='.csv'
|
||||
fext = '.csv'
|
||||
for event in self.eventlist:
|
||||
if not event.datapath in datapaths:
|
||||
datapaths.append(event.datapath)
|
||||
@ -2704,6 +2723,7 @@ class getExistingDirectories(QFileDialog):
|
||||
'''
|
||||
File dialog with possibility to select multiple folders.
|
||||
'''
|
||||
|
||||
def __init__(self, *args):
|
||||
super(getExistingDirectories, self).__init__(*args)
|
||||
self.setOption(self.DontUseNativeDialog, True)
|
||||
@ -2717,7 +2737,7 @@ class getExistingDirectories(QFileDialog):
|
||||
def create_window():
|
||||
app_created = False
|
||||
app = QCoreApplication.instance()
|
||||
#check for existing app (when using ipython)
|
||||
# check for existing app (when using ipython)
|
||||
if app is None:
|
||||
app = QApplication(sys.argv)
|
||||
app_created = True
|
||||
@ -2725,8 +2745,8 @@ def create_window():
|
||||
app.setOrganizationDomain("rub.de");
|
||||
app.setApplicationName("RUB");
|
||||
app.references = set()
|
||||
#app.references.add(window)
|
||||
#window.show()
|
||||
# app.references.add(window)
|
||||
# window.show()
|
||||
return app, app_created
|
||||
|
||||
|
||||
@ -2741,7 +2761,7 @@ def main(args=None):
|
||||
|
||||
# create the Qt application
|
||||
pylot_app, app_created = create_window()
|
||||
#pylot_app = QApplication(sys.argv)
|
||||
# pylot_app = QApplication(sys.argv)
|
||||
pixmap = QPixmap(":/splash/splash.png")
|
||||
splash = QSplashScreen(pixmap)
|
||||
splash.show()
|
||||
|
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'
|
||||
|
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()
|
||||
|
||||
@ -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