mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
4 Commits
26d1d63edb
...
dbcdace348
| Author | SHA1 | Date |
|---|---|---|
|
|
dbcdace348 | |
|
|
9375827949 | |
|
|
739f401fac | |
|
|
5f5a47679d |
|
|
@ -111,7 +111,7 @@ class Profile(SQLSubModel):
|
|||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
new = []
|
||||
new = {}
|
||||
status = data['status']
|
||||
|
||||
study = data['study']
|
||||
|
|
@ -140,18 +140,27 @@ class Profile(SQLSubModel):
|
|||
data = next(it)
|
||||
owner_scenario = next(it)
|
||||
|
||||
new_data = cls(profile, study)
|
||||
if profile not in new:
|
||||
new_data = cls(profile, study)
|
||||
new[profile] = new_data
|
||||
else:
|
||||
new_data = new[profile]
|
||||
|
||||
sf = ">" + ''.join(itertools.repeat("f", len_data))
|
||||
values = struct.unpack(sf, data)
|
||||
|
||||
for timestamp, value in zip(timestamps, values):
|
||||
new_data.set(timestamp, key, value)
|
||||
if key == "Z":
|
||||
new_data.update_water_limits(timestamp, value)
|
||||
|
||||
loaded.add(pid)
|
||||
new.append(new_data)
|
||||
return list(new.values())
|
||||
|
||||
return new
|
||||
def update_water_limits(self, timestamp, z):
|
||||
limits = self.geometry.get_water_limits(z)
|
||||
self.set(
|
||||
timestamp, "water_limits", limits
|
||||
)
|
||||
|
||||
def get_keys(self):
|
||||
return reduce(
|
||||
|
|
@ -196,7 +205,7 @@ class Profile(SQLSubModel):
|
|||
class Reach(SQLSubModel):
|
||||
_sub_classes = [Profile]
|
||||
|
||||
def __init__(self, reach, study):
|
||||
def __init__(self, reach, study, with_init=True):
|
||||
super(Reach, self).__init__(
|
||||
id=-1, status=study.status,
|
||||
owner_scenario=study.status.scenario.id
|
||||
|
|
@ -204,12 +213,14 @@ class Reach(SQLSubModel):
|
|||
|
||||
self._study = study
|
||||
self._reach = reach # Source reach in the study
|
||||
self._profiles = list(
|
||||
map(
|
||||
lambda p: Profile(p, self._study),
|
||||
reach.profiles
|
||||
self._profiles = []
|
||||
if with_init:
|
||||
self._profiles = list(
|
||||
map(
|
||||
lambda p: Profile(p, self._study),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def __len__(self):
|
||||
return len(self._profiles)
|
||||
|
|
@ -248,14 +259,12 @@ class Reach(SQLSubModel):
|
|||
reach = data["reach"]
|
||||
|
||||
new_reach = cls(
|
||||
data["reach"], data["study"]
|
||||
data["reach"], data["study"], with_init=False
|
||||
)
|
||||
|
||||
for profile in reach.profiles:
|
||||
for i, profile in enumerate(reach.profiles):
|
||||
data["profile"] = profile
|
||||
new_reach._profiles.append(
|
||||
Profile._db_load(execute, data)
|
||||
)
|
||||
new_reach._profiles += Profile._db_load(execute, data)
|
||||
|
||||
return new_reach
|
||||
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ class River(Graph):
|
|||
self._D90AdisTS = D90AdisTSList(status=self._status)
|
||||
self._DIFAdisTS = DIFAdisTSList(status=self._status)
|
||||
|
||||
self._results = {}
|
||||
self._results = None
|
||||
|
||||
@classmethod
|
||||
def _db_create(cls, execute):
|
||||
|
|
|
|||
|
|
@ -527,3 +527,11 @@ class Study(SQLModel):
|
|||
|
||||
self.status.set_as_editable()
|
||||
return new
|
||||
|
||||
@property
|
||||
def results(self):
|
||||
return self._river._results
|
||||
|
||||
@results.setter
|
||||
def results(self, results):
|
||||
self._river._results = results
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
|||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||
self.find(QAction, "action_import").triggered\
|
||||
.connect(self.import_from_file)
|
||||
.connect(self.import_from_file)
|
||||
|
||||
self.find(QAction, "action_generate_uniform")\
|
||||
.triggered.connect(self.generate_uniform)
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class FrictionsWindow(PamhyrWindow):
|
|||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||
self.find(QAction, "action_import").triggered\
|
||||
.connect(self.import_from_file)
|
||||
.connect(self.import_from_file)
|
||||
self.find(QAction, "action_edit_stricklers").triggered.connect(
|
||||
self.edit_stricklers
|
||||
)
|
||||
|
|
|
|||
|
|
@ -593,6 +593,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
def set_results(self, solver, results):
|
||||
self._last_solver = solver
|
||||
self._last_results = results
|
||||
self._study.results = results
|
||||
|
||||
self.enable_actions("action_menu_results_last", True)
|
||||
|
||||
|
|
@ -1607,6 +1608,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
if self._last_solver is None:
|
||||
return
|
||||
|
||||
if self._study is not None and self._study.results is not None:
|
||||
self._last_results = self._study.results
|
||||
|
||||
if self._last_solver._type == "mage8":
|
||||
self.open_solver_results(self._last_solver,
|
||||
self._last_results)
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class PlotAC(PamhyrPlot):
|
|||
|
||||
self.collection = self.canvas.axes.fill_between(
|
||||
x, z, water_z,
|
||||
where=z <= water_z,
|
||||
where=list(map(lambda x: x <= water_z, z)),
|
||||
color=self.color_plot_river_water_zone,
|
||||
alpha=0.7, interpolate=True
|
||||
)
|
||||
|
|
@ -254,7 +254,7 @@ class PlotAC(PamhyrPlot):
|
|||
self.collection.remove()
|
||||
self.collection = self.canvas.axes.fill_between(
|
||||
x, z, water_z,
|
||||
where=z <= water_z,
|
||||
where=list(map(lambda x: x <= water_z, z)),
|
||||
color=self.color_plot_river_water_zone,
|
||||
alpha=0.7, interpolate=True
|
||||
)
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@ class PlotXY(PamhyrPlot):
|
|||
water_z = profile.get_ts_key(
|
||||
self._current_timestamp, "Z"
|
||||
)
|
||||
|
||||
pt_left, pt_right = profile.get_ts_key(
|
||||
self._current_timestamp,
|
||||
"water_limits"
|
||||
|
|
|
|||
Loading…
Reference in New Issue