Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nefrathenrici committed Oct 25, 2023
1 parent 659e915 commit d806c1c
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 18 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Simulation outputs and logs
*.png
*.hdf5
output/*
test/test_init/iteration*
*.jld2
*.out

# System-specific files and directories generated by the BinaryProvider and BinDeps packages
Expand Down
6 changes: 3 additions & 3 deletions examples/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.9.3"
manifest_format = "2.0"
project_hash = "b8938cc33d8dc71cf7438a209c304619eed646c3"
project_hash = "6821a0942148031affdbc8ba4d0cdb4edc3c958f"

[[deps.ADTypes]]
git-tree-sha1 = "5d2e21d7b0d8c22f67483ef95ebdc39c0e6b6003"
Expand Down Expand Up @@ -266,9 +266,9 @@ version = "0.5.5"

[[deps.ClimaCore]]
deps = ["Adapt", "BandedMatrices", "BlockArrays", "CUDA", "ClimaComms", "CubedSphere", "DataStructures", "DocStringExtensions", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "LinearAlgebra", "PkgVersion", "RecursiveArrayTools", "Requires", "RootSolvers", "SparseArrays", "Static", "StaticArrays", "Statistics", "UnPack"]
git-tree-sha1 = "8174265fe74081f378b11e36962c3b9cbb11c44f"
git-tree-sha1 = "4a5138604b65cfa2d30b90ddf5252106874940c3"
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
version = "0.10.54"
version = "0.10.55"

[[deps.ClimaTimeSteppers]]
deps = ["CUDA", "ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"]
Expand Down
1 change: 1 addition & 0 deletions examples/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
CLIMAParameters = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"
CalibrateAtmos = "4347a170-ebd6-470c-89d3-5c705c0cacc2"
ClimaAtmos = "b2c96348-7fb7-4fe0-8da9-78d88439e717"
ClimaCore = "d414da3d-4745-48bb-8d80-42e94e092884"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
EnsembleKalmanProcesses = "aa8a2aa5-91d8-4396-bcef-d4f2ec43552d"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
Expand Down
8 changes: 4 additions & 4 deletions examples/driver.sbatch
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export JULIA_LOAD_PATH=":/examples/load_path"
job_id=${1?Error: no job ID given}
echo "Running job: $job_id"

julia --project=examples -e 'using Pkg; Pkg.develop(path="."); \
Pkg.instantiate(;verbose=true)'
julia --project=examples -e 'using Pkg; Pkg.develop(path=".");
Pkg.instantiate(;verbose=true)'

# This is a bit messy - could be file
julia --project=examples -e "import CalibrateAtmos; using Distributions; \
using EnsembleKalmanProcesses.ParameterDistributions; \
julia --project=examples -e "import CalibrateAtmos; using Distributions;
using EnsembleKalmanProcesses.ParameterDistributions;
CalibrateAtmos.initialize(\"$job_id\")"

echo 'Ensemble initialized for calibration.'
Expand Down
2 changes: 1 addition & 1 deletion examples/sphere_held_suarez_rhoe_equilmoist/ekp_config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
output_dir: output/sphere_held_suarez_rhoe_equilmoist
prior_path: examples/sphere_held_suarez_rhoe_equilmoist/prior.toml
parameter_names: ["ΔT_y_wet"]
parameter_names: ["equator_pole_temperature_gradient_wet"]
ensemble_size: 5
n_iterations: 5
obs_mean: examples/sphere_held_suarez_rhoe_equilmoist/truth.jld2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,15 @@ end
function observation_map(iteration, job_id)
config = YAML.load_file("examples/$job_id/ekp_config.yml")
output_dir = config["output_dir"]
# ensemble_size = config["ensemble_size"]
ensemble_size = 1
filename = "ta_60.0d_average.nc"
ensemble_size = config["ensemble_size"]
model_output = "ta_60.0d_average.nc"

dims = (19 - 2)
G_ens = Array{Float32}(undef, dims..., ensemble_size)
G_ens = Array{Float64}(undef, dims..., ensemble_size)
for m in 1:ensemble_size
member_path =
TOMLInterface.path_to_ensemble_member(output_dir, iteration, m)
ta = ncread(joinpath(member_path, filename), "ta")
ta = ncread(joinpath(member_path, model_output), "ta")

# Cut off first 120 days to get equilibrium, take second level slice
level_slice = 2
Expand Down
2 changes: 1 addition & 1 deletion examples/sphere_held_suarez_rhoe_equilmoist/prior.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
["ΔT_y_wet"]
["equator_pole_temperature_gradient_wet"]
prior = "Parameterized(Normal(65,20.0))"
constraint = "[bounded_below(0)]"
type = "float"
Expand Down
Binary file not shown.
5 changes: 3 additions & 2 deletions src/ekp_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function initialize(
output_dir,
"parameters.toml",
0, # Initial iteration = 0
apply_constraints = true,
apply_constraints = false,
)
JLD2.save_object(eki_path, eki)
return nothing
Expand Down Expand Up @@ -110,12 +110,13 @@ function update_ensemble(
prior_vec = [get_parameter_distribution(param_dict, n) for n in names]
prior = combine_distributions(prior_vec)
save_parameter_ensemble(
get_u_final(eki), # constraints applied when saving
EKP.get_u_final(eki), # constraints applied when saving
prior,
param_dict,
output_dir,
"parameters.toml",
iteration,
apply_constraints = false,
)

# Save EKI object for next iteration
Expand Down

0 comments on commit d806c1c

Please sign in to comment.