-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
174 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,37 @@ | ||
from pydantic import BaseModel | ||
from typing_extensions import TypedDict | ||
|
||
from .local_ensemble import LocalEnsemble | ||
|
||
|
||
class EverestRealizationInfo(TypedDict): | ||
geo_realization: int | ||
perturbation: int | None # None means it stems from unperturbed controls | ||
# Q: Maybe we also need result ID, or no? Ref if we have multiple evaluations | ||
# for unperturbed values, though the ERT real id will also differentiate them | ||
|
||
|
||
class _Index(BaseModel): | ||
ert2ev_realization_mapping: dict[int, EverestRealizationInfo] | None = None | ||
|
||
|
||
class EverestEnsemble: | ||
def __init__(self, ert_ensemble: LocalEnsemble): | ||
self._ert_ensemble = ert_ensemble | ||
self._index = _Index() | ||
|
||
@property | ||
def ert_ensemble(self) -> LocalEnsemble: | ||
return self._ert_ensemble | ||
|
||
def save_realization_mapping( | ||
self, realization_mapping: dict[int, EverestRealizationInfo] | ||
): | ||
self._index.ert2ev_realization_mapping = realization_mapping | ||
self._ert_ensemble._storage._write_transaction( | ||
self.ert_ensemble._path / "everest_index.json", | ||
self._index.model_dump_json().encode("utf-8"), | ||
) | ||
self._index = _Index.model_validate_json( | ||
(self.ert_ensemble._path / "everest_index.json").read_text(encoding="utf-8") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters