-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from CliMA/ln/sf-test
Add a perfect model example using SurfaceFluxes.jl
- Loading branch information
Showing
33 changed files
with
3,919 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
# Getting Started | ||
|
||
Before you run, make sure your system meets the dependencies of [CalibrateEmulateSample.jl](https://clima.github.io/CalibrateEmulateSample.jl/dev/installation_instructions/). TODO: remove if workaround | ||
|
||
## HPC Cluster | ||
A good way to get started is to run the initial experiment, `sphere_held_suarez_rhoe_equilmoist`. | ||
It is a perfect-model calibration, serving as a test case for the initial pipeline. | ||
|
||
This experiment runs the Held-Suarez configuration, estimating the parameter `equator_pole_temperature_gradient_wet`. | ||
By default, it runs 10 ensemble members for 3 iterations. | ||
By default, it runs 10 ensemble members for 3 iterations. | ||
|
||
To run this experiment: | ||
1. Log onto the Caltech HPC | ||
2. Clone CalibrateAtmos.jl and `cd` into the repository. | ||
3. Run: `bash experiments/pipeline.sh sphere_held_suarez_rhoe_equilmoist 8`. This will run the `sphere_held_suarez_rhoe_equilmoist` experiment with 8 tasks per ensemble member. | ||
|
||
## Local Machine | ||
To run an experiment on your local machine, you can use the `experiments/pipeline.jl` script. This is recommended for more lightweight experiments, such as the `surface_fluxes_perfect_model` experiment, which uses the [SurfaceFluxes.jl](https://github.com/CliMA/SurfaceFluxes.jl) package to generate a physical model that calculates the Monin Obukhov turbulent surface fluxes based on idealized atmospheric and surface conditions. Since this is a "perfect model" example, the same model is used to generate synthetic observations using its default parameters and a small amount of noise. These synthetic observations are considered to be the ground truth, which is used to assess the model ensembles' performance when parameters are drawn from the prior parameter distributions. To run this experiment, you can use the following command from terminal to run an interactive run: | ||
|
||
```bash | ||
julia -i experiments/pipeline.jl surface_fluxes_perfect_model | ||
``` | ||
|
||
This pipeline mirrors the pipeline of the bash srcipts, and the same example can be run on the HPC cluster if needed: | ||
|
||
```bash | ||
bash experiments/pipeline.sh surface_fluxes_perfect_model 8 | ||
``` | ||
|
||
The experiments (such as `surface_fluxes_perfect_model`) can be equally defined within the component model repos (in this case, `SurfaceFluxes.jl`), so that the internals of `CalibrateAtmos.jl` do not explicitly depend on component models. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# experiment-specific Project.toml instantiation, function extensions and config load | ||
|
||
using Pkg | ||
experiment_id = ARGS[1] | ||
Pkg.activate("experiments/$experiment_id") | ||
Pkg.instantiate() | ||
using CalibrateAtmos | ||
pkg_dir = pkgdir(CalibrateAtmos) | ||
experiment_path = "$pkg_dir/experiments/$experiment_id" | ||
include("$experiment_path/model_interface.jl") | ||
include("$experiment_path/generate_truth.jl") | ||
ekp_config = | ||
YAML.load_file(joinpath("experiments", experiment_id, "ekp_config.yml")) | ||
|
||
# initialize the CalibrateAtmos | ||
CalibrateAtmos.initialize(experiment_id) | ||
|
||
# run experiment with CalibrateAtmos for N_iter iterations | ||
N_iter = ekp_config["n_iterations"] | ||
N_mem = ekp_config["ensemble_size"] | ||
for i in 0:(N_iter - 1) | ||
# run G model to produce output from N_mem ensemble members | ||
physical_model = | ||
CalibrateAtmos.get_forward_model(Val(Symbol(experiment_id))) | ||
|
||
for m in 1:N_mem # TODO: parallelize with threads! | ||
# model run for each ensemble member | ||
model_config = | ||
CalibrateAtmos.get_config(physical_model, m, i, experiment_id) | ||
CalibrateAtmos.run_forward_model(physical_model, model_config) | ||
@info "Finished model run for member $m at iteration $i" | ||
end | ||
|
||
# update EKP with the ensemble output and update calibrated parameters | ||
G_ensemble = CalibrateAtmos.observation_map(Val(Symbol(experiment_id)), i) | ||
output_dir = ekp_config["output_dir"] | ||
iter_path = CalibrateAtmos.path_to_iteration(output_dir, i) | ||
JLD2.save_object(joinpath(iter_path, "observation_map.jld2"), G_ensemble) | ||
CalibrateAtmos.update_ensemble(experiment_id, i) | ||
|
||
end | ||
|
||
include("$pkg_dir/plot/convergence_$experiment_id.jl") |
Oops, something went wrong.