Skip to content

Commit 0945797

Browse files
committed
scripts for creating, running, and plotting ensembles of EDMF+1M/2M
1 parent 957694a commit 0945797

File tree

10 files changed

+976
-7
lines changed

10 files changed

+976
-7
lines changed

docs/make.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include(joinpath(@__DIR__, "src", "config_table.jl"))
1010
doctest(ClimaAtmos; plugins = [bib])
1111
disable_logging(Base.CoreLogging.BelowMinLevel) # Re-enable all logging
1212

13-
example_pages = ["Perturbation Experiments" => "perturbation_experiments.md"]
13+
example_pages = ["Perturbation Experiments" => "perturbed_dycoms_rf02.md"]
1414

1515
makedocs(;
1616
plugins = [bib],
@@ -26,7 +26,7 @@ makedocs(;
2626
),
2727
pages = [
2828
"Home" => "index.md",
29-
"Installation instructions" => "installation_instructions.md",
29+
"Installation Instructions" => "installation_instructions.md",
3030
"Contributor Guide" => "contributor_guide.md",
3131
"Equations" => "equations.md",
3232
"EDMF Equations" => "edmf_equations.md",

docs/src/assets/Hoffmann2020.jpg

177 KB
Loading

docs/src/installation_instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Installation instructions
1+
# Installation Instructions
22

33
ClimaAtmos.jl is a [registered Julia package](https://julialang.org/packages/). To install
44

docs/src/perturbation_experiments.md renamed to docs/src/perturbed_dycoms_rf02.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11

2-
# Creating custom arguments for perturbation experiments
2+
# Perturbed Initial Conditions Ensembles
3+
With a bit of setup, ClimaAtmos can be used to run ensembles of perturbed initial conditions. Here, we will use perturbed DYCOMS-RF02 initial conditions to create a spread of simulated marine stratocumulus clouds in a single column configuration with the EDMF scheme and 2-moment microphysics. As an example, we will create something similiar to the figure below (Hoffmann, 2020) using ClimaAtmos.
4+
5+
![](assets/Hoffmann2020.jpg)
6+
7+
# Creating Custom Config Arguments
38
In cases where it is of interest to run ensembles of the same model configuration but with perturbed initial conditions, it may be of use to add new keyword arguments to the .yml file. The idea is to allow modifications to initial conditions to be passed directly through the .yml file and then creating multiple copies of the files but with different variations and combinations of these parameters.
49

510
As an example, we will explore modifying the total water mixing ratio (`q_tot_0`), liquid-ice potential temperature profiles (`theta_0` & `theta_i`), and initial boundary layer height (`z_i`) in the DYCOMS-RF02 simulation setup.
@@ -64,7 +69,7 @@ for IC in (:Dycoms_RF01, :Dycoms_RF02)
6469
end
6570
```
6671

67-
### Add keywords to .yml & Modify default_config.yml
72+
### Add Keywords to .yml & Modify default_config.yml
6873
Now that we have added a new keyword argument to be used in initial conditions, it is time to define the keyword argument in the YAML files responsible for configuring the model runs. In the YAML file for running a DYCOMS-RF02 single column experiment, we add and adjust the following lines:
6974

7075
```
@@ -107,6 +112,47 @@ Finally, we need to update type_getters.jl with our new keyword arguments as wel
107112
[...]
108113
```
109114

110-
With this step complete, we are now ready to pass a new keyword argument that we defined ourselves to modify or change the initial conditions.
115+
With this step complete, we are now ready to pass a new keyword argument that we defined ourselves to modify or change the initial conditions. The scripts currently contained in /examples/perturbed_dycoms_rf02 contain code for running the ensemble as well as post-processing/plotting capabilities.
116+
117+
# Creating & Running Ensembles
118+
All example scripts referenced are stored in examples/perturbed_dycoms_rf02:
119+
120+
```
121+
script_folder = joinpath(pkgdir(CA), "examples", "perturbed_dycoms_rf02")
122+
```
123+
124+
The script `pipeline.jl` handles this entire step without parallelized runs, but the steps can also be performed individually.
125+
126+
The recommended workflow is the create multiple copies of the .yml files and label them according to the initial conditions used. For example, the default file might look like `prognostic_edmfx_dycoms_rf02_column_qtot0_9.45_theta0_288.3_thetai_295.0_zi_795.0_prescribedN_1.0e8.yml`.
127+
128+
We can use `make_yaml.jl` to generate multiple different configurations with ease. To do so, provide the function `make_yamls()` with a default file for which to copy, and an output path. This script uses nested for loops to generate every possible combination of parameters, and they can be altered directly in the file. This might look like:
111129

112-
The recommended workflow is the create multiple copies of the .yml files and label them according to the initial conditions used. For example, the default file might look like `prognostic_edmfx_dycoms_rf02_column_qtot0_6.5_theta0_284.0_thetai_290.0_zi_795.0_prescribedN_1.0e8.yml`.
130+
```
131+
include(joinpath(script_folder, "make_yaml.jl"))
132+
133+
default_data_path = default_prog_2M
134+
output_dir = prognostic_2M_config
135+
make_yamls(default_data_path, output_dir, is_prog=true)
136+
```
137+
138+
To use these configuration files, we can either parallelize or run them serially. If parallelization is desired, run:
139+
140+
```
141+
julia -p <num_processors> ./examples/perturbed_dycoms_rf02/parallel_driver.jl
142+
```
143+
144+
Be sure that the paths, which are handled by `all_paths.jl`, are referring to the right set of simulations. This example focuses in on prognostic EDMF+2M simulations, but the scripts have implementation for diagnostic EDMF as well as 1-moment microphysics as well.
145+
146+
# Visualizing Ensemble Output
147+
After the simulations are done being ran, we can use `process_plot_outputs.jl` to visualize changes in the liquid water path (LWP) and cloud droplet number concentration (N), in order to recreate the figure above.
148+
149+
```
150+
include(joinpath(script_folder, "process_plot_outputs.jl"))
151+
152+
output_dir = "./output" #output_2M
153+
all_outputs = make_edmf_vec(output_dir)
154+
filtered = filter_runs(all_outputs)
155+
# sampled = StatsBase.sample(filtered, 40; replace=false)
156+
157+
fig = plot_edmf(filtered, is_1M=false, is_time=false)
158+
```
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Dependencies
2+
import ClimaAtmos as CA
3+
4+
base_path = joinpath(pkgdir(CA), "LWP_N")
5+
mkpath(base_path)
6+
7+
base_reference_path = joinpath(base_path, "references")
8+
mkpath(base_reference_path)
9+
10+
default_diag_1M = joinpath(
11+
pkgdir(CA),
12+
base_reference_path,
13+
"diagnostic_edmfx_dycoms_rf02_column_1M.yml",
14+
)
15+
default_diag_2M = joinpath(
16+
pkgdir(CA),
17+
base_reference_path,
18+
"diagnostic_edmfx_dycoms_rf02_column_2M.yml",
19+
)
20+
default_prog_1M = joinpath(
21+
pkgdir(CA),
22+
base_reference_path,
23+
"prognostic_edmfx_dycoms_rf02_column_1M.yml",
24+
)
25+
default_prog_2M = joinpath(
26+
pkgdir(CA),
27+
base_reference_path,
28+
"prognostic_edmfx_dycoms_rf02_column_2M.yml",
29+
)
30+
31+
diagnostic_1M_config = joinpath(pkgdir(CA), base_path, "config_diagnostic_1M")
32+
diagnostic_2M_config = joinpath(pkgdir(CA), base_path, "config_diagnostic_2M")
33+
prognostic_1M_config = joinpath(pkgdir(CA), base_path, "config_prognostic_1M")
34+
prognostic_2M_config = joinpath(pkgdir(CA), base_path, "config_prognostic_2M")
35+
36+
mkpath(diagnostic_1M_config)
37+
mkpath(diagnostic_2M_config)
38+
mkpath(prognostic_1M_config)
39+
mkpath(prognostic_2M_config)
40+
41+
output_1M = joinpath(pkgdir(CA), base_path, "output_1M")
42+
output_2M = joinpath(pkgdir(CA), base_path, "output_2M")

0 commit comments

Comments
 (0)