From c1ec8e9d7ac52bcbed58777003b3bc671d9b025a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eide?= Date: Fri, 16 Aug 2024 14:11:44 +0200 Subject: [PATCH] Move obs_config_file to ErtConfig --- src/ert/config/ert_config.py | 7 ++++--- src/ert/config/model_config.py | 4 ---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/ert/config/ert_config.py b/src/ert/config/ert_config.py index 74eae7ae062..f220f6dfa67 100644 --- a/src/ert/config/ert_config.py +++ b/src/ert/config/ert_config.py @@ -106,6 +106,7 @@ class ErtConfig: model_config: ModelConfig = field(default_factory=ModelConfig) user_config_file: str = "no_config" config_path: str = field(init=False) + obs_config_file: Optional[str] = None def __eq__(self, other: object) -> bool: if not isinstance(other, ErtConfig): @@ -119,7 +120,7 @@ def __post_init__(self) -> None: if self.user_config_file else os.getcwd() ) - self.enkf_obs: EnkfObs = self._create_observations() + self.enkf_obs: EnkfObs = self._create_observations(self.obs_config_file) if len(self.summary_keys) != 0: self.ensemble_config.addNode(self._create_summary_config()) @@ -267,6 +268,7 @@ def from_dict(cls, config_dict) -> Self: ), model_config=model_config, user_config_file=config_file_path, + obs_config_file=config_dict.get(ConfigKeys.OBS_CONFIG), ) @classmethod @@ -890,9 +892,8 @@ def _create_summary_config(self) -> SummaryConfig: refcase=time_map, ) - def _create_observations(self) -> EnkfObs: + def _create_observations(self, obs_config_file: str) -> EnkfObs: obs_vectors: Dict[str, ObsVector] = {} - obs_config_file = self.model_config.obs_config_file obs_time_list: Sequence[datetime] = [] if self.ensemble_config.refcase is not None: obs_time_list = self.ensemble_config.refcase.all_dates diff --git a/src/ert/config/model_config.py b/src/ert/config/model_config.py index 07663ba8992..16349ff8cc8 100644 --- a/src/ert/config/model_config.py +++ b/src/ert/config/model_config.py @@ -46,7 +46,6 @@ class ModelConfig: jobname_format_string: str = DEFAULT_JOBNAME_FORMAT eclbase_format_string: str = DEFAULT_ECLBASE_FORMAT gen_kw_export_name: str = DEFAULT_GEN_KW_EXPORT_NAME - obs_config_file: Optional[str] = None time_map: Optional[List[datetime]] = None @field_validator("runpath_format_string", mode="before") @@ -127,7 +126,6 @@ def from_dict(cls, config_dict: ConfigDict) -> "ModelConfig": gen_kw_export_name=config_dict.get( ConfigKeys.GEN_KW_EXPORT_NAME, DEFAULT_GEN_KW_EXPORT_NAME ), - obs_config_file=config_dict.get(ConfigKeys.OBS_CONFIG), time_map=time_map, ) @@ -140,7 +138,6 @@ def __repr__(self) -> str: f"jobname_format_string={self.jobname_format_string}, " f"eclbase_format_string={self.eclbase_format_string}, " f"gen_kw_export_name={self.gen_kw_export_name}, " - f"obs_config_file={self.obs_config_file}, " ")" ) @@ -158,7 +155,6 @@ def __eq__(self, other: object) -> bool: self.jobname_format_string == other.jobname_format_string, self.eclbase_format_string == other.eclbase_format_string, self.gen_kw_export_name == other.gen_kw_export_name, - self.obs_config_file == other.obs_config_file, self.time_map == other.time_map, ] )