feature/port-to-py3 #11

Merged
marcel merged 59 commits from feature/port-to-py3 into develop 2022-03-21 15:30:06 +01:00
8 changed files with 20 additions and 19 deletions
Showing only changes of commit ca56139922 - Show all commits

View File

@ -1492,7 +1492,7 @@ class MainWindow(QMainWindow):
wf_dir = wf_stat[self.data.processed] wf_dir = wf_stat[self.data.processed]
if wf_dir is not None: if wf_dir is not None:
wf_path = os.path.join(event_path, wf_dir) wf_path = os.path.join(event_path, wf_dir)
if wf_dir is 'processed' and not os.path.exists(wf_path): if wf_dir == 'processed' and not os.path.exists(wf_path):
wf_path = os.path.join(event_path, 'raw') wf_path = os.path.join(event_path, 'raw')
else: else:
wf_path = event_path wf_path = event_path

View File

@ -145,7 +145,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
exf = ['root', 'dpath', 'dbase'] exf = ['root', 'dpath', 'dbase']
if parameter['eventID'] is not '*' and fnames == 'None': if parameter['eventID'] != '*' and fnames == 'None':
dsfields['eventID'] = parameter['eventID'] dsfields['eventID'] = parameter['eventID']
exf.append('eventID') exf.append('eventID')
@ -189,12 +189,12 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
if not input_dict: if not input_dict:
# started in production mode # started in production mode
datapath = datastructure.expandDataPath() datapath = datastructure.expandDataPath()
if fnames == 'None' and parameter['eventID'] is '*': if fnames == 'None' and parameter['eventID'] != '*':
# multiple event processing # multiple event processing
# read each event in database # read each event in database
events = [event for event in glob.glob(os.path.join(datapath, '*')) if events = [event for event in glob.glob(os.path.join(datapath, '*')) if
(os.path.isdir(event) and not event.endswith('EVENTS-INFO'))] (os.path.isdir(event) and not event.endswith('EVENTS-INFO'))]
elif fnames == 'None' and parameter['eventID'] is not '*' and not type(parameter['eventID']) == list: elif fnames == 'None' and parameter['eventID'] != '*' and not type(parameter['eventID']) == list:
# single event processing # single event processing
events = glob.glob(os.path.join(datapath, parameter['eventID'])) events = glob.glob(os.path.join(datapath, parameter['eventID']))
elif fnames == 'None' and type(parameter['eventID']) == list: elif fnames == 'None' and type(parameter['eventID']) == list:

View File

@ -55,7 +55,7 @@ class Data(object):
elif type(evtdata) in str_TypeLst: elif type(evtdata) in str_TypeLst:
kaan marked this conversation as resolved Outdated

See above!

See above!
try: try:
cat = read_events(evtdata) cat = read_events(evtdata)
if len(cat) is not 1: if len(cat) != 1:
raise ValueError('ambiguous event information for file: ' raise ValueError('ambiguous event information for file: '
'{file}'.format(file=evtdata)) '{file}'.format(file=evtdata))
evtdata = cat[0] evtdata = cat[0]
@ -322,7 +322,7 @@ class Data(object):
del picks_copy[k] del picks_copy[k]
break break
lendiff = len(picks) - len(picks_copy) lendiff = len(picks) - len(picks_copy)
if lendiff is not 0: if lendiff != 0:
print("Manual as well as automatic picks available. Prefered the {} manual ones!".format(lendiff)) print("Manual as well as automatic picks available. Prefered the {} manual ones!".format(lendiff))
if upperErrors: if upperErrors:

View File

@ -232,7 +232,7 @@ def picksdict_from_picks(evt):
for pick in evt.picks: for pick in evt.picks:
phase = {} phase = {}
station = pick.waveform_id.station_code station = pick.waveform_id.station_code
if pick.waveform_id.channel_code == None: if pick.waveform_id.channel_code is None:
channel = '' channel = ''
else: else:
channel = pick.waveform_id.channel_code channel = pick.waveform_id.channel_code
@ -774,7 +774,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
Ponset = arrivals[key]['P']['mpp'] Ponset = arrivals[key]['P']['mpp']
Pweight = arrivals[key]['P']['weight'] Pweight = arrivals[key]['P']['weight']
Prt = Ponset - stime # onset time relative to source time Prt = Ponset - stime # onset time relative to source time
if n % 6 is not 0: if n % 6 != 0:
fid.write('%-4sP%d%6.2f' % (stat, Pweight, Prt)) fid.write('%-4sP%d%6.2f' % (stat, Pweight, Prt))
else: else:
fid.write('%-4sP%d%6.2f\n' % (stat, Pweight, Prt)) fid.write('%-4sP%d%6.2f\n' % (stat, Pweight, Prt))
@ -788,7 +788,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
Sonset = arrivals[key]['S']['mpp'] Sonset = arrivals[key]['S']['mpp']
Sweight = arrivals[key]['S']['weight'] Sweight = arrivals[key]['S']['weight']
Srt = Ponset - stime # onset time relative to source time Srt = Ponset - stime # onset time relative to source time
if n % 6 is not 0: if n % 6 != 0:
fid.write('%-4sS%d%6.2f' % (stat, Sweight, Srt)) fid.write('%-4sS%d%6.2f' % (stat, Sweight, Srt))
else: else:
fid.write('%-4sS%d%6.2f\n' % (stat, Sweight, Srt)) fid.write('%-4sS%d%6.2f\n' % (stat, Sweight, Srt))
@ -1080,7 +1080,7 @@ def getQualitiesfromxml(xmlnames, ErrorsP, ErrorsS, plotflag=1):
del mpick del mpick
break break
lendiff = len(arrivals) - len(arrivals_copy) lendiff = len(arrivals) - len(arrivals_copy)
if lendiff is not 0: if lendiff != 0:
print("Found manual as well as automatic picks, prefered the {} manual ones!".format(lendiff)) print("Found manual as well as automatic picks, prefered the {} manual ones!".format(lendiff))
for Pick in arrivals_copy: for Pick in arrivals_copy:

