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

View File

@ -115,4 +115,4 @@ dependencies:
- zipp=3.4.1=pyhd8ed1ab_0 - zipp=3.4.1=pyhd8ed1ab_0
- zlib=1.2.11=h516909a_1010 - zlib=1.2.11=h516909a_1010
- zstd=1.4.9=ha95c52a_0 - 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 -*- # -*- coding: utf-8 -*-
import copy 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, \ from pylot.core.util.utils import fnConstructor, full_range, check4rotated, \
check4gapsAndMerge, trim_station_components check4gapsAndMerge, trim_station_components
try:
str_TypeLst = [str, unicode] # if python 2.X
except NameError:
str_TypeLst = [str] # if python 3.*
class Data(object): class Data(object):
""" """
@ -52,7 +48,7 @@ class Data(object):
elif isinstance(evtdata, dict): elif isinstance(evtdata, dict):
evt = readPILOTEvent(**evtdata) evt = readPILOTEvent(**evtdata)
evtdata = evt evtdata = evt
elif type(evtdata) in str_TypeLst: elif isinstance(evtdata, str):
try: try:
cat = read_events(evtdata) cat = read_events(evtdata)
if len(cat) != 1: if len(cat) != 1:

View File

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

View File

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

View File

@ -59,7 +59,6 @@ from autoPyLoT import autoPyLoT
from pylot.core.util.thread import Thread from pylot.core.util.thread import Thread
from pylot.core.util.dataprocessing import Metadata from pylot.core.util.dataprocessing import Metadata
if sys.version_info.major == 3: if sys.version_info.major == 3:
import icons_rc_3 as icons_rc import icons_rc_3 as icons_rc
elif sys.version_info.major == 2: elif sys.version_info.major == 2:
@ -67,6 +66,7 @@ elif sys.version_info.major == 2:
else: else:
raise ImportError('Could not determine python version.') raise ImportError('Could not determine python version.')
# workaround to prevent PyCharm from deleting icons_rc import when optimizing imports # workaround to prevent PyCharm from deleting icons_rc import when optimizing imports
# icons_rc = icons_rc # icons_rc = icons_rc
@ -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 = np.array([time for index, time in enumerate(time_ax) if not index % nth_sample])
times_syn = np.array( times_syn = np.array(
[time for index, time in enumerate(time_ax_syn) if not index % nth_sample] if st_syn else []) [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) trace_syn.data = np.array([datum + n for index, datum in enumerate(trace_syn.data)
if not index % nth_sample] if st_syn else []) if not index % nth_sample] if st_syn else [])
plots.append((times, trace.data, plots.append((times, trace.data,
@ -1518,8 +1519,6 @@ class SingleTextLineDialog(QtWidgets.QDialog):
self._buttonbox.rejected.connect(self.reject) self._buttonbox.rejected.connect(self.reject)
class PhaseDefaults(QtWidgets.QDialog): class PhaseDefaults(QtWidgets.QDialog):
def __init__(self, parent=None, nrow=10, def __init__(self, parent=None, nrow=10,
phase_defaults=['P', 'S'], phase_defaults=['P', 'S'],
@ -1988,6 +1987,7 @@ class PickDlg(QDialog):
settings = QtCore.QSettings() settings = QtCore.QSettings()
p_phases = settings.value('p_phases') p_phases = settings.value('p_phases')
s_phases = settings.value('s_phases') s_phases = settings.value('s_phases')
phases = ''
if not p_phases and not s_phases: if not p_phases and not s_phases:
print('No phases for TauPy selected in Preferences.') print('No phases for TauPy selected in Preferences.')
if p_phases and s_phases: if p_phases and s_phases:
@ -2235,7 +2235,6 @@ class PickDlg(QDialog):
self.draw() self.draw()
else: else:
self.draw() self.draw()
# self.pick_block = self.togglePickBlocker()
self.disconnect_pick_delete() self.disconnect_pick_delete()
def deactivatePicking(self): def deactivatePicking(self):
@ -2460,7 +2459,8 @@ class PickDlg(QDialog):
# wfdata.filter(**filteroptions)# MP MP removed filtering of original data # wfdata.filter(**filteroptions)# MP MP removed filtering of original data
except ValueError as e: except ValueError as e:
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information, 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() self.qmb.show()
snr = [] snr = []
@ -2588,7 +2588,6 @@ class PickDlg(QDialog):
FM = fmpicker(self.getWFData().select(channel=channel), wfdata, parameter.get('fmpickwin'), FM = fmpicker(self.getWFData().select(channel=channel), wfdata, parameter.get('fmpickwin'),
pick - stime_diff) pick - stime_diff)
# save pick times for actual phase # save pick times for actual phase
phasepicks = dict(epp=epp, lpp=lpp, mpp=mpp, spe=spe, fm=FM, phasepicks = dict(epp=epp, lpp=lpp, mpp=mpp, spe=spe, fm=FM,
picker='manual', channel=channel, picker='manual', channel=channel,
@ -2602,8 +2601,6 @@ class PickDlg(QDialog):
self.disconnectPressEvent() self.disconnectPressEvent()
self.enable_ar_buttons() self.enable_ar_buttons()
self.zoomAction.setEnabled(True) self.zoomAction.setEnabled(True)
# self.pick_block = self.togglPickBlocker()
# self.resetZoom()
self.leave_picking_mode() self.leave_picking_mode()
@ -2905,11 +2902,6 @@ class PickDlg(QDialog):
if phase: if phase:
filtoptions = self.getFilterOptions(self.getPhaseID(phase), gui_filter=True).parseFilterOptions() 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: if filtoptions is not None:
data.detrend('linear') data.detrend('linear')
data.taper(0.02, type='cosine') data.taper(0.02, type='cosine')
@ -3028,8 +3020,6 @@ class PickDlg(QDialog):
# set channel labels # set channel labels
self.multicompfig.setYTickLabels(pos, labels) self.multicompfig.setYTickLabels(pos, labels)
# self.multicompfig.setXLims(ax, self.getXLims())
# self.multicompfig.setYLims(ax, self.getYLims())
def zoom(self): def zoom(self):
if self.zoomAction.isChecked() and self.pick_block: if self.zoomAction.isChecked() and self.pick_block: