more work on adists results

adists_release
Theophile Terraz 2024-12-05 16:03:40 +01:00
parent c2c77304d7
commit f1d6eb8990
6 changed files with 114 additions and 89 deletions

View File

@ -240,3 +240,4 @@ class PlotAdis_dt(PamhyrPlot):
self._type_pol = type_pol
self._current_pol_id = pol_id
self.update()
self.update_current()

View File

@ -53,22 +53,31 @@ class PlotAdis_dx(PamhyrPlot):
self._key = key
self._type_pol = type_pol
self.label_x = self._trad["unit_pk"]
self.label_x = self._trad["unit_rk"]
self._available_values_y = self._trad.get_dict("values_y_pol")
self.label = {}
self.label["C"] = _translate("Results", "Concentration")
self.label["M"] = _translate("Results", "Mass")
self.label_max = {}
self.label_min = {}
self.label["C"] = _translate("Results", "Concentration")
self.label_max["C"] = _translate("Results", "Max Concentration")
self.label_max["M"] = _translate("Results", "Max Mass")
self.label_min["C"] = _translate("Results", "Min Concentration")
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")
self.label_y = self._available_values_y["unit_thickness"]
else:
self.label["M"] = _translate("Results", "Mass")
self.label_max["M"] = _translate("Results", "Max Mass")
self.label_min["M"] = _translate("Results", "Min Mass")
self.label_y = self._available_values_y["unit_"+self._key]
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]
self._isometric_axis = False
@ -95,15 +104,13 @@ class PlotAdis_dx(PamhyrPlot):
self._init = False
return
self.draw_max(reach)
self.draw_min_and_max(reach)
self.draw_data(reach, profile)
self.draw_current(reach)
self.draw_profiles_hs(reach)
self.enable_legend()
self.set_y_lim()
self.idle()
self.update_current()
self._init = True
@ -151,8 +158,6 @@ class PlotAdis_dx(PamhyrPlot):
reach.profiles
))
self.set_y_lim()
self._line, = self.canvas.axes.plot(
x, y,
label=self.label[self._key],
@ -160,6 +165,8 @@ class PlotAdis_dx(PamhyrPlot):
**self.plot_default_kargs
)
self.set_y_lim()
def draw_current(self, reach):
rk = reach.geometry.get_rk()
@ -171,7 +178,7 @@ class PlotAdis_dx(PamhyrPlot):
lw=1.
)
def draw_max(self, reach):
def draw_min_and_max(self, reach):
profile = reach.profile(self._current_profile_id)
x = reach.geometry.get_rk()
@ -179,11 +186,13 @@ class PlotAdis_dx(PamhyrPlot):
y=[0.0]*len(x)
else:
y = []
z = []
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))
z.append(np.min(rk_y))
self._line_max, = self.canvas.axes.plot(
x, y,
@ -194,6 +203,15 @@ class PlotAdis_dx(PamhyrPlot):
markersize=0
)
self._line_min, = self.canvas.axes.plot(
x, y,
label=self.label_min[self._key],
color='g',
linestyle='dotted',
lw=1.,
markersize=0
)
def set_reach(self, reach_id):
self._current_reach_id = reach_id
self._current_profile_id = 0
@ -212,12 +230,12 @@ class PlotAdis_dx(PamhyrPlot):
if not self._init:
self.draw()
self.update_max()
self.update_min_and_max()
self.update_data()
self.set_y_lim
self.update_idle()
def update_max(self):
def update_min_and_max(self):
reach = self.results.river.reach(self._current_reach_id)
profile = reach.profile(self._current_profile_id)
x = reach.geometry.get_rk()
@ -226,13 +244,16 @@ class PlotAdis_dx(PamhyrPlot):
y=[0.0]*len(x)
else:
y = []
z = []
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))
z.append(np.min(rk_y))
self._line_max.set_data(x, y)
self._line_min.set_data(x, z)
def update_data(self):
reach = self.results.river.reach(self._current_reach_id)
@ -297,7 +318,7 @@ class PlotAdis_dx(PamhyrPlot):
self.y_max = np.max(y)
self.y_min = np.min(y)
if self.y_max - self.y_min < 1:
if self.y_max - self.y_min < 0.000001:
self.y_min = (self.y_max + self.y_min)/2 - 0.5
self.y_max = (self.y_max + self.y_min)/2 + 0.5

View File

@ -59,6 +59,7 @@ class TableModel(PamhyrTableModel):
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)
@ -101,17 +102,12 @@ class TableModel(PamhyrTableModel):
tmp_list.remove("total_sediment")
tmp_list2 = self._data.pollutants_list.copy()
for pol in tmp_list:
print('head name: ', self._headers[column])
print("pols: ", tmp_list, pol)
pol_index = tmp_list2.index(pol)
header_name = pol + " Concentration"
#print(f"_lst({row}): {len(self._lst[row])}")
#print(f"longueur : {len(self._lst[row].get_ts_key(self._timestamp, 'pols')[pol_index])}")
if self._headers[column] == header_name:
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==7: #####
print(self._lst[row].get_ts_key(self._timestamp, "pols")[pol_index])
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]
@ -134,7 +130,6 @@ class TableModel(PamhyrTableModel):
def timestamp(self):
return self._timestamp
@timestamp.setter
def timestamp(self, timestamp):
def set_timestamp(self, timestamp):
self._timestamp = timestamp
self.layoutChanged.emit()

View File

@ -107,7 +107,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
self._hash_data.append(self._results)
self._additional_plot = {}
self._pol_id = 0
self._pol_id = 1
self._reach_id = 0
self._profile_id = 0
@ -122,7 +122,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
self.setup_connections()
self.update_table_selection_reach(self._reach_id)
self.update_table_selection_profile(self._profile_id)
self.update_table_selection_pol(self._pol_id)
self.update_table_selection_pol(self._pol_id-1)
except Exception as e:
logger_exception(e)
return
@ -130,7 +130,6 @@ class ResultsWindowAdisTS(PamhyrWindow):
def set_type_pol(self):
self._type_pol = []
tmp_list = self._results.river.reach(0).profiles
print(self._results.pollutants_list)
for pol_index in range(self._results.nb_pollutants):
if self._results.pollutants_list[pol_index] == "total_sediment":
self._type_pol.append(-1)
@ -291,6 +290,62 @@ class ResultsWindowAdisTS(PamhyrWindow):
if self._type_pol[self._pol_id] != 7:
self.find(QTabWidget, "tabWidget").setTabVisible(2, False)
# Thickness
self.canvas_tdx = MplCanvas(width=5, height=4, dpi=100)
self.canvas_tdx.setObjectName("canvas_tdx")
self.toolbar_tdx = PamhyrPlotToolbar(
self.canvas_tdx, self, items=[
"home", "move", "zoom", "save",
"iso", "back/forward"
]
)
self.plot_layout_tdx = self.find(
QVBoxLayout, "verticalLayout_tdx")
self.plot_layout_tdx.addWidget(self.toolbar_tdx)
self.plot_layout_tdx.addWidget(self.canvas_tdx)
self.plot_tdx = PlotAdis_dx(
canvas=self.canvas_tdx,
results=self._results,
reach_id=self._reach_id,
profile_id=self._profile_id,
pol_id=0,
key="M",
type_pol = self._type_pol[0],
trad=self._trad,
toolbar=self.toolbar_tdx
)
self.plot_tdx.draw()
self.canvas_tdt = MplCanvas(width=5, height=4, dpi=100)
self.canvas_tdt.setObjectName("canvas_tdt")
self.toolbar_tdt = PamhyrPlotToolbar(
self.canvas_tdt, self, items=[
"home", "move", "zoom", "save",
"iso", "back/forward"
]
)
self.plot_layout_tdt = self.find(
QVBoxLayout, "verticalLayout_tdt")
self.plot_layout_tdt.addWidget(self.toolbar_tdt)
self.plot_layout_tdt.addWidget(self.canvas_tdt)
self.plot_tdt = PlotAdis_dt(
canvas=self.canvas_tdt,
results=self._results,
reach_id=self._reach_id,
profile_id=self._profile_id,
pol_id=0,
key="M",
type_pol = self._type_pol[0],
trad=self._trad,
toolbar=self.toolbar_tdt
)
self.plot_tdt.draw()
def closeEvent(self, event):
try:
self._timer.stop()
@ -402,7 +457,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
table.scrollTo(index)
self._table["profile"].update(ind)
###self._table["raw_data"].update(ind)
self._table["raw_data"].update(ind)
def update_table_selection_profile(self, ind):
for t in ["profile"]:###, "raw_data"]:
@ -439,6 +494,8 @@ class ResultsWindowAdisTS(PamhyrWindow):
if self._type_pol[self._pol_id] != 1:
self.plot_mdx.set_reach(reach_id)
self.plot_mdt.set_reach(reach_id)
self.plot_tdt.set_reach(reach_id)
self.plot_tdx.set_reach(reach_id)
self.update_table_selection_reach(reach_id)
self.update_table_selection_profile(0)
@ -449,11 +506,13 @@ class ResultsWindowAdisTS(PamhyrWindow):
if self._type_pol[self._pol_id] != 1:
self.plot_mdx.set_profile(profile_id)
self.plot_mdt.set_profile(profile_id)
self.plot_tdt.set_profile(profile_id)
self.plot_tdx.set_profile(profile_id)
self.update_table_selection_profile(profile_id)
if pol_id is not None:
self._pol_id = pol_id
self._pol_id = pol_id+1
self.plot_cdt.set_pollutant(self._pol_id,
self._type_pol[self._pol_id])
self.plot_cdx.set_pollutant(self._pol_id,
@ -467,7 +526,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
else:
self.find(QTabWidget, "tabWidget").setTabVisible(2, False)
self.update_table_selection_pol(self._pol_id)
self.update_table_selection_pol(self._pol_id-1)
if timestamp is not None:
self.plot_cdt.set_timestamp(timestamp)
@ -475,8 +534,10 @@ class ResultsWindowAdisTS(PamhyrWindow):
if self._type_pol[self._pol_id] != 1:
self.plot_mdx.set_timestamp(timestamp)
self.plot_mdt.set_timestamp(timestamp)
self.plot_tdt.set_timestamp(timestamp)
self.plot_tdx.set_timestamp(timestamp)
self._table["raw_data"].timestamp = timestamp
self._table["raw_data"].set_timestamp(timestamp)
self.update_statusbar()
@ -529,12 +590,16 @@ 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_tdt.results = self._results
self.plot_tdx.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_tdt.draw()
self.plot_tdx.draw()
def _reload_slider(self):
self._slider_time = self.find(QSlider, f"horizontalSlider_time")

View File

@ -129,5 +129,6 @@ class ResultsTranslate(MainTranslate):
self._sub_dict["values_y_pol"] = {
"unit_C": self._dict["unit_concentration"],
"unit_M": self._dict["unit_mass"],
"unit_thickness": self._dict["unit_thickness"],
}

View File

@ -293,64 +293,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Total Sediments</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_tot">
<item>
<widget class="QTabWidget" name="tabWidget_tot">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Concentration</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_tot_c"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_6">
<attribute name="title">
<string>Left thickness</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_tot_left_2"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_7">
<attribute name="title">
<string>Minor thickness</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_tot_minor"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_8">
<attribute name="title">
<string>Right thickness</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_tot_right"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_thickness">
<attribute name="title">
<string>Thickness</string>
@ -419,7 +361,7 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3"/>
<layout class="QVBoxLayout" name="verticalLayout_tdx"/>
</item>
</layout>
</widget>
@ -429,7 +371,7 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_6"/>
<layout class="QVBoxLayout" name="verticalLayout_tdt"/>
</item>
</layout>
</widget>