From 08f9c312dde6dee458818aa75f7f162d3e3e9558 Mon Sep 17 00:00:00 2001 From: nefrathenrici Date: Fri, 21 Jun 2024 15:02:01 -0700 Subject: [PATCH] initialize func without noise input --- src/ekp_interface.jl | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/ekp_interface.jl b/src/ekp_interface.jl index bd1c811e..3c78b1e9 100644 --- a/src/ekp_interface.jl +++ b/src/ekp_interface.jl @@ -214,6 +214,45 @@ initialize(config::ExperimentConfig; kwargs...) = initialize( kwargs..., ) +function initialize( + ensemble_size, + observations, + prior, + output_dir; + rng_seed = 1234, + ekp_kwargs..., +) + Random.seed!(rng_seed) + rng_ekp = Random.MersenneTwister(rng_seed) + + initial_ensemble = + EKP.construct_initial_ensemble(rng_ekp, prior, ensemble_size) + eki = EKP.EnsembleKalmanProcess( + initial_ensemble, + observations, + EKP.Inversion(); + rng = rng_ekp, + failure_handler_method = EKP.SampleSuccGauss(), + ekp_kwargs..., + ) + + param_dict = get_param_dict(prior) + + save_parameter_ensemble( + EKP.get_u_final(eki), # constraints applied when saving + prior, + param_dict, + output_dir, + "parameters.toml", + 0, # Initial iteration = 0 + ) + + # Save the EKI object in the 'iteration_000' folder + eki_path = joinpath(output_dir, "iteration_000", "eki_file.jld2") + JLD2.save_object(eki_path, eki) + return eki +end + function initialize( ensemble_size, observations,