Implemented merge suggestions #11

This commit is contained in:
Kaan Cökerim 2021-08-12 15:43:23 +02:00
parent a738dc57ec
commit 321a871d62
5 changed files with 30 additions and 66 deletions

View File

@ -36,10 +36,6 @@ import traceback
import json import json
from datetime import datetime from datetime import datetime
# set environment variables to use Qt5 and don't convert to Qt4 syntax
# os.environ['PYQTGRAPH_QT_LIB'] = 'PyQt5'
# os.environ["QT_API"] = "pyqt5"
matplotlib.use('Qt5Agg') matplotlib.use('Qt5Agg')
from PySide2 import QtGui, QtCore, QtWidgets from PySide2 import QtGui, QtCore, QtWidgets
@ -3249,8 +3245,6 @@ class MainWindow(QMainWindow):
'auto': event.pylot_autopicks} 'auto': event.pylot_autopicks}
ma_count = {'manual': 0, ma_count = {'manual': 0,
'auto': 0} 'auto': 0}
#ma_count_total = {'manual': 0,
# 'auto': 0}
for ma in ma_props.keys(): for ma in ma_props.keys():
if ma_props[ma]: if ma_props[ma]:
@ -3260,7 +3254,6 @@ class MainWindow(QMainWindow):
continue continue
if pick.get('spe'): if pick.get('spe'):
ma_count[ma] += 1 ma_count[ma] += 1
#ma_count_total[ma] += 1
# init table items for current row # init table items for current row
item_delete = QTableWidgetItem() item_delete = QTableWidgetItem()

View File

@ -115,4 +115,4 @@ dependencies:
- zipp=3.4.1=pyhd8ed1ab_0 - zipp=3.4.1=pyhd8ed1ab_0
- zlib=1.2.11=h516909a_1010 - zlib=1.2.11=h516909a_1010
- zstd=1.4.9=ha95c52a_0 - zstd=1.4.9=ha95c52a_0
prefix: /home/kaan/.conda/envs/pylot_py35 prefix:

View File

@ -1,4 +1,4 @@
#!/usr/bin/env pyth n #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import copy import copy
@ -21,10 +21,6 @@ from pylot.core.util.obspyDMT_interface import qml_from_obspyDMT
from pylot.core.util.utils import fnConstructor, full_range, check4rotated, \ from pylot.core.util.utils import fnConstructor, full_range, check4rotated, \
check4gapsAndMerge, trim_station_components check4gapsAndMerge, trim_station_components
try:
str_TypeLst = [str, unicode] # if python 2.X
except NameError:
str_TypeLst = [str] # if python 3.*
class Data(object): class Data(object):
""" """
@ -52,7 +48,7 @@ class Data(object):
elif isinstance(evtdata, dict): elif isinstance(evtdata, dict):
evt = readPILOTEvent(**evtdata) evt = readPILOTEvent(**evtdata)
evtdata = evt evtdata = evt
elif type(evtdata) in str_TypeLst: elif isinstance(evtdata, str):
try: try:
cat = read_events(evtdata) cat = read_events(evtdata)
if len(cat) != 1: if len(cat) != 1:

View File

@ -8,16 +8,12 @@ import matplotlib
from PySide2 import QtCore, QtGui, QtWidgets from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import Qt from PySide2.QtCore import Qt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure
import matplotlib.patheffects as PathEffects import matplotlib.patheffects as PathEffects
import cartopy.crs as ccrs import cartopy.crs as ccrs
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import cartopy.feature as cf import cartopy.feature as cf
import cartopy.io.shapereader as shpr from cartopy.mpl.gridliner import LongitudeFormatter, LatitudeFormatter
from cartopy.feature import ShapelyFeature
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
import traceback import traceback
import obspy import obspy
@ -30,7 +26,6 @@ from pylot.core.pick.utils import get_quality_class
matplotlib.use('Qt5Agg') matplotlib.use('Qt5Agg')
class MplCanvas(FigureCanvas): class MplCanvas(FigureCanvas):
def __init__(self, parent=None, extern_axes=None, width=5, height=4, dpi=100): def __init__(self, parent=None, extern_axes=None, width=5, height=4, dpi=100):
@ -47,7 +42,6 @@ class MplCanvas(FigureCanvas):
class Array_map(QtWidgets.QWidget): class Array_map(QtWidgets.QWidget):
def __init__(self, parent, metadata, parameter=None, axes=None, annotate=True, pointsize=25., def __init__(self, parent, metadata, parameter=None, axes=None, annotate=True, pointsize=25.,
linewidth=1.5, width=5e6, height=2e6): linewidth=1.5, width=5e6, height=2e6):
# super(Array_map, self).__init__(parent)
QtWidgets.QWidget.__init__(self) QtWidgets.QWidget.__init__(self)
assert (parameter is not None or parent is not None), 'either parent or parameter has to be set' assert (parameter is not None or parent is not None), 'either parent or parameter has to be set'
@ -95,7 +89,7 @@ class Array_map(QtWidgets.QWidget):
def init_graphics(self): def init_graphics(self):
""" """
Initializes all GUI components and figure elements to be populeted by other functions Initializes all GUI components and figure elements to be populated by other functions
""" """
# initialize figure elements # initialize figure elements
@ -111,7 +105,6 @@ class Array_map(QtWidgets.QWidget):
self.map_reset_button = QtWidgets.QPushButton('Reset Map View') self.map_reset_button = QtWidgets.QPushButton('Reset Map View')
self.save_map_button = QtWidgets.QPushButton('Save Map') self.save_map_button = QtWidgets.QPushButton('Save Map')
self.go2eq_button = QtWidgets.QPushButton('Go to Event Location') self.go2eq_button = QtWidgets.QPushButton('Go to Event Location')
# self.map_reset_button.resize(150, 50)
self.main_box = QtWidgets.QVBoxLayout() self.main_box = QtWidgets.QVBoxLayout()
self.setLayout(self.main_box) self.setLayout(self.main_box)
@ -151,7 +144,6 @@ class Array_map(QtWidgets.QWidget):
self.top_row.addWidget(self.refresh_button) self.top_row.addWidget(self.refresh_button)
self.main_box.addWidget(self.plotWidget, 1) self.main_box.addWidget(self.plotWidget, 1)
# self.main_box.addWidget(NavigationToolbar(self.plotWidget, self), 0)
self.bot_row = QtWidgets.QHBoxLayout() self.bot_row = QtWidgets.QHBoxLayout()
self.main_box.addLayout(self.bot_row, 0.3) self.main_box.addLayout(self.bot_row, 0.3)
@ -177,21 +169,17 @@ class Array_map(QtWidgets.QWidget):
# parallels and meridians # parallels and meridians
self.add_merid_paral() self.add_merid_paral()
# self.canvas.axes.set_global()
self.canvas.fig.tight_layout() self.canvas.fig.tight_layout()
# self.plotWidget.draw_idle()
def add_merid_paral(self): def add_merid_paral(self):
self.gridlines = self.canvas.axes.gridlines(draw_labels=False, alpha=0.8, color='gray', linewidth=self.linewidth/2, zorder=7) self.gridlines = self.canvas.axes.gridlines(draw_labels=False, alpha=0.8, color='gray', linewidth=self.linewidth/2, zorder=7)
# current cartopy version does not support label removal. Devs are working on it. # TODO: current cartopy version does not support label removal. Devs are working on it.
# Should be fixed with next cartopy version # Should be fixed with next cartopy version
# self.gridlines.xformatter = LONGITUDE_FORMATTER # self.gridlines.xformatter = LONGITUDE_FORMATTER
# self.gridlines.yformatter = LATITUDE_FORMATTER # self.gridlines.yformatter = LATITUDE_FORMATTER
def remove_merid_paral(self): def remove_merid_paral(self):
if len(self.gridlines.xline_artists): if len(self.gridlines.xline_artists):
# for i in self.gridlines.xline_artists:
# i.remove()
self.gridlines.xline_artists[0].remove() self.gridlines.xline_artists[0].remove()
self.gridlines.yline_artists[0].remove() self.gridlines.yline_artists[0].remove()
@ -477,8 +465,6 @@ class Array_map(QtWidgets.QWidget):
facecolors='none', zorder=12, facecolors='none', zorder=12,
transform=ccrs.PlateCarree(), label='deleted')) transform=ccrs.PlateCarree(), label='deleted'))
# self.canvas.idle_draw()
def openPickDlg(self, ind): def openPickDlg(self, ind):
data = self._parent.get_data().getWFData() data = self._parent.get_data().getWFData()
for index in ind: for index in ind:

View File

@ -53,13 +53,12 @@ from pylot.core.util.utils import prepTimeAxis, full_range, demeanTrace, isSorte
pick_linestyle_plt, pick_color_plt, \ pick_linestyle_plt, pick_color_plt, \
check4rotated, check4doubled, merge_stream, identifyPhase, \ check4rotated, check4doubled, merge_stream, identifyPhase, \
loopIdentifyPhase, trim_station_components, transformFilteroptions2String, \ loopIdentifyPhase, trim_station_components, transformFilteroptions2String, \
identifyPhaseID, get_Bool, get_None, pick_color, getAutoFilteroptions, SetChannelComponents,\ identifyPhaseID, get_Bool, get_None, pick_color, getAutoFilteroptions, SetChannelComponents, \
station_id_remove_channel station_id_remove_channel
from autoPyLoT import autoPyLoT from autoPyLoT import autoPyLoT
from pylot.core.util.thread import Thread from pylot.core.util.thread import Thread
from pylot.core.util.dataprocessing import Metadata from pylot.core.util.dataprocessing import Metadata
if sys.version_info.major == 3: if sys.version_info.major == 3:
import icons_rc_3 as icons_rc import icons_rc_3 as icons_rc
elif sys.version_info.major == 2: elif sys.version_info.major == 2:
@ -67,6 +66,7 @@ elif sys.version_info.major == 2:
else: else:
raise ImportError('Could not determine python version.') raise ImportError('Could not determine python version.')
# workaround to prevent PyCharm from deleting icons_rc import when optimizing imports # workaround to prevent PyCharm from deleting icons_rc import when optimizing imports
# icons_rc = icons_rc # icons_rc = icons_rc
@ -302,7 +302,7 @@ class AddMetadataWidget(QWidget):
item = QtGui.QStandardItem(inventory_path) item = QtGui.QStandardItem(inventory_path)
item.setEditable(False) item.setEditable(False)
self.inventories_add.append(inventory_path) self.inventories_add.append(inventory_path)
self.list_model.appendRow(item) # adds path to visible list self.list_model.appendRow(item) # adds path to visible list
self.selection_box.setText("") self.selection_box.setText("")
def remove_item(self): def remove_item(self):
@ -313,8 +313,8 @@ class AddMetadataWidget(QWidget):
""" """
for index in reversed(sorted(self.list_view.selectionModel().selectedIndexes())): for index in reversed(sorted(self.list_view.selectionModel().selectedIndexes())):
item = self.list_model.itemData(index) item = self.list_model.itemData(index)
inventory_path = item[0] # marked path inventory_path = item[0] # marked path
self.list_model.removeRow(index.row()) # aus der Anzeige-Liste gelöscht self.list_model.removeRow(index.row()) # aus der Anzeige-Liste gelöscht
if inventory_path in self.inventories_add: if inventory_path in self.inventories_add:
self.inventories_add.remove(inventory_path) self.inventories_add.remove(inventory_path)
else: else:
@ -876,7 +876,8 @@ class WaveformWidgetPG(QtWidgets.QWidget):
times = np.array([time for index, time in enumerate(time_ax) if not index % nth_sample]) times = np.array([time for index, time in enumerate(time_ax) if not index % nth_sample])
times_syn = np.array( times_syn = np.array(
[time for index, time in enumerate(time_ax_syn) if not index % nth_sample] if st_syn else []) [time for index, time in enumerate(time_ax_syn) if not index % nth_sample] if st_syn else [])
trace.data = np.array([datum * gain + n for index, datum in enumerate(trace.data) if not index % nth_sample]) trace.data = np.array(
[datum * gain + n for index, datum in enumerate(trace.data) if not index % nth_sample])
trace_syn.data = np.array([datum + n for index, datum in enumerate(trace_syn.data) trace_syn.data = np.array([datum + n for index, datum in enumerate(trace_syn.data)
if not index % nth_sample] if st_syn else []) if not index % nth_sample] if st_syn else [])
plots.append((times, trace.data, plots.append((times, trace.data,
@ -1518,8 +1519,6 @@ class SingleTextLineDialog(QtWidgets.QDialog):
self._buttonbox.rejected.connect(self.reject) self._buttonbox.rejected.connect(self.reject)
class PhaseDefaults(QtWidgets.QDialog): class PhaseDefaults(QtWidgets.QDialog):
def __init__(self, parent=None, nrow=10, def __init__(self, parent=None, nrow=10,
phase_defaults=['P', 'S'], phase_defaults=['P', 'S'],
@ -2236,7 +2235,6 @@ class PickDlg(QDialog):
self.draw() self.draw()
else: else:
self.draw() self.draw()
# self.pick_block = self.togglePickBlocker()
self.disconnect_pick_delete() self.disconnect_pick_delete()
def deactivatePicking(self): def deactivatePicking(self):
@ -2447,7 +2445,7 @@ class PickDlg(QDialog):
data.normalize() data.normalize()
if not data: if not data:
QtWidgets.QMessageBox.warning(self, 'No channel to plot', QtWidgets.QMessageBox.warning(self, 'No channel to plot',
'No channel to plot for phase: {}.'.format(phase)) 'No channel to plot for phase: {}.'.format(phase))
self.leave_picking_mode() self.leave_picking_mode()
return return
@ -2461,7 +2459,8 @@ class PickDlg(QDialog):
# wfdata.filter(**filteroptions)# MP MP removed filtering of original data # wfdata.filter(**filteroptions)# MP MP removed filtering of original data
except ValueError as e: except ValueError as e:
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information, self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Denied', 'setIniPick{}: Could not filter waveform: {}'.format(phase, e)) 'Denied',
'setIniPick{}: Could not filter waveform: {}'.format(phase, e))
self.qmb.show() self.qmb.show()
snr = [] snr = []
@ -2546,7 +2545,7 @@ class PickDlg(QDialog):
wfdata.filter(**filteroptions) wfdata.filter(**filteroptions)
except ValueError as e: except ValueError as e:
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information, self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Denied', 'setPick: Could not filter waveform: {}'.format(e)) 'Denied', 'setPick: Could not filter waveform: {}'.format(e))
self.qmb.show() self.qmb.show()
# get earliest and latest possible pick and symmetric pick error # get earliest and latest possible pick and symmetric pick error
@ -2586,9 +2585,8 @@ class PickDlg(QDialog):
minFMSNR = parameter.get('minFMSNR') minFMSNR = parameter.get('minFMSNR')
quality = get_quality_class(spe, parameter.get('timeerrorsP')) quality = get_quality_class(spe, parameter.get('timeerrorsP'))
if quality <= minFMweight and snr >= minFMSNR: if quality <= minFMweight and snr >= minFMSNR:
FM = fmpicker(self.getWFData().select(channel=channel), wfdata, parameter.get('fmpickwin'), FM = fmpicker(self.getWFData().select(channel=channel), wfdata, parameter.get('fmpickwin'),
pick -stime_diff) pick - stime_diff)
# save pick times for actual phase # save pick times for actual phase
phasepicks = dict(epp=epp, lpp=lpp, mpp=mpp, spe=spe, fm=FM, phasepicks = dict(epp=epp, lpp=lpp, mpp=mpp, spe=spe, fm=FM,
@ -2603,8 +2601,6 @@ class PickDlg(QDialog):
self.disconnectPressEvent() self.disconnectPressEvent()
self.enable_ar_buttons() self.enable_ar_buttons()
self.zoomAction.setEnabled(True) self.zoomAction.setEnabled(True)
# self.pick_block = self.togglPickBlocker()
# self.resetZoom()
self.leave_picking_mode() self.leave_picking_mode()
@ -2618,7 +2614,7 @@ class PickDlg(QDialog):
def warn_unknown_phase(self, phase=None): def warn_unknown_phase(self, phase=None):
QtWidgets.QMessageBox.warning(self, 'Unknown phase ID', QtWidgets.QMessageBox.warning(self, 'Unknown phase ID',
'Could not identify phase ID: {}.'.format(phase)) 'Could not identify phase ID: {}.'.format(phase))
def disconnectPressEvent(self): def disconnectPressEvent(self):
self.multicompfig.mpl_disconnect(self.cidpress) self.multicompfig.mpl_disconnect(self.cidpress)
@ -2799,7 +2795,7 @@ class PickDlg(QDialog):
self.renamePhaseInDict(picks, phase, new_phase) self.renamePhaseInDict(picks, phase, new_phase)
except KeyError as e: except KeyError as e:
QtWidgets.QMessageBox.warning(self, 'Could not rename phase', QtWidgets.QMessageBox.warning(self, 'Could not rename phase',
'Could not rename phase {} to {}: {}'.format(phase, new_phase, e)) 'Could not rename phase {} to {}: {}'.format(phase, new_phase, e))
self.leave_rename_phase() self.leave_rename_phase()
self.refreshPlot() self.refreshPlot()
@ -2906,11 +2902,6 @@ class PickDlg(QDialog):
if phase: if phase:
filtoptions = self.getFilterOptions(self.getPhaseID(phase), gui_filter=True).parseFilterOptions() filtoptions = self.getFilterOptions(self.getPhaseID(phase), gui_filter=True).parseFilterOptions()
# if self.filterActionP.isChecked() or self.filterActionS.isChecked():
# if not phase:
# filtoptions = FilterOptionsDialog.getFilterObject()
# filtoptions = filtoptions.parseFilterOptions()
if filtoptions is not None: if filtoptions is not None:
data.detrend('linear') data.detrend('linear')
data.taper(0.02, type='cosine') data.taper(0.02, type='cosine')
@ -3029,8 +3020,6 @@ class PickDlg(QDialog):
# set channel labels # set channel labels
self.multicompfig.setYTickLabels(pos, labels) self.multicompfig.setYTickLabels(pos, labels)
# self.multicompfig.setXLims(ax, self.getXLims())
# self.multicompfig.setYLims(ax, self.getYLims())
def zoom(self): def zoom(self):
if self.zoomAction.isChecked() and self.pick_block: if self.zoomAction.isChecked() and self.pick_block:
@ -3065,7 +3054,7 @@ class PickDlg(QDialog):
else: else:
self.refreshPlot() self.refreshPlot()
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information, self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Denied', 'New picks rejected!') 'Denied', 'New picks rejected!')
self.qmb.show() self.qmb.show()
def accept(self): def accept(self):
@ -3074,7 +3063,7 @@ class PickDlg(QDialog):
QDialog.accept(self) QDialog.accept(self)
else: else:
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information, self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Accepted', 'New picks applied!') 'Accepted', 'New picks applied!')
self.qmb.show() self.qmb.show()
@ -3092,7 +3081,7 @@ class CanvasWidget(QWidget):
''' '''
def __init__(self, parent, canvas): def __init__(self, parent, canvas):
QtWidgets.QWidget.__init__(self, parent)#, 1) QtWidgets.QWidget.__init__(self, parent) # , 1)
canvas = canvas canvas = canvas
self.main_layout = QtWidgets.QVBoxLayout() self.main_layout = QtWidgets.QVBoxLayout()
self.setLayout(self.main_layout) self.setLayout(self.main_layout)
@ -3812,7 +3801,7 @@ class TuneAutopicker(QWidget):
'savexml': False, 'savexml': False,
'obspyDMT_wfpath': wfpath} 'obspyDMT_wfpath': wfpath}
event = self.get_current_event() event = self.get_current_event()
#self.parent().saveData(event, event.path, '.xml') MP MP uncommented because overwriting pick files in tune mode # self.parent().saveData(event, event.path, '.xml') MP MP uncommented because overwriting pick files in tune mode
for key in self.fig_dict.keys(): for key in self.fig_dict.keys():
if not key == 'plot_style': if not key == 'plot_style':
self.fig_dict[key].clear() self.fig_dict[key].clear()
@ -3888,7 +3877,7 @@ class TuneAutopicker(QWidget):
def _warn(self, message, info=None): def _warn(self, message, info=None):
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Warning, self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Warning,
'Warning', message) 'Warning', message)
self.qmb.setDetailedText(str(info)) self.qmb.setDetailedText(str(info))
self.qmb.show() self.qmb.show()
@ -4131,7 +4120,7 @@ class PylotParaBox(QtWidgets.QWidget):
layout = QtWidgets.QVBoxLayout() layout = QtWidgets.QVBoxLayout()
dialog.setLayout(layout) dialog.setLayout(layout)
buttonbox = QtWidgets.QDialogButtonBox(QDialogButtonBox.Ok | buttonbox = QtWidgets.QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel) QDialogButtonBox.Cancel)
buttonbox.accepted.connect(dialog.accept) buttonbox.accepted.connect(dialog.accept)
buttonbox.accepted.connect(self.refresh) buttonbox.accepted.connect(self.refresh)
buttonbox.accepted.connect(self.params_from_gui) buttonbox.accepted.connect(self.params_from_gui)
@ -4315,7 +4304,7 @@ class PylotParaBox(QtWidgets.QWidget):
def _warn(self, message): def _warn(self, message):
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Warning, self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Warning,
'Warning', message) 'Warning', message)
self.qmb.show() self.qmb.show()
@ -4685,7 +4674,7 @@ class InputsTab(PropTab):
"data/Structure": self.structureSelect.setCurrentIndex(index), "data/Structure": self.structureSelect.setCurrentIndex(index),
"tstart": self.tstartBox.setValue(0), "tstart": self.tstartBox.setValue(0),
"tstop": self.tstopBox.setValue(1e6), "tstop": self.tstopBox.setValue(1e6),
"autosaveXML": self.autosaveXML_checkbox.setChecked(True),} "autosaveXML": self.autosaveXML_checkbox.setChecked(True), }
return values return values