Skip to content

Commit

Permalink
Move obs_config_file to ErtConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Aug 16, 2024
1 parent ee09626 commit c1ec8e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/ert/config/ert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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())
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/ert/config/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
)

Expand All @@ -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}, "
")"
)

Expand All @@ -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,
]
)
Expand Down

0 comments on commit c1ec8e9

Please sign in to comment.