From bd9c1d0f73bddb9c33c20f53ff91c730c18ef171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20C=C3=B6kerim?= Date: Fri, 9 Jul 2021 10:06:28 +0200 Subject: [PATCH] Some Minor Fixes --- PyLoT.py | 7 ++++--- pylot/core/util/array_map.py | 2 +- pylot/core/util/event.py | 2 +- pylot/core/util/generate_array_maps.py | 13 ++++++++----- pylot/core/util/gui.py | 2 +- pylot/core/util/utils.py | 2 +- pylot/core/util/widgets.py | 6 ++---- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/PyLoT.py b/PyLoT.py index 6c8e21ed..e8349e3c 100755 --- a/PyLoT.py +++ b/PyLoT.py @@ -35,9 +35,11 @@ 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') -# matplotlib.rcParams['backend.qt4'] = 'PySide' -# matplotlib.rcParams['savefig.dpi'] = 300 from PySide2 import QtGui, QtCore, QtWidgets from PySide2.QtCore import QCoreApplication, QSettings, Signal, QFile, \ @@ -57,7 +59,6 @@ from pylot.core.util.obspyDMT_interface import check_obspydmt_structure import pyqtgraph as pg - try: from matplotlib.backends.backend_qt5agg import FigureCanvas except ImportError: diff --git a/pylot/core/util/array_map.py b/pylot/core/util/array_map.py index 1581f495..8d8a80ea 100644 --- a/pylot/core/util/array_map.py +++ b/pylot/core/util/array_map.py @@ -157,7 +157,7 @@ class Array_map(QtWidgets.QWidget): self.canvas.axes.add_feature(cf.COASTLINE, linewidth=1, edgecolor='gray') self.canvas.axes.add_feature(cf.BORDERS, alpha=0.7) self.canvas.axes.add_feature(cf.LAKES, alpha=0.7) - self.canvas.axes.add_feature(cf.RIVERS, linewidth=0.8) + self.canvas.axes.add_feature(cf.RIVERS, linewidth=1) # parallels and meridians self.add_merid_paral() diff --git a/pylot/core/util/event.py b/pylot/core/util/event.py index 69763801..1d71ba7f 100644 --- a/pylot/core/util/event.py +++ b/pylot/core/util/event.py @@ -73,7 +73,7 @@ class Event(ObsPyEvent): text = lines[0] self.addNotes(text) try: - datetime = UTCDateTime(path.split('/')[-1]) + datetime = UTCDateTime(self.path.split('/')[-1]) origin = Origin(resource_id=self.resource_id, time=datetime, latitude=0, longitude=0, depth=0) self.origins.append(origin) except: diff --git a/pylot/core/util/generate_array_maps.py b/pylot/core/util/generate_array_maps.py index c974df8d..e625d017 100755 --- a/pylot/core/util/generate_array_maps.py +++ b/pylot/core/util/generate_array_maps.py @@ -11,6 +11,7 @@ from pylot.core.util.array_map import Array_map import matplotlib.pyplot as plt + def main(project_file_path, manual=False, auto=True, file_format='png', f_ext='', ncores=None): project = Project.load(project_file_path) nEvents = len(project.eventlist) @@ -18,7 +19,7 @@ def main(project_file_path, manual=False, auto=True, file_format='png', f_ext='' for index, event in enumerate(project.eventlist): # MP MP TESTING +++ - #if not eventdir.endswith('20170908_044946.a'): + # if not eventdir.endswith('20170908_044946.a'): # continue # MP MP ---- kwargs = dict(project=project, event=event, nEvents=nEvents, index=index, manual=manual, auto=auto, @@ -34,6 +35,7 @@ def main(project_file_path, manual=False, auto=True, file_format='png', f_ext='' pool.close() pool.join() + def array_map_worker(input_dict): event = input_dict['event'] eventdir = event.path @@ -52,7 +54,7 @@ def array_map_worker(input_dict): if not metadata: metadata = Metadata(inventory=metadata_path, verbosity=0) # create figure to plot on - fig = plt.figure(figsize=(16,9)) + fig = plt.figure(figsize=(16, 9)) # create array map object map = Array_map(None, metadata, parameter=input_dict['project'].parameter, figure=fig, width=2.13e6, height=1.2e6, pointsize=15., linewidth=1.0) @@ -65,11 +67,12 @@ def array_map_worker(input_dict): fig.savefig(fpath_out, dpi=300.) print('Wrote file: {}'.format(fpath_out)) + if __name__ == '__main__': dataroot = '/home/marcel' - infiles=['alparray_all_events_0.03-0.1_mantle_correlated_v3.plp'] + infiles = ['alparray_all_events_0.03-0.1_mantle_correlated_v3.plp'] for infile in infiles: main(os.path.join(dataroot, infile), f_ext='_correlated_0.1Hz', ncores=10) - #main('E:\Shared\AlpArray\\test_aa.plp', f_ext='_correlated_0.5Hz', ncores=1) - #main('/home/marcel/alparray_m6.5-6.9_mantle_correlated_v3.plp', f_ext='_correlated_0.5Hz') + # main('E:\Shared\AlpArray\\test_aa.plp', f_ext='_correlated_0.5Hz', ncores=1) + # main('/home/marcel/alparray_m6.5-6.9_mantle_correlated_v3.plp', f_ext='_correlated_0.5Hz') diff --git a/pylot/core/util/gui.py b/pylot/core/util/gui.py index 1f237a89..c80d8706 100644 --- a/pylot/core/util/gui.py +++ b/pylot/core/util/gui.py @@ -49,7 +49,7 @@ def which(program, parameter): :rtype: str """ try: - from PySide.QtCore import QSettings + from PySide2.QtCore import QSettings settings = QSettings() for key in settings.allKeys(): if 'binPath' in key: diff --git a/pylot/core/util/utils.py b/pylot/core/util/utils.py index 81f43b80..01b95299 100644 --- a/pylot/core/util/utils.py +++ b/pylot/core/util/utils.py @@ -964,7 +964,7 @@ def check4rotated(data, metadata=None, verbosity=1): z, n, e = rotate2zne(wfstream[0], azimuts[0], dips[0], wfstream[1], azimuts[1], dips[1], wfstream[2], azimuts[2], dips[2]) - print('check4rotated: rotated trace {} to ZNE'.format(trace_id)) + print('check4rotated: rotated trace {} to ZNE'.format(trace_ids)) # replace old data with rotated data, change the channel code to ZNE z_index = dips.index(min( dips)) # get z-trace index, z has minimum dip of -90 (dip is measured from 0 to -90, with -90 being vertical) diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 09b0a789..66cf180d 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -719,7 +719,7 @@ class WaveformWidgetPG(QtWidgets.QWidget): station = self.orig_parent.getTraceID(wfID) abstime = self.wfstart + x if self.orig_parent.get_current_event(): - self.status_label.setText("station = {}, T = {}, t = {} [s]".format(station, abstime, x)) + self.status_label.setText("station = {}, T = {}, t = {} [s], sampling rate = ".format(station, abstime, x)) self.vLine.setPos(mousePoint.x()) self.hLine.setPos(mousePoint.y()) @@ -4618,8 +4618,6 @@ class InputsTab(PropTab): self.cuttimesLayout.addWidget(self.tstopBox, 10) self.cuttimesLayout.addWidget(QLabel('[s]'), 0) - - from pylot.core.util.structure import DATASTRUCTURE self.structureSelect.addItems(list(DATASTRUCTURE.keys())) @@ -4628,7 +4626,7 @@ class InputsTab(PropTab): self.structureSelect.setCurrentIndex(dsind) - layout = QFormLayout() + layout = QtWidgets.QFormLayout() layout.addRow("Data root directory: ", self.dataDirEdit) layout.addRow("Full name for user '{0}': ".format(pylot_user), self.fullNameEdit) layout.addRow("Data structure: ", self.structureSelect)