From a017c4deb4312a042d2c0a317ea81f20e3fde61c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Jul 2017 15:26:39 +0200 Subject: [PATCH] [bugfix] various bugfixes while testing on Windows with py3 --- QtPyLoT.py | 3 +++ icons_rc_3.py | 2 +- pylot/core/io/phases.py | 6 +++--- pylot/core/pick/utils.py | 17 +++++++++-------- pylot/core/util/dataprocessing.py | 3 +-- pylot/core/util/map_projection.py | 1 + pylot/core/util/widgets.py | 10 +++++++--- 7 files changed, 25 insertions(+), 17 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index b1e132f8..6b326114 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -1940,6 +1940,9 @@ class MainWindow(QMainWindow): if picks['epp'] and picks['lpp']: epp = picks['epp'] - stime lpp = picks['lpp'] - stime + else: + epp = None + lpp = None spe = picks['spe'] if not spe and epp and lpp: diff --git a/icons_rc_3.py b/icons_rc_3.py index 476f229c..aff2fffe 100644 --- a/icons_rc_3.py +++ b/icons_rc_3.py @@ -6,7 +6,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore +from PySide import QtCore qt_resource_data = b"\ \x00\x00\x9e\x04\ diff --git a/pylot/core/io/phases.py b/pylot/core/io/phases.py index 5405894b..2d46ec9a 100644 --- a/pylot/core/io/phases.py +++ b/pylot/core/io/phases.py @@ -253,8 +253,8 @@ def picks_from_picksdict(picks, creation_info=None): lpp = phase['lpp'] pick.time_errors.lower_uncertainty = onset - epp pick.time_errors.upper_uncertainty = lpp - onset - except KeyError as e: - warnings.warn(e.message, RuntimeWarning) + except (KeyError, TypeError) as e: + warnings.warn(str(e), RuntimeWarning) try: picker = phase['picker'] except KeyError as e: @@ -274,7 +274,7 @@ def picks_from_picksdict(picks, creation_info=None): else: pick.polarity = 'undecidable' except KeyError as e: - if 'fm' in e.message: # no polarity information found for this phase + if 'fm' in str(e): # no polarity information found for this phase pass else: raise e diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index e8ad357f..53a9430d 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -480,14 +480,15 @@ def getResolutionWindow(snr, extent): 'global': {'HRW': 40., 'MRW': 100., 'LRW': 200., 'VLRW': 300.} } - if snr < 1.5: - time_resolution = res_wins[extent]['VLRW'] - elif snr < 2.: - time_resolution = res_wins[extent]['LRW'] - elif snr < 3.: - time_resolution = res_wins[extent]['MRW'] - elif snr >3.: - time_resolution = res_wins[extent]['HRW'] + if snr: + if snr < 1.5: + time_resolution = res_wins[extent]['VLRW'] + elif snr < 2.: + time_resolution = res_wins[extent]['LRW'] + elif snr < 3.: + time_resolution = res_wins[extent]['MRW'] + elif snr >3.: + time_resolution = res_wins[extent]['HRW'] else: time_resolution = res_wins[extent]['VLRW'] diff --git a/pylot/core/util/dataprocessing.py b/pylot/core/util/dataprocessing.py index dc8536ed..2eea80a8 100644 --- a/pylot/core/util/dataprocessing.py +++ b/pylot/core/util/dataprocessing.py @@ -4,7 +4,6 @@ import os import glob import sys -from obspy.io.xseed import Parser import numpy as np @@ -170,7 +169,7 @@ def read_metadata(path_to_inventory): invfile = list() respfile = list() # possible file extensions specified here: - inv = dict(dless=dlfile, xml=invfile, resp=respfile, dseed=dlfile) + inv = dict(dless=dlfile, xml=invfile, resp=respfile, dseed=dlfile[:]) if os.path.isfile(path_to_inventory): ext = os.path.splitext(path_to_inventory)[1].split('.')[1] inv[ext] += [path_to_inventory] diff --git a/pylot/core/util/map_projection.py b/pylot/core/util/map_projection.py index 8a577c83..c874e97b 100644 --- a/pylot/core/util/map_projection.py +++ b/pylot/core/util/map_projection.py @@ -19,6 +19,7 @@ class map_projection(QtGui.QWidget): ''' QtGui.QWidget.__init__(self) self._parent = parent + self.metadata = parent.metadata self.parser = parent.metadata[1] self.picks = None self.picks_dict = None diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index e627fe55..c33781fd 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -829,7 +829,7 @@ class PickDlg(QDialog): self.drawArrivals() except Exception as e: print('Warning: Could not init expected picks from taup: {}'.format(e)) - + def setupUi(self): menuBar = QtGui.QMenuBar(self) if not self._embedded: @@ -952,7 +952,11 @@ class PickDlg(QDialog): station_id = self.data.traces[0].get_id() parser = self.parent().metadata[1] station_coords = parser.get_coordinates(station_id) - source_origin = self.parent().get_current_event().origins[0] + origins = self.parent().get_current_event().origins + if origins: + source_origin = origins[0] + else: + raise ValueError('No source origin given.') arrivals = self.model.get_travel_times_geo(source_origin.depth, source_origin.latitude, source_origin.longitude, @@ -2760,7 +2764,7 @@ class InputsTab(PropTab): from pylot.core.util.structure import DATASTRUCTURE - self.structureSelect.addItems(DATASTRUCTURE.keys()) + self.structureSelect.addItems(list(DATASTRUCTURE.keys())) dsind = findComboBoxIndex(self.structureSelect, curstructure)