diff --git a/src/View/Results/CustomPlot/Translate.py b/src/View/Results/CustomPlot/Translate.py index b00bab0a..abc6b244 100644 --- a/src/View/Results/CustomPlot/Translate.py +++ b/src/View/Results/CustomPlot/Translate.py @@ -59,20 +59,3 @@ class CustomPlotTranslate(ResultsTranslate): self._dict['3-meter'] = self._dict["unit_height"] self._dict['4-dimensionless'] = self._dict["unit_froude"] self._dict['5-m2'] = self._dict["wet_area"] - - # SubDict - - self._sub_dict["values_x"] = { - "rk": self._dict["rk"], - "time": self._dict["time"], - } - self._sub_dict["values_y"] = { - "elevation": self._dict["elevation"], - "water_elevation": self._dict["water_elevation"], - "discharge": self._dict["discharge"], - "velocity": self._dict["velocity"], - "depth": self._dict["max_depth"], - "mean_depth": self._dict["mean_depth"], - "froude": self._dict["froude"], - "wet_area": self._dict["wet_area"], - } diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index f51ed02c..60fc14ee 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -606,10 +606,25 @@ class ResultsWindow(PamhyrWindow): timestamps = sorted(self._results.get("timestamps")) if x == "rk": timestamp = self._get_current_timestamp() - self._export_rk(timestamp, y, filename) + val_dict = self._export_rk(timestamp, y, filename) elif x == "time": profile = self._get_current_profile() - self._export_time(profile, y, filename) + val_dict = self._export_time(profile, y, filename) + + with open(filename, 'w', newline='') as csvfile: + writer = csv.writer(csvfile, delimiter=',', + quotechar='|', quoting=csv.QUOTE_MINIMAL) + dict_x = self._trad.get_dict("values_x") + dict_y = self._trad.get_dict("values_y") + header = [dict_x[x]] + for text in y: + header.append(dict_y[text]) + writer.writerow(header) + for row in range(len(val_dict[x])): + line = [val_dict[x][row]] + for var in y: + line.append(val_dict[var][row]) + writer.writerow(line) def export_all(self, reach, directory, timestamps): name = reach.name @@ -651,8 +666,8 @@ class ResultsWindow(PamhyrWindow): def _export_rk(self, timestamp, y, filename): reach = self._results.river.reachs[self._get_current_reach()] - rk = reach.geometry.get_rk() my_dict = {} + my_dict["rk"] = reach.geometry.get_rk() if "elevation" in y: my_dict["elevation"] = reach.geometry.get_z_min() if "discharge" in y: @@ -719,23 +734,14 @@ class ResultsWindow(PamhyrWindow): ) ) - with open(filename, 'w', newline='') as csvfile: - writer = csv.writer(csvfile, delimiter=',', - quotechar='|', quoting=csv.QUOTE_MINIMAL) - header = ["rk"] + y - writer.writerow(header) - for row in range(len(rk)): - line = [rk[row]] - for var in y: - line.append(my_dict[var][row]) - writer.writerow(line) + return my_dict def _export_time(self, profile, y, filename): reach = self._results.river.reachs[self._get_current_reach()] profile = reach.profile(profile) ts = list(self._results.get("timestamps")) - ts.sort() my_dict = {} + my_dict["time"] = ts.sort() z = profile.get_key("Z") q = profile.get_key("Q") if "elevation" in y: @@ -773,13 +779,4 @@ class ResultsWindow(PamhyrWindow): map(lambda z: profile.geometry.wet_area(z), z) ) - with open(filename, 'w', newline='') as csvfile: - writer = csv.writer(csvfile, delimiter=',', - quotechar='|', quoting=csv.QUOTE_MINIMAL) - header = ["time"] + y - writer.writerow(header) - for row in range(len(ts)): - line = [ts[row]] - for var in y: - line.append(my_dict[var][row]) - writer.writerow(line) + return my_dict diff --git a/src/View/Results/translate.py b/src/View/Results/translate.py index faab6ecb..e434af9d 100644 --- a/src/View/Results/translate.py +++ b/src/View/Results/translate.py @@ -66,3 +66,19 @@ class ResultsTranslate(MainTranslate): "hydraulic_radius": self._dict["unit_hydraulic_radius"], "froude": self._dict["unit_froude"], } + + self._sub_dict["values_x"] = { + "rk": self._dict["unit_rk"], + "time": self._dict["unit_time_s"], + } + + self._sub_dict["values_y"] = { + "elevation": self._dict["unit_elevation"], + "water_elevation": self._dict["unit_water_elevation"], + "discharge": self._dict["unit_discharge"], + "velocity": self._dict["unit_speed"], + "depth": self._dict["unit_max_height"], + "mean_depth": self._dict["unit_mean_height"], + "froude": self._dict["unit_froude"], + "wet_area": self._dict["unit_wet_area"], + } diff --git a/src/View/ui/InitialConditions_Dialog_Generator_Height.ui b/src/View/ui/InitialConditions_Dialog_Generator_Height.ui index 414c3d12..36d77a44 100644 --- a/src/View/ui/InitialConditions_Dialog_Generator_Height.ui +++ b/src/View/ui/InitialConditions_Dialog_Generator_Height.ui @@ -55,6 +55,12 @@ false + + -1000000.000000000000000 + + + 1000000.000000000000000 + @@ -73,6 +79,9 @@ -1000000.000000000000000 + + 1000000.000000000000000 + 0.000000000000000