more work on adis results

adists_release
Theophile Terraz 2024-12-04 16:09:33 +01:00
parent 01de0cfe93
commit b72ffe03c3
4 changed files with 282 additions and 180 deletions

View File

@ -37,7 +37,7 @@ logger = logging.getLogger()
class PlotAdis_dt(PamhyrPlot):
def __init__(self, canvas=None, trad=None, toolbar=None,
results=None, reach_id=0, profile_id=0,
pol_id=0, key="C", parent=None):
pol_id=0, key="C", type_pol=7, parent=None):
super(PlotAdis_dt, self).__init__(
canvas=canvas,
trad=trad,
@ -51,6 +51,7 @@ class PlotAdis_dt(PamhyrPlot):
self._current_profile_id = profile_id
self._current_pol_id = pol_id
self._key = key
self._type_pol = type_pol
self.label_x = self._trad["unit_time_s"]
self._available_values_y = self._trad.get_dict("values_y_pol")
@ -61,9 +62,11 @@ class PlotAdis_dt(PamhyrPlot):
self.label_max = {}
self.label_max["C"] = _translate("Results", "Max Concentration")
self.label_max["M"] = _translate("Results", "Max Mass")
self.sed_id = {}
self.sed_id["C"] = 0
self.sed_id["M"] = 1
self.val_id = {}
self.val_id["C"] = 0
self.val_id["G"] = 1
self.val_id["M"] = 2
self.val_id["D"] = 3
self.label_y = self._available_values_y["unit_"+self._key]
@ -109,9 +112,12 @@ class PlotAdis_dt(PamhyrPlot):
self.ts.sort()
x = self.ts
y = list(map(lambda data_el: data_el[self._current_pol_id][self.sed_id[self._key]],
profile.get_key("pols")
))
if self.val_id[self._key] > 0 and self._type_pol == 1:
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")
))
self._line, = self.canvas.axes.plot(
x, y,
@ -134,12 +140,15 @@ class PlotAdis_dt(PamhyrPlot):
self.ts.sort()
x = self.ts
y = []
for ts in x:
ts_y = list(map(
lambda p: p.get_ts_key(ts, "pols")[self._current_pol_id][self.sed_id[self._key]],
reach.profiles))
y.append(np.max(ts_y))
if self.val_id[self._key] > 0 and self._type_pol == 1:
y=[0.0]*len(x)
else:
y = []
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))
y.append(np.max(ts_y))
self._line_max, = self.canvas.axes.plot(
x, y,
@ -168,17 +177,39 @@ class PlotAdis_dt(PamhyrPlot):
if not self._init:
self.draw()
self.update_max()
self.update_data()
self.update_idle()
def update_max(self):
reach = self.results.river.reach(self._current_reach_id)
self.ts = list(self.results.get("timestamps"))
self.ts.sort()
x = self.ts
if self.val_id[self._key] > 0 and self._type_pol == 1:
y=[0.0]*len(x)
else:
y = []
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))
y.append(np.max(ts_y))
self._line_max.set_data(x, y)
def update_data(self):
reach = self.results.river.reach(self._current_reach_id)
profile = reach.profile(self._current_profile_id)
x = self.ts
y = list(map(lambda data_el: data_el[self._current_pol_id][self.sed_id[self._key]],
profile.get_key("pols")
))
if self.val_id[self._key] > 0 and self._type_pol == 1:
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")
))
self._line.set_data(x, y)
@ -204,7 +235,8 @@ class PlotAdis_dt(PamhyrPlot):
def show_current(self):
self._current.set_visible(True)
def set_pollutant(self, pol_id):
def set_pollutant(self, pol_id, type_pol):
if pol_id != self._current_pol_id:
self._type_pol = type_pol
self._current_pol_id = pol_id
self.update()

View File

