Skip to content

Commit

Permalink
use new apip for adaptive localization
Browse files Browse the repository at this point in the history
  • Loading branch information
Blunde1 committed Nov 30, 2023
1 parent b325e34 commit e6a80b9
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/ert/analysis/_es_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,11 @@ def analysis_ES(
for param_batch_idx in TimedIterator(batches, progress_callback):
X_local = temp_storage[param_group.name][param_batch_idx, :]
D = smoother_adaptive_es.perturb_observations(
size=S.shape, alpha=1.0
ensemble_size=ensemble_size, alpha=1.0
)
temp_storage[param_group.name][
param_batch_idx, :
] = smoother_adaptive_es.adaptive_assimilate(
] = smoother_adaptive_es.assimilate(
X=X_local,
Y=S,
D=D,
Expand Down Expand Up @@ -612,10 +612,14 @@ def analysis_IES(
ens_mask: npt.NDArray[np.bool_],
source_fs: EnsembleReader,
target_fs: EnsembleAccessor,
iterative_ensemble_smoother: ies.SIES,
iterative_ensemble_smoother: Optional[ies.SIES],
progress_callback: Callable[[AnalysisEvent], None],
misfit_process: bool,
) -> None:
# perhaps we should return iterative_ensemble_smoother: ies.SIES object?
# if it is not passed, create it and return
# if it is passed, update with new iteration and return

iens_active_index = np.flatnonzero(ens_mask)

tot_num_params = sum(
Expand All @@ -624,6 +628,8 @@ def analysis_IES(
)
param_groups = list(source_fs.experiment.parameter_configuration.keys())
ensemble_size = ens_mask.sum()

# modify this to always return all parameters
param_ensemble = _param_ensemble_for_projection(
source_fs, iens_active_index, ensemble_size, param_groups, tot_num_params
)
Expand Down Expand Up @@ -655,6 +661,20 @@ def analysis_IES(
)

noise = rng.standard_normal(size=(len(observation_values), S.shape[1]))

if iterative_ensemble_smoother is not None:
iterative_ensemble_smoother = ies.SIES(
parameters=param_ensemble,
covariance=observation_errors**2,
observations=observation_values,
seed=rng,
)

iterative_ensemble_smoother.sies_iteration(
S, step_length,
)

# where is step-length?? perhaps on init outside?
iterative_ensemble_smoother.fit(
S,
observation_errors,
Expand Down

0 comments on commit e6a80b9

Please sign in to comment.