mirror of https://gitlab.com/pamhyr/pamhyr2
cleaning
parent
f1d6eb8990
commit
b38e252746
|
|
@ -176,7 +176,8 @@ class TableModel(PamhyrTableModel):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif self._headers[column] == "pol":
|
elif self._headers[column] == "pol":
|
||||||
pol = next(filter(lambda x: x.name == value, self._data._Pollutants.Pollutants_List))
|
pol = next(filter(lambda x: x.name == value,
|
||||||
|
self._data._Pollutants.Pollutants_List))
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetPolCommand(
|
SetPolCommand(
|
||||||
self._lst, row, pol.id
|
self._lst, row, pol.id
|
||||||
|
|
|
||||||
|
|
@ -952,4 +952,3 @@ class CustomPlot(PamhyrPlot):
|
||||||
x = self._timestamp
|
x = self._timestamp
|
||||||
self._current.set_data([x, x], self.canvas.axes.get_ylim())
|
self._current.set_data([x, x], self.canvas.axes.get_ylim())
|
||||||
self.canvas.draw_idle()
|
self.canvas.draw_idle()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,162 +0,0 @@
|
||||||
# PlotCAdisTS.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
|
|
||||||
|
|
||||||
from tools import timer, trace
|
|
||||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
|
||||||
QCoreApplication
|
|
||||||
)
|
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
|
||||||
|
|
||||||
logger = logging.getLogger()
|
|
||||||
|
|
||||||
|
|
||||||
class PlotC(PamhyrPlot):
|
|
||||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
|
||||||
results=None, reach_id=0, profile_id=0, pol_id=0,
|
|
||||||
parent=None):
|
|
||||||
super(PlotC, 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("************//////////////////")
|
|
||||||
###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_pollutant(self, pol_id):
|
|
||||||
self._current_pol_id = pol_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)
|
|
||||||
|
|
@ -1,173 +0,0 @@
|
||||||
# PlotMAdisTS.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 PlotM(PamhyrPlot):
|
|
||||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
|
||||||
results=None, reach_id=0, profile_id=0, pol_id=0,
|
|
||||||
parent=None):
|
|
||||||
super(PlotM, 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
|
|
||||||
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()
|
|
||||||
|
|
||||||
###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)
|
|
||||||
###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_pollutant(self, pol_id):
|
|
||||||
self._current_pol_id = pol_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")
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
@ -115,7 +115,9 @@ class PlotAdis_dt(PamhyrPlot):
|
||||||
if self.val_id[self._key] > 0 and self._type_pol == 1:
|
if self.val_id[self._key] > 0 and self._type_pol == 1:
|
||||||
y = [0.0]*len(x)
|
y = [0.0]*len(x)
|
||||||
else:
|
else:
|
||||||
y = list(map(lambda data_el: data_el[self._current_pol_id][self.val_id[self._key]],
|
val_id = self.val_id[self._key]
|
||||||
|
y = list(map(lambda data_el:
|
||||||
|
data_el[self._current_pol_id][val_id],
|
||||||
profile.get_key("pols")
|
profile.get_key("pols")
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
@ -144,9 +146,12 @@ class PlotAdis_dt(PamhyrPlot):
|
||||||
y = [0.0]*len(x)
|
y = [0.0]*len(x)
|
||||||
else:
|
else:
|
||||||
y = []
|
y = []
|
||||||
|
val_id = self.val_id[self._key]
|
||||||
for ts in x:
|
for ts in x:
|
||||||
ts_y = list(map(
|
ts_y = list(map(lambda p:
|
||||||
lambda p: p.get_ts_key(ts, "pols")[self._current_pol_id][self.val_id[self._key]],
|
p.get_ts_key(
|
||||||
|
ts, "pols"
|
||||||
|
)[self._current_pol_id][val_id],
|
||||||
reach.profiles))
|
reach.profiles))
|
||||||
y.append(np.max(ts_y))
|
y.append(np.max(ts_y))
|
||||||
|
|
||||||
|
|
@ -191,9 +196,12 @@ class PlotAdis_dt(PamhyrPlot):
|
||||||
y = [0.0]*len(x)
|
y = [0.0]*len(x)
|
||||||
else:
|
else:
|
||||||
y = []
|
y = []
|
||||||
|
val_id = self.val_id[self._key]
|
||||||
for ts in x:
|
for ts in x:
|
||||||
ts_y = list(map(
|
ts_y = list(map(lambda p:
|
||||||
lambda p: p.get_ts_key(ts, "pols")[self._current_pol_id][self.val_id[self._key]],
|
p.get_ts_key(
|
||||||
|
ts, "pols"
|
||||||
|
)[self._current_pol_id][val_id],
|
||||||
reach.profiles))
|
reach.profiles))
|
||||||
y.append(np.max(ts_y))
|
y.append(np.max(ts_y))
|
||||||
|
|
||||||
|
|
@ -207,7 +215,8 @@ class PlotAdis_dt(PamhyrPlot):
|
||||||
if self.val_id[self._key] > 0 and self._type_pol == 1:
|
if self.val_id[self._key] > 0 and self._type_pol == 1:
|
||||||
y = [0.0]*len(x)
|
y = [0.0]*len(x)
|
||||||
else:
|
else:
|
||||||
y = list(map(lambda data_el: data_el[self._current_pol_id][self.val_id[self._key]],
|
y = list(map(lambda data_el:
|
||||||
|
data_el[self._current_pol_id][self.val_id[self._key]],
|
||||||
profile.get_key("pols")
|
profile.get_key("pols")
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@ class PlotAdis_dx(PamhyrPlot):
|
||||||
self.val_id["M"] = 2
|
self.val_id["M"] = 2
|
||||||
self.val_id["D"] = 3
|
self.val_id["D"] = 3
|
||||||
|
|
||||||
|
|
||||||
self._isometric_axis = False
|
self._isometric_axis = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -153,10 +152,11 @@ class PlotAdis_dx(PamhyrPlot):
|
||||||
if self.val_id[self._key] > 0 and self._type_pol == 1:
|
if self.val_id[self._key] > 0 and self._type_pol == 1:
|
||||||
y = [0.0]*len(x)
|
y = [0.0]*len(x)
|
||||||
else:
|
else:
|
||||||
y = list(map(
|
y = list(map(lambda p:
|
||||||
lambda p: p.get_ts_key(self._current_timestamp, "pols")[self._current_pol_id][self.val_id[self._key]],
|
p.get_ts_key(
|
||||||
reach.profiles
|
self._current_timestamp, "pols"
|
||||||
))
|
)[self._current_pol_id][self.val_id[self._key]],
|
||||||
|
reach.profiles))
|
||||||
|
|
||||||
self._line, = self.canvas.axes.plot(
|
self._line, = self.canvas.axes.plot(
|
||||||
x, y,
|
x, y,
|
||||||
|
|
@ -187,8 +187,10 @@ class PlotAdis_dx(PamhyrPlot):
|
||||||
else:
|
else:
|
||||||
y = []
|
y = []
|
||||||
z = []
|
z = []
|
||||||
|
val_id = self.val_id[self._key]
|
||||||
for p in reach.profiles:
|
for p in reach.profiles:
|
||||||
rk_y = list(map(lambda data_el: data_el[self._current_pol_id][self.val_id[self._key]],
|
rk_y = list(map(lambda data_el:
|
||||||
|
data_el[self._current_pol_id][val_id],
|
||||||
p.get_key("pols")
|
p.get_key("pols")
|
||||||
))
|
))
|
||||||
y.append(np.max(rk_y))
|
y.append(np.max(rk_y))
|
||||||
|
|
@ -245,8 +247,10 @@ class PlotAdis_dx(PamhyrPlot):
|
||||||
else:
|
else:
|
||||||
y = []
|
y = []
|
||||||
z = []
|
z = []
|
||||||
|
val_id = self.val_id[self._key]
|
||||||
for p in reach.profiles:
|
for p in reach.profiles:
|
||||||
rk_y = list(map(lambda data_el: data_el[self._current_pol_id][self.val_id[self._key]],
|
rk_y = list(map(lambda data_el:
|
||||||
|
data_el[self._current_pol_id][val_id],
|
||||||
p.get_key("pols")
|
p.get_key("pols")
|
||||||
))
|
))
|
||||||
y.append(np.max(rk_y))
|
y.append(np.max(rk_y))
|
||||||
|
|
@ -265,9 +269,10 @@ class PlotAdis_dx(PamhyrPlot):
|
||||||
y = [0.0]*len(x)
|
y = [0.0]*len(x)
|
||||||
else:
|
else:
|
||||||
y = list(map(
|
y = list(map(
|
||||||
lambda p: p.get_ts_key(self._current_timestamp, "pols")[self._current_pol_id][self.val_id[self._key]],
|
lambda p: p.get_ts_key(
|
||||||
reach.profiles
|
self._current_timestamp, "pols"
|
||||||
))
|
)[self._current_pol_id][self.val_id[self._key]],
|
||||||
|
reach.profiles))
|
||||||
|
|
||||||
self._line.set_data(x, y)
|
self._line.set_data(x, y)
|
||||||
|
|
||||||
|
|
@ -307,14 +312,12 @@ class PlotAdis_dx(PamhyrPlot):
|
||||||
if self.val_id[self._key] > 0 and self._type_pol == 1:
|
if self.val_id[self._key] > 0 and self._type_pol == 1:
|
||||||
y = [0.0]
|
y = [0.0]
|
||||||
else:
|
else:
|
||||||
|
val_id = self.val_id[self._key]
|
||||||
y = list(
|
y = list(
|
||||||
map(lambda p:
|
map(lambda p:
|
||||||
list(map(lambda data_el: data_el[self._current_pol_id][self.val_id[self._key]],
|
list(map(lambda data_el:
|
||||||
p.get_key("pols"))
|
data_el[self._current_pol_id][val_id],
|
||||||
),
|
p.get_key("pols"))), reach.profiles))
|
||||||
reach.profiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
self.y_max = np.max(y)
|
self.y_max = np.max(y)
|
||||||
self.y_min = np.min(y)
|
self.y_min = np.min(y)
|
||||||
|
|
|
||||||
|
|
@ -1,160 +0,0 @@
|
||||||
# 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)
|
|
||||||
|
|
@ -1,160 +0,0 @@
|
||||||
# PlotTotSedEDAdisTS.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 PlotTotSedED(PamhyrPlot):
|
|
||||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
|
||||||
results=None, reach_id=0, profile_id=0, pol_id=0,
|
|
||||||
parent=None):
|
|
||||||
super(PlotTotSedED, 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][3], profile.get_key("pols")))
|
|
||||||
|
|
||||||
print("Total Sed ED ************//////////////////")
|
|
||||||
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][3], profile.get_key("pols")))
|
|
||||||
|
|
||||||
self._line.set_data(x, y)
|
|
||||||
|
|
@ -1,160 +0,0 @@
|
||||||
# PlotTotSedEGAdisTS.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 PlotTotSedEG(PamhyrPlot):
|
|
||||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
|
||||||
results=None, reach_id=0, profile_id=0, pol_id=0,
|
|
||||||
parent=None):
|
|
||||||
super(PlotTotSedEG, 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][1], profile.get_key("pols")))
|
|
||||||
|
|
||||||
print("Total Sed EG ************//////////////////")
|
|
||||||
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][1], profile.get_key("pols")))
|
|
||||||
|
|
||||||
self._line.set_data(x, y)
|
|
||||||
|
|
@ -1,160 +0,0 @@
|
||||||
# PlotTotSedEMAdisTS.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 PlotTotSedEM(PamhyrPlot):
|
|
||||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
|
||||||
results=None, reach_id=0, profile_id=0, pol_id=0,
|
|
||||||
parent=None):
|
|
||||||
super(PlotTotSedEM, 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][2], profile.get_key("pols")))
|
|
||||||
|
|
||||||
print("Total Sed EM ************//////////////////")
|
|
||||||
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][2], profile.get_key("pols")))
|
|
||||||
|
|
||||||
self._line.set_data(x, y)
|
|
||||||
|
|
@ -45,29 +45,20 @@ _translate = QCoreApplication.translate
|
||||||
class TableModel(PamhyrTableModel):
|
class TableModel(PamhyrTableModel):
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
_river = self._data.river
|
_river = self._data.river
|
||||||
###print("//////////////////opt_data: ", self._opt_data)
|
|
||||||
###print("data: ", self._data)
|
|
||||||
###print("river: ", _river)
|
|
||||||
###print("reaches: ", _river.reachs)
|
|
||||||
if self._opt_data == "reach":
|
if self._opt_data == "reach":
|
||||||
self._lst = _river.reachs
|
self._lst = _river.reachs
|
||||||
###print("optreach: ", self._lst)
|
|
||||||
elif self._opt_data == "profile":
|
elif self._opt_data == "profile":
|
||||||
self._lst = _river.reach(0).profiles
|
self._lst = _river.reach(0).profiles
|
||||||
elif self._opt_data == "raw_data":
|
elif self._opt_data == "raw_data":
|
||||||
self._lst = _river.reach(0).profiles
|
self._lst = _river.reach(0).profiles
|
||||||
elif self._opt_data == "pollutants":
|
elif self._opt_data == "pollutants":
|
||||||
tmp_list = self._data.pollutants_list.copy()
|
tmp_list = self._data.pollutants_list.copy()
|
||||||
###print(type(tmp_list))
|
|
||||||
tmp_list.remove("total_sediment")
|
tmp_list.remove("total_sediment")
|
||||||
#tmp_list.insert(len(tmp_list), "total_sediment")
|
|
||||||
self._lst = tmp_list
|
self._lst = tmp_list
|
||||||
###print("=====table pollutants: ", self._lst)
|
|
||||||
|
|
||||||
def __init__(self, type_pol, **kwargs):
|
def __init__(self, type_pol, **kwargs):
|
||||||
self._timestamp = 0.0
|
self._timestamp = 0.0
|
||||||
self._type_pol = type_pol
|
self._type_pol = type_pol
|
||||||
print("typ pol from raw data: ", self._type_pol)
|
|
||||||
super(TableModel, self).__init__(**kwargs)
|
super(TableModel, self).__init__(**kwargs)
|
||||||
|
|
||||||
def data(self, index, role=Qt.DisplayRole):
|
def data(self, index, role=Qt.DisplayRole):
|
||||||
|
|
@ -105,12 +96,17 @@ class TableModel(PamhyrTableModel):
|
||||||
pol_index = tmp_list2.index(pol)
|
pol_index = tmp_list2.index(pol)
|
||||||
header_name = pol + " Concentration"
|
header_name = pol + " Concentration"
|
||||||
if self._headers[column] == header_name:
|
if self._headers[column] == header_name:
|
||||||
v = self._lst[row].get_ts_key(self._timestamp, "pols")[pol_index][0]
|
v = self._lst[row].get_ts_key(
|
||||||
|
self._timestamp, "pols")[pol_index][0]
|
||||||
return f"{v:.4f}"
|
return f"{v:.4f}"
|
||||||
if self._headers[column] == pol + " Mass" and self._type_pol[pol_index]==7:
|
if (self._headers[column] == pol + " Mass"
|
||||||
m1 = self._lst[row].get_ts_key(self._timestamp, "pols")[pol_index][1]
|
and self._type_pol[pol_index] == 7):
|
||||||
m2 = self._lst[row].get_ts_key(self._timestamp, "pols")[pol_index][2]
|
m1 = self._lst[row].get_ts_key(
|
||||||
m3 = self._lst[row].get_ts_key(self._timestamp, "pols")[pol_index][3]
|
self._timestamp, "pols")[pol_index][1]
|
||||||
|
m2 = self._lst[row].get_ts_key(
|
||||||
|
self._timestamp, "pols")[pol_index][2]
|
||||||
|
m3 = self._lst[row].get_ts_key(
|
||||||
|
self._timestamp, "pols")[pol_index][3]
|
||||||
v = m1 + m2 + m3
|
v = m1 + m2 + m3
|
||||||
return f"{v:.4f}"
|
return f"{v:.4f}"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,14 +46,8 @@ from PyQt5.QtWidgets import (
|
||||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||||
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||||
|
|
||||||
from View.Results.PlotCAdisTS import PlotC
|
|
||||||
from View.Results.PlotMAdisTS import PlotM
|
|
||||||
from View.Results.PlotSedAdisDt import PlotAdis_dt
|
from View.Results.PlotSedAdisDt import PlotAdis_dt
|
||||||
from View.Results.PlotSedAdisDx import PlotAdis_dx
|
from View.Results.PlotSedAdisDx import PlotAdis_dx
|
||||||
from View.Results.PlotTotSedCAdisTS import PlotTotSedC
|
|
||||||
from View.Results.PlotTotSedEGAdisTS import PlotTotSedEG
|
|
||||||
from View.Results.PlotTotSedEMAdisTS import PlotTotSedEM
|
|
||||||
from View.Results.PlotTotSedEDAdisTS import PlotTotSedED
|
|
||||||
|
|
||||||
from View.Results.CustomPlot.Plot import CustomPlot
|
from View.Results.CustomPlot.Plot import CustomPlot
|
||||||
from View.Results.CustomPlot.CustomPlotValuesSelectionDialog import (
|
from View.Results.CustomPlot.CustomPlotValuesSelectionDialog import (
|
||||||
|
|
@ -111,7 +105,6 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||||
self._reach_id = 0
|
self._reach_id = 0
|
||||||
self._profile_id = 0
|
self._profile_id = 0
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._timestamps = sorted(list(self._results.get("timestamps")))
|
self._timestamps = sorted(list(self._results.get("timestamps")))
|
||||||
self.set_type_pol()
|
self.set_type_pol()
|
||||||
|
|
@ -187,8 +180,6 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||||
)
|
)
|
||||||
self.plot_layout_cdt = self.find(
|
self.plot_layout_cdt = self.find(
|
||||||
QVBoxLayout, "verticalLayout_concentration_dt")
|
QVBoxLayout, "verticalLayout_concentration_dt")
|
||||||
#self.plot_layout_cdt = self.find(
|
|
||||||
#QVBoxLayout, "verticalLayout_cdt")
|
|
||||||
self.plot_layout_cdt.addWidget(self.toolbar_cdt)
|
self.plot_layout_cdt.addWidget(self.toolbar_cdt)
|
||||||
self.plot_layout_cdt.addWidget(self.canvas_cdt)
|
self.plot_layout_cdt.addWidget(self.canvas_cdt)
|
||||||
|
|
||||||
|
|
@ -215,8 +206,6 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||||
)
|
)
|
||||||
self.plot_layout_cdx = self.find(
|
self.plot_layout_cdx = self.find(
|
||||||
QVBoxLayout, "verticalLayout_concentration_dx")
|
QVBoxLayout, "verticalLayout_concentration_dx")
|
||||||
#self.plot_layout_cdx = self.find(
|
|
||||||
#QVBoxLayout, "verticalLayout_cdx")
|
|
||||||
self.plot_layout_cdx.addWidget(self.toolbar_cdx)
|
self.plot_layout_cdx.addWidget(self.toolbar_cdx)
|
||||||
self.plot_layout_cdx.addWidget(self.canvas_cdx)
|
self.plot_layout_cdx.addWidget(self.canvas_cdx)
|
||||||
|
|
||||||
|
|
@ -408,7 +397,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||||
# Action
|
# Action
|
||||||
actions = {
|
actions = {
|
||||||
"action_reload": self._reload,
|
"action_reload": self._reload,
|
||||||
###"action_add": self._add_custom_plot,
|
# TODO "action_add": self._add_custom_plot,
|
||||||
"action_export": self.export,
|
"action_export": self.export,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -425,7 +414,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||||
"raw_data": self._set_current_profile_raw_data,
|
"raw_data": self._set_current_profile_raw_data,
|
||||||
}
|
}
|
||||||
|
|
||||||
for t in ["reach", "profile", "pollutants"]:###, "raw_data"]:
|
for t in ["reach", "profile", "pollutants"]:
|
||||||
table = self.find(QTableView, f"tableView_{t}")
|
table = self.find(QTableView, f"tableView_{t}")
|
||||||
|
|
||||||
table.selectionModel()\
|
table.selectionModel()\
|
||||||
|
|
@ -460,7 +449,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||||
self._table["raw_data"].update(ind)
|
self._table["raw_data"].update(ind)
|
||||||
|
|
||||||
def update_table_selection_profile(self, ind):
|
def update_table_selection_profile(self, ind):
|
||||||
for t in ["profile"]:###, "raw_data"]:
|
for t in ["profile"]:
|
||||||
table = self.find(QTableView, f"tableView_{t}")
|
table = self.find(QTableView, f"tableView_{t}")
|
||||||
selectionModel = table.selectionModel()
|
selectionModel = table.selectionModel()
|
||||||
index = table.model().index(ind, 0)
|
index = table.model().index(ind, 0)
|
||||||
|
|
@ -474,7 +463,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||||
table.scrollTo(index)
|
table.scrollTo(index)
|
||||||
|
|
||||||
def update_table_selection_pol(self, ind):
|
def update_table_selection_pol(self, ind):
|
||||||
for t in ["pollutants"]:###, "raw_data"]:
|
for t in ["pollutants"]:
|
||||||
table = self.find(QTableView, f"tableView_{t}")
|
table = self.find(QTableView, f"tableView_{t}")
|
||||||
selectionModel = table.selectionModel()
|
selectionModel = table.selectionModel()
|
||||||
index = table.model().index(ind, 0)
|
index = table.model().index(ind, 0)
|
||||||
|
|
@ -487,7 +476,8 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
||||||
)
|
)
|
||||||
table.scrollTo(index)
|
table.scrollTo(index)
|
||||||
|
|
||||||
def update(self, reach_id=None, profile_id=None, pol_id=None, timestamp=None):
|
def update(self, reach_id=None, profile_id=None,
|
||||||
|
pol_id=None, timestamp=None):
|
||||||
if reach_id is not None:
|
if reach_id is not None:
|
||||||
self.plot_cdt.set_reach(reach_id)
|
self.plot_cdt.set_reach(reach_id)
|
||||||
self.plot_cdx.set_reach(reach_id)
|
self.plot_cdx.set_reach(reach_id)
|
||||||
|
|
|
||||||
|
|
@ -102,9 +102,10 @@ class ResultsTranslate(MainTranslate):
|
||||||
self._sub_dict["table_headers_raw_data"] = {
|
self._sub_dict["table_headers_raw_data"] = {
|
||||||
"name": _translate("Results", "Profile"),
|
"name": _translate("Results", "Profile"),
|
||||||
}
|
}
|
||||||
for i, pol in enumerate(self.pollutants):
|
tmp = self._sub_dict["table_headers_raw_data"]
|
||||||
self._sub_dict["table_headers_raw_data"][pol + " Concentration"] = pol + "\n Concentration"
|
for pol in self.pollutants:
|
||||||
self._sub_dict["table_headers_raw_data"][pol + " Mass"] = pol + "\n Mass"
|
tmp[pol + " Concentration"] = pol + "\n Concentration"
|
||||||
|
tmp[pol + " Mass"] = pol + "\n Mass"
|
||||||
else:
|
else:
|
||||||
self._sub_dict["table_headers_raw_data"] = {
|
self._sub_dict["table_headers_raw_data"] = {
|
||||||
"name": _translate("Results", "Profile"),
|
"name": _translate("Results", "Profile"),
|
||||||
|
|
@ -131,4 +132,3 @@ class ResultsTranslate(MainTranslate):
|
||||||
"unit_M": self._dict["unit_mass"],
|
"unit_M": self._dict["unit_mass"],
|
||||||
"unit_thickness": self._dict["unit_thickness"],
|
"unit_thickness": self._dict["unit_thickness"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,9 @@ class UnitTranslate(CommonWordTranslate):
|
||||||
)
|
)
|
||||||
self._dict["unit_froude"] = _translate("Unit", "Froude number")
|
self._dict["unit_froude"] = _translate("Unit", "Froude number")
|
||||||
self._dict["unit_mass"] = _translate("Unit", "Mass (kg)")
|
self._dict["unit_mass"] = _translate("Unit", "Mass (kg)")
|
||||||
self._dict["unit_concentration"] = _translate("Unit", "Concentration (kg/m^3)")
|
self._dict["unit_concentration"] = _translate(
|
||||||
|
"Unit", "Concentration (kg/m^3)"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MainTranslate(UnitTranslate):
|
class MainTranslate(UnitTranslate):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue