Compare commits
2 Commits
2ccdfb8470
...
0c43040faf
Author | SHA1 | Date | |
---|---|---|---|
|
0c43040faf | ||
|
04067cac8e |
118
pylot.yml
Normal file
118
pylot.yml
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
name: pylot_py35
|
||||||
|
channels:
|
||||||
|
- conda-forge
|
||||||
|
- defaults
|
||||||
|
dependencies:
|
||||||
|
- _libgcc_mutex=0.1=conda_forge
|
||||||
|
- _openmp_mutex=4.5=1_gnu
|
||||||
|
- brotlipy=0.7.0=py36h8f6f2f9_1001
|
||||||
|
- c-ares=1.17.1=h7f98852_1
|
||||||
|
- ca-certificates=2021.5.30=ha878542_0
|
||||||
|
- cartopy=0.18.0=py36h104b3a8_13
|
||||||
|
- certifi=2021.5.30=py36h5fab9bb_0
|
||||||
|
- cffi=1.14.5=py36hc120d54_0
|
||||||
|
- chardet=4.0.0=py36h5fab9bb_1
|
||||||
|
- cryptography=3.4.6=py36hb60f036_0
|
||||||
|
- cycler=0.10.0=py_2
|
||||||
|
- dbus=1.13.6=hfdff14a_1
|
||||||
|
- decorator=4.4.2=py_0
|
||||||
|
- expat=2.2.10=h9c3ff4c_0
|
||||||
|
- fontconfig=2.13.1=hba837de_1004
|
||||||
|
- freetype=2.10.4=h0708190_1
|
||||||
|
- future=0.18.2=py36h5fab9bb_3
|
||||||
|
- geos=3.9.1=h9c3ff4c_2
|
||||||
|
- gettext=0.19.8.1=h0b5b191_1005
|
||||||
|
- glib=2.68.0=h9c3ff4c_1
|
||||||
|
- glib-tools=2.68.0=h9c3ff4c_1
|
||||||
|
- greenlet=1.0.0=py36hc4f0c31_0
|
||||||
|
- gst-plugins-base=1.18.4=h29181c9_0
|
||||||
|
- gstreamer=1.18.4=h76c114f_0
|
||||||
|
- icu=68.1=h58526e2_0
|
||||||
|
- idna=2.10=pyh9f0ad1d_0
|
||||||
|
- importlib-metadata=3.7.3=py36h5fab9bb_0
|
||||||
|
- jpeg=9d=h36c2ea0_0
|
||||||
|
- kiwisolver=1.3.1=py36h605e78d_1
|
||||||
|
- krb5=1.17.2=h926e7f8_0
|
||||||
|
- lcms2=2.12=hddcbb42_0
|
||||||
|
- ld_impl_linux-64=2.35.1=hea4e1c9_2
|
||||||
|
- libblas=3.9.0=8_openblas
|
||||||
|
- libcblas=3.9.0=8_openblas
|
||||||
|
- libclang=11.1.0=default_ha53f305_0
|
||||||
|
- libcurl=7.75.0=hc4aaa36_0
|
||||||
|
- libedit=3.1.20191231=he28a2e2_2
|
||||||
|
- libev=4.33=h516909a_1
|
||||||
|
- libevent=2.1.10=hcdb4288_3
|
||||||
|
- libffi=3.3=h58526e2_2
|
||||||
|
- libgcc-ng=9.3.0=h2828fa1_18
|
||||||
|
- libgfortran-ng=9.3.0=hff62375_18
|
||||||
|
- libgfortran5=9.3.0=hff62375_18
|
||||||
|
- libglib=2.68.0=h3e27bee_1
|
||||||
|
- libgomp=9.3.0=h2828fa1_18
|
||||||
|
- libiconv=1.16=h516909a_0
|
||||||
|
- liblapack=3.9.0=8_openblas
|
||||||
|
- libllvm11=11.1.0=hf817b99_0
|
||||||
|
- libnghttp2=1.43.0=h812cca2_0
|
||||||
|
- libopenblas=0.3.12=pthreads_h4812303_1
|
||||||
|
- libpng=1.6.37=h21135ba_2
|
||||||
|
- libpq=13.1=hfd2b0eb_2
|
||||||
|
- libssh2=1.9.0=ha56f1ee_6
|
||||||
|
- libstdcxx-ng=9.3.0=h6de172a_18
|
||||||
|
- libtiff=4.2.0=hdc55705_0
|
||||||
|
- libuuid=2.32.1=h7f98852_1000
|
||||||
|
- libwebp-base=1.2.0=h7f98852_2
|
||||||
|
- libxcb=1.13=h7f98852_1003
|
||||||
|
- libxkbcommon=1.0.3=he3ba5ed_0
|
||||||
|
- libxml2=2.9.10=h72842e0_3
|
||||||
|
- libxslt=1.1.33=h15afd5d_2
|
||||||
|
- lxml=4.6.2=py36h04a5ba7_1
|
||||||
|
- lz4-c=1.9.3=h9c3ff4c_0
|
||||||
|
- matplotlib-base=3.3.4=py36hd391965_0
|
||||||
|
- mysql-common=8.0.23=ha770c72_1
|
||||||
|
- mysql-libs=8.0.23=h935591d_1
|
||||||
|
- ncurses=6.2=h58526e2_4
|
||||||
|
- nspr=4.30=h9c3ff4c_0
|
||||||
|
- nss=3.63=hb5efdd6_0
|
||||||
|
- numpy=1.19.5=py36h2aa4a07_1
|
||||||
|
- obspy=1.2.2=py36h785e9b2_0
|
||||||
|
- olefile=0.46=pyh9f0ad1d_1
|
||||||
|
- openssl=1.1.1k=h7f98852_0
|
||||||
|
- pandas=1.1.5=py36h284efc9_0
|
||||||
|
- pcre=8.44=he1b5a44_0
|
||||||
|
- pillow=8.1.2=py36ha6010c0_0
|
||||||
|
- pip=21.0.1=pyhd8ed1ab_0
|
||||||
|
- proj=7.2.0=h277dcde_2
|
||||||
|
- pthread-stubs=0.4=h36c2ea0_1001
|
||||||
|
- pycparser=2.20=pyh9f0ad1d_2
|
||||||
|
- pyopenssl=20.0.1=pyhd8ed1ab_0
|
||||||
|
- pyparsing=2.4.7=pyh9f0ad1d_0
|
||||||
|
- pyqt5-sip=4.19.18=py36hc4f0c31_7
|
||||||
|
- pyqtgraph=0.11.1=pyhd3deb0d_0
|
||||||
|
- pyshp=2.1.3=pyh44b312d_0
|
||||||
|
- pyside2=5.13.2=py36h6b97533_4
|
||||||
|
- pysocks=1.7.1=py36h5fab9bb_3
|
||||||
|
- python=3.6.13=hffdb5ce_0_cpython
|
||||||
|
- python-dateutil=2.8.1=py_0
|
||||||
|
- python_abi=3.6=1_cp36m
|
||||||
|
- pytz=2021.1=pyhd8ed1ab_0
|
||||||
|
- qt=5.12.9=hda022c4_4
|
||||||
|
- qtpy=1.9.0=py_0
|
||||||
|
- readline=8.0=he28a2e2_2
|
||||||
|
- requests=2.25.1=pyhd3deb0d_0
|
||||||
|
- scipy=1.5.3=py36h9e8f40b_0
|
||||||
|
- setuptools=49.6.0=py36h5fab9bb_3
|
||||||
|
- shapely=1.7.1=py36h93b233e_4
|
||||||
|
- six=1.15.0=pyh9f0ad1d_0
|
||||||
|
- sqlalchemy=1.4.2=py36h8f6f2f9_0
|
||||||
|
- sqlite=3.34.0=h74cdb3f_0
|
||||||
|
- tk=8.6.10=h21135ba_1
|
||||||
|
- tornado=6.1=py36h8f6f2f9_1
|
||||||
|
- typing_extensions=3.7.4.3=py_0
|
||||||
|
- urllib3=1.26.4=pyhd8ed1ab_0
|
||||||
|
- wheel=0.36.2=pyhd3deb0d_0
|
||||||
|
- xorg-libxau=1.0.9=h7f98852_0
|
||||||
|
- xorg-libxdmcp=1.1.3=h7f98852_0
|
||||||
|
- xz=5.2.5=h516909a_1
|
||||||
|
- 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
|
@ -1,45 +1,50 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import sys
|
||||||
import os
|
import os
|
||||||
import matplotlib
|
import matplotlib
|
||||||
|
|
||||||
matplotlib.use('Qt5Agg')
|
matplotlib.use('Qt5Agg')
|
||||||
|
|
||||||
|
from PySide2 import QtCore, QtGui, QtWidgets
|
||||||
import matplotlib.pyplot as plt
|
from PySide2.QtCore import Qt
|
||||||
import numpy as np
|
|
||||||
import obspy
|
|
||||||
import traceback
|
|
||||||
from PySide2 import QtWidgets
|
|
||||||
from matplotlib.figure import Figure
|
|
||||||
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
|
|
||||||
# from mpl_toolkits.basemap import Basemap
|
|
||||||
from scipy.interpolate import griddata
|
|
||||||
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 cartopy.crs as ccrs
|
import cartopy.crs as ccrs
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
import cartopy.feature as cf
|
import cartopy.feature as cf
|
||||||
from cartopy.feature import ShapelyFeature
|
|
||||||
from cartopy.io.shapereader import Reader
|
from cartopy.io.shapereader import Reader
|
||||||
|
from cartopy.feature import ShapelyFeature
|
||||||
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
|
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
|
||||||
|
|
||||||
from pylot.core.util.widgets import PickDlg, PylotCanvas
|
import traceback
|
||||||
|
import obspy
|
||||||
|
import numpy as np
|
||||||
|
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
|
||||||
|
from scipy.interpolate import griddata
|
||||||
|
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
|
||||||
|
|
||||||
plt.interactive(False)
|
class MplCanvas(FigureCanvas):
|
||||||
|
|
||||||
|
def __init__(self, parent=None, width=5, height=4, dpi=100):
|
||||||
|
self.fig = plt.figure(figsize=(width, height), dpi=dpi)
|
||||||
|
self.axes = self.fig.add_subplot(111)
|
||||||
|
super(MplCanvas, self).__init__(self.fig)
|
||||||
|
|
||||||
|
|
||||||
class Array_map(QtWidgets.QWidget):
|
class Array_map(QtWidgets.QWidget):
|
||||||
def __init__(self, parent, metadata, parameter=None, figure=None, annotate=True, pointsize=25.,
|
def __init__(self, parent, metadata, parameter=None, figure=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)
|
||||||
Create a map of the array.
|
|
||||||
:param parent: object of PyLoT Mainwindow class
|
|
||||||
:param parameter: object of PyLoT parameter class
|
|
||||||
:param figure:
|
|
||||||
'''
|
|
||||||
QtWidgets.QWidget.__init__(self)
|
QtWidgets.QWidget.__init__(self)
|
||||||
|
|
||||||
assert (parameter != None or parent != None), 'either parent or parameter has to be set'
|
assert (parameter != None or parent != None), 'either parent or parameter has to be set'
|
||||||
|
# set properties
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
self.metadata = metadata
|
self.metadata = metadata
|
||||||
self.pointsize = pointsize
|
self.pointsize = pointsize
|
||||||
@ -54,196 +59,41 @@ class Array_map(QtWidgets.QWidget):
|
|||||||
self.hybrids_dict = None
|
self.hybrids_dict = None
|
||||||
self.eventLoc = None
|
self.eventLoc = None
|
||||||
self.parameter = parameter if parameter else parent._inputs
|
self.parameter = parameter if parameter else parent._inputs
|
||||||
self.figure = figure
|
|
||||||
self.picks_rel = {}
|
self.picks_rel = {}
|
||||||
self.marked_stations = []
|
self.marked_stations = []
|
||||||
self.highlighted_stations = []
|
self.highlighted_stations = []
|
||||||
|
|
||||||
|
# call functions to draw everything
|
||||||
self.init_graphics()
|
self.init_graphics()
|
||||||
self.init_stations()
|
self.init_stations()
|
||||||
self.init_basemap()
|
self.init_crtpyMap()
|
||||||
self.init_map()
|
self.init_map()
|
||||||
self._style = None if not hasattr(parent, '_style') else parent._style
|
# set original map limits to fall back on when home button is pressed
|
||||||
self.show()
|
self.org_xlim = self.canvas.axes.get_xlim()
|
||||||
|
self.org_ylim = self.canvas.axes.get_ylim()
|
||||||
|
|
||||||
def update_hybrids_dict(self):
|
self._style = None if not hasattr(parent, '_style') else parent._style
|
||||||
self.hybrids_dict = self.picks_dict.copy()
|
|
||||||
for station, pick in self.autopicks_dict.items():
|
self.show()
|
||||||
if not station in self.hybrids_dict.keys():
|
|
||||||
self.hybrids_dict[station] = pick
|
|
||||||
return self.hybrids_dict
|
|
||||||
|
|
||||||
def init_map(self):
|
def init_map(self):
|
||||||
self.init_colormap()
|
self.init_colormap()
|
||||||
self.connectSignals()
|
self.connectSignals()
|
||||||
self.draw_everything()
|
self.draw_everything()
|
||||||
# self.canvas.setZoomBorders2content()
|
|
||||||
|
|
||||||
def init_colormap(self):
|
|
||||||
self.init_lat_lon_dimensions()
|
|
||||||
self.init_lat_lon_grid()
|
|
||||||
# self.init_x_y_dimensions()
|
|
||||||
|
|
||||||
def onpick(self, event):
|
|
||||||
ind = event.ind
|
|
||||||
button = event.mouseevent.button
|
|
||||||
if ind == []:
|
|
||||||
return
|
|
||||||
if button == 1:
|
|
||||||
self.openPickDlg(ind)
|
|
||||||
elif button == 2:
|
|
||||||
self.deletePick(ind)
|
|
||||||
elif button == 3:
|
|
||||||
self.pickInfo(ind)
|
|
||||||
|
|
||||||
def deletePick(self, ind):
|
|
||||||
self.update_hybrids_dict()
|
|
||||||
for index in ind:
|
|
||||||
network, station = self._station_onpick_ids[index].split('.')[:2]
|
|
||||||
try:
|
|
||||||
phase = self.comboBox_phase.currentText()
|
|
||||||
picks = self.current_picks_dict()[station]
|
|
||||||
pick = picks.get(phase)
|
|
||||||
if pick:
|
|
||||||
picker = pick['picker']
|
|
||||||
message = 'Deleted {} pick for phase {}, station {}.{} at timestamp {}'
|
|
||||||
message = message.format(picker, phase, network, station,
|
|
||||||
pick['mpp'])
|
|
||||||
if picker == 'auto':
|
|
||||||
del (self.autopicks_dict[station])
|
|
||||||
elif picker == 'manual':
|
|
||||||
del (self.picks_dict[station])
|
|
||||||
else:
|
|
||||||
raise TypeError('Unknown "picker" {}'.format(picker))
|
|
||||||
print(message)
|
|
||||||
pyl_mw = self._parent
|
|
||||||
pyl_mw.deletePicks(station, pick, type=picker)
|
|
||||||
pyl_mw.setDirty(True)
|
|
||||||
pyl_mw.update_status(message)
|
|
||||||
if self.auto_refresh_box.isChecked():
|
|
||||||
self._refresh_drawings()
|
|
||||||
else:
|
|
||||||
self.highlight_station(network, station, color='red')
|
|
||||||
pyl_mw.drawPicks(station)
|
|
||||||
pyl_mw.draw()
|
|
||||||
except Exception as e:
|
|
||||||
print('Could not delete pick for station {}.{}: {}'.format(network, station, e))
|
|
||||||
|
|
||||||
def highlight_station(self, network, station, color):
|
|
||||||
stat_dict = self.stations_dict['{}.{}'.format(network, station)]
|
|
||||||
lat = stat_dict['latitude']
|
|
||||||
lon = stat_dict['longitude']
|
|
||||||
self.highlighted_stations.append(self.basemap.scatter(lon, lat, s=self.pointsize, edgecolors=color,
|
|
||||||
facecolors='none', zorder=12, label='deleted'))
|
|
||||||
|
|
||||||
self.canvas.draw()
|
|
||||||
|
|
||||||
def pickInfo(self, ind):
|
|
||||||
self.update_hybrids_dict()
|
|
||||||
for index in ind:
|
|
||||||
network, station = self._station_onpick_ids[index].split('.')[:2]
|
|
||||||
dic = self.current_picks_dict()[station]
|
|
||||||
for phase, picks in dic.items():
|
|
||||||
# because of wadati...
|
|
||||||
if phase == 'SPt':
|
|
||||||
continue
|
|
||||||
print('{} - Pick:'.format(phase))
|
|
||||||
for key, info in picks.items():
|
|
||||||
print('{}: {}'.format(key, info))
|
|
||||||
|
|
||||||
def openPickDlg(self, ind):
|
|
||||||
data = self._parent.get_data().getWFData()
|
|
||||||
for index in ind:
|
|
||||||
network, station = self._station_onpick_ids[index].split('.')[:2]
|
|
||||||
pyl_mw = self._parent
|
|
||||||
try:
|
|
||||||
data = data.select(station=station)
|
|
||||||
if not data:
|
|
||||||
self._warn('No data for station {}'.format(station))
|
|
||||||
return
|
|
||||||
pickDlg = PickDlg(self._parent, parameter=self.parameter,
|
|
||||||
data=data, network=network, station=station,
|
|
||||||
picks=self._parent.get_current_event().getPick(station),
|
|
||||||
autopicks=self._parent.get_current_event().getAutopick(station),
|
|
||||||
filteroptions=self._parent.filteroptions, metadata=self.metadata,
|
|
||||||
event=pyl_mw.get_current_event())
|
|
||||||
except Exception as e:
|
|
||||||
message = 'Could not generate Plot for station {st}.\n {er}'.format(st=station, er=e)
|
|
||||||
self._warn(message)
|
|
||||||
print(message, e)
|
|
||||||
print(traceback.format_exc())
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
if pickDlg.exec_():
|
|
||||||
pyl_mw.setDirty(True)
|
|
||||||
pyl_mw.update_status('picks accepted ({0})'.format(station))
|
|
||||||
pyl_mw.addPicks(station, pickDlg.getPicks(picktype='manual'), type='manual')
|
|
||||||
pyl_mw.addPicks(station, pickDlg.getPicks(picktype='auto'), type='auto')
|
|
||||||
if self.auto_refresh_box.isChecked():
|
|
||||||
self._refresh_drawings()
|
|
||||||
else:
|
|
||||||
self.highlight_station(network, station, color='yellow')
|
|
||||||
pyl_mw.drawPicks(station)
|
|
||||||
pyl_mw.draw()
|
|
||||||
else:
|
|
||||||
pyl_mw.update_status('picks discarded ({0})'.format(station))
|
|
||||||
except Exception as e:
|
|
||||||
message = 'Could not save picks for station {st}.\n{er}'.format(st=station, er=e)
|
|
||||||
self._warn(message)
|
|
||||||
print(message, e)
|
|
||||||
print(traceback.format_exc())
|
|
||||||
|
|
||||||
def connectSignals(self):
|
|
||||||
self.comboBox_phase.currentIndexChanged.connect(self._refresh_drawings)
|
|
||||||
self.comboBox_am.currentIndexChanged.connect(self._refresh_drawings)
|
|
||||||
self.cmaps_box.currentIndexChanged.connect(self._refresh_drawings)
|
|
||||||
self.annotations_box.stateChanged.connect(self.switch_annotations)
|
|
||||||
self.refresh_button.clicked.connect(self._refresh_drawings)
|
|
||||||
self.canvas.mpl_connect('motion_notify_event', self.mouse_moved)
|
|
||||||
self.canvas.mpl_connect('scroll_event', self.zoom)
|
|
||||||
|
|
||||||
def _from_dict(self, function, key):
|
|
||||||
return function(self.stations_dict.values(), key=lambda x: x[key])[key]
|
|
||||||
|
|
||||||
def get_min_from_stations(self, key):
|
|
||||||
return self._from_dict(min, key)
|
|
||||||
|
|
||||||
def get_max_from_stations(self, key):
|
|
||||||
return self._from_dict(max, key)
|
|
||||||
|
|
||||||
def get_min_from_picks(self):
|
|
||||||
return min(self.picks_rel.values())
|
|
||||||
|
|
||||||
def get_max_from_picks(self):
|
|
||||||
return max(self.picks_rel.values())
|
|
||||||
|
|
||||||
def mouse_moved(self, event):
|
|
||||||
if not event.inaxes == self.main_ax:
|
|
||||||
return
|
|
||||||
x = event.xdata
|
|
||||||
y = event.ydata
|
|
||||||
# lat, lon = self.basemap(x, y, inverse=True)
|
|
||||||
lat = y
|
|
||||||
lon = x
|
|
||||||
self.status_label.setText('Latitude: {}, Longitude: {}'.format(lat, lon))
|
|
||||||
|
|
||||||
def current_picks_dict(self):
|
|
||||||
picktype = self.comboBox_am.currentText().split(' ')[0]
|
|
||||||
auto_manu = {'auto': self.autopicks_dict,
|
|
||||||
'manual': self.picks_dict,
|
|
||||||
'hybrid': self.hybrids_dict}
|
|
||||||
return auto_manu[picktype]
|
|
||||||
|
|
||||||
def init_graphics(self):
|
def init_graphics(self):
|
||||||
if not self.figure:
|
"""
|
||||||
self.figure = plt.figure()
|
Initializes all GUI components and figure elements to be populeted by other functions
|
||||||
|
"""
|
||||||
|
# initialize figure elements
|
||||||
|
self.canvas = MplCanvas(self)
|
||||||
|
self.plotWidget = FigureCanvas(self.canvas.fig)
|
||||||
|
|
||||||
|
# initialize GUI elements
|
||||||
self.status_label = QtWidgets.QLabel()
|
self.status_label = QtWidgets.QLabel()
|
||||||
|
self.map_reset_button = QtWidgets.QPushButton('Reset Map View')
|
||||||
self.main_ax = self.figure.add_subplot(111)
|
self.map_reset_button.resize(150, 50)
|
||||||
#self.main_ax.set_facecolor('0.7')
|
|
||||||
self.canvas = FigureCanvas(self.figure)
|
|
||||||
|
|
||||||
# parent=self._parent, multicursor=True, panZoomX=False, panZoomY=False)
|
|
||||||
|
|
||||||
self.main_box = QtWidgets.QVBoxLayout()
|
self.main_box = QtWidgets.QVBoxLayout()
|
||||||
self.setLayout(self.main_box)
|
self.setLayout(self.main_box)
|
||||||
@ -282,8 +132,220 @@ class Array_map(QtWidgets.QWidget):
|
|||||||
self.top_row.addWidget(self.auto_refresh_box)
|
self.top_row.addWidget(self.auto_refresh_box)
|
||||||
self.top_row.addWidget(self.refresh_button)
|
self.top_row.addWidget(self.refresh_button)
|
||||||
|
|
||||||
self.main_box.addWidget(self.canvas, 1)
|
self.main_box.addWidget(self.plotWidget, 1)
|
||||||
self.main_box.addWidget(self.status_label, 0)
|
# 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)
|
||||||
|
self.bot_row.addWidget(self.map_reset_button)
|
||||||
|
self.bot_row.addWidget(self.status_label)
|
||||||
|
# self.connectSignals()
|
||||||
|
|
||||||
|
def init_colormap(self):
|
||||||
|
self.init_lat_lon_dimensions()
|
||||||
|
self.init_lat_lon_grid()
|
||||||
|
|
||||||
|
def init_crtpyMap(self):
|
||||||
|
self.canvas.axes.cla()
|
||||||
|
self.canvas.axes = plt.axes(projection=ccrs.PlateCarree())
|
||||||
|
self.canvas.axes.add_feature(cf.LAND)
|
||||||
|
self.canvas.axes.add_feature(cf.OCEAN)
|
||||||
|
self.canvas.axes.add_feature(cf.COASTLINE, linewidth=1, edgecolor='gray')
|
||||||
|
self.canvas.axes.add_feature(cf.BORDERS, alpha=0.7)
|
||||||
|
|
||||||
|
# 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.5, zorder=7)
|
||||||
|
# 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()
|
||||||
|
|
||||||
|
def org_map_view(self):
|
||||||
|
self.canvas.axes.set_xlim(self.org_xlim[0], self.org_xlim[1])
|
||||||
|
self.canvas.axes.set_ylim(self.org_ylim[0], self.org_ylim[1])
|
||||||
|
# parallels and meridians
|
||||||
|
self.remove_merid_paral()
|
||||||
|
self.add_merid_paral()
|
||||||
|
|
||||||
|
self.canvas.axes.figure.canvas.draw_idle()
|
||||||
|
|
||||||
|
def connectSignals(self):
|
||||||
|
self.comboBox_phase.currentIndexChanged.connect(self._refresh_drawings)
|
||||||
|
self.comboBox_am.currentIndexChanged.connect(self._refresh_drawings)
|
||||||
|
self.cmaps_box.currentIndexChanged.connect(self._refresh_drawings)
|
||||||
|
self.annotations_box.stateChanged.connect(self.switch_annotations)
|
||||||
|
self.refresh_button.clicked.connect(self._refresh_drawings)
|
||||||
|
self.map_reset_button.clicked.connect(self.org_map_view)
|
||||||
|
|
||||||
|
self.plotWidget.mpl_connect('motion_notify_event', self.mouse_moved)
|
||||||
|
self.plotWidget.mpl_connect('scroll_event', self.mouse_scroll)
|
||||||
|
self.plotWidget.mpl_connect('button_press_event', self.mouseLeftPress)
|
||||||
|
self.plotWidget.mpl_connect('button_release_event', self.mouseLeftRelease)
|
||||||
|
|
||||||
|
# set mouse events -----------------------------------------------------
|
||||||
|
def mouse_moved(self, event):
|
||||||
|
if not event.inaxes == self.canvas.axes:
|
||||||
|
return
|
||||||
|
lat = event.ydata
|
||||||
|
lon = event.xdata
|
||||||
|
self.status_label.setText('Latitude: {}, Longitude: {}'.format(lat, lon))
|
||||||
|
|
||||||
|
def mouse_scroll(self, event):
|
||||||
|
if not event.inaxes == self.canvas.axes:
|
||||||
|
return
|
||||||
|
|
||||||
|
zoom = {'up': 1. / 2., 'down': 2.}
|
||||||
|
|
||||||
|
if event.button in zoom:
|
||||||
|
xlim = self.canvas.axes.get_xlim()
|
||||||
|
ylim = self.canvas.axes.get_ylim()
|
||||||
|
|
||||||
|
x, y = event.xdata, event.ydata
|
||||||
|
|
||||||
|
factor = zoom[event.button]
|
||||||
|
xdiff = (xlim[1] - xlim[0]) * factor
|
||||||
|
xl = x - 0.5 * xdiff
|
||||||
|
xr = x + 0.5 * xdiff
|
||||||
|
ydiff = (ylim[1] - ylim[0]) * factor
|
||||||
|
yb = y - 0.5 * ydiff
|
||||||
|
yt = y + 0.5 * ydiff
|
||||||
|
|
||||||
|
self.canvas.axes.set_xlim(xl, xr)
|
||||||
|
self.canvas.axes.set_ylim(yb, yt)
|
||||||
|
# parallels and meridians
|
||||||
|
self.remove_merid_paral()
|
||||||
|
self.add_merid_paral()
|
||||||
|
|
||||||
|
self.canvas.axes.figure.canvas.draw_idle()
|
||||||
|
|
||||||
|
def mouseLeftPress(self, event):
|
||||||
|
if not event.inaxes == self.canvas.axes:
|
||||||
|
return
|
||||||
|
self.map_x = event.xdata
|
||||||
|
self.map_y = event.ydata
|
||||||
|
self.map_xlim = self.canvas.axes.get_xlim()
|
||||||
|
self.map_ylim = self.canvas.axes.get_ylim()
|
||||||
|
|
||||||
|
def mouseLeftRelease(self, event):
|
||||||
|
if not event.inaxes == self.canvas.axes:
|
||||||
|
return
|
||||||
|
new_x = event.xdata
|
||||||
|
new_y = event.ydata
|
||||||
|
|
||||||
|
dx = new_x - self.map_x
|
||||||
|
dy = new_y - self.map_y
|
||||||
|
|
||||||
|
self.canvas.axes.set_xlim((self.map_xlim[0] - dx, self.map_xlim[1] - dx))
|
||||||
|
self.canvas.axes.set_ylim(self.map_ylim[0] - dy, self.map_ylim[1] - dy)
|
||||||
|
# parallels and meridians
|
||||||
|
self.remove_merid_paral()
|
||||||
|
self.add_merid_paral()
|
||||||
|
|
||||||
|
self.canvas.axes.figure.canvas.draw_idle()
|
||||||
|
|
||||||
|
def onpick(self, event):
|
||||||
|
ind = event.ind
|
||||||
|
button = event.mouseevent.button
|
||||||
|
if ind == []:
|
||||||
|
return
|
||||||
|
if button == 1:
|
||||||
|
self.openPickDlg(ind)
|
||||||
|
elif button == 2:
|
||||||
|
self.deletePick(ind)
|
||||||
|
elif button == 3:
|
||||||
|
self.pickInfo(ind)
|
||||||
|
|
||||||
|
# data handling -----------------------------------------------------
|
||||||
|
def update_hybrids_dict(self):
|
||||||
|
self.hybrids_dict = self.picks_dict.copy()
|
||||||
|
for station, pick in self.autopicks_dict.items():
|
||||||
|
if not station in self.hybrids_dict.keys():
|
||||||
|
self.hybrids_dict[station] = pick
|
||||||
|
return self.hybrids_dict
|
||||||
|
|
||||||
|
def deletePick(self, ind):
|
||||||
|
self.update_hybrids_dict()
|
||||||
|
for index in ind:
|
||||||
|
network, station = self._station_onpick_ids[index].split('.')[:2]
|
||||||
|
try:
|
||||||
|
phase = self.comboBox_phase.currentText()
|
||||||
|
picks = self.current_picks_dict()[station]
|
||||||
|
pick = picks.get(phase)
|
||||||
|
if pick:
|
||||||
|
picker = pick['picker']
|
||||||
|
message = 'Deleted {} pick for phase {}, station {}.{} at timestamp {}'
|
||||||
|
message = message.format(picker, phase, network, station,
|
||||||
|
pick['mpp'])
|
||||||
|
if picker == 'auto':
|
||||||
|
del (self.autopicks_dict[station])
|
||||||
|
elif picker == 'manual':
|
||||||
|
del (self.picks_dict[station])
|
||||||
|
else:
|
||||||
|
raise TypeError('Unknown "picker" {}'.format(picker))
|
||||||
|
print(message)
|
||||||
|
pyl_mw = self._parent
|
||||||
|
pyl_mw.deletePicks(station, pick, type=picker)
|
||||||
|
pyl_mw.setDirty(True)
|
||||||
|
pyl_mw.update_status(message)
|
||||||
|
if self.auto_refresh_box.isChecked():
|
||||||
|
self._refresh_drawings()
|
||||||
|
else:
|
||||||
|
self.highlight_station(network, station, color='red')
|
||||||
|
pyl_mw.drawPicks(station)
|
||||||
|
pyl_mw.draw()
|
||||||
|
except Exception as e:
|
||||||
|
print('Could not delete pick for station {}.{}: {}'.format(network, station, e))
|
||||||
|
|
||||||
|
def pickInfo(self, ind):
|
||||||
|
self.update_hybrids_dict()
|
||||||
|
for index in ind:
|
||||||
|
network, station = self._station_onpick_ids[index].split('.')[:2]
|
||||||
|
dic = self.current_picks_dict()[station]
|
||||||
|
for phase, picks in dic.items():
|
||||||
|
# because of wadati...
|
||||||
|
if phase == 'SPt':
|
||||||
|
continue
|
||||||
|
print('{} - Pick:'.format(phase))
|
||||||
|
for key, info in picks.items():
|
||||||
|
print('{}: {}'.format(key, info))
|
||||||
|
|
||||||
|
def _from_dict(self, function, key):
|
||||||
|
return function(self.stations_dict.values(), key=lambda x: x[key])[key]
|
||||||
|
|
||||||
|
def get_min_from_stations(self, key):
|
||||||
|
return self._from_dict(min, key)
|
||||||
|
|
||||||
|
def get_max_from_stations(self, key):
|
||||||
|
return self._from_dict(max, key)
|
||||||
|
|
||||||
|
def get_min_from_picks(self):
|
||||||
|
return min(self.picks_rel.values())
|
||||||
|
|
||||||
|
def get_max_from_picks(self):
|
||||||
|
return max(self.picks_rel.values())
|
||||||
|
|
||||||
|
def current_picks_dict(self):
|
||||||
|
picktype = self.comboBox_am.currentText().split(' ')[0]
|
||||||
|
auto_manu = {'auto': self.autopicks_dict,
|
||||||
|
'manual': self.picks_dict,
|
||||||
|
'hybrid': self.hybrids_dict}
|
||||||
|
return auto_manu[picktype]
|
||||||
|
|
||||||
def init_stations(self):
|
def init_stations(self):
|
||||||
self.stations_dict = self.metadata.get_all_coordinates()
|
self.stations_dict = self.metadata.get_all_coordinates()
|
||||||
@ -337,35 +399,6 @@ class Array_map(QtWidgets.QWidget):
|
|||||||
self.londim = self.lonmax - self.lonmin
|
self.londim = self.lonmax - self.lonmin
|
||||||
self.latdim = self.latmax - self.latmin
|
self.latdim = self.latmax - self.latmin
|
||||||
|
|
||||||
def init_basemap(self):
|
|
||||||
# initialize cartopy coordinate reference system
|
|
||||||
proj = ccrs.Mercator() # PlateCarree(central_longitude=self.lonmin + abs(self.lonmax - self.lonmin) / 2.)
|
|
||||||
# crtpy_map = self.figure.axes
|
|
||||||
self.main_ax = plt.axes(projection=proj)
|
|
||||||
mapxtent = [self.lonmin, self.lonmax, self.latmin, self.latmax] # add conditional buffer
|
|
||||||
self.main_ax.set_extent(mapxtent) # find way to directly open zoomed map on area
|
|
||||||
# self.main_ax.set_global()
|
|
||||||
|
|
||||||
# add features (option for plate boundaries)
|
|
||||||
self.main_ax.add_feature(cf.LAND, edgecolor='face', facecolor=cf.COLORS['land']) # replace with background map
|
|
||||||
self.main_ax.add_feature(cf.OCEAN, edgecolor='face', facecolor=cf.COLORS['water'])
|
|
||||||
self.main_ax.add_feature(cf.BORDERS, linestyle=':', edgecolor='k') # include province borders
|
|
||||||
self.main_ax.add_feature(cf.COASTLINE, color='gray', linewidth=1)
|
|
||||||
# fname = 'PB2002_plates.shp'
|
|
||||||
# plateBoundaries = ShapelyFeature(Reader(fname).geometries(), ccrs.PlateCarree(), facecolor='none', edgecolor='r')
|
|
||||||
# crtpy_map.add_feature(plateBoundaries)
|
|
||||||
|
|
||||||
# parallels and meridians
|
|
||||||
gridlines = self.main_ax.gridlines(draw_labels=True, alpha=0.5, zorder=7)
|
|
||||||
gridlines.xformatter = LONGITUDE_FORMATTER
|
|
||||||
gridlines.yformatter = LATITUDE_FORMATTER
|
|
||||||
|
|
||||||
self.basemap = self.main_ax
|
|
||||||
# plt.show()
|
|
||||||
# self.show()
|
|
||||||
# self.figure._tight = True
|
|
||||||
# self.figure.tight_layout()
|
|
||||||
|
|
||||||
def init_lat_lon_grid(self, nstep=250):
|
def init_lat_lon_grid(self, nstep=250):
|
||||||
# create a regular grid to display colormap
|
# create a regular grid to display colormap
|
||||||
lataxis = np.linspace(self.latmin, self.latmax, nstep)
|
lataxis = np.linspace(self.latmin, self.latmax, nstep)
|
||||||
@ -401,34 +434,87 @@ class Array_map(QtWidgets.QWidget):
|
|||||||
longitudes.append(self.stations_dict[st_id]['longitude'])
|
longitudes.append(self.stations_dict[st_id]['longitude'])
|
||||||
return picks, uncertainties, latitudes, longitudes
|
return picks, uncertainties, latitudes, longitudes
|
||||||
|
|
||||||
|
# plotting -----------------------------------------------------
|
||||||
|
def highlight_station(self, network, station, color):
|
||||||
|
stat_dict = self.stations_dict['{}.{}'.format(network, station)]
|
||||||
|
lat = stat_dict['latitude']
|
||||||
|
lon = stat_dict['longitude']
|
||||||
|
self.highlighted_stations.append(self.canvas.axes.scatter(lon, lat, s=self.pointsize, edgecolors=color,
|
||||||
|
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:
|
||||||
|
network, station = self._station_onpick_ids[index].split('.')[:2]
|
||||||
|
pyl_mw = self._parent
|
||||||
|
try:
|
||||||
|
data = data.select(station=station)
|
||||||
|
if not data:
|
||||||
|
self._warn('No data for station {}'.format(station))
|
||||||
|
return
|
||||||
|
pickDlg = PickDlg(self._parent, parameter=self.parameter,
|
||||||
|
data=data, network=network, station=station,
|
||||||
|
picks=self._parent.get_current_event().getPick(station),
|
||||||
|
autopicks=self._parent.get_current_event().getAutopick(station),
|
||||||
|
filteroptions=self._parent.filteroptions, metadata=self.metadata,
|
||||||
|
event=pyl_mw.get_current_event())
|
||||||
|
except Exception as e:
|
||||||
|
message = 'Could not generate Plot for station {st}.\n {er}'.format(st=station, er=e)
|
||||||
|
self._warn(message)
|
||||||
|
print(message, e)
|
||||||
|
print(traceback.format_exc())
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
if pickDlg.exec_():
|
||||||
|
pyl_mw.setDirty(True)
|
||||||
|
pyl_mw.update_status('picks accepted ({0})'.format(station))
|
||||||
|
pyl_mw.addPicks(station, pickDlg.getPicks(picktype='manual'), type='manual')
|
||||||
|
pyl_mw.addPicks(station, pickDlg.getPicks(picktype='auto'), type='auto')
|
||||||
|
if self.auto_refresh_box.isChecked():
|
||||||
|
self._refresh_drawings()
|
||||||
|
else:
|
||||||
|
self.highlight_station(network, station, color='yellow')
|
||||||
|
pyl_mw.drawPicks(station)
|
||||||
|
pyl_mw.draw()
|
||||||
|
else:
|
||||||
|
pyl_mw.update_status('picks discarded ({0})'.format(station))
|
||||||
|
except Exception as e:
|
||||||
|
message = 'Could not save picks for station {st}.\n{er}'.format(st=station, er=e)
|
||||||
|
self._warn(message)
|
||||||
|
print(message, e)
|
||||||
|
print(traceback.format_exc())
|
||||||
|
|
||||||
def draw_contour_filled(self, nlevel=100):
|
def draw_contour_filled(self, nlevel=100):
|
||||||
# self.test_gradient()
|
# 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.basemap.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, transform=ccrs.PlateCarree(),
|
||||||
alpha=0.7, zorder=8, cmap=self.get_colormap())
|
alpha=0.7, 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='.',
|
# 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')
|
# zorder=10, picker=True, edgecolor='0.5', label='Not Picked')
|
||||||
|
|
||||||
self.sc = self.basemap.scatter(lons, lats, s=self.pointsize, facecolor='none', marker='.',
|
self.sc = self.canvas.axes.scatter(lons, lats, s=self.pointsize, facecolor='none', marker='.',
|
||||||
zorder=10, picker=True, edgecolor='0.5', label='Not Picked',
|
zorder=10, picker=True, edgecolor='0.5', label='Not Picked',
|
||||||
transform=ccrs.PlateCarree())
|
transform=ccrs.PlateCarree())
|
||||||
|
|
||||||
self.cid = self.canvas.mpl_connect('pick_event', self.onpick)
|
self.cid = self.plotWidget.mpl_connect('pick_event', self.onpick)
|
||||||
self._station_onpick_ids = stations
|
self._station_onpick_ids = stations
|
||||||
if self.eventLoc:
|
if self.eventLoc:
|
||||||
lats, lons = self.eventLoc
|
lats, lons = self.eventLoc
|
||||||
self.sc_event = self.basemap.scatter(lons, lats, s=2*self.pointsize, facecolor='red', zorder=11,
|
self.sc_event = self.canvas.axes.scatter(lons, lats, s=2 * self.pointsize, facecolor='red', zorder=11,
|
||||||
label='Event (might be outside map region)',
|
label='Event (might be outside map region)',
|
||||||
transform=ccrs.PlateCarree())
|
transform=ccrs.PlateCarree())
|
||||||
|
|
||||||
def scatter_picked_stations(self):
|
def scatter_picked_stations(self):
|
||||||
picks, uncertainties, lats, lons = self.get_picks_lat_lon()
|
picks, uncertainties, lats, lons = self.get_picks_lat_lon()
|
||||||
@ -441,22 +527,12 @@ class Array_map(QtWidgets.QWidget):
|
|||||||
for uncertainty in uncertainties])
|
for uncertainty in uncertainties])
|
||||||
|
|
||||||
cmap = self.get_colormap()
|
cmap = self.get_colormap()
|
||||||
self.sc_picked = self.basemap.scatter(lons, lats, s=sizes, edgecolors='white', cmap=cmap,
|
self.sc_picked = self.canvas.axes.scatter(lons, lats, s=sizes, edgecolors='white', cmap=cmap,
|
||||||
c=picks, zorder=11, label='Picked', transform=ccrs.PlateCarree())
|
c=picks, zorder=11, label='Picked', transform=ccrs.PlateCarree())
|
||||||
# workaround because of an issue with latlon transformation of arrays with len <3
|
|
||||||
# if len(lons) <= 2 and len(lats) <= 2:
|
|
||||||
# self.sc_picked = self.basemap.scatter(lons[0], lats[0], s=sizes, edgecolors='white', cmap=cmap,
|
|
||||||
# c=picks[0], zorder=11, transform=ccrs.PlateCarree())
|
|
||||||
# if len(lons) == 2 and len(lats) == 2:
|
|
||||||
# self.sc_picked = self.basemap.scatter(lons[1], lats[1], s=sizes, edgecolors='white', cmap=cmap,
|
|
||||||
# c=picks[1], zorder=11, transform=ccrs.PlateCarree())
|
|
||||||
# if len(lons) > 2 and len(lats) > 2:
|
|
||||||
# self.sc_picked = self.basemap.scatter(lons, lats, s=sizes, edgecolors='white', cmap=cmap,
|
|
||||||
# c=picks, zorder=11, label='Picked', transform=ccrs.PlateCarree())
|
|
||||||
|
|
||||||
def annotate_ax(self):
|
def annotate_ax(self):
|
||||||
self.annotations = []
|
self.annotations = []
|
||||||
stations, xs, ys = self.get_st_lat_lon_for_plot()
|
stations, ys, xs = self.get_st_lat_lon_for_plot()
|
||||||
# MP MP testing station highlighting if they have high impact on mean gradient of color map
|
# MP MP testing station highlighting if they have high impact on mean gradient of color map
|
||||||
# if self.picks_rel:
|
# if self.picks_rel:
|
||||||
# self.test_gradient()
|
# self.test_gradient()
|
||||||
@ -469,15 +545,17 @@ class Array_map(QtWidgets.QWidget):
|
|||||||
color = 'lightgrey'
|
color = 'lightgrey'
|
||||||
if st in self.marked_stations:
|
if st in self.marked_stations:
|
||||||
color = 'red'
|
color = 'red'
|
||||||
self.annotations.append(self.main_ax.annotate(' %s' % st, xy=(x, y), fontsize=self.pointsize/4.,
|
self.annotations.append(self.canvas.axes.annotate(' %s' % st, xy=(x, y), fontsize=self.pointsize / 4.,
|
||||||
fontweight='semibold', color=color, zorder=14))
|
fontweight='semibold', color=color,
|
||||||
self.legend = self.main_ax.legend(loc=1)
|
transform=ccrs.PlateCarree(), zorder=14,
|
||||||
|
path_effects=[PathEffects.withStroke(linewidth=self.pointsize / 4., foreground='k')]))
|
||||||
|
self.legend = self.canvas.axes.legend(loc=1)
|
||||||
self.legend.get_frame().set_facecolor((1, 1, 1, 0.75))
|
self.legend.get_frame().set_facecolor((1, 1, 1, 0.75))
|
||||||
|
|
||||||
def add_cbar(self, label):
|
def add_cbar(self, label):
|
||||||
self.cbax_bg = inset_axes(self.main_ax, width="6%", height="75%", loc=5)
|
self.cbax_bg = inset_axes(self.canvas.axes, width="6%", height="75%", loc=5)
|
||||||
cbax = inset_axes(self.main_ax, width='2%', height='70%', loc=5)
|
cbax = inset_axes(self.canvas.axes, width='2%', height='70%', loc=5)
|
||||||
cbar = self.main_ax.figure.colorbar(self.sc_picked, cax=cbax)
|
cbar = self.canvas.axes.figure.colorbar(self.sc_picked, cax=cbax)
|
||||||
cbar.set_label(label)
|
cbar.set_label(label)
|
||||||
cbax.yaxis.tick_left()
|
cbax.yaxis.tick_left()
|
||||||
cbax.yaxis.set_label_position('left')
|
cbax.yaxis.set_label_position('left')
|
||||||
@ -488,7 +566,7 @@ class Array_map(QtWidgets.QWidget):
|
|||||||
self.cbax_bg.patch.set_facecolor((1, 1, 1, 0.75))
|
self.cbax_bg.patch.set_facecolor((1, 1, 1, 0.75))
|
||||||
return cbar
|
return cbar
|
||||||
|
|
||||||
|
# handle drawings -----------------------------------------------------
|
||||||
def refresh_drawings(self, picks=None, autopicks=None):
|
def refresh_drawings(self, picks=None, autopicks=None):
|
||||||
self.picks_dict = picks
|
self.picks_dict = picks
|
||||||
self.autopicks_dict = autopicks
|
self.autopicks_dict = autopicks
|
||||||
@ -528,7 +606,7 @@ class Array_map(QtWidgets.QWidget):
|
|||||||
self.comboBox_phase.setEnabled(False)
|
self.comboBox_phase.setEnabled(False)
|
||||||
if self.annotate:
|
if self.annotate:
|
||||||
self.annotate_ax()
|
self.annotate_ax()
|
||||||
self.canvas.draw()
|
self.plotWidget.draw_idle()
|
||||||
|
|
||||||
def remove_drawings(self):
|
def remove_drawings(self):
|
||||||
self.remove_annotations()
|
self.remove_annotations()
|
||||||
@ -552,7 +630,7 @@ class Array_map(QtWidgets.QWidget):
|
|||||||
self.remove_contourf()
|
self.remove_contourf()
|
||||||
del self.contourf
|
del self.contourf
|
||||||
if hasattr(self, 'cid'):
|
if hasattr(self, 'cid'):
|
||||||
self.canvas.mpl_disconnect(self.cid)
|
self.plotWidget.mpl_disconnect(self.cid)
|
||||||
del self.cid
|
del self.cid
|
||||||
try:
|
try:
|
||||||
self.sc.remove()
|
self.sc.remove()
|
||||||
@ -562,7 +640,7 @@ class Array_map(QtWidgets.QWidget):
|
|||||||
self.legend.remove()
|
self.legend.remove()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Warning: could not remove legend. Reason: {}'.format(e))
|
print('Warning: could not remove legend. Reason: {}'.format(e))
|
||||||
self.canvas.draw()
|
self.plotWidget.draw_idle()
|
||||||
|
|
||||||
def remove_contourf(self):
|
def remove_contourf(self):
|
||||||
for item in self.contourf.collections:
|
for item in self.contourf.collections:
|
||||||
@ -573,43 +651,79 @@ class Array_map(QtWidgets.QWidget):
|
|||||||
annotation.remove()
|
annotation.remove()
|
||||||
self.annotations = []
|
self.annotations = []
|
||||||
|
|
||||||
def zoom(self, event):
|
|
||||||
if not event.inaxes == self.canvas.axes:
|
|
||||||
return
|
|
||||||
|
|
||||||
zoom = {'up': 1. / 2.,
|
|
||||||
'down': 2.}
|
|
||||||
|
|
||||||
# if not event.xdata or not event.ydata:
|
|
||||||
# return
|
|
||||||
|
|
||||||
if event.button in zoom:
|
|
||||||
m = self.basemap
|
|
||||||
xlim = m.get_xlim()
|
|
||||||
ylim = m.get_ylim()
|
|
||||||
x, y = event.xdata, event.ydata
|
|
||||||
|
|
||||||
factor = zoom[event.button]
|
|
||||||
xdiff = (xlim[1] - xlim[0]) * factor
|
|
||||||
xl = x - 0.5 * xdiff
|
|
||||||
xr = x + 0.5 * xdiff
|
|
||||||
ydiff = (ylim[1] - ylim[0]) * factor
|
|
||||||
yb = y - 0.5 * ydiff
|
|
||||||
yt = y + 0.5 * ydiff
|
|
||||||
|
|
||||||
#if xl < map.xmin or yb < map.ymin or xr > map.xmax or yt > map.ymax:
|
|
||||||
# xl, xr = map.xmin, map.xmax
|
|
||||||
# yb, yt = map.ymin, map.ymax
|
|
||||||
m.set_xlim(xl, xr)
|
|
||||||
m.set_ylim(yb, yt)
|
|
||||||
m.figure.canvas.draw_idle()
|
|
||||||
|
|
||||||
def _warn(self, message):
|
def _warn(self, message):
|
||||||
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Warning,
|
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Warning, 'Warning', message)
|
||||||
'Warning', message)
|
|
||||||
self.qmb.show()
|
self.qmb.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user