@ -37,7 +37,7 @@ logger = logging.getLogger()
class PlotAdis_dx(PamhyrPlot):
def __init__(self, canvas=None, trad=None, toolbar=None,
results=None, reach_id=0, profile_id=0,
pol_id=0, key="C", parent=None):
pol_id=0, key="C", type_pol=7, parent=None):
super(PlotAdis_dx, self).__init__(
canvas=canvas,
trad=trad,
@ -51,6 +51,7 @@ class PlotAdis_dx(PamhyrPlot):
self._current_profile_id = profile_id
self._current_pol_id = pol_id
self._key = key
self._type_pol = type_pol
self.label_x = self._trad["unit_pk"]
self._available_values_y = self._trad.get_dict("values_y_pol")
@ -61,9 +62,11 @@ class PlotAdis_dx(PamhyrPlot):
self.label_max = {}
self.label_max["C"] = _translate("Results", "Max Concentration")
self.label_max["M"] = _translate("Results", "Max Mass")
self.sed_id = {}
self.sed_id["C"] = 0
self.sed_id["M"] = 1
self.val_id = {}
self.val_id["C"] = 0
self.val_id["G"] = 1
self.val_id["M"] = 2
self.val_id["D"] = 3
self.label_y = self._available_values_y["unit_"+self._key]
@ -140,10 +143,13 @@ class PlotAdis_dx(PamhyrPlot):
profile = reach.profile(self._current_profile_id)
x = reach.geometry.get_rk()
y = list(map(
lambda p: p.get_ts_key(self._current_timestamp, "pols")[self._current_pol_id][self.sed_id[self._key]],
reach.profiles
))
if self.val_id[self._key] > 0 and self._type_pol == 1:
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
))
self.set_y_lim()
@ -169,12 +175,15 @@ class PlotAdis_dx(PamhyrPlot):
profile = reach.profile(self._current_profile_id)
x = reach.geometry.get_rk()
y = []
for p in reach.profiles:
rk_y = list(map(lambda data_el: data_el[self._current_pol_id][self.sed_id[self._key]],
p.get_key("pols")
))
y.append(np.max(rk_y))
if self.val_id[self._key] > 0 and self._type_pol == 1:
y=[0.0]*len(x)
else:
y = []
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")
))
y.append(np.max(rk_y))
self._line_max, = self.canvas.axes.plot(
x, y,
@ -203,19 +212,41 @@ class PlotAdis_dx(PamhyrPlot):
if not self._init:
self.draw()
self.update_max()
self.update_data()
self.set_y_lim
self.update_idle()
def update_max(self):
reach = self.results.river.reach(self._current_reach_id)
profile = reach.profile(self._current_profile_id)
x = reach.geometry.get_rk()
if self.val_id[self._key] > 0 and self._type_pol == 1:
y=[0.0]*len(x)
else:
y = []
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")
))
y.append(np.max(rk_y))
self._line_max.set_data(x, y)
def update_data(self):
reach = self.results.river.reach(self._current_reach_id)
profile = reach.profile(self._current_profile_id)
x = reach.geometry.get_rk()
y = list(map(
lambda p: p.get_ts_key(self._current_timestamp, "pols")[self._current_pol_id][self.sed_id[self._key]],
reach.profiles
))
if self.val_id[self._key] > 0 and self._type_pol == 1:
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
))
self._line.set_data(x, y)
@ -243,22 +274,26 @@ class PlotAdis_dx(PamhyrPlot):
def show_current(self):
self._current.set_visible(True)
def set_pollutant(self, pol_id):
def set_pollutant(self, pol_id, type_pol):
if pol_id != self._current_pol_id:
self._type_pol = type_pol
self._current_pol_id = pol_id
self.update()
def set_y_lim(self):
reach = self.results.river.reach(self._current_reach_id)
y = list(
map(lambda p:
list(map(lambda data_el: data_el[self._current_pol_id][self.sed_id[self._key]],
p.get_key("pols"))
),
reach.profiles
)
if self.val_id[self._key] > 0 and self._type_pol == 1:
y=[0.0]
else:
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
)
)
self.y_max = np.max(y)
self.y_min = np.min(y)

View File

@ -107,7 +107,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
self._hash_data.append(self._results)
self._additional_plot = {}
self._pol_id = 1
self._pol_id = 0
self._reach_id = 0
self._profile_id = 0
@ -200,6 +200,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
profile_id=self._profile_id,
pol_id=self._pol_id,
key="C",
type_pol = self._type_pol[self._pol_id],
trad=self._trad,
toolbar=self.toolbar_cdt
)
@ -227,6 +228,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
profile_id=self._profile_id,
pol_id=self._pol_id,
key="C",
type_pol = self._type_pol[self._pol_id],
trad=self._trad,
toolbar=self.toolbar_cdx
)
@ -252,6 +254,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
profile_id=self._profile_id,
pol_id=self._pol_id,
key="M",
type_pol = self._type_pol[self._pol_id],
trad=self._trad,
toolbar=self.toolbar_mdx
)
@ -278,6 +281,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
profile_id=self._profile_id,
pol_id=self._pol_id,
key="M",
type_pol = self._type_pol[self._pol_id],
trad=self._trad,
toolbar=self.toolbar_mdt
)
@ -287,106 +291,6 @@ class ResultsWindowAdisTS(PamhyrWindow):
if self._type_pol[self._pol_id] != 7:
self.find(QTabWidget, "tabWidget").setTabVisible(2, False)
self.canvas_2 = MplCanvas(width=5, height=4, dpi=100)
self.canvas_2.setObjectName("canvas_2")
self.toolbar_2 = PamhyrPlotToolbar(
self.canvas_2, self, items=[
"home", "move", "zoom", "save",
"iso", "back/forward"
]
)
self.plot_layout_2 = self.find(
QVBoxLayout, "verticalLayout_tot_c")
self.plot_layout_2.addWidget(self.toolbar_2)
self.plot_layout_2.addWidget(self.canvas_2)
self.plot_tot_c = PlotTotSedC(
canvas=self.canvas_2,
results=self._results,
reach_id=self._reach_id,
profile_id=self._profile_id,
pol_id=self._results.pollutants_list.index("total_sediment"),
trad=self._trad,
toolbar=self.toolbar_2
)
self.plot_tot_c.draw()
self.canvas_1 = MplCanvas(width=5, height=4, dpi=100)
self.canvas_1.setObjectName("canvas_1")
self.toolbar_1 = PamhyrPlotToolbar(
self.canvas_1, self, items=[
"home", "move", "zoom", "save",
"iso", "back/forward"
]
)
self.plot_layout_1 = self.find(
QVBoxLayout, "verticalLayout_tot_left_2")
self.plot_layout_1.addWidget(self.toolbar_1)
self.plot_layout_1.addWidget(self.canvas_1)
self.plot_tot_eg = PlotTotSedEG(
canvas=self.canvas_1,
results=self._results,
reach_id=self._reach_id,
profile_id=self._profile_id,
pol_id=self._results.pollutants_list.index("total_sediment"),
trad=self._trad,
toolbar=self.toolbar_1
)
self.plot_tot_eg.draw()
self.canvas_0 = MplCanvas(width=5, height=4, dpi=100)
self.canvas_0.setObjectName("canvas_0")
self.toolbar_0 = PamhyrPlotToolbar(
self.canvas_0, self, items=[
"home", "move", "zoom", "save",
"iso", "back/forward"
]
)
self.plot_layout_0 = self.find(
QVBoxLayout, "verticalLayout_tot_minor")
self.plot_layout_0.addWidget(self.toolbar_0)
self.plot_layout_0.addWidget(self.canvas_0)
self.plot_tot_em = PlotTotSedEM(
canvas=self.canvas_0,
results=self._results,
reach_id=self._reach_id,
profile_id=self._profile_id,
pol_id=self._results.pollutants_list.index("total_sediment"),
trad=self._trad,
toolbar=self.toolbar_0
)
self.plot_tot_em.draw()
self.canvas_5 = MplCanvas(width=5, height=4, dpi=100)
self.canvas_5.setObjectName("canvas_5")
self.toolbar_5 = PamhyrPlotToolbar(
self.canvas_5, self, items=[
"home", "move", "zoom", "save",
"iso", "back/forward"
]
)
self.plot_layout_5 = self.find(
QVBoxLayout, "verticalLayout_tot_right")
self.plot_layout_5.addWidget(self.toolbar_5)
self.plot_layout_5.addWidget(self.canvas_5)
self.plot_tot_ed = PlotTotSedED(
canvas=self.canvas_5,
results=self._results,
reach_id=self._reach_id,
profile_id=self._profile_id,
pol_id=self._results.pollutants_list.index("total_sediment"),
trad=self._trad,
toolbar=self.toolbar_5
)
self.plot_tot_ed.draw()
def closeEvent(self, event):
try:
self._timer.stop()
@ -532,39 +436,34 @@ class ResultsWindowAdisTS(PamhyrWindow):
if reach_id is not None:
self.plot_cdt.set_reach(reach_id)
self.plot_cdx.set_reach(reach_id)
if self._type_pol[self._pol_id] == 7:
if self._type_pol[self._pol_id] != 1:
self.plot_mdx.set_reach(reach_id)
self.plot_mdt.set_reach(reach_id)
self.plot_tot_c.set_reach(reach_id)
self.plot_tot_eg.set_reach(reach_id)
self.plot_tot_em.set_reach(reach_id)
self.plot_tot_ed.set_reach(reach_id)
self.update_table_selection_reach(reach_id)
self.update_table_selection_profile(0)
self.update_table_selection_pol(0)
if profile_id is not None:
self.plot_cdt.set_profile(profile_id)
self.plot_cdx.set_profile(profile_id)
if self._type_pol[self._pol_id] == 7:
if self._type_pol[self._pol_id] != 1:
self.plot_mdx.set_profile(profile_id)
self.plot_mdt.set_profile(profile_id)
self.plot_tot_c.set_profile(profile_id)
self.plot_tot_eg.set_profile(profile_id)
self.plot_tot_em.set_profile(profile_id)
self.plot_tot_ed.set_profile(profile_id)
self.update_table_selection_profile(profile_id)
if pol_id is not None:
self._pol_id = pol_id
self.plot_cdt.set_pollutant(self._pol_id)
self.plot_cdx.set_pollutant(self._pol_id)
if self._type_pol[self._pol_id] == 7:
self.plot_cdt.set_pollutant(self._pol_id,
self._type_pol[self._pol_id])
self.plot_cdx.set_pollutant(self._pol_id,
self._type_pol[self._pol_id])
if self._type_pol[self._pol_id] != 1:
self.find(QTabWidget, "tabWidget").setTabVisible(2, True)
self.plot_mdx.set_pollutant(self._pol_id)
self.plot_mdt.set_pollutant(self._pol_id)
self.plot_mdx.set_pollutant(self._pol_id,
self._type_pol[self._pol_id])
self.plot_mdt.set_pollutant(self._pol_id,
self._type_pol[self._pol_id])
else:
self.find(QTabWidget, "tabWidget").setTabVisible(2, False)
@ -573,13 +472,9 @@ class ResultsWindowAdisTS(PamhyrWindow):
if timestamp is not None:
self.plot_cdt.set_timestamp(timestamp)
self.plot_cdx.set_timestamp(timestamp)
if self._type_pol[self._pol_id] == 7:
if self._type_pol[self._pol_id] != 1:
self.plot_mdx.set_timestamp(timestamp)
self.plot_mdt.set_timestamp(timestamp)
#self.plot_tot_c.set_timestamp(timestamp)
#self.plot_tot_eg.set_timestamp(timestamp)
#self.plot_tot_em.set_timestamp(timestamp)
#self.plot_tot_ed.set_timestamp(timestamp)
self._table["raw_data"].timestamp = timestamp
@ -634,20 +529,12 @@ class ResultsWindowAdisTS(PamhyrWindow):
if self._type_pol[self._pol_id] == 7:
self.plot_mdx.results = self._results
self.plot_mdt.results = self._results
self.plot_tot_c.results = self._results
self.plot_tot_eg.results = self._results
self.plot_tot_em.results = self._results
self.plot_tot_ed.results = self._results
self.plot_cdt.draw()
self.plot_cdx.draw()
if self._type_pol[self._pol_id] == 7:
self.plot_mdx.draw()
self.plot_mdt.draw()
self.plot_tot_c.draw()
self.plot_tot_eg.draw()
self.plot_tot_em.draw()
self.plot_tot_ed.draw()
def _reload_slider(self):
self._slider_time = self.find(QSlider, f"horizontalSlider_time")

