Compare commits

...

2 Commits

Author SHA1 Message Date
Kaan Cökerim
321a871d62 Implemented merge suggestions #11 2021-08-12 15:43:23 +02:00
Kaan Cökerim
a738dc57ec Minor bug fixes. Fixes #16 2021-08-12 14:24:05 +02:00
6 changed files with 39 additions and 84 deletions

View File

@ -36,10 +36,6 @@ 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')
from PySide2 import QtGui, QtCore, QtWidgets
@ -3249,8 +3245,6 @@ class MainWindow(QMainWindow):
'auto': event.pylot_autopicks}
ma_count = {'manual': 0,
'auto': 0}
#ma_count_total = {'manual': 0,
# 'auto': 0}
for ma in ma_props.keys():
if ma_props[ma]:
@ -3260,7 +3254,6 @@ class MainWindow(QMainWindow):
continue
if pick.get('spe'):
ma_count[ma] += 1
#ma_count_total[ma] += 1
# init table items for current row
item_delete = QTableWidgetItem()

View File

@ -115,4 +115,4 @@ dependencies:
- zipp=3.4.1=pyhd8ed1ab_0
- zlib=1.2.11=h516909a_1010
- zstd=1.4.9=ha95c52a_0
prefix: /home/kaan/.conda/envs/pylot_py35
prefix:

View File

@ -1,4 +1,4 @@
#!/usr/bin/env pyth n
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import copy
@ -21,10 +21,6 @@ from pylot.core.util.obspyDMT_interface import qml_from_obspyDMT
from pylot.core.util.utils import fnConstructor, full_range, check4rotated, \
check4gapsAndMerge, trim_station_components
try:
str_TypeLst = [str, unicode] # if python 2.X
except NameError:
str_TypeLst = [str] # if python 3.*
class Data(object):
"""
@ -52,7 +48,7 @@ class Data(object):
elif isinstance(evtdata, dict):
evt = readPILOTEvent(**evtdata)
evtdata = evt
elif type(evtdata) in str_TypeLst:
elif isinstance(evtdata, str):
try:
cat = read_events(evtdata)
if len(cat) != 1:

View File

@ -8,16 +8,12 @@ import matplotlib
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import Qt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure
import matplotlib.patheffects as PathEffects
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import cartopy.feature as cf
import cartopy.io.shapereader as shpr
from cartopy.feature import ShapelyFeature
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
from cartopy.mpl.gridliner import LongitudeFormatter, LatitudeFormatter
import traceback
import obspy
@ -30,7 +26,6 @@ from pylot.core.pick.utils import get_quality_class
matplotlib.use('Qt5Agg')
class MplCanvas(FigureCanvas):
def __init__(self, parent=None, extern_axes=None, width=5, height=4, dpi=100):
@ -47,7 +42,6 @@ class MplCanvas(FigureCanvas):
class Array_map(QtWidgets.QWidget):
def __init__(self, parent, metadata, parameter=None, axes=None, annotate=True, pointsize=25.,
linewidth=1.5, width=5e6, height=2e6):
# super(Array_map, self).__init__(parent)
QtWidgets.QWidget.__init__(self)
assert (parameter is not None or parent is not None), 'either parent or parameter has to be set'
@ -95,7 +89,7 @@ class Array_map(QtWidgets.QWidget):
def init_graphics(self):
"""
Initializes all GUI components and figure elements to be populeted by other functions
Initializes all GUI components and figure elements to be populated by other functions
"""
# initialize figure elements
@ -104,8 +98,6 @@ class Array_map(QtWidgets.QWidget):
self.plotWidget = FigureCanvas(self.canvas.fig)
else:
self.canvas = MplCanvas(self, extern_axes=self.extern_plot_axes)
#self.canvas.axes = self.extern_plot_axes
#self.canvas.fig = self.extern_plot_axes.figure
self.plotWidget = FigureCanvas(self.canvas.fig)
# initialize GUI elements
@ -113,7 +105,6 @@ class Array_map(QtWidgets.QWidget):
self.map_reset_button = QtWidgets.QPushButton('Reset Map View')
self.save_map_button = QtWidgets.QPushButton('Save Map')
self.go2eq_button = QtWidgets.QPushButton('Go to Event Location')
# self.map_reset_button.resize(150, 50)
self.main_box = QtWidgets.QVBoxLayout()
self.setLayout(self.main_box)
@ -153,9 +144,6 @@ class Array_map(QtWidgets.QWidget):
self.top_row.addWidget(self.refresh_button)
self.main_box.addWidget(self.plotWidget, 1)
# self.main_box.addWidget(self.map_reset_button, 0)
# self.main_box.addWidget(NavigationToolbar(self.plotWidget, self), 0)
# self.main_box.addWidget(self.status_label, 0)
self.bot_row = QtWidgets.QHBoxLayout()
self.main_box.addLayout(self.bot_row, 0.3)
@ -163,7 +151,6 @@ class Array_map(QtWidgets.QWidget):
self.bot_row.addWidget(self.go2eq_button)
self.bot_row.addWidget(self.save_map_button)
self.bot_row.addWidget(self.status_label)
# self.connectSignals()
def init_colormap(self):
self.init_lat_lon_dimensions()
@ -182,21 +169,17 @@ class Array_map(QtWidgets.QWidget):
# parallels and meridians
self.add_merid_paral()
# self.canvas.axes.set_global()
self.canvas.fig.tight_layout()
# self.plotWidget.draw_idle()
def add_merid_paral(self):
self.gridlines = self.canvas.axes.gridlines(draw_labels=False, alpha=0.8, color='dimgray', linewidth=self.linewidth, zorder=7)
# current cartopy version does not support label removal. Devs are working on it.
# Should be fixed with next cartopy version
self.gridlines = self.canvas.axes.gridlines(draw_labels=False, alpha=0.8, color='gray', linewidth=self.linewidth/2, zorder=7)
# TODO: current cartopy version does not support label removal. Devs are working on it.
# Should be fixed with next cartopy version
# self.gridlines.xformatter = LONGITUDE_FORMATTER
# self.gridlines.yformatter = LATITUDE_FORMATTER
def remove_merid_paral(self):
if len(self.gridlines.xline_artists):
# for i in self.gridlines.xline_artists:
# i.remove()
self.gridlines.xline_artists[0].remove()
self.gridlines.yline_artists[0].remove()
@ -482,8 +465,6 @@ class Array_map(QtWidgets.QWidget):
facecolors='none', zorder=12,
transform=ccrs.PlateCarree(), label='deleted'))
# self.canvas.idle_draw()
def openPickDlg(self, ind):
data = self._parent.get_data().getWFData()
for index in ind:
@ -526,22 +507,18 @@ class Array_map(QtWidgets.QWidget):
print(message, e)
print(traceback.format_exc())
def draw_contour_filled(self, nlevel=100):
# self.test_gradient()
def draw_contour_filled(self, nlevel=50):
levels = np.linspace(self.get_min_from_picks(), self.get_max_from_picks(), nlevel)
self.contourf = self.canvas.axes.contourf(self.longrid, self.latgrid, self.picksgrid_active, levels,
linewidths=self.linewidth, transform=ccrs.PlateCarree(),
alpha=0.7, zorder=8, cmap=self.get_colormap())
linewidths=self.linewidth*4, transform=ccrs.PlateCarree(),
alpha=0.4, zorder=8, cmap=self.get_colormap())
def get_colormap(self):
return plt.get_cmap(self.cmaps_box.currentText())
def scatter_all_stations(self):
stations, lats, lons = self.get_st_lat_lon_for_plot()
# self.sc = self.basemap.scatter(lons, lats, s=self.pointsize, facecolor='none', latlon=True, marker='.',
# zorder=10, picker=True, edgecolor='0.5', label='Not Picked')
self.sc = self.canvas.axes.scatter(lons, lats, s=self.pointsize * 3, facecolor='none', marker='.',
zorder=10, picker=True, edgecolor='0.5', label='Not Picked',
@ -593,6 +570,7 @@ class Array_map(QtWidgets.QWidget):
linewidth=self.pointsize / 15., foreground='k')]))
self.legend = self.canvas.axes.legend(loc=1, framealpha=1)
self.legend.set_zorder(100)
self.legend.get_frame().set_facecolor((1, 1, 1, 0.95))
def add_cbar(self, label):

View File

@ -79,11 +79,9 @@ if __name__ == '__main__':
cl = argparse.ArgumentParser()
cl.add_argument('--dataroot', help='Directory containing the PyLoT .plp file', type=str)
cl.add_argument('--infiles', help='.plp files to use', nargs='+')
cl.add_argument('--ncores', hepl='Specify number of parallel processes', type=int, default=1)
args = cl.parse_args()
#dataroot = '/home/kaan/master_thesis/waveformData/dmt_dir_proj'
#infiles = ['mag_8_sym_proj.plp']
for infile in args.infiles:
main(os.path.join(args.dataroot, infile), f_ext='_correlated_0.03-0.1', ncores=1)
# 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(os.path.join(args.dataroot, infile), f_ext='_correlated_0.03-0.1', ncores=args.ncores)

View File

@ -53,13 +53,12 @@ from pylot.core.util.utils import prepTimeAxis, full_range, demeanTrace, isSorte
pick_linestyle_plt, pick_color_plt, \
check4rotated, check4doubled, merge_stream, identifyPhase, \
loopIdentifyPhase, trim_station_components, transformFilteroptions2String, \
identifyPhaseID, get_Bool, get_None, pick_color, getAutoFilteroptions, SetChannelComponents,\
identifyPhaseID, get_Bool, get_None, pick_color, getAutoFilteroptions, SetChannelComponents, \
station_id_remove_channel
from autoPyLoT import autoPyLoT
from pylot.core.util.thread import Thread
from pylot.core.util.dataprocessing import Metadata
if sys.version_info.major == 3:
import icons_rc_3 as icons_rc
elif sys.version_info.major == 2:
@ -67,6 +66,7 @@ elif sys.version_info.major == 2:
else:
raise ImportError('Could not determine python version.')
# workaround to prevent PyCharm from deleting icons_rc import when optimizing imports
# icons_rc = icons_rc
@ -302,7 +302,7 @@ class AddMetadataWidget(QWidget):
item = QtGui.QStandardItem(inventory_path)
item.setEditable(False)
self.inventories_add.append(inventory_path)
self.list_model.appendRow(item) # adds path to visible list
self.list_model.appendRow(item) # adds path to visible list
self.selection_box.setText("")
def remove_item(self):
@ -313,8 +313,8 @@ class AddMetadataWidget(QWidget):
"""
for index in reversed(sorted(self.list_view.selectionModel().selectedIndexes())):
item = self.list_model.itemData(index)
inventory_path = item[0] # marked path
self.list_model.removeRow(index.row()) # aus der Anzeige-Liste gelöscht
inventory_path = item[0] # marked path
self.list_model.removeRow(index.row()) # aus der Anzeige-Liste gelöscht
if inventory_path in self.inventories_add:
self.inventories_add.remove(inventory_path)
else:
@ -876,7 +876,8 @@ class WaveformWidgetPG(QtWidgets.QWidget):
times = np.array([time for index, time in enumerate(time_ax) if not index % nth_sample])
times_syn = np.array(
[time for index, time in enumerate(time_ax_syn) if not index % nth_sample] if st_syn else [])
trace.data = np.array([datum * gain + n for index, datum in enumerate(trace.data) if not index % nth_sample])
trace.data = np.array(
[datum * gain + n for index, datum in enumerate(trace.data) if not index % nth_sample])
trace_syn.data = np.array([datum + n for index, datum in enumerate(trace_syn.data)
if not index % nth_sample] if st_syn else [])
plots.append((times, trace.data,
@ -1518,8 +1519,6 @@ class SingleTextLineDialog(QtWidgets.QDialog):
self._buttonbox.rejected.connect(self.reject)
class PhaseDefaults(QtWidgets.QDialog):
def __init__(self, parent=None, nrow=10,
phase_defaults=['P', 'S'],
@ -1988,6 +1987,7 @@ class PickDlg(QDialog):
settings = QtCore.QSettings()
p_phases = settings.value('p_phases')
s_phases = settings.value('s_phases')
phases = ''
if not p_phases and not s_phases:
print('No phases for TauPy selected in Preferences.')
if p_phases and s_phases:
@ -2235,7 +2235,6 @@ class PickDlg(QDialog):
self.draw()
else:
self.draw()
# self.pick_block = self.togglePickBlocker()
self.disconnect_pick_delete()
def deactivatePicking(self):
@ -2446,7 +2445,7 @@ class PickDlg(QDialog):
data.normalize()
if not data:
QtWidgets.QMessageBox.warning(self, 'No channel to plot',
'No channel to plot for phase: {}.'.format(phase))
'No channel to plot for phase: {}.'.format(phase))
self.leave_picking_mode()
return
@ -2460,7 +2459,8 @@ class PickDlg(QDialog):
# wfdata.filter(**filteroptions)# MP MP removed filtering of original data
except ValueError as e:
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Denied', 'setIniPick{}: Could not filter waveform: {}'.format(phase, e))
'Denied',
'setIniPick{}: Could not filter waveform: {}'.format(phase, e))
self.qmb.show()
snr = []
@ -2545,7 +2545,7 @@ class PickDlg(QDialog):
wfdata.filter(**filteroptions)
except ValueError as e:
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Denied', 'setPick: Could not filter waveform: {}'.format(e))
'Denied', 'setPick: Could not filter waveform: {}'.format(e))
self.qmb.show()
# get earliest and latest possible pick and symmetric pick error
@ -2586,8 +2586,7 @@ class PickDlg(QDialog):
quality = get_quality_class(spe, parameter.get('timeerrorsP'))
if quality <= minFMweight and snr >= minFMSNR:
FM = fmpicker(self.getWFData().select(channel=channel), wfdata, parameter.get('fmpickwin'),
pick -stime_diff)
pick - stime_diff)
# save pick times for actual phase
phasepicks = dict(epp=epp, lpp=lpp, mpp=mpp, spe=spe, fm=FM,
@ -2602,8 +2601,6 @@ class PickDlg(QDialog):
self.disconnectPressEvent()
self.enable_ar_buttons()
self.zoomAction.setEnabled(True)
# self.pick_block = self.togglPickBlocker()
# self.resetZoom()
self.leave_picking_mode()
@ -2617,7 +2614,7 @@ class PickDlg(QDialog):
def warn_unknown_phase(self, phase=None):
QtWidgets.QMessageBox.warning(self, 'Unknown phase ID',
'Could not identify phase ID: {}.'.format(phase))
'Could not identify phase ID: {}.'.format(phase))
def disconnectPressEvent(self):
self.multicompfig.mpl_disconnect(self.cidpress)
@ -2798,7 +2795,7 @@ class PickDlg(QDialog):
self.renamePhaseInDict(picks, phase, new_phase)
except KeyError as e:
QtWidgets.QMessageBox.warning(self, 'Could not rename phase',
'Could not rename phase {} to {}: {}'.format(phase, new_phase, e))
'Could not rename phase {} to {}: {}'.format(phase, new_phase, e))
self.leave_rename_phase()
self.refreshPlot()
@ -2905,11 +2902,6 @@ class PickDlg(QDialog):
if phase:
filtoptions = self.getFilterOptions(self.getPhaseID(phase), gui_filter=True).parseFilterOptions()
# if self.filterActionP.isChecked() or self.filterActionS.isChecked():
# if not phase:
# filtoptions = FilterOptionsDialog.getFilterObject()
# filtoptions = filtoptions.parseFilterOptions()
if filtoptions is not None:
data.detrend('linear')
data.taper(0.02, type='cosine')
@ -3028,8 +3020,6 @@ class PickDlg(QDialog):
# set channel labels
self.multicompfig.setYTickLabels(pos, labels)
# self.multicompfig.setXLims(ax, self.getXLims())
# self.multicompfig.setYLims(ax, self.getYLims())
def zoom(self):
if self.zoomAction.isChecked() and self.pick_block:
@ -3064,7 +3054,7 @@ class PickDlg(QDialog):
else:
self.refreshPlot()
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Denied', 'New picks rejected!')
'Denied', 'New picks rejected!')
self.qmb.show()
def accept(self):
@ -3073,7 +3063,7 @@ class PickDlg(QDialog):
QDialog.accept(self)
else:
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Accepted', 'New picks applied!')
'Accepted', 'New picks applied!')
self.qmb.show()
@ -3091,7 +3081,7 @@ class CanvasWidget(QWidget):
'''
def __init__(self, parent, canvas):
QtWidgets.QWidget.__init__(self, parent)#, 1)
QtWidgets.QWidget.__init__(self, parent) # , 1)
canvas = canvas
self.main_layout = QtWidgets.QVBoxLayout()
self.setLayout(self.main_layout)
@ -3811,7 +3801,7 @@ class TuneAutopicker(QWidget):
'savexml': False,
'obspyDMT_wfpath': wfpath}
event = self.get_current_event()
#self.parent().saveData(event, event.path, '.xml') MP MP uncommented because overwriting pick files in tune mode
# self.parent().saveData(event, event.path, '.xml') MP MP uncommented because overwriting pick files in tune mode
for key in self.fig_dict.keys():
if not key == 'plot_style':
self.fig_dict[key].clear()
@ -3887,7 +3877,7 @@ class TuneAutopicker(QWidget):
def _warn(self, message, info=None):
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Warning,
'Warning', message)
'Warning', message)
self.qmb.setDetailedText(str(info))
self.qmb.show()
@ -4130,7 +4120,7 @@ class PylotParaBox(QtWidgets.QWidget):
layout = QtWidgets.QVBoxLayout()
dialog.setLayout(layout)
buttonbox = QtWidgets.QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel)
QDialogButtonBox.Cancel)
buttonbox.accepted.connect(dialog.accept)
buttonbox.accepted.connect(self.refresh)
buttonbox.accepted.connect(self.params_from_gui)
@ -4314,7 +4304,7 @@ class PylotParaBox(QtWidgets.QWidget):
def _warn(self, message):
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Warning,
'Warning', message)
'Warning', message)
self.qmb.show()
@ -4684,7 +4674,7 @@ class InputsTab(PropTab):
"data/Structure": self.structureSelect.setCurrentIndex(index),
"tstart": self.tstartBox.setValue(0),
"tstop": self.tstopBox.setValue(1e6),
"autosaveXML": self.autosaveXML_checkbox.setChecked(True),}
"autosaveXML": self.autosaveXML_checkbox.setChecked(True), }
return values