[fix] made PyLoT start again #7

Closed
sebastianw wants to merge 3 commits from feature/python-3-compatibility into develop
14 changed files with 108789 additions and 109233 deletions
Showing only changes of commit cf70c65e83 - Show all commits

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (pylot)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pylot.iml" filepath="$PROJECT_DIR$/.idea/pylot.iml" />
</modules>
</component>
</project>

12
.idea/pylot.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.9 (pylot)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
</module>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -35,18 +35,17 @@ import traceback
import json import json
from datetime import datetime from datetime import datetime
matplotlib.use('Qt4Agg') matplotlib.use('Qt5Agg')
matplotlib.rcParams['backend.qt4'] = 'PySide'
matplotlib.rcParams['savefig.dpi'] = 300 matplotlib.rcParams['savefig.dpi'] = 300
from PySide2 import QtGui, QtCore, QtWidgets
from PySide import QtGui, QtCore from PySide2.QtCore import QCoreApplication, QSettings, Signal, QFile, \
from PySide.QtCore import QCoreApplication, QSettings, Signal, QFile, \
QFileInfo, Qt, QSize QFileInfo, Qt, QSize
from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \ from PySide2.QtGui import QIcon, QKeySequence, QPixmap
QWidget, QHBoxLayout, QVBoxLayout, QStyle, QKeySequence, QLabel, QFrame, QAction, \ from PySide2.QtWidgets import QMainWindow, QInputDialog, QFileDialog, \
QDialog, QApplication, QPixmap, QMessageBox, QSplashScreen, \ QWidget, QHBoxLayout, QVBoxLayout, QStyle, QLabel, QFrame, QAction, \
QActionGroup, QListWidget, QListView, QAbstractItemView, \ QDialog, QErrorMessage, QApplication, QMessageBox, QSplashScreen, \
QActionGroup, QListWidget, QLineEdit, QListView, QAbstractItemView, \
QTreeView, QComboBox, QTabWidget, QPushButton, QGridLayout QTreeView, QComboBox, QTabWidget, QPushButton, QGridLayout
import numpy as np import numpy as np
from obspy import UTCDateTime, Stream from obspy import UTCDateTime, Stream
@ -58,9 +57,10 @@ from pylot.core.util.obspyDMT_interface import check_obspydmt_structure
import pyqtgraph as pg import pyqtgraph as pg
try: try:
from matplotlib.backends.backend_qt4agg import FigureCanvas from matplotlib.backends.backend_qt5agg import FigureCanvas
except ImportError: except ImportError:
from matplotlib.backends.backend_qt4agg 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 from matplotlib.figure import Figure
from pylot.core.analysis.magnitude import LocalMagnitude, MomentMagnitude from pylot.core.analysis.magnitude import LocalMagnitude, MomentMagnitude
@ -87,7 +87,7 @@ from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
PylotCanvas, WaveformWidgetPG, PropertiesDlg, HelpForm, createAction, PickDlg, \ PylotCanvas, WaveformWidgetPG, PropertiesDlg, HelpForm, createAction, PickDlg, \
ComparisonWidget, TuneAutopicker, PylotParaBox, AutoPickDlg, CanvasWidget, AutoPickWidget, \ ComparisonWidget, TuneAutopicker, PylotParaBox, AutoPickDlg, CanvasWidget, AutoPickWidget, \
CompareEventsWidget, ProgressBarWidget, AddMetadataWidget, SingleTextLineDialog CompareEventsWidget, ProgressBarWidget, AddMetadataWidget, SingleTextLineDialog
from pylot.core.util.array_map import Array_map #from pylot.core.util.array_map import Array_map
from pylot.core.util.structure import DATASTRUCTURE from pylot.core.util.structure import DATASTRUCTURE
from pylot.core.util.thread import Thread, Worker from pylot.core.util.thread import Thread, Worker
from pylot.core.util.version import get_git_version as _getVersionString from pylot.core.util.version import get_git_version as _getVersionString
@ -581,7 +581,6 @@ class MainWindow(QMainWindow):
self.autoPickMenu = self.pickMenu.addMenu(self.autopicksicon_small, 'Automatic picking') self.autoPickMenu = self.pickMenu.addMenu(self.autopicksicon_small, 'Automatic picking')
self.autoPickMenu.setEnabled(False) self.autoPickMenu.setEnabled(False)
autoPickActions = (self.auto_pick, self.auto_pick_local, self.auto_pick_sge) autoPickActions = (self.auto_pick, self.auto_pick_local, self.auto_pick_sge)
self.helpMenu = self.menuBar().addMenu('&Help') self.helpMenu = self.menuBar().addMenu('&Help')
@ -714,7 +713,6 @@ class MainWindow(QMainWindow):
self.setCentralWidget(_widget) self.setCentralWidget(_widget)
def init_wfWidget(self): def init_wfWidget(self):
xlab = self.startTime.strftime('seconds since %Y/%m/%d %H:%M:%S (%Z)') 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())
@ -760,7 +758,6 @@ class MainWindow(QMainWindow):
if event.key() == QtCore.Qt.Key.Key_R: if event.key() == QtCore.Qt.Key.Key_R:
self.reset_gain() self.reset_gain()
def keyReleaseEvent(self, event): def keyReleaseEvent(self, event):
if event.key() == QtCore.Qt.Key.Key_Control: if event.key() == QtCore.Qt.Key.Key_Control:
self._ctrl = False self._ctrl = False
@ -932,7 +929,6 @@ class MainWindow(QMainWindow):
self.recentProjectsMenu.addAction(action) self.recentProjectsMenu.addAction(action)
@property @property
def inputs(self): def inputs(self):
return self._inputs return self._inputs
@ -1151,7 +1147,8 @@ class MainWindow(QMainWindow):
eventlist_file = os.path.join(basepath, 'eventlist.txt') eventlist_file = os.path.join(basepath, 'eventlist.txt')
if os.path.isfile(eventlist_file): if os.path.isfile(eventlist_file):
with open(eventlist_file, 'r') as infile: with open(eventlist_file, 'r') as infile:
eventlist_subset = [os.path.join(basepath, filename.split('\n')[0]) for filename in infile.readlines()] eventlist_subset = [os.path.join(basepath, filename.split('\n')[0]) for filename in
infile.readlines()]
msg = 'Found file "eventlist.txt" in database path. WILL ONLY USE SELECTED EVENTS out of {} events ' \ msg = 'Found file "eventlist.txt" in database path. WILL ONLY USE SELECTED EVENTS out of {} events ' \
'contained in this subset' 'contained in this subset'
print(msg.format(len(eventlist_subset))) print(msg.format(len(eventlist_subset)))
@ -1505,6 +1502,7 @@ class MainWindow(QMainWindow):
event = self.get_current_event() event = self.get_current_event()
if not type(outformats) == list: if not type(outformats) == list:
outformats = [outformats] outformats = [outformats]
def getSavePath(event, directory, outformats): def getSavePath(event, directory, outformats):
if not directory: if not directory:
title = 'Save event data as {} to directory ...'.format(outformats) title = 'Save event data as {} to directory ...'.format(outformats)
@ -2870,7 +2868,6 @@ class MainWindow(QMainWindow):
else: else:
event.addAutopicks(picksdict['auto']) event.addAutopicks(picksdict['auto'])
def drawPicks(self, station=None, picktype=None, stime=None): def drawPicks(self, station=None, picktype=None, stime=None):
# if picktype not specified, draw both # if picktype not specified, draw both
if not stime: if not stime:
@ -3392,7 +3389,6 @@ class MainWindow(QMainWindow):
if event == current_event: if event == current_event:
set_background_color(item_list, QtGui.QColor(*(0, 143, 143, 255))) set_background_color(item_list, QtGui.QColor(*(0, 143, 143, 255)))
def set_metadata(self): def set_metadata(self):
self.project.inventories = self.metadata.inventories self.project.inventories = self.metadata.inventories
if self.metadata.inventories: if self.metadata.inventories:
@ -3697,7 +3693,6 @@ class MainWindow(QMainWindow):
self.plotWaveformDataThread() self.plotWaveformDataThread()
self.refreshTabs() self.refreshTabs()
def PyLoTprefs(self): def PyLoTprefs(self):
if not self._props: if not self._props:
self._props = PropertiesDlg(self, infile=self.infile, self._props = PropertiesDlg(self, infile=self.infile,

View File

@ -29,7 +29,6 @@
<file>icons/map.png</file> <file>icons/map.png</file>
<file>icons/openloc.png</file> <file>icons/openloc.png</file>
<file>icons/compare_button.png</file> <file>icons/compare_button.png</file>
<file>icons/pick_qualities_button.png</file>
<file>icons/locate_button.png</file> <file>icons/locate_button.png</file>
<file>icons/Matlab_PILOT_icon.png</file> <file>icons/Matlab_PILOT_icon.png</file>
<file>icons/printer.png</file> <file>icons/printer.png</file>

217791
icons_rc_3.py

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ from obspy.core import read, Stream, UTCDateTime
from obspy.core.event import Event as ObsPyEvent from obspy.core.event import Event as ObsPyEvent
from obspy.io.sac import SacIOError from obspy.io.sac import SacIOError
from PySide.QtGui import QMessageBox from PySide2.QtWidgets import QMessageBox
import pylot.core.loc.velest as velest import pylot.core.loc.velest as velest
import pylot.core.loc.focmec as focmec import pylot.core.loc.focmec as focmec
@ -21,6 +21,7 @@ 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
class Data(object): class Data(object):
""" """
Data container with attributes wfdata holding ~obspy.core.stream. Data container with attributes wfdata holding ~obspy.core.stream.
@ -47,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, unicode]: elif type(evtdata) == str:
try: try:
cat = read_events(evtdata) cat = read_events(evtdata)
if len(cat) is not 1: if len(cat) is not 1:
@ -288,6 +289,7 @@ class Data(object):
self.checkEvent(event, fcheck) self.checkEvent(event, fcheck)
self.setEvtData(event) self.setEvtData(event)
self.get_evt_data().write(fnout + fnext, format=evtformat) self.get_evt_data().write(fnout + fnext, format=evtformat)
# try exporting event # try exporting event
@ -489,7 +491,8 @@ class Data(object):
real_or_syn_data[synthetic] += read(fname, format='GSE2', starttime=self.tstart, endtime=self.tstop) real_or_syn_data[synthetic] += read(fname, format='GSE2', starttime=self.tstart, endtime=self.tstop)
except Exception as e: except Exception as e:
try: try:
real_or_syn_data[synthetic] += read(fname, format='SEGY', starttime=self.tstart, endtime=self.tstop) real_or_syn_data[synthetic] += read(fname, format='SEGY', starttime=self.tstart,
endtime=self.tstop)
except Exception as e: except Exception as e:
warnmsg += '{0}\n{1}\n'.format(fname, e) warnmsg += '{0}\n{1}\n'.format(fname, e)
except SacIOError as se: except SacIOError as se:

View File

@ -6,7 +6,8 @@ import matplotlib.pyplot as plt
import numpy as np import numpy as np
import obspy import obspy
import traceback import traceback
from PySide import QtGui #from PySide2 import QtGui
from PySide2 import QtWidgets as QtGui
from matplotlib.figure import Figure from matplotlib.figure import Figure
from mpl_toolkits.axes_grid1.inset_locator import inset_axes from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap

View File

@ -4,8 +4,8 @@ import os
import sys import sys
import traceback import traceback
from PySide.QtCore import QThread, Signal, Qt, Slot, QRunnable, QObject from PySide2.QtCore import QThread, Signal, Qt, Slot, QRunnable, QObject
from PySide.QtGui import QDialog, QProgressBar, QLabel, QHBoxLayout from PySide2.QtWidgets import QDialog, QProgressBar, QLabel, QHBoxLayout
class Thread(QThread): class Thread(QThread):

View File

@ -17,27 +17,28 @@ import sys
import time import time
import traceback import traceback
matplotlib.use('QT4Agg') matplotlib.use('QT5Agg')
from matplotlib.figure import Figure from matplotlib.figure import Figure
try: try:
from matplotlib.backends.backend_qt4agg import FigureCanvas from matplotlib.backends.backend_qt5agg import FigureCanvas
except ImportError: except ImportError:
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT
from matplotlib.widgets import MultiCursor from matplotlib.widgets import MultiCursor
from obspy import read from obspy import read
from PySide import QtCore, QtGui from PySide2 import QtCore, QtGui
from PySide.QtGui import QAction, QApplication, QCheckBox, QComboBox, \ from PySide2.QtGui import QIcon, QPixmap, QKeySequence
from PySide2.QtWidgets import QAction, QApplication, QCheckBox, QComboBox, \
QDateTimeEdit, QDialog, QDialogButtonBox, QDoubleSpinBox, QGroupBox, \ QDateTimeEdit, QDialog, QDialogButtonBox, QDoubleSpinBox, QGroupBox, \
QGridLayout, QFormLayout, QIcon, QLabel, QLineEdit, QMessageBox, \ QGridLayout, QFormLayout, QLabel, QLineEdit, QMessageBox, \
QPixmap, QSpinBox, QTabWidget, QToolBar, QVBoxLayout, QHBoxLayout, QWidget, \ QSpinBox, QTabWidget, QToolBar, QVBoxLayout, QHBoxLayout, QWidget, \
QPushButton, QFileDialog, QInputDialog, QKeySequence QPushButton, QFileDialog, QInputDialog
from PySide.QtCore import QSettings, Qt, QUrl, Signal from PySide2.QtCore import QSettings, Qt, QUrl, Signal, Slot
from PySide.QtWebKit import QWebView from PySide2.QtWebEngineWidgets import QWebEngineView as QWebView
from obspy import Stream, Trace, UTCDateTime from obspy import Stream, UTCDateTime
from obspy.core.util import AttribDict from obspy.core.util import AttribDict
from obspy.taup import TauPyModel from obspy.taup import TauPyModel
from obspy.taup.utils import get_phase_names from obspy.taup.utils import get_phase_names