View File

@ -24,7 +24,7 @@
</size>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QSplitter" name="splitter_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -133,7 +133,7 @@
<bool>true</bool>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_4">
<attribute name="title">
@ -198,12 +198,68 @@
<bool>true</bool>
</property>
<attribute name="title">
<string>Mass</string>
<string>Linear mass density</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_13">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6" stretch="0,0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="radioButton_left">
<property name="text">
<string>Left bed</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_center">
<property name="text">
<string>Minor bed</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_right">
<property name="text">
<string>Right bed</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTabWidget" name="tabWidget_m">
<property name="enabled">
<bool>true</bool>
@ -213,7 +269,7 @@
</property>
<widget class="QWidget" name="mdx">
<attribute name="title">
<string>Mass dx</string>
<string>Linear mass density dx</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_15">
<item row="0" column="0">
@ -223,7 +279,7 @@
</widget>
<widget class="QWidget" name="mdt">
<attribute name="title">
<string>Mass dt</string>
<string>Linear mass density dt</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_14">
<item row="0" column="0">
@ -295,6 +351,94 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_thickness">
<attribute name="title">
<string>Thickness</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QRadioButton" name="radioButton_left_2">
<property name="text">
<string>Left bed</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_center_2">
<property name="text">
<string>Minor bed</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_right_2">
<property name="text">
<string>Right bed</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_tdx">
<attribute name="title">
<string>Thickness dx</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_tdt">
<attribute name="title">
<string>Thickness dt</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_6"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@ -370,4 +514,8 @@
</widget>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_2"/>
</buttongroups>
</ui>