mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
SL: Add reach sediment layers plot.
This commit is contained in:
1 parent
5fab694c27
commit
ebd05768a4
4 files changed
+144
-9
No files matched your search
@@ -0,0 +1,101 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from tools import timer
|
||||
from View.Plot.APlot import APlot
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class Plot(APlot):
|
||||
def __init__(self, canvas=None, data=None, toolbar=None,
|
||||
display_current=True):
|
||||
super(Plot, self).__init__(
|
||||
canvas=canvas,
|
||||
data=data,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self._display_current = display_current
|
||||
|
||||
self.line_kp_zmin = None
|
||||
self.line_kp_sl = []
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
if self.data is None:
|
||||
return
|
||||
|
||||
if self.data.number_profiles == 0:
|
||||
return
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "Kp (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Height (m)"),
|
||||
color='green', fontsize=12
|
||||
)
|
||||
|
||||
kp = self.data.get_kp()
|
||||
sl = self.data.get_sl()
|
||||
z_min = self.data.get_z_min()
|
||||
z_max = self.data.get_z_max()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(kp), right = max(kp)
|
||||
)
|
||||
|
||||
z_sl = reduce(
|
||||
lambda acc, v: acc + [
|
||||
list(
|
||||
map(lambda x, y: y - x, v, acc[-1])
|
||||
)
|
||||
],
|
||||
sl,
|
||||
[z_min]
|
||||
)
|
||||
|
||||
for i, z in enumerate(z_sl):
|
||||
self.line_kp_sl.append(None)
|
||||
self.line_kp_sl[i], = self.canvas.axes.plot(
|
||||
kp, z,
|
||||
linestyle="solid" if i == 0 else "--",
|
||||
lw=1.8,
|
||||
color='grey' if i == 0 else None
|
||||
)
|
||||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
self._init = True
|
||||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
if ind is None:
|
||||
kp = self.data.get_kp()
|
||||
z_min = self.data.get_z_min()
|
||||
z_max = self.data.get_z_max()
|
||||
|
||||
self.line_kp_zmin.set_data(kp, z_min)
|
||||
|
||||
self.canvas.axes.autoscale_view(True, True, True)
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
@@ -26,6 +26,7 @@ from PyQt5.QtWidgets import (
|
||||
|
||||
from View.SedimentLayers.Reach.UndoCommand import *
|
||||
from View.SedimentLayers.Reach.Table import *
|
||||
from View.SedimentLayers.Reach.Plot import Plot
|
||||
|
||||
from View.Plot.MplCanvas import MplCanvas
|
||||
from View.SedimentLayers.Reach.translate import *
|
||||
@@ -98,13 +99,13 @@ class ReachSedimentLayersWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout_2")
|
||||
self.plot_layout.addWidget(self.canvas)
|
||||
|
||||
# self.plot = PlotKPC(
|
||||
# canvas = self.canvas,
|
||||
# data = self._reach.reach,
|
||||
# toolbar = None,
|
||||
# display_current = False
|
||||
# )
|
||||
# self.plot.draw()
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._reach,
|
||||
toolbar = None,
|
||||
display_current = False
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
|
||||
def setup_connections(self):
|
||||
|
||||
Reference in new issue
Block a user