[bugfix] origins object will be created independent to notes.txt,
[update] pycharm code restructuring (accidently)
This commit is contained in:
parent
a017c4deb4
commit
897b915eff
50
QtPyLoT.py
50
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,6 +83,7 @@ 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
|
||||
|
||||
if sys.version_info.major == 3:
|
||||
import icons_rc_3 as icons_rc
|
||||
elif sys.version_info.major == 2:
|
||||
@ -607,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()
|
||||
@ -862,11 +862,21 @@ class MainWindow(QMainWindow):
|
||||
# get path from first event in list and split them
|
||||
path = eventlist[0]
|
||||
try:
|
||||
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': '',
|
||||
@ -1222,7 +1232,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_()
|
||||
@ -1516,7 +1527,8 @@ 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):
|
||||
@ -1917,8 +1929,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 = {
|
||||
@ -1956,7 +1970,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)
|
||||
@ -2151,6 +2166,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:
|
||||
@ -2352,10 +2368,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
|
||||
@ -2558,6 +2576,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
|
||||
@ -2583,7 +2602,7 @@ class Project(object):
|
||||
self.setDirty()
|
||||
else:
|
||||
print('Skipping event with path {}. Already part of project.'.format(event.path))
|
||||
#self.search_eventfile_info()
|
||||
self.search_eventfile_info()
|
||||
|
||||
def read_eventfile_info(self, filename, separator=','):
|
||||
'''
|
||||
@ -2610,13 +2629,17 @@ class Project(object):
|
||||
print(e, datetime, filename)
|
||||
continue
|
||||
for event in self.eventlist:
|
||||
if not event.origins:
|
||||
continue
|
||||
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'))
|
||||
@ -2704,6 +2727,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)
|
||||
|
Loading…
Reference in New Issue
Block a user