Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate calibration pipeline into atmos #2895

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

nefrathenrici
Copy link
Member

@nefrathenrici nefrathenrici commented Apr 11, 2024

This PR adds the framework for reproducible calibration experiments, starting with one example experiment.

calibration/README.md provides an overview. Most of the actual code is in ClimaCalibrate

Content

calibration/model_interface.jl: Model interface hooks for CalibrateAtmos. This will be used in every atmos calibration.
test/calibration_interface.jl: Basic tests for the model interface file.
calibration/experiments: Folder containing subfolders of calibration experiments. Currently only contains sphere_held_suarez_rhoe_equilmoist

sphere_held_suarez_rhoe_equilmoist/

  • experiment_config.yml: Stores filepaths for calibration artifacts and other configuration data
  • model_config.yml: Atmos yaml config for the calibration
  • pipeline.sbatch: Script to run calibration experiment on central
  • observation_map.jl: Code to process model output into observation space
  • postprocessing.jl: Plotting script
  • prior.toml: Prior distribution file

Comment on lines +15 to +30
file_path = joinpath(member_path, "parameters.toml")
mkpath(dirname(file_path))
touch(file_path)

atmos_config = ClimaCalibrate.set_up_forward_model(1, 1, experiment_dir)
(; parsed_args) = atmos_config

@testset "Atmos Configuration" begin
@test parsed_args["moist"] == "equil"
@test parsed_args["toml"] == [file_path]
@test parsed_args["output_dir"] == member_path
@test parsed_args["restart_file"] ==
"/groups/esm/ClimaArtifacts/artifacts/atmos_held_suarez_obs/day200.0.hdf5"
end

rm(file_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use temporary folders instead of relying on creating a new folder and removing it. The folder will not be cleaned in case of failing tests.

@test parsed_args["toml"] == [file_path]
@test parsed_args["output_dir"] == member_path
@test parsed_args["restart_file"] ==
"/groups/esm/ClimaArtifacts/artifacts/atmos_held_suarez_obs/day200.0.hdf5"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use Artifacts or ClimaArtifacts instead of hardcoding the path.

This test has to be reproducible even outside of the Caltech cluster

@Sbozzolo
Copy link
Member

I am not too familiar with the calibration pipeline, so it will take me a little bit of time to understand and properly review this PR.

YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"

[compat]
ClimaAtmos = "=0.24.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ClimaAtmos is pinned to a specific version, why do we need to have a job in buildkite?

Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
EnsembleKalmanProcesses = "aa8a2aa5-91d8-4396-bcef-d4f2ec43552d"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
NetCDF = "30363a11-5582-574a-97bb-aa9a979735b9"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is NetCDF needed?

Comment on lines +14 to +19
try
G_ensemble[:, m] .= process_member_data(simdir)
catch err
@info "Error during observation map for ensemble member $m" err
G_ensemble[:, m] .= NaN
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you trying to try-catch here?

const config = ExperimentConfig(@__DIR__)
function observation_map(iteration)
(; ensemble_size, output_dir) = config
dims = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe dims can have a more descrpitive name. dims of what?

Comment on lines +27 to +30
ensemble_error += abs(i - theta_star)^2
ensemble_spread += abs(i - ensemble_mean)^2

end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ensemble_error += abs(i - theta_star)^2
ensemble_spread += abs(i - ensemble_mean)^2
end
ensemble_error += abs(i - theta_star)^2
ensemble_spread += abs(i - ensemble_mean)^2
end

Comment on lines +23 to +24
ensemble_error = 0
ensemble_spread = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ensemble_error = 0
ensemble_spread = 0
ensemble_error = 0.0
ensemble_spread = 0.0

set_up_forward_model(member, iteration, experiment_dir::AbstractString)

Returns an AtmosConfig object for the given member and iteration.
If given an experiment id string, it will load the config from the corresponding YAML file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this implemented?

Comment on lines +19 to +23
if haskey(config_dict, "restart_file") &&
!isabspath(config_dict["restart_file"])
config_dict["restart_file"] =
joinpath(experiment_dir, config_dict["restart_file"])
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be handled internally by Atmos?

@Sbozzolo
Copy link
Member

What is the ultimate intent of this PR? Is it to test that things work? To teach people how to do calibration? Other reasons?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants