Commit c118d4fa authored by Youcef Aouad's avatar Youcef Aouad
Browse files

tot sed plots

No related merge requests found
Pipeline #58244 passed with stages
in 58 seconds
Showing with 257 additions and 11 deletions
+257 -11
......@@ -106,10 +106,10 @@ class PlotC(PamhyrPlot):
#First 0 for pol and second 0 for phys var
y = list(map(lambda data_el: data_el[pollutant][0], profile.get_key("pols")))
print("************//////////////////")
print("profile: ", self._current_profile_id)
print("reach: ", self._current_reach_id)
print("pollutant: ", pollutant)
###print("************//////////////////")
###print("profile: ", self._current_profile_id)
###print("reach: ", self._current_reach_id)
###print("pollutant: ", pollutant)
###print("*****************draw data: ", len(x),len(y))
###print("x: ", x)
......
......@@ -112,10 +112,10 @@ class PlotM(PamhyrPlot):
y = (np.array(y1) + np.array(y2) + np.array(y3)).tolist()
print("************//////////////////")
print("profile: ", self._current_profile_id)
print("reach: ", self._current_reach_id)
print("pollutant: ", pollutant)
###print("************//////////////////")
###print("profile: ", self._current_profile_id)
###print("reach: ", self._current_reach_id)
###print("pollutant: ", pollutant)
###print("*****************draw data: ", len(x),len(y))
###print("x: ", x)
......@@ -163,6 +163,11 @@ class PlotM(PamhyrPlot):
x = self.ts
#y = profile.get_key("Q")
y = list(map(lambda data_el: data_el[pollutant][0], profile.get_key("pols")))
y1 = list(map(lambda data_el: data_el[pollutant][1], profile.get_key("pols")))
y2 = list(map(lambda data_el: data_el[pollutant][2], profile.get_key("pols")))
y3 = list(map(lambda data_el: data_el[pollutant][3], profile.get_key("pols")))
y = (np.array(y1) + np.array(y2) + np.array(y3)).tolist()
self._line.set_data(x, y)
# PlotTotSedCAdisTS.py -- Pamhyr
# Copyright (C) 2023-2024 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 datetime import datetime
import numpy as np
from tools import timer, trace
from View.Tools.PamhyrPlot import PamhyrPlot
from PyQt5.QtCore import (
QCoreApplication
)
_translate = QCoreApplication.translate
logger = logging.getLogger()
class PlotTotSedC(PamhyrPlot):
def __init__(self, canvas=None, trad=None, toolbar=None,
results=None, reach_id=0, profile_id=0, pol_id=0,
parent=None):
super(PlotTotSedC, self).__init__(
canvas=canvas,
trad=trad,
data=results,
toolbar=toolbar,
parent=parent
)
self._mode = "time"
self._current_timestamp = max(results.get("timestamps"))
self._current_reach_id = reach_id
self._current_profile_id = profile_id
self._current_pol_id = pol_id
self.label_x = _translate("Results", "Time (s)")
self.label_y = _translate("Results", "Discharge (m³/s)")
self.label_discharge = _translate("Results", "Cross-section discharge")
self.label_discharge_max = _translate("Results", "Max discharge")
self.label_timestamp = _translate("Results", "Current timestamp")
self._isometric_axis = False
self._auto_relim_update = False
self._autoscale_update = False
@property
def results(self):
return self.data
@results.setter
def results(self, results):
self.data = results
self._current_timestamp = max(results.get("timestamps"))
@timer
def draw(self, highlight=None):
self.init_axes()
if self.results is None:
return
reach = self.results.river.reach(self._current_reach_id)
profile = reach.profile(self._current_profile_id)
pollutant = self._current_pol_id
if reach.geometry.number_profiles == 0:
self._init = False
return
self.draw_data(reach, profile, pollutant)
self.set_ticks_time_formater()
self.enable_legend()
self.idle()
self._init = True
def draw_data(self, reach, profile, pollutant):
self.ts = list(self.results.get("timestamps"))
self.ts.sort()
x = self.ts
#y = profile.get_key("Q")
#First 0 for pol and second 0 for phys var
y = list(map(lambda data_el: data_el[pollutant][0], profile.get_key("pols")))
print("Total Sed C************//////////////////")
print("profile: ", self._current_profile_id)
print("reach: ", self._current_reach_id)
print("pollutant: ", pollutant)
###print("*****************draw data: ", len(x),len(y))
###print("x: ", x)
###print("y: ", y)
###print("reach: ", reach)
###print("profile: ", profile)
###print("pollutant: ", pollutant)
self._line, = self.canvas.axes.plot(
x, y,
label=self.label_discharge,
color=self.color_plot,
**self.plot_default_kargs
)
def set_reach(self, reach_id):
self._current_reach_id = reach_id
self._current_profile_id = 0
self.draw()
def set_profile(self, profile_id):
self._current_profile_id = profile_id
self.update()
def set_timestamp(self, timestamp):
self._current_timestamp = timestamp
self.update()
def update(self):
if not self._init:
self.draw()
self.update_data()
self.update_idle()
def update_data(self):
reach = self.results.river.reach(self._current_reach_id)
profile = reach.profile(self._current_profile_id)
pollutant = self._current_pol_id
x = self.ts
#y = profile.get_key("Q")
y = list(map(lambda data_el: data_el[pollutant][0], profile.get_key("pols")))
self._line.set_data(x, y)
......@@ -48,6 +48,7 @@ from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
from View.Results.PlotCAdisTS import PlotC
from View.Results.PlotMAdisTS import PlotM
from View.Results.PlotTotSedCAdisTS import PlotTotSedC
from View.Results.CustomPlot.Plot import CustomPlot
from View.Results.CustomPlot.CustomPlotValuesSelectionDialog import (
......@@ -184,6 +185,30 @@ class ResultsWindowAdisTS(PamhyrWindow):
)
self.plot_m.draw()
self.canvas_2 = MplCanvas(width=5, height=4, dpi=100)
self.canvas_2.setObjectName("canvas_2")
self.toolbar_2 = PamhyrPlotToolbar(
self.canvas_2, self, items=[
"home", "move", "zoom", "save",
"iso", "back/forward"
]
)
self.plot_layout_2 = self.find(
QVBoxLayout, "verticalLayout_tot_c")
self.plot_layout_2.addWidget(self.toolbar_2)
self.plot_layout_2.addWidget(self.canvas_2)
self.plot_tot_c = PlotTotSedC(
canvas=self.canvas_2,
results=self._results,
reach_id=0,
profile_id=0,
pol_id=self._results.pollutants_list.index("total_sediment"),
trad=self._trad,
toolbar=self.toolbar_2
)
self.plot_tot_c.draw()
def closeEvent(self, event):
try:
self._timer.stop()
......@@ -312,6 +337,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
if reach_id is not None:
self.plot_c.set_reach(reach_id)
self.plot_m.set_reach(reach_id)
self.plot_tot_c.set_reach(reach_id)
self.update_table_selection_reach(reach_id)
self.update_table_selection_profile(0)
......@@ -320,6 +346,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
if profile_id is not None:
self.plot_c.set_profile(profile_id)
self.plot_m.set_profile(profile_id)
self.plot_tot_c.set_profile(profile_id)
self.update_table_selection_profile(profile_id)
......@@ -335,6 +362,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
if timestamp is not None:
self.plot_c.set_timestamp(timestamp)
self.plot_m.set_timestamp(timestamp)
self.plot_tot_c.set_timestamp(timestamp)
self._table["raw_data"].timestamp = timestamp
......@@ -389,9 +417,11 @@ class ResultsWindowAdisTS(PamhyrWindow):
def _reload_plots(self):
self.plot_c.results = self._results
self.plot_m.results = self._results
self.plot_tot_c.results = self._results
self.plot_c.draw()
self.plot_m.draw()
self.plot_tot_c.draw()
def _reload_slider(self):
self._slider_time = self.find(QSlider, f"horizontalSlider_time")
......
......@@ -49,6 +49,9 @@
<item>
<widget class="QTableView" name="tableView_phys_var"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_tot_left"/>
</item>
</layout>
</widget>
</widget>
......@@ -60,7 +63,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>3</number>
</property>
<widget class="QWidget" name="tab_4">
<attribute name="title">
......@@ -105,7 +108,55 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_total"/>
<layout class="QVBoxLayout" name="verticalLayout_total">
<item>
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Concentration</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_tot_c"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_6">
<attribute name="title">
<string>Left thickness</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_tot_left_2"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_7">
<attribute name="title">
<string>Minor thickness</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_tot_minor"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_8">
<attribute name="title">
<string>Right thickness</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_tot_right"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment