feature/port-to-py3 #11
7
PyLoT.py
7
PyLoT.py
@ -36,10 +36,6 @@ import traceback
|
||||
import json
|
||||
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')
|
||||
|
||||
from PySide2 import QtGui, QtCore, QtWidgets
|
||||
kaan marked this conversation as resolved
Outdated
|
||||
@ -3249,8 +3245,6 @@ class MainWindow(QMainWindow):
|
||||
'auto': event.pylot_autopicks}
|
||||
ma_count = {'manual': 0,
|
||||
'auto': 0}
|
||||
#ma_count_total = {'manual': 0,
|
||||
# 'auto': 0}
|
||||
|
||||
for ma in ma_props.keys():
|
||||
if ma_props[ma]:
|
||||
@ -3260,7 +3254,6 @@ class MainWindow(QMainWindow):
|
||||
continue
|
||||
if pick.get('spe'):
|
||||
ma_count[ma] += 1
|
||||
#ma_count_total[ma] += 1
|
||||
|
||||
# init table items for current row
|
||||
item_delete = QTableWidgetItem()
|
||||
|
@ -115,4 +115,4 @@ dependencies:
|
||||
- zipp=3.4.1=pyhd8ed1ab_0
|
||||
- zlib=1.2.11=h516909a_1010
|
||||
- zstd=1.4.9=ha95c52a_0
|
||||
prefix: /home/kaan/.conda/envs/pylot_py35
|
||||
prefix:
|
||||
kaan marked this conversation as resolved
Outdated
sebastianw
commented
This has no benefit for other users than Kaan. Please generalize the file. This has no benefit for other users than Kaan. Please generalize the file.
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env pyth n
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
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, \
|
||||
check4gapsAndMerge, trim_station_components
|
||||
|
||||
try:
|
||||
str_TypeLst = [str, unicode] # if python 2.X
|
||||
except NameError:
|
||||
str_TypeLst = [str] # if python 3.*
|
||||
|
||||
class Data(object):
|
||||
"""
|
||||
@ -52,7 +48,7 @@ class Data(object):
|
||||
elif isinstance(evtdata, dict):
|
||||
evt = readPILOTEvent(**evtdata)
|
||||
evtdata = evt
|
||||
elif type(evtdata) in str_TypeLst:
|
||||
elif isinstance(evtdata, str):
|
||||
try:
|
||||
cat = read_events(evtdata)
|
||||
if len(cat) != 1:
|
||||
|
@ -8,16 +8,12 @@ import matplotlib
|
||||
from PySide2 import QtCore, QtGui, QtWidgets
|
||||
from PySide2.QtCore import Qt
|
||||
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 cartopy.crs as ccrs
|
||||
import matplotlib.pyplot as plt
|
||||
import cartopy.feature as cf
|
||||
import cartopy.io.shapereader as shpr
|
||||
from cartopy.feature import ShapelyFeature
|
||||
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
|
||||
from cartopy.mpl.gridliner import LongitudeFormatter, LatitudeFormatter
|
||||
|
||||
import traceback
|
||||
import obspy
|
||||
@ -30,7 +26,6 @@ from pylot.core.pick.utils import get_quality_class
|
||||
matplotlib.use('Qt5Agg')
|
||||
|
||||
|
||||
|
||||
class MplCanvas(FigureCanvas):
|
||||
|
||||
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):
|
||||
def __init__(self, parent, metadata, parameter=None, axes=None, annotate=True, pointsize=25.,
|
||||
linewidth=1.5, width=5e6, height=2e6):
|
||||
# super(Array_map, self).__init__(parent)
|
||||
QtWidgets.QWidget.__init__(self)
|
||||
|
||||
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):
|
||||
"""
|
||||
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
|
||||
|
||||
@ -111,7 +105,6 @@ class Array_map(QtWidgets.QWidget):
|
||||
self.map_reset_button = QtWidgets.QPushButton('Reset Map View')
|
||||
self.save_map_button = QtWidgets.QPushButton('Save Map')
|
||||
self.go2eq_button = QtWidgets.QPushButton('Go to Event Location')
|
||||
# self.map_reset_button.resize(150, 50)
|
||||
|
||||
kaan marked this conversation as resolved
Outdated
sebastianw
commented
see above, commented code see above, commented code
|
||||
self.main_box = QtWidgets.QVBoxLayout()
|
||||
self.setLayout(self.main_box)
|
||||
@ -151,7 +144,6 @@ class Array_map(QtWidgets.QWidget):
|
||||
self.top_row.addWidget(self.refresh_button)
|
||||
|
||||
self.main_box.addWidget(self.plotWidget, 1)
|
||||
# self.main_box.addWidget(NavigationToolbar(self.plotWidget, self), 0)
|
||||
|
||||
self.bot_row = QtWidgets.QHBoxLayout()
|
||||
self.main_box.addLayout(self.bot_row, 0.3)
|
||||
@ -177,21 +169,17 @@ class Array_map(QtWidgets.QWidget):
|
||||
# parallels and meridians
|
||||
self.add_merid_paral()
|
||||
|
||||
# self.canvas.axes.set_global()
|
||||
self.canvas.fig.tight_layout()
|
||||
# self.plotWidget.draw_idle()
|
||||
|
||||
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)
|
||||
# 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
|
||||
# self.gridlines.xformatter = LONGITUDE_FORMATTER
|
||||
# self.gridlines.yformatter = LATITUDE_FORMATTER
|
||||
|
||||
def remove_merid_paral(self):
|
||||
if len(self.gridlines.xline_artists):
|
||||
# for i in self.gridlines.xline_artists:
|
||||
# i.remove()
|
||||
self.gridlines.xline_artists[0].remove()
|
||||
self.gridlines.yline_artists[0].remove()
|
||||
|
||||
@ -477,8 +465,6 @@ class Array_map(QtWidgets.QWidget):
|
||||
facecolors='none', zorder=12,
|
||||
transform=ccrs.PlateCarree(), label='deleted'))
|
||||
|
||||
# self.canvas.idle_draw()
|
||||
|
||||
def openPickDlg(self, ind):
|
||||
data = self._parent.get_data().getWFData()
|
||||
for index in ind:
|
||||
|
@ -53,13 +53,12 @@ from pylot.core.util.utils import prepTimeAxis, full_range, demeanTrace, isSorte
|
||||
pick_linestyle_plt, pick_color_plt, \
|
||||
check4rotated, check4doubled, merge_stream, identifyPhase, \
|
||||
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
|
||||
from autoPyLoT import autoPyLoT
|
||||
from pylot.core.util.thread import Thread
|
||||
from pylot.core.util.dataprocessing import Metadata
|
||||
|
||||
|
||||
if sys.version_info.major == 3:
|
||||
import icons_rc_3 as icons_rc
|
||||
elif sys.version_info.major == 2:
|
||||
@ -67,6 +66,7 @@ elif sys.version_info.major == 2:
|
||||
else:
|
||||
raise ImportError('Could not determine python version.')
|
||||
|
||||
|
||||
# workaround to prevent PyCharm from deleting icons_rc import when optimizing imports
|
||||
# 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_syn = np.array(
|
||||
[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)
|
||||
if not index % nth_sample] if st_syn else [])
|
||||
plots.append((times, trace.data,
|
||||
@ -1518,8 +1519,6 @@ class SingleTextLineDialog(QtWidgets.QDialog):
|
||||
self._buttonbox.rejected.connect(self.reject)
|
||||
|
||||
|
||||
|
||||
|
||||
class PhaseDefaults(QtWidgets.QDialog):
|
||||
def __init__(self, parent=None, nrow=10,
|
||||
phase_defaults=['P', 'S'],
|
||||
@ -2236,7 +2235,6 @@ class PickDlg(QDialog):
|
||||
self.draw()
|
||||
else:
|
||||
self.draw()
|
||||
# self.pick_block = self.togglePickBlocker()
|
||||
self.disconnect_pick_delete()
|
||||
|
||||
def deactivatePicking(self):
|
||||
@ -2461,7 +2459,8 @@ class PickDlg(QDialog):
|
||||
# wfdata.filter(**filteroptions)# MP MP removed filtering of original data
|
||||
except ValueError as e:
|
||||
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()
|
||||
|
||||
snr = []
|
||||
@ -2587,8 +2586,7 @@ class PickDlg(QDialog):
|
||||
quality = get_quality_class(spe, parameter.get('timeerrorsP'))
|
||||
if quality <= minFMweight and snr >= minFMSNR:
|
||||
FM = fmpicker(self.getWFData().select(channel=channel), wfdata, parameter.get('fmpickwin'),
|
||||
pick -stime_diff)
|
||||
|
||||
pick - stime_diff)
|
||||
|
||||
# save pick times for actual phase
|
||||
phasepicks = dict(epp=epp, lpp=lpp, mpp=mpp, spe=spe, fm=FM,
|
||||
@ -2603,8 +2601,6 @@ class PickDlg(QDialog):
|
||||
self.disconnectPressEvent()
|
||||
self.enable_ar_buttons()
|
||||
self.zoomAction.setEnabled(True)
|
||||
# self.pick_block = self.togglPickBlocker()
|
||||
# self.resetZoom()
|
||||
|
||||
self.leave_picking_mode()
|
||||
|
||||
@ -2906,11 +2902,6 @@ class PickDlg(QDialog):
|
||||
if phase:
|
||||
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:
|
||||
data.detrend('linear')
|
||||
data.taper(0.02, type='cosine')
|
||||
@ -3029,8 +3020,6 @@ class PickDlg(QDialog):
|
||||
|
||||
# set channel labels
|
||||
self.multicompfig.setYTickLabels(pos, labels)
|
||||
# self.multicompfig.setXLims(ax, self.getXLims())
|
||||
# self.multicompfig.setYLims(ax, self.getYLims())
|
||||
|
||||
def zoom(self):
|
||||
if self.zoomAction.isChecked() and self.pick_block:
|
||||
@ -3092,7 +3081,7 @@ class CanvasWidget(QWidget):
|
||||
'''
|
||||
|
||||
def __init__(self, parent, canvas):
|
||||
QtWidgets.QWidget.__init__(self, parent)#, 1)
|
||||
QtWidgets.QWidget.__init__(self, parent) # , 1)
|
||||
canvas = canvas
|
||||
self.main_layout = QtWidgets.QVBoxLayout()
|
||||
self.setLayout(self.main_layout)
|
||||
@ -3812,7 +3801,7 @@ class TuneAutopicker(QWidget):
|
||||
'savexml': False,
|
||||
'obspyDMT_wfpath': wfpath}
|
||||
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():
|
||||
if not key == 'plot_style':
|
||||
self.fig_dict[key].clear()
|
||||
@ -4685,7 +4674,7 @@ class InputsTab(PropTab):
|
||||
"data/Structure": self.structureSelect.setCurrentIndex(index),
|
||||
"tstart": self.tstartBox.setValue(0),
|
||||
"tstop": self.tstopBox.setValue(1e6),
|
||||
"autosaveXML": self.autosaveXML_checkbox.setChecked(True),}
|
||||
"autosaveXML": self.autosaveXML_checkbox.setChecked(True), }
|
||||
return values
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
Please remove commented code if not needed for backup solution implementation. In this case just remove.