Skip to content

Commit

Permalink
Simplify EKP config slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
nefrathenrici committed Feb 26, 2024
1 parent e5f13e7 commit 929cac9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
2 changes: 0 additions & 2 deletions docs/src/experiment_setup_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,13 @@ The EKP configuration file must contain the following:
- `n_iterations`, the number of iterations to run
- `ensemble_size`, the ensemble size
- `prior_path`, the path to the TOML file with the prior parameter distributions
- `parameter_names`, a list of the long names of the parameters being calibrated
- `truth_data`, the truth data
- `truth_noise`, the covariance of the truth data
- `output_dir`, the folder where you want calibration data and logs to be output. This must be the same as the `output_dir` in the model configuration file.
Example:
```
output_dir: output/sphere_held_suarez_rhoe_equilmoist
prior_path: experiments/sphere_held_suarez_rhoe_equilmoist/prior.toml
parameter_names: ["equator_pole_temperature_gradient_wet"]
ensemble_size: 10
n_iterations: 3
truth_data: experiments/sphere_held_suarez_rhoe_equilmoist/obs_mean.jld2
Expand Down
3 changes: 1 addition & 2 deletions src/atmos_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ Turns off default diagnostics and sets the TOML parameter file to the member's p
This assumes that the config dictionary has `output_dir` and `restart_file` keys.
"""
function get_atmos_config(member, iteration, config_dict::AbstractDict)
# Specify member path for output_dir
# Set TOML to use EKP parameter(s)
# Specify member path for output_dir and set TOML to use EKP parameter(s)
output_dir = config_dict["output_dir"]
member_path =
EKP.TOMLInterface.path_to_ensemble_member(output_dir, iteration, member)
Expand Down
13 changes: 3 additions & 10 deletions src/ekp_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,11 @@ function initialize(
rng_ekp = Random.MersenneTwister(rng_seed)

output_dir = config["output_dir"]
prior_path = config["prior_path"]
param_names = config["parameter_names"]
ensemble_size = config["ensemble_size"]
# Save in EKI object in iteration_000 folder
eki_path = joinpath(output_dir, "iteration_000", "eki_file.jld2")

param_dict = TOML.parsefile(prior_path)
prior_vec = [get_parameter_distribution(param_dict, n) for n in param_names]
prior = combine_distributions(prior_vec)
prior = get_prior(config["prior_path"])

initial_ensemble =
EKP.construct_initial_ensemble(rng_ekp, prior, ensemble_size)
Expand Down Expand Up @@ -100,7 +96,6 @@ function update_ensemble(
config = YAML.load_file("experiments/$experiment_id/ekp_config.yml"),
)
output_dir = config["output_dir"]
names = config["parameter_names"]
# Load EKI object from iteration folder
iter_path = path_to_iteration(output_dir, iteration)
eki_path = joinpath(iter_path, "eki_file.jld2")
Expand All @@ -114,10 +109,8 @@ function update_ensemble(
iteration += 1

# Update and save parameters for next iteration
prior_path = config["prior_path"]
param_dict = TOML.parsefile(prior_path)
prior_vec = [get_parameter_distribution(param_dict, n) for n in names]
prior = combine_distributions(prior_vec)
prior = get_prior(config["prior_path"])

save_parameter_ensemble(
EKP.get_u_final(eki), # constraints applied when saving
prior,
Expand Down
1 change: 0 additions & 1 deletion test/test_init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ param_names = ["one", "two"]
config = Dict(
"output_dir" => output_dir,
"prior_path" => prior_path,
"parameter_names" => param_names,
"ensemble_size" => 10,
)
Γ = 0.1 * I
Expand Down

0 comments on commit 929cac9

Please sign in to comment.