diff --git a/src/View/BoundaryConditionsAdisTS/Table.py b/src/View/BoundaryConditionsAdisTS/Table.py index f4c1dd30..b0676a67 100644 --- a/src/View/BoundaryConditionsAdisTS/Table.py +++ b/src/View/BoundaryConditionsAdisTS/Table.py @@ -176,7 +176,8 @@ class TableModel(PamhyrTableModel): ) ) 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( SetPolCommand( self._lst, row, pol.id diff --git a/src/View/Results/CustomPlot/Plot.py b/src/View/Results/CustomPlot/Plot.py index 4770fc7d..0d77df14 100644 --- a/src/View/Results/CustomPlot/Plot.py +++ b/src/View/Results/CustomPlot/Plot.py @@ -161,7 +161,7 @@ class CustomPlot(PamhyrPlot): sl, z ), ts_z_bedrock, # Bedrock elevations - asarray(sl)[:,0,:,0] # Sediment layers + asarray(sl)[:, 0, :, 0] # Sediment layers ) ) return ts_z_min @@ -952,4 +952,3 @@ class CustomPlot(PamhyrPlot): x = self._timestamp self._current.set_data([x, x], self.canvas.axes.get_ylim()) self.canvas.draw_idle() - diff --git a/src/View/Results/PlotCAdisTS.py b/src/View/Results/PlotCAdisTS.py deleted file mode 100644 index 60c3ed68..00000000 --- a/src/View/Results/PlotCAdisTS.py +++ /dev/null @@ -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 . - -# -*- 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) diff --git a/src/View/Results/PlotMAdisTS.py b/src/View/Results/PlotMAdisTS.py deleted file mode 100644 index 7b439cb6..00000000 --- a/src/View/Results/PlotMAdisTS.py +++ /dev/null @@ -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 . - -# -*- 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) diff --git a/src/View/Results/PlotSedAdisDt.py b/src/View/Results/PlotSedAdisDt.py index 86265b2b..0c0ed5a2 100644 --- a/src/View/Results/PlotSedAdisDt.py +++ b/src/View/Results/PlotSedAdisDt.py @@ -113,11 +113,13 @@ class PlotAdis_dt(PamhyrPlot): x = self.ts if self.val_id[self._key] > 0 and self._type_pol == 1: - y=[0.0]*len(x) + y = [0.0]*len(x) else: - y = list(map(lambda data_el: data_el[self._current_pol_id][self.val_id[self._key]], - profile.get_key("pols") - )) + 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") + )) self._line, = self.canvas.axes.plot( x, y, @@ -141,13 +143,16 @@ class PlotAdis_dt(PamhyrPlot): x = self.ts if self.val_id[self._key] > 0 and self._type_pol == 1: - y=[0.0]*len(x) + y = [0.0]*len(x) else: y = [] + val_id = self.val_id[self._key] for ts in x: - ts_y = list(map( - lambda p: p.get_ts_key(ts, "pols")[self._current_pol_id][self.val_id[self._key]], - reach.profiles)) + ts_y = list(map(lambda p: + p.get_ts_key( + ts, "pols" + )[self._current_pol_id][val_id], + reach.profiles)) y.append(np.max(ts_y)) self._line_max, = self.canvas.axes.plot( @@ -188,13 +193,16 @@ class PlotAdis_dt(PamhyrPlot): x = self.ts if self.val_id[self._key] > 0 and self._type_pol == 1: - y=[0.0]*len(x) + y = [0.0]*len(x) else: y = [] + val_id = self.val_id[self._key] for ts in x: - ts_y = list(map( - lambda p: p.get_ts_key(ts, "pols")[self._current_pol_id][self.val_id[self._key]], - reach.profiles)) + ts_y = list(map(lambda p: + p.get_ts_key( + ts, "pols" + )[self._current_pol_id][val_id], + reach.profiles)) y.append(np.max(ts_y)) self._line_max.set_data(x, y) @@ -205,11 +213,12 @@ class PlotAdis_dt(PamhyrPlot): x = self.ts if self.val_id[self._key] > 0 and self._type_pol == 1: - y=[0.0]*len(x) + y = [0.0]*len(x) else: - y = list(map(lambda data_el: data_el[self._current_pol_id][self.val_id[self._key]], - profile.get_key("pols") - )) + y = list(map(lambda data_el: + data_el[self._current_pol_id][self.val_id[self._key]], + profile.get_key("pols") + )) self._line.set_data(x, y) diff --git a/src/View/Results/PlotSedAdisDx.py b/src/View/Results/PlotSedAdisDx.py index c831aa74..eeee2e89 100644 --- a/src/View/Results/PlotSedAdisDx.py +++ b/src/View/Results/PlotSedAdisDx.py @@ -62,7 +62,7 @@ class PlotAdis_dx(PamhyrPlot): self.label["C"] = _translate("Results", "Concentration") self.label_max["C"] = _translate("Results", "Max Concentration") self.label_min["C"] = _translate("Results", "Min Concentration") - if self._type_pol == -1: # Total + if self._type_pol == -1: # Total self.label["M"] = _translate("Results", "Thickness") self.label_max["M"] = _translate("Results", "Max Thickness") self.label_min["M"] = _translate("Results", "Min Thickness") @@ -78,7 +78,6 @@ class PlotAdis_dx(PamhyrPlot): self.val_id["M"] = 2 self.val_id["D"] = 3 - self._isometric_axis = False @property @@ -151,12 +150,13 @@ class PlotAdis_dx(PamhyrPlot): x = reach.geometry.get_rk() if self.val_id[self._key] > 0 and self._type_pol == 1: - y=[0.0]*len(x) + y = [0.0]*len(x) else: - y = list(map( - lambda p: p.get_ts_key(self._current_timestamp, "pols")[self._current_pol_id][self.val_id[self._key]], - reach.profiles - )) + y = list(map(lambda p: + p.get_ts_key( + self._current_timestamp, "pols" + )[self._current_pol_id][self.val_id[self._key]], + reach.profiles)) self._line, = self.canvas.axes.plot( x, y, @@ -183,14 +183,16 @@ class PlotAdis_dx(PamhyrPlot): x = reach.geometry.get_rk() if self.val_id[self._key] > 0 and self._type_pol == 1: - y=[0.0]*len(x) + y = [0.0]*len(x) else: y = [] z = [] + val_id = self.val_id[self._key] for p in reach.profiles: - rk_y = list(map(lambda data_el: data_el[self._current_pol_id][self.val_id[self._key]], - p.get_key("pols") - )) + rk_y = list(map(lambda data_el: + data_el[self._current_pol_id][val_id], + p.get_key("pols") + )) y.append(np.max(rk_y)) z.append(np.min(rk_y)) @@ -241,14 +243,16 @@ class PlotAdis_dx(PamhyrPlot): x = reach.geometry.get_rk() if self.val_id[self._key] > 0 and self._type_pol == 1: - y=[0.0]*len(x) + y = [0.0]*len(x) else: y = [] z = [] + val_id = self.val_id[self._key] for p in reach.profiles: - rk_y = list(map(lambda data_el: data_el[self._current_pol_id][self.val_id[self._key]], - p.get_key("pols") - )) + rk_y = list(map(lambda data_el: + data_el[self._current_pol_id][val_id], + p.get_key("pols") + )) y.append(np.max(rk_y)) z.append(np.min(rk_y)) @@ -262,12 +266,13 @@ class PlotAdis_dx(PamhyrPlot): x = reach.geometry.get_rk() if self.val_id[self._key] > 0 and self._type_pol == 1: - y=[0.0]*len(x) + y = [0.0]*len(x) else: y = list(map( - lambda p: p.get_ts_key(self._current_timestamp, "pols")[self._current_pol_id][self.val_id[self._key]], - reach.profiles - )) + lambda p: p.get_ts_key( + self._current_timestamp, "pols" + )[self._current_pol_id][self.val_id[self._key]], + reach.profiles)) self._line.set_data(x, y) @@ -305,16 +310,14 @@ class PlotAdis_dx(PamhyrPlot): reach = self.results.river.reach(self._current_reach_id) if self.val_id[self._key] > 0 and self._type_pol == 1: - y=[0.0] + y = [0.0] else: + val_id = self.val_id[self._key] y = list( map(lambda p: - list(map(lambda data_el: data_el[self._current_pol_id][self.val_id[self._key]], - p.get_key("pols")) - ), - reach.profiles - ) - ) + list(map(lambda data_el: + data_el[self._current_pol_id][val_id], + p.get_key("pols"))), reach.profiles)) self.y_max = np.max(y) self.y_min = np.min(y) diff --git a/src/View/Results/PlotTotSedCAdisTS.py b/src/View/Results/PlotTotSedCAdisTS.py deleted file mode 100644 index bcf00b08..00000000 --- a/src/View/Results/PlotTotSedCAdisTS.py +++ /dev/null @@ -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 . - -# -*- 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) diff --git a/src/View/Results/PlotTotSedEDAdisTS.py b/src/View/Results/PlotTotSedEDAdisTS.py deleted file mode 100644 index 007b5038..00000000 --- a/src/View/Results/PlotTotSedEDAdisTS.py +++ /dev/null @@ -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 . - -# -*- 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) diff --git a/src/View/Results/PlotTotSedEGAdisTS.py b/src/View/Results/PlotTotSedEGAdisTS.py deleted file mode 100644 index ba1f5a75..00000000 --- a/src/View/Results/PlotTotSedEGAdisTS.py +++ /dev/null @@ -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 . - -# -*- 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) diff --git a/src/View/Results/PlotTotSedEMAdisTS.py b/src/View/Results/PlotTotSedEMAdisTS.py deleted file mode 100644 index 36387d83..00000000 --- a/src/View/Results/PlotTotSedEMAdisTS.py +++ /dev/null @@ -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 . - -# -*- 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) diff --git a/src/View/Results/TableAdisTS.py b/src/View/Results/TableAdisTS.py index b2937362..f88ce179 100644 --- a/src/View/Results/TableAdisTS.py +++ b/src/View/Results/TableAdisTS.py @@ -45,29 +45,20 @@ _translate = QCoreApplication.translate class TableModel(PamhyrTableModel): def _setup_lst(self): _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": self._lst = _river.reachs - ###print("optreach: ", self._lst) elif self._opt_data == "profile": self._lst = _river.reach(0).profiles elif self._opt_data == "raw_data": self._lst = _river.reach(0).profiles elif self._opt_data == "pollutants": tmp_list = self._data.pollutants_list.copy() - ###print(type(tmp_list)) tmp_list.remove("total_sediment") - #tmp_list.insert(len(tmp_list), "total_sediment") self._lst = tmp_list - ###print("=====table pollutants: ", self._lst) def __init__(self, type_pol, **kwargs): self._timestamp = 0.0 self._type_pol = type_pol - print("typ pol from raw data: ", self._type_pol) super(TableModel, self).__init__(**kwargs) def data(self, index, role=Qt.DisplayRole): @@ -105,12 +96,17 @@ class TableModel(PamhyrTableModel): pol_index = tmp_list2.index(pol) header_name = pol + " Concentration" 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}" - if self._headers[column] == pol + " Mass" and self._type_pol[pol_index]==7: - m1 = self._lst[row].get_ts_key(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] + if (self._headers[column] == pol + " Mass" + and self._type_pol[pol_index] == 7): + m1 = self._lst[row].get_ts_key( + 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 return f"{v:.4f}" diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index c87c998e..0ddc87ef 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -685,7 +685,7 @@ class ResultsWindow(PamhyrWindow): my_dict[dict_x["rk"]] = reach.geometry.get_rk() if "bed_elevation" in y: my_dict[dict_y["bed_elevation"]] = reach.geometry.get_z_min() - #if envelop and reach.has_sediment(): + # if envelop and reach.has_sediment(): if "discharge" in y: my_dict[dict_y["discharge"]] = list( map( diff --git a/src/View/Results/WindowAdisTS.py b/src/View/Results/WindowAdisTS.py index 30fa5693..f72160a2 100644 --- a/src/View/Results/WindowAdisTS.py +++ b/src/View/Results/WindowAdisTS.py @@ -46,14 +46,8 @@ from PyQt5.QtWidgets import ( from View.Tools.Plot.PamhyrCanvas import MplCanvas 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.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.CustomPlotValuesSelectionDialog import ( @@ -111,7 +105,6 @@ class ResultsWindowAdisTS(PamhyrWindow): self._reach_id = 0 self._profile_id = 0 - try: self._timestamps = sorted(list(self._results.get("timestamps"))) self.set_type_pol() @@ -187,8 +180,6 @@ class ResultsWindowAdisTS(PamhyrWindow): ) self.plot_layout_cdt = self.find( 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.canvas_cdt) @@ -199,7 +190,7 @@ class ResultsWindowAdisTS(PamhyrWindow): profile_id=self._profile_id, pol_id=self._pol_id, key="C", - type_pol = self._type_pol[self._pol_id], + type_pol=self._type_pol[self._pol_id], trad=self._trad, toolbar=self.toolbar_cdt ) @@ -215,8 +206,6 @@ class ResultsWindowAdisTS(PamhyrWindow): ) self.plot_layout_cdx = self.find( 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.canvas_cdx) @@ -227,7 +216,7 @@ class ResultsWindowAdisTS(PamhyrWindow): profile_id=self._profile_id, pol_id=self._pol_id, key="C", - type_pol = self._type_pol[self._pol_id], + type_pol=self._type_pol[self._pol_id], trad=self._trad, toolbar=self.toolbar_cdx ) @@ -253,7 +242,7 @@ class ResultsWindowAdisTS(PamhyrWindow): profile_id=self._profile_id, pol_id=self._pol_id, key="M", - type_pol = self._type_pol[self._pol_id], + type_pol=self._type_pol[self._pol_id], trad=self._trad, toolbar=self.toolbar_mdx ) @@ -280,7 +269,7 @@ class ResultsWindowAdisTS(PamhyrWindow): profile_id=self._profile_id, pol_id=self._pol_id, key="M", - type_pol = self._type_pol[self._pol_id], + type_pol=self._type_pol[self._pol_id], trad=self._trad, toolbar=self.toolbar_mdt ) @@ -312,7 +301,7 @@ class ResultsWindowAdisTS(PamhyrWindow): profile_id=self._profile_id, pol_id=0, key="M", - type_pol = self._type_pol[0], + type_pol=self._type_pol[0], trad=self._trad, toolbar=self.toolbar_tdx ) @@ -339,7 +328,7 @@ class ResultsWindowAdisTS(PamhyrWindow): profile_id=self._profile_id, pol_id=0, key="M", - type_pol = self._type_pol[0], + type_pol=self._type_pol[0], trad=self._trad, toolbar=self.toolbar_tdt ) @@ -408,7 +397,7 @@ class ResultsWindowAdisTS(PamhyrWindow): # Action actions = { "action_reload": self._reload, - ###"action_add": self._add_custom_plot, + # TODO "action_add": self._add_custom_plot, "action_export": self.export, } @@ -425,7 +414,7 @@ class ResultsWindowAdisTS(PamhyrWindow): "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.selectionModel()\ @@ -460,7 +449,7 @@ class ResultsWindowAdisTS(PamhyrWindow): self._table["raw_data"].update(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}") selectionModel = table.selectionModel() index = table.model().index(ind, 0) @@ -474,7 +463,7 @@ class ResultsWindowAdisTS(PamhyrWindow): table.scrollTo(index) def update_table_selection_pol(self, ind): - for t in ["pollutants"]:###, "raw_data"]: + for t in ["pollutants"]: table = self.find(QTableView, f"tableView_{t}") selectionModel = table.selectionModel() index = table.model().index(ind, 0) @@ -487,7 +476,8 @@ class ResultsWindowAdisTS(PamhyrWindow): ) 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: self.plot_cdt.set_reach(reach_id) self.plot_cdx.set_reach(reach_id) diff --git a/src/View/Results/translate.py b/src/View/Results/translate.py index 515ac420..480b621a 100644 --- a/src/View/Results/translate.py +++ b/src/View/Results/translate.py @@ -102,9 +102,10 @@ class ResultsTranslate(MainTranslate): self._sub_dict["table_headers_raw_data"] = { "name": _translate("Results", "Profile"), } - for i, pol in enumerate(self.pollutants): - self._sub_dict["table_headers_raw_data"][pol + " Concentration"] = pol + "\n Concentration" - self._sub_dict["table_headers_raw_data"][pol + " Mass"] = pol + "\n Mass" + tmp = self._sub_dict["table_headers_raw_data"] + for pol in self.pollutants: + tmp[pol + " Concentration"] = pol + "\n Concentration" + tmp[pol + " Mass"] = pol + "\n Mass" else: self._sub_dict["table_headers_raw_data"] = { "name": _translate("Results", "Profile"), @@ -131,4 +132,3 @@ class ResultsTranslate(MainTranslate): "unit_M": self._dict["unit_mass"], "unit_thickness": self._dict["unit_thickness"], } - diff --git a/src/View/Translate.py b/src/View/Translate.py index b8413791..c431d9c2 100644 --- a/src/View/Translate.py +++ b/src/View/Translate.py @@ -145,7 +145,9 @@ class UnitTranslate(CommonWordTranslate): ) self._dict["unit_froude"] = _translate("Unit", "Froude number") 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):