mirror of https://gitlab.com/pamhyr/pamhyr2
pollutant selection done
parent
71729578dd
commit
1fcdaa8b81
|
|
@ -634,20 +634,20 @@ class AdisTSlc(AdisTS):
|
|||
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||
# end data
|
||||
|
||||
print("dta tmp AAA")
|
||||
print("-----------")
|
||||
print(data_tmp["AAA-silt"])
|
||||
###print("dta tmp AAA")
|
||||
###print("-----------")
|
||||
###print(data_tmp["AAA-silt"])
|
||||
|
||||
pollutants_keys = list(data_tmp.keys())
|
||||
timestamps_keys = list(data_tmp[pollutants_keys[0]].keys())
|
||||
phys_data_names = list(data_tmp[pollutants_keys[0]][timestamps_keys[0]].keys())
|
||||
|
||||
print("pol keys: ", pollutants_keys)
|
||||
print("t keys: ", timestamps_keys)
|
||||
print("phys var: ", phys_data_names)
|
||||
###print("pol keys: ", pollutants_keys)
|
||||
###print("t keys: ", timestamps_keys)
|
||||
###print("phys var: ", phys_data_names)
|
||||
#print("set timestamps keys: ", set(timestamps_keys))
|
||||
#print("isma")
|
||||
print("iprofiles: ", iprofiles)
|
||||
###print("iprofiles: ", iprofiles)
|
||||
|
||||
pi_tmp = []
|
||||
reach_tmp = []
|
||||
|
|
@ -669,20 +669,20 @@ class AdisTSlc(AdisTS):
|
|||
|
||||
reach.set(p_i, t_data, "pols", pol_view)
|
||||
|
||||
print("pi_tmp: ", pi_tmp)
|
||||
print("pol view: ", pol_view)
|
||||
print("reach from i: ", reach_tmp)
|
||||
###print("pi_tmp: ", pi_tmp)
|
||||
###print("pol view: ", pol_view)
|
||||
###print("reach from i: ", reach_tmp)
|
||||
#print("pol view: ", pol_view)
|
||||
#print("results: ", results)
|
||||
results.set("timestamps", set(timestamps_keys))
|
||||
#print("------------------------set timestamps results meta data: ", set(timestamps_keys))
|
||||
|
||||
print("debug profiles for draw:")
|
||||
print("------------------------")
|
||||
print(data_tmp["AAA-silt"][0.0]["C"][0])
|
||||
print(data_tmp["AAA-silt"][600.0]["C"][0])
|
||||
print(data_tmp["AAA-silt"][1205.7208829578194]["C"][0])
|
||||
print("========================")
|
||||
###print("debug profiles for draw:")
|
||||
###print("------------------------")
|
||||
###print(data_tmp["AAA-silt"][0.0]["C"][0])
|
||||
###print(data_tmp["AAA-silt"][600.0]["C"][0])
|
||||
###print(data_tmp["AAA-silt"][1205.7208829578194]["C"][0])
|
||||
###print("========================")
|
||||
|
||||
@timer
|
||||
def results(self, study, repertory, qlog=None, name=None):
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ logger = logging.getLogger()
|
|||
|
||||
class PlotH(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||
results=None, reach_id=0, profile_id=0,
|
||||
results=None, reach_id=0, profile_id=0, pol_id=0,
|
||||
parent=None):
|
||||
super(PlotH, self).__init__(
|
||||
canvas=canvas,
|
||||
|
|
@ -50,6 +50,7 @@ class PlotH(PamhyrPlot):
|
|||
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)")
|
||||
|
|
@ -81,14 +82,13 @@ class PlotH(PamhyrPlot):
|
|||
|
||||
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_max(reach)
|
||||
self.draw_data(reach, profile)
|
||||
#self.draw_current(reach, profile)
|
||||
self.draw_data(reach, profile, pollutant)
|
||||
|
||||
self.set_ticks_time_formater()
|
||||
|
||||
|
|
@ -97,24 +97,26 @@ class PlotH(PamhyrPlot):
|
|||
self.idle()
|
||||
self._init = True
|
||||
|
||||
def draw_data(self, reach, profile):
|
||||
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[0][0], profile.get_key("pols")))
|
||||
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("*****************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,
|
||||
|
|
@ -123,46 +125,6 @@ class PlotH(PamhyrPlot):
|
|||
**self.plot_default_kargs
|
||||
)
|
||||
|
||||
def draw_current(self, reach, profile):
|
||||
min_y, max_y = reduce(
|
||||
lambda acc, p: (
|
||||
acc[0] + [min(p.get_key("Q"))],
|
||||
acc[1] + [max(p.get_key("Q"))]
|
||||
),
|
||||
reach.profiles,
|
||||
([], [])
|
||||
)
|
||||
|
||||
self._current, = self.canvas.axes.plot(
|
||||
[self._current_timestamp, self._current_timestamp],
|
||||
[min(min_y), max(max_y)],
|
||||
# label=self.label_timestamp,
|
||||
color=self.color_plot_river_bottom,
|
||||
linestyle="dashed",
|
||||
lw=1.,
|
||||
)
|
||||
|
||||
def draw_max(self, reach):
|
||||
self.ts = list(self.results.get("timestamps"))
|
||||
self.ts.sort()
|
||||
|
||||
x = self.ts
|
||||
y = []
|
||||
for ts in x:
|
||||
ts_y = -9999
|
||||
for profile in reach.profiles:
|
||||
q = profile.get_ts_key(ts, "Q")
|
||||
ts_y = max(ts_y, q)
|
||||
y.append(ts_y)
|
||||
|
||||
self._line_max, = self.canvas.axes.plot(
|
||||
x, y,
|
||||
label=self.label_discharge_max,
|
||||
color=self.color_plot_highlight,
|
||||
linestyle='dotted',
|
||||
**self.plot_default_kargs
|
||||
)
|
||||
|
||||
def set_reach(self, reach_id):
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = 0
|
||||
|
|
@ -172,6 +134,10 @@ class PlotH(PamhyrPlot):
|
|||
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()
|
||||
|
|
@ -187,15 +153,10 @@ class PlotH(PamhyrPlot):
|
|||
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[0][0], profile.get_key("pols")))
|
||||
y = list(map(lambda data_el: data_el[pollutant][0], profile.get_key("pols")))
|
||||
|
||||
self._line.set_data(x, y)
|
||||
|
||||
### _, min_max = self._current.get_data()
|
||||
###self._current.set_data(
|
||||
###self._current_timestamp,
|
||||
###min_max
|
||||
###)
|
||||
|
|
|
|||
|
|
@ -45,13 +45,13 @@ _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)
|
||||
###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)
|
||||
###print("optreach: ", self._lst)
|
||||
elif self._opt_data == "profile":
|
||||
self._lst = _river.reach(0).profiles
|
||||
elif self._opt_data == "raw_data":
|
||||
|
|
@ -59,10 +59,10 @@ class TableModel(PamhyrTableModel):
|
|||
elif self._opt_data == "pollutants":
|
||||
tmp_list = self._data.pollutants_list.copy()
|
||||
tmp_list.remove("total_sediment")
|
||||
print(type(tmp_list))
|
||||
###print(type(tmp_list))
|
||||
tmp_list.insert(len(tmp_list), "total_sediment")
|
||||
self._lst = tmp_list
|
||||
print("=====table pollutants: ", self._lst)
|
||||
###print("=====table pollutants: ", self._lst)
|
||||
elif self._opt_data == "phys_var":
|
||||
self._lst = self._data.phys_var_list
|
||||
#print("=====table pollutants: ", self._lst)
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
|||
results=self._results,
|
||||
reach_id=0,
|
||||
profile_id=0,
|
||||
pol_id=0,
|
||||
trad=self._trad,
|
||||
toolbar=self.toolbar_4
|
||||
)
|
||||
|
|
@ -185,8 +186,17 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
|||
|
||||
pname = profile.name if profile.name != "" else profile.kp
|
||||
|
||||
# Pollutant
|
||||
table = self.find(QTableView, f"tableView_pollutants")
|
||||
indexes = table.selectedIndexes()
|
||||
if len(indexes) == 0:
|
||||
pollutant = self._results.pollutants_list[0]
|
||||
else:
|
||||
pollutant = self._results.pollutants_list[indexes[0].row()]
|
||||
|
||||
return (f"Reach: {reach.name} | " +
|
||||
f"Profile: {pname})")
|
||||
f"Profile: {pname} | " +
|
||||
f"Pollutant: {pollutant}")
|
||||
|
||||
def setup_statusbar(self):
|
||||
txt = self._compute_status_label()
|
||||
|
|
@ -201,7 +211,7 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
|||
# Action
|
||||
actions = {
|
||||
"action_reload": self._reload,
|
||||
"action_add": self._add_custom_plot,
|
||||
###"action_add": self._add_custom_plot,
|
||||
"action_export": self.export,
|
||||
}
|
||||
|
||||
|
|
@ -214,10 +224,11 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
|||
fun = {
|
||||
"reach": self._set_current_reach,
|
||||
"profile": self._set_current_profile,
|
||||
"pollutants": self._set_current_pol,
|
||||
"raw_data": self._set_current_profile_raw_data,
|
||||
}
|
||||
|
||||
for t in ["reach", "profile"]:###, "raw_data"]:
|
||||
for t in ["reach", "profile", "pollutants"]:###, "raw_data"]:
|
||||
table = self.find(QTableView, f"tableView_{t}")
|
||||
|
||||
table.selectionModel()\
|
||||
|
|
@ -258,18 +269,41 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
|||
)
|
||||
table.scrollTo(index)
|
||||
|
||||
def update(self, reach_id=None, profile_id=None, timestamp=None):
|
||||
def update_table_selection_pol(self, ind):
|
||||
for t in ["pollutants"]:###, "raw_data"]:
|
||||
table = self.find(QTableView, f"tableView_{t}")
|
||||
selectionModel = table.selectionModel()
|
||||
index = table.model().index(ind, 0)
|
||||
|
||||
selectionModel.select(
|
||||
index,
|
||||
QItemSelectionModel.Rows |
|
||||
QItemSelectionModel.ClearAndSelect |
|
||||
QItemSelectionModel.Select
|
||||
)
|
||||
table.scrollTo(index)
|
||||
|
||||
def update(self, reach_id=None, profile_id=None, pol_id=None, timestamp=None):
|
||||
if reach_id is not None:
|
||||
self.plot_h.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_h.set_profile(profile_id)
|
||||
|
||||
self.update_table_selection_profile(profile_id)
|
||||
|
||||
print("--**//++update pol_id before None: ", pol_id)
|
||||
|
||||
if pol_id is not None:
|
||||
print("--**//++//**//** update pol_id: ", pol_id)
|
||||
self.plot_h.set_pollutant(pol_id)
|
||||
|
||||
self.update_table_selection_pol(pol_id)
|
||||
|
||||
if timestamp is not None:
|
||||
self.plot_h.set_timestamp(timestamp)
|
||||
|
||||
|
|
@ -277,27 +311,6 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
|||
|
||||
self.update_statusbar()
|
||||
|
||||
def _get_current_reach(self):
|
||||
table = self.find(QTableView, f"tableView_reach")
|
||||
indexes = table.selectedIndexes()
|
||||
if len(indexes) == 0:
|
||||
return 0
|
||||
|
||||
return indexes[0].row()
|
||||
|
||||
def _get_current_profile(self):
|
||||
table = self.find(QTableView, f"tableView_profile")
|
||||
indexes = table.selectedIndexes()
|
||||
if len(indexes) == 0:
|
||||
return 0
|
||||
|
||||
return indexes[0].row()
|
||||
|
||||
def _get_current_timestamp(self):
|
||||
return self._timestamps[
|
||||
self._slider_time.value()
|
||||
]
|
||||
|
||||
def _set_current_reach(self):
|
||||
table = self.find(QTableView, f"tableView_reach")
|
||||
indexes = table.selectedIndexes()
|
||||
|
|
@ -316,6 +329,16 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
|||
self.update(profile_id=ind)
|
||||
###self._slider_profile.setValue(ind)
|
||||
|
||||
def _set_current_pol(self):
|
||||
table = self.find(QTableView, f"tableView_pollutants")
|
||||
indexes = table.selectedIndexes()
|
||||
if len(indexes) == 0:
|
||||
return
|
||||
|
||||
ind = indexes[0].row()
|
||||
print("set pol id: ", ind)
|
||||
self.update(pol_id=ind)
|
||||
|
||||
def _set_current_profile_raw_data(self):
|
||||
table = self.find(QTableView, f"tableView_raw_data")
|
||||
indexes = table.selectedIndexes()
|
||||
|
|
@ -353,49 +376,6 @@ class ResultsWindowAdisTS(PamhyrWindow):
|
|||
self._reload_plots()
|
||||
###self._reload_slider()
|
||||
|
||||
def _add_custom_plot(self):
|
||||
dlg = CustomPlotValuesSelectionDialog(parent=self)
|
||||
if dlg.exec():
|
||||
x, y = dlg.value
|
||||
self.create_new_tab_custom_plot(x, y)
|
||||
|
||||
def create_new_tab_custom_plot(self, x: str, y: list):
|
||||
name = f"{x}: {','.join(y)}"
|
||||
wname = f"tab_custom_{x}_{y}"
|
||||
|
||||
tab_widget = self.find(QTabWidget, f"tabWidget")
|
||||
|
||||
widget = QWidget()
|
||||
grid = QGridLayout()
|
||||
|
||||
widget.setObjectName(wname)
|
||||
|
||||
canvas = MplCanvas(width=5, height=4, dpi=100)
|
||||
canvas.setObjectName(f"canvas_{x}_{y}")
|
||||
toolbar = PamhyrPlotToolbar(
|
||||
canvas, self
|
||||
)
|
||||
|
||||
plot = CustomPlot(
|
||||
x, y,
|
||||
self._get_current_reach(),
|
||||
self._get_current_profile(),
|
||||
self._get_current_timestamp(),
|
||||
data=self._results,
|
||||
canvas=canvas,
|
||||
toolbar=toolbar,
|
||||
parent=self,
|
||||
)
|
||||
plot.draw()
|
||||
|
||||
# Add plot to additional plot
|
||||
self._additional_plot[name] = plot
|
||||
|
||||
grid.addWidget(toolbar, 0, 0)
|
||||
grid.addWidget(canvas, 1, 0)
|
||||
widget.setLayout(grid)
|
||||
tab_widget.addTab(widget, name)
|
||||
|
||||
def _copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue