mirror of https://gitlab.com/pamhyr/pamhyr2
more work on import data results
parent
68b62a5630
commit
84486c03ed
|
|
@ -599,13 +599,7 @@ class CustomPlot(PamhyrPlot):
|
||||||
self.lines["wet_area"] = line
|
self.lines["wet_area"] = line
|
||||||
|
|
||||||
# Legend
|
# Legend
|
||||||
lns = reduce(
|
self.update_legend()
|
||||||
lambda acc, line: acc + line,
|
|
||||||
map(lambda line: self.lines[line], self.lines),
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
labs = list(map(lambda line: self._trad[line], self.lines))
|
|
||||||
self.canvas.axes.legend(lns, labs, loc="best")
|
|
||||||
|
|
||||||
def _redraw_rk(self):
|
def _redraw_rk(self):
|
||||||
results = self.data[self._current_res_id]
|
results = self.data[self._current_res_id]
|
||||||
|
|
@ -1103,13 +1097,7 @@ class CustomPlot(PamhyrPlot):
|
||||||
self._customize_x_axes_time(ts)
|
self._customize_x_axes_time(ts)
|
||||||
|
|
||||||
# Legend
|
# Legend
|
||||||
lns = reduce(
|
self.update_legend()
|
||||||
lambda acc, line: acc + line,
|
|
||||||
map(lambda line: self.lines[line], self.lines),
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
labs = list(map(lambda line: self._trad[line], self.lines))
|
|
||||||
self.canvas.axes.legend(lns, labs, loc="best")
|
|
||||||
|
|
||||||
def _redraw_time(self):
|
def _redraw_time(self):
|
||||||
|
|
||||||
|
|
@ -1419,3 +1407,12 @@ 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()
|
||||||
|
|
||||||
|
def update_legend(self):
|
||||||
|
lns = reduce(
|
||||||
|
lambda acc, line: acc + line,
|
||||||
|
map(lambda line: self.lines[line], self.lines),
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
labs = list(map(lambda line: self._trad[line], self.lines))
|
||||||
|
self.canvas.axes.legend(lns, labs, loc="best")
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,9 @@ class CustomPlotTranslate(ResultsTranslate):
|
||||||
self._dict['wet_perimeter'] = self._dict["unit_wet_perimeter"]
|
self._dict['wet_perimeter'] = self._dict["unit_wet_perimeter"]
|
||||||
self._dict['hydraulic_radius'] = self._dict["unit_hydraulic_radius"]
|
self._dict['hydraulic_radius'] = self._dict["unit_hydraulic_radius"]
|
||||||
self._dict['froude'] = self._dict["unit_froude"]
|
self._dict['froude'] = self._dict["unit_froude"]
|
||||||
|
self._dict['user_imported'] = _translate(
|
||||||
|
"CustomPlot", "user_imported"
|
||||||
|
)
|
||||||
|
|
||||||
# Unit corresponding long name (plot axes display)
|
# Unit corresponding long name (plot axes display)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
import os
|
import os
|
||||||
import csv
|
import csv
|
||||||
import logging
|
import logging
|
||||||
|
from functools import reduce
|
||||||
# import rasterio
|
# import rasterio
|
||||||
|
|
||||||
from numpy import sqrt
|
from numpy import sqrt
|
||||||
|
|
@ -1268,17 +1269,45 @@ class ResultsWindow(PamhyrWindow):
|
||||||
if not ok:
|
if not ok:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
legend, ok = QInputDialog.getText(
|
||||||
|
self, 'Legend','Legend:' )
|
||||||
|
|
||||||
|
if not ok:
|
||||||
|
return
|
||||||
|
|
||||||
|
if legend.strip() == '':
|
||||||
|
legend = '*'
|
||||||
|
|
||||||
|
tmp_dict = {'Z': 'water_elevation',
|
||||||
|
'Q': 'discharge',
|
||||||
|
'x': 'rk',
|
||||||
|
't': 'time'}
|
||||||
|
|
||||||
|
tmp_unit = {'Z': ' (m)',
|
||||||
|
'Q': ' (m³/s)'}
|
||||||
|
|
||||||
if data_type == 'Z(x)':
|
if data_type == 'Z(x)':
|
||||||
self.canvas_2.axes.scatter(x, y, marker="+")
|
line = self.canvas_2.axes.plot(x, y, marker="+",
|
||||||
self.plot_rkc.idle()
|
label = legend + ' (m)')
|
||||||
|
self.plot_rkc.canvas.draw_idle()
|
||||||
|
self.plot_rkc.update_idle()
|
||||||
if data_type == 'Q(t)':
|
if data_type == 'Q(t)':
|
||||||
self.canvas_4.axes.scatter(x, y, marker="+")
|
line = self.canvas_4.axes.plot(x, y,
|
||||||
self.plot_h.idle()
|
marker="+",
|
||||||
if data_type == 'Z(t)':
|
label = legend + ' (m³/s)')
|
||||||
for plot in self._additional_plot:
|
self.plot_h._line.append(line)
|
||||||
x_key = plot.split(": ")[0]
|
self.plot_h.enable_legend()
|
||||||
y_key = plot.split(": ")[1].split(",")
|
for p in self._additional_plot:
|
||||||
if 'time' in x_key and 'water_elevation' in y_key:
|
plot = self._additional_plot[p]
|
||||||
self._additional_plot[plot].canvas.axes.scatter(
|
x_key = p.split(": ")[0]
|
||||||
x, y, marker="+")
|
y_key = p.split(": ")[1].split(",")
|
||||||
self._additional_plot[plot].idle()
|
if (tmp_dict[data_type[2]] in x_key and
|
||||||
|
tmp_dict[data_type[0]] in y_key):
|
||||||
|
while legend in plot.lines:
|
||||||
|
legend += '*'
|
||||||
|
plot._trad._dict[legend] = legend + tmp_unit[data_type[0]]
|
||||||
|
plot.lines[legend] = plot.canvas.axes.plot(x, y,
|
||||||
|
marker="+",
|
||||||
|
linestyle="--")
|
||||||
|
plot.update_legend()
|
||||||
|
plot.idle()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue