An error occurred while loading the file. Please try again.
-
Pierre-Antoine Rouby authored4ce597a2
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
107
108
109
110
111
112
113
# PlotStricklers.py -- Pamhyr
# Copyright (C) 2023 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
from tools import timer, flatten
from View.Tools.PamhyrPlot import PamhyrPlot
from PyQt5.QtCore import (
QCoreApplication
)
_translate = QCoreApplication.translate
class PlotStricklers(PamhyrPlot):
def draw_frictions(self, frictions, color="r"):
lst = frictions
lst.sort(key = lambda s: s.begin_kp)
coef = flatten(
map(
lambda s: [s.begin_strickler, s.end_strickler],
lst
)
)
kp = flatten(
map(
lambda s: [s.begin_kp, s.end_kp],
lst
)
)
coef_minor = list(map(lambda s: s.minor, coef))
coef_medium = list(map(lambda s: s.medium, coef))
self.line_kp_elevation = self.canvas.axes.plot(
kp, coef_minor,
color=color, lw=1.
)
self.line_kp_elevation = self.canvas.axes.plot(
kp, coef_medium,
color=color, lw=1.
)
@timer
def draw(self, highlight=None):
self.canvas.axes.cla()
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
if self.data is None:
return
self.canvas.axes.set_ylabel(
_translate("MainWindow_reach", "Stricklers"),
color='green', fontsize=11
)
self.canvas.axes.set_xlabel(
_translate("MainWindow_reach", "Kp (m)"),
color='green', fontsize=11
)
kp = self.data.reach.get_kp()
self.canvas.axes.set_xlim(
left = min(kp), right = max(kp)
)
frictions = self.data.frictions
if len(frictions) != 0:
lst = frictions.frictions
self.draw_frictions(lst)
# HightLight
kp_min, kp_max = (-1, -1)
if highlight is not None:
kp_min, kp_max = highlight
lst = list(
filter(
lambda s: (s.begin_kp == kp_min and
s.end_kp == kp_max),
frictions.frictions
)
)
self.draw_frictions(lst, color="b")
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