Skip to content

Commit

Permalink
Append paramater_config from design matrix to existing parameters bef…
Browse files Browse the repository at this point in the history
…ore running experiment
  • Loading branch information
xjules committed Oct 22, 2024
1 parent 1ad1fa0 commit 349abd0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
5 changes: 3 additions & 2 deletions src/ert/enkf_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ def sample_prior(
in the case of GEN_KW we sample the data and store it, and if INIT_FILES
are used without FORWARD_INIT we load files and store them. If FORWARD_INIT
is set the state is set to INITIALIZED, but no parameters are saved to storage
until after the forward model has completed.
until after the forward model has completed. If parameters come from the DESIGN_MATRIX_GROUP
they are handled separately via save_design_matrix_to_ensemble.
"""
random_seed = _seed_sequence(random_seed)
t = time.perf_counter()
Expand All @@ -183,7 +184,7 @@ def sample_prior(
parameters = list(parameter_configs.keys())
for parameter in parameters:
config_node = parameter_configs[parameter]
if config_node.forward_init:
if config_node.forward_init or config_node.name == DESIGN_MATRIX_GROUP:
continue
for realization_nr in active_realizations:
ds = config_node.sample_or_load(
Expand Down
33 changes: 11 additions & 22 deletions src/ert/run_models/ensemble_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def run_experiment(
restart: bool = False,
) -> None:
self.log_at_startup()
# If design matrix is present, we substitute the experiment parameters
# with those in the design matrix
# If design matrix is present, we append design matrix parameters
# to the experiment parameters and set new active realizations
parameters_config = self.ert_config.ensemble_config.parameter_configuration
if self.ert_config.analysis_config.design_matrix is not None:
if (
self.ert_config.analysis_config.design_matrix.parameter_configuration
Expand All @@ -74,18 +75,19 @@ def run_experiment(
self.ert_config.analysis_config.design_matrix.parameter_configuration
is not None
)
parameters_config = [
parameters_config.append(
self.ert_config.analysis_config.design_matrix.parameter_configuration[
DESIGN_MATRIX_GROUP
]
]
)
assert (
self.ert_config.analysis_config.design_matrix.active_realizations
is not None
)
self.active_realizations = (
self.ert_config.analysis_config.design_matrix.active_realizations
)
if not restart:
self.experiment = self._storage.create_experiment(
name=self.experiment_name,
parameters=parameters_config,
Expand All @@ -97,18 +99,6 @@ def run_experiment(
name=self.ensemble_name,
ensemble_size=self.ensemble_size,
)
elif not restart:
self.experiment = self._storage.create_experiment(
name=self.experiment_name,
parameters=self.ert_config.ensemble_config.parameter_configuration,
observations=self.ert_config.observations,
responses=self.ert_config.ensemble_config.response_configuration,
)
self.ensemble = self._storage.create_ensemble(
self.experiment,
name=self.ensemble_name,
ensemble_size=self.ensemble_size,
)
else:
self.active_realizations = self._create_mask_from_failed_realizations()

Expand All @@ -133,12 +123,11 @@ def run_experiment(
self.ensemble,
np.where(self.active_realizations)[0],
)
else:
sample_prior(
self.ensemble,
np.where(self.active_realizations)[0],
random_seed=self.random_seed,
)
sample_prior(
self.ensemble,
np.where(self.active_realizations)[0],
random_seed=self.random_seed,
)

self._evaluate_and_postprocess(
run_args,
Expand Down

0 comments on commit 349abd0

Please sign in to comment.