Failed to fetch fork details. Try again later.
-
Delaigue Olivier authored1c9553e7
Forked from
HYCAR-Hydro / airGR
Source project has a limited visibility.
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
114
115
116
117
118
# Plot.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 -*-
import logging
from functools import reduce
from tools import timer
from View.Tools.PamhyrPlot import PamhyrPlot
logger = logging.getLogger()
unit = {
"elevation": "meter",
"water_elevation": "meter",
"discharge": "m3s",
}
class CustomPlot(PamhyrPlot):
def __init__(self, x, y, reach, profile, timestamp,
data=None, canvas=None, trad=None,
toolbar=None, parent=None):
super(CustomPlot, self).__init__(
canvas=canvas,
trad=trad,
data=data,
toolbar=toolbar,
parent=parent
)
self._x = x
self._y = y
self._reach = reach
self._profile = profile
self._timestamp = timestamp
logger.debug(
"Create custom plot for: " +
f"{x} -> {','.join(y)}: " +
f"reach={reach}, profile={profile}, " +
f"timestamp={timestamp}"
)
self._y_axis = list(
set(
map(
lambda y: self._trad[y],
self._y
)
)
)
@timer
def draw(self):
self.canvas.axes.cla()
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
if self.data is None:
return
self.canvas.axes.set_xlabel(
self._trad[self._x],
color='green', fontsize=12
)
self.canvas.axes.set_ylabel(
self._trad[self._y_axis[0]],
color='green', fontsize=12
)
for axes in self._y_axis[1:]:
logger.info(axes)
ax_new = ax.twinx()
ax_new.set_ylabel(
self._trad[axes],
color='green', fontsize=12
)
if self._x is "kp":
if "elevation" in self._y:
logging.info("TODO: kp/elevation")
if "water_elevation" in self._y:
logging.info("TODO: kp/water_elevation")
if "discharge" in self._y:
logging.info("TODO: kp/discharge")
elif self._x is "time":
if "elevation" in self._y:
logging.info("TODO: time/elevation")
if "water_elevation" in self._y:
logging.info("TODO: time/water_elevation")
if "discharge" in self._y:
logging.info("TODO: time/discharge")
self.canvas.figure.tight_layout()
self.canvas.figure.canvas.draw_idle()
if self.toolbar is not None:
self.toolbar.update()
@timer
def update(self, reach, profile, timestamp):
if not self._init:
self.draw()
return