Skip to content

Commit

Permalink
Enable load results manually from any available iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSava committed Sep 25, 2024
1 parent 535e314 commit 0a92a82
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/ert/gui/tools/load_results/load_results_panel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

from pathlib import Path

from qtpy.QtCore import Qt, Signal
from qtpy.QtWidgets import QFormLayout, QMessageBox, QTextEdit, QWidget

Expand Down Expand Up @@ -63,7 +65,8 @@ def __init__(self, facade: LibresFacade, notifier: ErtNotifier):
self._iterations_model, # type: ignore
"load_results_manually/iterations",
)
self._iterations_field.setValidator(IntegerArgument(from_value=0))

self._iterations_field.setValidator(self._iter_validator)
self._iterations_field.setObjectName("iterations_field_lrm")
layout.addRow("Iteration to load:", self._iterations_field)

Expand All @@ -76,6 +79,14 @@ def __init__(self, facade: LibresFacade, notifier: ErtNotifier):

self.setLayout(layout)

@property
def _iter_validator(self) -> IntegerArgument:
cur_run_path = self.readCurrentRunPath().replace("<IENS>", "0")
curent_iter = 0
while Path(cur_run_path.replace("<ITER>", str(curent_iter))).exists():
curent_iter += 1
return IntegerArgument(from_value=0, to_value=curent_iter - 1)

def readCurrentRunPath(self) -> str:
current_ensemble = self._notifier.current_ensemble_name
run_path = self._facade.run_path
Expand Down
1 change: 1 addition & 0 deletions src/ert/libres_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def load_from_forward_model(
),
realisations,
ensemble=ensemble,
iteration=iteration,
)
nr_loaded = self._load_from_run_path(
self.config.model_config.num_realizations,
Expand Down
4 changes: 3 additions & 1 deletion src/ert/run_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ def create_run_arguments(
runpaths: Runpaths,
active_realizations: Union[List[bool], npt.NDArray[np.bool_]],
ensemble: Ensemble,
iteration: Optional[int] = None,
) -> List[RunArg]:
iteration = ensemble.iteration
if iteration is None:
iteration = ensemble.iteration
run_args = []
runpaths.set_ert_ensemble(ensemble.name)
paths = runpaths.get_paths(range(len(active_realizations)), iteration)
Expand Down

0 comments on commit 0a92a82

Please sign in to comment.