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

@ -59,7 +59,6 @@ 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
@ -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):
@ -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 = []
@ -2589,7 +2588,6 @@ class PickDlg(QDialog):
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,
picker='manual', channel=channel, picker='manual', channel=channel,
@ -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()
@ -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: