An error occurred while loading the file. Please try again.
-
Pierre-Antoine Rouby authored6c794d2e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- coding: utf-8 -*-
import logging
from functools import reduce
from tools import timer
from View.Tools.PamhyrPlot import PamhyrPlot
from PyQt5.QtCore import (
QCoreApplication
)
_translate = QCoreApplication.translate
logger = logging.getLogger()
class Plot(PamhyrPlot):
def __init__(self, data=None, display_current=True,
canvas=None, trad=None, toolbar=None,
parent=None):
super(Plot, self).__init__(
canvas=canvas,
trad=trad,
data=data,
toolbar=toolbar,
parent=parent
)
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(
self._trad["kp"],
color='green', fontsize=10
)
self.canvas.axes.set_ylabel(
self._trad["height"],
color='green', fontsize=10
)
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)
)
# Compute sediment layer in function to profile z_min
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(reversed(z_sl)):
self.line_kp_sl.append(None)
self.line_kp_sl[i], = self.canvas.axes.plot(
kp, z,
linestyle="solid" if i == len(z_sl) - 1 else "--",
lw=1.8,
color='grey' if i == len(z_sl) - 1 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 not self._init:
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()