Skip to content

Commit

Permalink
renamed: ../../ekp_config.yml -> ekp_config.yml
Browse files Browse the repository at this point in the history
modified:   ../../generate_observations.sbatch
modified:   ../../observation_map.jl
  • Loading branch information
akshaysridhar committed Mar 7, 2024
1 parent 1018f51 commit 1368b90
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
File renamed without changes.
3 changes: 2 additions & 1 deletion calibration/generate_observations.sbatch
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ include("coupler_component_init.jl")
include("coupler_driver_calibration.jl");
solve_coupler!(cs); # Integrate the coupled model
ta = ncread(joinpath(output_dir, "", "ta_150s_average.nc"), "ta")
testdir = "/Users/akshaysridhar/Research/Codes/ClimaCoupler.jl/calibration/experiments/amip_coupled/truth_simulation/"
wa = NCDataset(joinpath(testdir, "", "wa_inst.nc"))["wa"]
include(joinpath(experiment_dir, "observation_map.jl"))
(; observation, variance) = process_member_data(ta; output_variance = true)
JLD2.save_object(joinpath(experiment_dir, "obs_mean.jld2"), observation)
Expand Down
34 changes: 34 additions & 0 deletions calibration/observation_map.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
### Place holder for NCEP data from the ClimaCoupler outputs
#

function observation_map(iteration)
experiment_id = "amip_coupled"
config = YAML.load_file(joinpath("experiments", experiment_id, "ekp_config.yml"))
output_dir = config["output_dir"]
ensemble_size = config["ensemble_size"]
model_output = "wa_inst.nc"
dims = 1
G_ensemble = 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, model_output), "wa")
G_ensemble[:, m] = process_member_data(ta)
end
return G_ensemble
end

function process_member_data(wa; output_variance = false)
# Cut off first 120 days to get equilibrium, take second level slice
level_slice = 2
wa_second_height = wa[3:size(wa)[1], :, :, level_slice]
# Average over long and latitude
area_avg_wa_second_height =
longitudinal_avg(latitudinal_avg(wa_second_height))
observation = Float64[area_avg_wa_second_height[3]]
if !(output_variance)
return observation
else
variance = Matrix{Float64}(undef, 1, 1)
variance[1] = var(area_avg_wa_second_height)
return (; observation, variance)
end
end

0 comments on commit 1368b90

Please sign in to comment.