View File

@ -150,7 +150,7 @@ class CharacteristicFunction(object):
if self.cut[0] == 0 and self.cut[1] == 0: if self.cut[0] == 0 and self.cut[1] == 0:
start = 0 start = 0
stop = len(self.orig_data[0]) stop = len(self.orig_data[0])
elif self.cut[0] == 0 and self.cut[1] is not 0: elif self.cut[0] == 0 and self.cut[1] != 0:
start = 0 start = 0
stop = self.cut[1] / self.dt stop = self.cut[1] / self.dt
else: else:
@ -167,7 +167,7 @@ class CharacteristicFunction(object):
if self.cut[0] == 0 and self.cut[1] == 0: if self.cut[0] == 0 and self.cut[1] == 0:
start = 0 start = 0
stop = min([len(self.orig_data[0]), len(self.orig_data[1])]) stop = min([len(self.orig_data[0]), len(self.orig_data[1])])
elif self.cut[0] == 0 and self.cut[1] is not 0: elif self.cut[0] == 0 and self.cut[1] != 0:
start = 0 start = 0
stop = min([self.cut[1] / self.dt, len(self.orig_data[0]), stop = min([self.cut[1] / self.dt, len(self.orig_data[0]),
len(self.orig_data[1])]) len(self.orig_data[1])])
@ -187,7 +187,7 @@ class CharacteristicFunction(object):
start = 0 start = 0
stop = min([self.cut[1] / self.dt, len(self.orig_data[0]), stop = min([self.cut[1] / self.dt, len(self.orig_data[0]),
len(self.orig_data[1]), len(self.orig_data[2])]) len(self.orig_data[1]), len(self.orig_data[2])])
elif self.cut[0] == 0 and self.cut[1] is not 0: elif self.cut[0] == 0 and self.cut[1] != 0:
start = 0 start = 0
stop = self.cut[1] / self.dt stop = self.cut[1] / self.dt
else: else:

View File

@ -5,8 +5,6 @@ import sys
import os import os
import matplotlib import matplotlib
matplotlib.use('Qt5Agg')
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
@ -29,6 +27,9 @@ from scipy.interpolate import griddata
from pylot.core.util.widgets import PickDlg from pylot.core.util.widgets import PickDlg
from pylot.core.pick.utils import get_quality_class from pylot.core.pick.utils import get_quality_class
matplotlib.use('Qt5Agg')
class MplCanvas(FigureCanvas): class MplCanvas(FigureCanvas):
@ -49,7 +50,7 @@ class Array_map(QtWidgets.QWidget):
# super(Array_map, self).__init__(parent) # super(Array_map, self).__init__(parent)
QtWidgets.QWidget.__init__(self) QtWidgets.QWidget.__init__(self)
assert (parameter != None or parent != 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'
# set properties # set properties
self._parent = parent self._parent = parent
self.metadata = metadata self.metadata = metadata

View File

@ -227,7 +227,7 @@ def findComboBoxIndex(combo_box, val):
:type val: basestring :type val: basestring
:return: index value of item with name val or 0 :return: index value of item with name val or 0
""" """
return combo_box.findText(val) if combo_box.findText(val) is not -1 else 0 return combo_box.findText(val) if combo_box.findText(val) != -1 else 0
def find_in_list(list, str): def find_in_list(list, str):
@ -1016,7 +1016,7 @@ def scaleWFData(data, factor=None, components='all'):
:return: scaled waveform data :return: scaled waveform data
:rtype: `~obspy.core.stream.Stream` object :rtype: `~obspy.core.stream.Stream` object
""" """
if components is not 'all': if components != 'all':
for comp in components: for comp in components:
if factor is None: if factor is None:
max_val = np.max(np.abs(data.select(component=comp)[0].data)) max_val = np.max(np.abs(data.select(component=comp)[0].data))

View File

@ -8,7 +8,7 @@ setup(
packages=['pylot', 'pylot.core', 'pylot.core.loc', 'pylot.core.pick', packages=['pylot', 'pylot.core', 'pylot.core.loc', 'pylot.core.pick',
'pylot.core.io', 'pylot.core.util', 'pylot.core.active', 'pylot.core.io', 'pylot.core.util', 'pylot.core.active',
'pylot.core.analysis', 'pylot.testing'], 'pylot.core.analysis', 'pylot.testing'],
requires=['obspy', 'PySide', 'matplotlib', 'numpy', 'scipy', 'pyqtgraph'], requires=['obspy', 'PySide2', 'matplotlib', 'numpy', 'scipy', 'pyqtgraph', 'cartopy'],
url='dummy', url='dummy',
license='LGPLv3', license='LGPLv3',
author='Sebastian Wehling-Benatelli', author='Sebastian Wehling-Benatelli',