From 54222b7f11342d0966fb70098f11f9b8bc031e33 Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Wed, 12 Apr 2017 16:43:29 +0200 Subject: [PATCH] added method for array plotting to QtPyLoT, to do: button to call array plot --- QtPyLoT.py | 23 ++++++++++++++++--- pylot/RELEASE-VERSION | 2 +- .../core/util/map_projection.py | 8 +------ 3 files changed, 22 insertions(+), 11 deletions(-) rename map_projection.py => pylot/core/util/map_projection.py (97%) diff --git a/QtPyLoT.py b/QtPyLoT.py index ee12c770..f75b322b 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -58,6 +58,7 @@ from pylot.core.io.location import create_creation_info, create_event from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \ WaveformWidget, PropertiesDlg, HelpForm, createAction, PickDlg, \ getDataType, ComparisonDialog +from pylot.core.util.map_projection import map_projection from pylot.core.util.structure import DATASTRUCTURE from pylot.core.util.thread import AutoPickThread from pylot.core.util.version import get_git_version as _getVersionString @@ -119,6 +120,9 @@ class MainWindow(QMainWindow): self.picks = {} self.autopicks = {} self.loc = False + self._metadata = None + + self.array_map = None # initialize event data if self.recentfiles: @@ -1034,8 +1038,16 @@ class MainWindow(QMainWindow): self.get_data().applyEVTData(lt.read_location(locpath), type='event') self.get_data().applyEVTData(self.calc_magnitude(), type='event') - - def calc_magnitude(self, type='ML'): + def show_array_map(self): + if not self.array_map: + self.get_metadata() + if not self.metadata: + return + self.array_map = map_projection(self) + else: + self.array_map.show() + + def get_metadata(self): def set_inv(settings): fninv, _ = QFileDialog.getOpenFileName(self, self.tr( "Select inventory..."), self.tr("Select file")) @@ -1070,7 +1082,12 @@ class MainWindow(QMainWindow): return None else: self.metadata = read_metadata(fninv) - + + def calc_magnitude(self, type='ML'): + self.get_metadata() + if not self.metadata: + return None + wf_copy = self.get_data().getWFData().copy() corr_wf = restitute_data(wf_copy, *self.metadata) # if not rest_flag: diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 4c175fdd..1977aa0d 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -bb60-dirty +50f6-dirty diff --git a/map_projection.py b/pylot/core/util/map_projection.py similarity index 97% rename from map_projection.py rename to pylot/core/util/map_projection.py index 6e254747..e7e9fbbe 100644 --- a/map_projection.py +++ b/pylot/core/util/map_projection.py @@ -7,7 +7,6 @@ from scipy.interpolate import griddata from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar from PySide import QtCore, QtGui -from pylot.core.util.dataprocessing import read_metadata from pylot.core.util.widgets import PickDlg plt.interactive(False) @@ -16,7 +15,7 @@ class map_projection(QtGui.QWidget): def __init__(self, mainwindow): QtGui.QWidget.__init__(self) self.pyl_mainwindow = mainwindow - self.parser = self.get_metadata('/data/Geothermie/Insheim/STAT_INFO/MAGS2_net.dless') + self.parser = mainwindow.metadata[1] self.init_graphics() self.init_stations() self.init_lat_lon_dimensions() @@ -57,11 +56,6 @@ class map_projection(QtGui.QWidget): except Exception as e: print('Could not generate Plot for station {st}.\n{er}'.format(st=station, er=e)) - def get_metadata(self, path): - metadata=read_metadata(path) - parser=metadata[1] - return parser - def connectSignals(self): self.combobox.currentIndexChanged.connect(self.refresh_drawings)