Skip to content

Commit e006d12

Browse files
authored
Merge pull request #1267 from CliMA/js/eh-tut
Add simple standalone EnergyHydrology, Canopy tutorials
2 parents f5405e4 + 8bedd9c commit e006d12

21 files changed

+325
-126
lines changed

.buildkite/pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ steps:
117117
agents:
118118
slurm_ntasks_per_node: 4
119119
slurm_nodes: 1
120-
slurm_mem: 16G
120+
slurm_mem: 24G
121121

122122
- label: "Canopy Implicit Stepping CPU"
123123
command: "julia --color=yes --project=.buildkite experiments/standalone/Vegetation/timestep_test.jl"

README.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ component) or standalone (single component) modes. </strong>
2424
# Introduction
2525

2626
This is the repository of the CliMA land model code. Here are some notable features:
27-
- ClimaLand has a modular design, models can be run as standalone (e.g., soil moisture only) or integrated (e.g., soil moisture and energy AND canopy AND snow, etc.)
27+
- ClimaLand has a modular design, models can be run as standalone (e.g., soil moisture/energy only) or integrated (e.g., soil moisture/energy AND canopy AND snow, etc.)
2828
- ClimaLand can simulate single columns, regional boxes, and global runs
2929
- ClimaLand is CPU and GPU compatible
30-
- ClimaLand welcome contributions: please feel free to reach out to us with questions about how to get started, create a branch, and extend our code. For example, a modeler might want to test a new stomatal conductance model.
31-
- ClimaLand provides APIs and UIs at multiple levels.
30+
- ClimaLand welcomes contributions! Please feel free to reach out to us with questions about how to get started, create a branch, and extend our code.
3231

3332
## Installation
3433

@@ -40,36 +39,31 @@ julia> using Pkg
4039
julia> Pkg.add(ClimaLand)
4140
```
4241

43-
Which is equivalent to doing
44-
45-
```Julia
46-
julia> ] # typing the ] key with go into package REPL mode
47-
pkg> add ClimaLand
48-
```
49-
50-
You are now ready to use `ClimaLand.jl`. To get started, we recommend reading the [documentation](https://clima.github.io/ClimaLand.jl/dev/).
42+
You are now ready to use `ClimaLand.jl`.
43+
To run a simple first simulation, please see our documentation page [Running your first simulation](https://clima.github.io/ClimaLand.jl/stable/getting_started/).
5144

5245
## Models
5346

5447
In our code base, a "model" define a set of prognostic variables which must be timestepped. The equations which govern the time evolution likely contain parameters and are informed by parameterization and physical domain choices. Any ClimaLand model contains all of the information needed to evaluate these equations. Below are the current models we support:
5548

5649
<strong> Component Models: </strong>
5750

58-
- RichardsModel <: AbstractSoilModel <: AbstractModel (runnable only in standalone mode)
51+
- `RichardsModel`: Soil model option; runnable only in standalone mode
5952

60-
- EnergyHydrologyModel <: AbstractSoilModel <: AbstractModel (runnable in standalone mode, or as part of a land model)
53+
- `EnergyHydrology`: Soil model option; runnable in standalone mode, or as part of an integrated model
6154

62-
- CanopyModel <: AbstractVegetationModel <: AbstractModel (runnable in standalone mode, or as part of a land model)
55+
- `CanopyModel`: runnable in standalone mode, or as part of an integrated model
6356

64-
- SnowModel <: AbstractSnowModel <: AbstractModel (runnable in standalone mode, or as part of a land model)
57+
- `SnowModel`: runnable in standalone mode, or as part of an integrated model
6558

6659
<strong> Combined Models: </strong>
6760

68-
- SoilCanopyModel <: AbstractLandModel <: AbstractModel (an example of a land model, made of individual component models which are solved simultaneously but taking into account interactions between the components)
61+
- `SoilCanopyModel`: an integrated model made of individual component models `EnergyHydrology` + `CanopyModel`
62+
- `LandModel`: an integrated model made of individual component models `EnergyHydrology` + `CanopyModel` + `SnowModel` + `SoilCO2Model`
6963

7064
## Notes
7165

72-
Recommended Julia Version: Stable release v1.11.1. CI tests Julia v1.10 and 1.11.
66+
Recommended Julia Version: Stable release v1.11.x. CI tests Julia v1.10 and 1.11.
7367

7468
ClimaLand.jl is a different model from the original CliMA Land,
7569
which aims to utilize remote sensing data through more complex canopy RT

docs/list_tutorials.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ tutorials = [
1616
"Changing soil parameterizations" => "standalone/Soil/changing_soil_parameterizations.jl",
1717
],
1818
"Canopy" => [
19+
"Default Canopy" => "standalone/Canopy/default_canopy.jl",
1920
"Standalone Canopy" => "standalone/Canopy/canopy_tutorial.jl",
2021
"Changing canopy parameterizations" => "standalone/Canopy/changing_canopy_parameterizations.jl",
2122
],

docs/src/architectures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Below, we have descriptions for how to specify the context when trying to run a
2020
simulation in different setups. There are two ways to do this: internally within a
2121
script/REPL, or in the terminal via environment variables.
2222

23-
For more detailed information, please see the ClimaComms.jl [documentation](https://clima.github.io/ClimaComms.jl/dev/).
23+
For more detailed information, please see the ClimaComms.jl [documentation](https://clima.github.io/ClimaComms.jl/stable/).
2424

2525
## Choosing the architecture within a script/REPL
2626

docs/src/calibration.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ EKP.jl is possible, CliMA's preferred approach is using
4343
optimized for running on compute clusters. `ClimaCalibrate` handles efficient
4444
job orchestration and abstracts the details of the underlying system, providing
4545
a simpler user experience. Consult the
46-
[ClimaCalibrate documentation](https://clima.github.io/ClimaCalibrate.jl/dev/)
46+
[ClimaCalibrate documentation](https://clima.github.io/ClimaCalibrate.jl/stable/)
4747
for further information.
4848

4949
## Calibrate a land model
@@ -98,20 +98,20 @@ target plus or minus the noise at specific space and time, the goal is reached.
9898
- `TransformUnscented.Unscented` is a method in EKP, that requires `2p + 1`
9999
ensemble members for each iteration, where `p` is the number of parameters.
100100
For more information, read the
101-
[EKP documentation for that method](https://clima.github.io/EnsembleKalmanProcesses.jl/dev/unscented_kalman_inversion/).
101+
[EKP documentation for that method](https://clima.github.io/EnsembleKalmanProcesses.jl/stable/unscented_kalman_inversion/).
102102

103103
- `verbose = true` is a setting that writes information about your calibration
104104
run to a log file.
105105

106106
- `rng` is a set random seed.
107107

108108
- `Scheduler` is a EKP setting for timestepping, please read
109-
[EKP schedulers documentation](https://clima.github.io/EnsembleKalmanProcesses.jl/dev/learning_rate_scheduler/).
109+
[EKP schedulers documentation](https://clima.github.io/EnsembleKalmanProcesses.jl/stable/learning_rate_scheduler/).
110110

111111
- `ClimaCalibrate.WorkerBackend` defines how to interact with the underlying
112112
compute system. For other possible backends (for example, `JuliaBackend`,
113113
`ClimaGPUBackend`, or `DerechoBackend`), see the
114-
[backend documentation in ClimaCalibrate](https://clima.github.io/ClimaCalibrate.jl/dev/backends/).
114+
[backend documentation in ClimaCalibrate](https://clima.github.io/ClimaCalibrate.jl/stable/backends/).
115115

116116
Each backend is optimized for specific use cases and computing resources. The
117117
backend system is implemented through Julia's multiple dispatch, so that code
@@ -126,7 +126,7 @@ prior_sc = EKP.constrained_gaussian("sc", 5e-6, 5e-4, 0, Inf);
126126
prior_pc = EKP.constrained_gaussian("pc", -2e6, 1e6, -Inf, Inf);
127127
prior = EKP.combine_distributions([prior_sc, prior_pc]);
128128
```
129-
For more documentation about prior distribution, see [this EKP documentation page](https://clima.github.io/EnsembleKalmanProcesses.jl/dev/parameter_distributions/).
129+
For more documentation about prior distribution, see [this EKP documentation page](https://clima.github.io/EnsembleKalmanProcesses.jl/stable/parameter_distributions/).
130130

131131
- `n_iterations` is the number of times your priors distribution will be
132132
updated, at each iteration your model is run for the number of
@@ -323,7 +323,7 @@ For the land calibration, the default optimization method is
323323
scheduler, you need to go to the `experiments/calibration/run_calibration.jl`
324324
file and modify it there. For more information about the different optimization
325325
methods, see
326-
[EnsembleKalmanProcesses.jl](https://clima.github.io/EnsembleKalmanProcesses.jl/dev/)
326+
[EnsembleKalmanProcesses.jl](https://clima.github.io/EnsembleKalmanProcesses.jl/stable/)
327327
for more information.
328328

329329
### Observation settings
@@ -359,14 +359,14 @@ over a particular year or over multiple years for example.
359359

360360
To change the covariance matrix, you need to go to `generate_observations.jl`
361361
and modify the covariance matrix that is passed in. See
362-
[ClimaCalibrate.jl documentation](https://clima.github.io/ClimaCalibrate.jl/dev/api/#Observation-Recipe-Interface)
362+
[ClimaCalibrate.jl documentation](https://clima.github.io/ClimaCalibrate.jl/stable/api/#Observation-Recipe-Interface)
363363
for a list of different covariance matrices that can be used.
364364

365365
#### Data pipelines
366366

367367
!!! note "Data preprocessing"
368368
The data preprocessing uses ClimaAnalysis.jl. See the
369-
[ClimaAnalysis.jl documentation](https://clima.github.io/ClimaAnalysis.jl/dev/api/)
369+
[ClimaAnalysis.jl documentation](https://clima.github.io/ClimaAnalysis.jl/stable/api/)
370370
for functions you can use for preprocessing.
371371

372372
To add additional variables or change how a variable is preprocessed, you must

docs/src/getting_started.md

Lines changed: 93 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,119 @@
1-
# Getting Started
2-
31
## Installation of Julia and ClimaLand
42

53
ClimaLand is provided as a Julia package, so it requires having Julia installed. Information about Julia packages is available on the [Julia website](https://julialang.org/packages/).
64

75
First, download and install Julia by following the instructions at [https://julialang.org/downloads/](https://julialang.org/downloads/).
8-
Then, you can launch a [Julia REPL](https://docs.julialang.org/en/v1/stdlib/REPL/) and install the
9-
ClimaLand.jl package by running:
6+
Then, you can launch a [Julia REPL](https://docs.julialang.org/en/v1/stdlib/REPL/) by running `julia --project` and install the
7+
ClimaLand.jl package by running the following within the REPL:
108

119
```julia
12-
julia> using Pkg
13-
julia> Pkg.add(ClimaLand)
14-
julia> using ClimaLand
10+
using Pkg
11+
Pkg.add(ClimaLand)
1512
```
1613

17-
A typical land simulation employs several different parameterizations to model the various land-surface processes. Let's start our journey into ClimaLand by looking at one of those.
18-
19-
### Parameterization
14+
## Running a simple soil model
2015

21-
Let's start with a basic example: compute canopy gross photosynthesis (GPP).
16+
Now that we have Julia installed, let's set up and run a simple ClimaLand simulation!
17+
You can follow along by copying the following code segments into your REPL.
2218

23-
```@repl
19+
First we import the necessary Julia packages:
20+
```julia
21+
import ClimaParams as CP
2422
using ClimaLand
25-
@doc ClimaLand.Canopy.compute_GPP
23+
using ClimaLand.Domains
24+
using ClimaLand.Soil
25+
import ClimaLand.Simulations: LandSimulation, solve!
26+
import ClimaLand.Parameters as LP
27+
using Dates
2628
```
2729

28-
As you can see, our parameterization for GPP is located in the [`Canopy`](@ref Photosynthesis) Module, and requires four arguments.
29-
For example, with An = 5 µmol m⁻² s⁻¹, K = 0.5, LAI = 3 m² m⁻², Ω = 0.7, you can compute GPP like below:
30-
31-
```@repl
32-
import ClimaLand.Canopy as canopy
33-
canopy.compute_GPP(5.0, 0.5, 3.0, 0.7)
30+
Choose a floating point precision, and get the parameter set, which holds constants used across CliMA models.
31+
Note: we use SI units unless otherwise specified.
32+
See our [Physical Units](https://clima.github.io/ClimaLand.jl/stable/physical_units/) documentation for more information.
33+
```julia
34+
FT = Float32
35+
earth_param_set = LP.LandParameters(FT);
3436
```
3537

36-
Et voilà!
38+
We will run this simulation on a column domain with 1 meter depth, at a lat/lon location
39+
near Pasadena, California.
3740

38-
Note that our package [ParamViz](https://github.com/CliMA/ParamViz.jl) allows interactive visualisation of
39-
our parameterizations. See examples in the standalone models pages.
41+
```julia
42+
zmax = FT(0)
43+
zmin = FT(-1.0)
44+
longlat = FT.((34.1, -118.1))
45+
domain = Domains.Column(; zlim = (zmin, zmax), nelements = 10, longlat);
46+
surface_space = domain.space.surface;
47+
```
4048

41-
### ClimaLand structure
49+
We choose the initial and final simulation times as `DateTime`s, and a timestep in seconds.
50+
```julia
51+
start_date = DateTime(2008);
52+
end_date = start_date + Second(60 * 60 * 72);
53+
dt = 1000.0;
54+
```
4255

43-
ClimaLand contains multiple modules. They are listed below:
56+
The soil model takes in 2 forcing objects, atmosphere and radiation,
57+
which we read in from ERA5 data.
58+
```julia
59+
era5_ncdata_path =
60+
ClimaLand.Artifacts.era5_land_forcing_data2008_path(; lowres = true);
61+
atmos, radiation = ClimaLand.prescribed_forcing_era5(
62+
era5_ncdata_path,
63+
surface_space,
64+
start_date,
65+
earth_param_set,
66+
FT,
67+
);
68+
```
4469

45-
```@repl
46-
using MethodAnalysis, ClimaLand
47-
child_modules(ClimaLand)
70+
Now, we can create the [`EnergyHydrology`](@ref ClimaLand.Soil.EnergyHydrology) model.
71+
This constructor uses default parameters and parameterizations, but these can also be
72+
overwritten, which we'll demonstrate in later tutorials.
73+
```julia
74+
model = Soil.EnergyHydrology{FT}(
75+
domain,
76+
(; atmos, radiation),
77+
earth_param_set,
78+
);
4879
```
4980

50-
To explore what modules, functions and types are exported in a particular module, you can use [About.jl](https://github.com/tecosaur/About.jl):
81+
Define a function to set initial conditions for the prognostic variables.
82+
```julia
83+
function set_ic!(Y, p, t0, model)
84+
Y.soil.ϑ_l .= FT(0.24);
85+
Y.soil.θ_i .= FT(0.0);
86+
T = FT(290.15);
87+
ρc_s = Soil.volumetric_heat_capacity.(
88+
Y.soil.ϑ_l,
89+
Y.soil.θ_i,
90+
model.parameters.ρc_ds,
91+
model.parameters.earth_param_set,
92+
);
93+
Y.soil.ρe_int .=
94+
Soil.volumetric_internal_energy.(
95+
Y.soil.θ_i,
96+
ρc_s,
97+
T,
98+
model.parameters.earth_param_set,
99+
);
100+
end
101+
```
51102

52-
```@repl
53-
using ClimaLand
54-
using About
55-
about(ClimaLand.Soil.Biogeochemistry)
103+
Now construct the `LandSimulation` object, which contains the model
104+
and additional timestepping information.
105+
```julia
106+
simulation = LandSimulation(start_date, end_date, dt, model; set_ic!, user_callbacks = ());
107+
```
108+
109+
Now we can run the simulation!
110+
```julia
111+
solve!(simulation);
56112
```
57113

58-
Where modules are shown in red, functions are shown in blue, and types are shown in yellow.
114+
That's it! For more complex examples and pretty plots,
115+
please see the tutorial section of our docs.
59116

60-
To see the documentation about a particular module, function or type, you can use ? to go in help mode
61-
in the REPL, or `@doc` as in [Parameterization above](#Parameterization).
117+
Atmospheric forcing data citation:
118+
Hersbach, Hans, et al. "The ERA5 global reanalysis."
119+
Quarterly journal of the royal meteorological society 146.730 (2020): 1999-2049.

docs/src/itime.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
`ITime`, or _integer time_, is a time type used by CliMA simulations to keep
44
track of simulation time. For more information, refer to the
5-
[TimeManager section](https://clima.github.io/ClimaUtilities.jl/dev/timemanager/)
5+
[TimeManager section](https://clima.github.io/ClimaUtilities.jl/stable/timemanager/)
66
in ClimaUtilities and the
7-
[ITime section](https://clima.github.io/ClimaAtmos.jl/dev/itime/) in ClimaAtmos.
7+
[ITime section](https://clima.github.io/ClimaAtmos.jl/stable/itime/) in ClimaAtmos.
88

99
### How do I use ITime?
1010

@@ -70,7 +70,7 @@ chosen for the `ITime`.
7070
If no period is provided, then the constructor for `ITime` will assume the
7171
provided value is in seconds and choose a reasonable value for the period.
7272
See
73-
[TimeManager section](https://clima.github.io/ClimaUtilities.jl/dev/timemanager/)
73+
[TimeManager section](https://clima.github.io/ClimaUtilities.jl/stable/timemanager/)
7474
in ClimaUtilities for more information.
7575

7676
Next, the different types of `dt1`, `dt2`, and `dt3` can lead to problems as

docs/src/leaderboard/leaderboard.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ modified to add a new variable to the leaderboard. The dictionaries are `sim_var
2323

2424
To add a variable for the leaderboard, add a key-value pair to the dictionary `sim_var_dict`
2525
whose key is the short name of the variable and the value is a function that returns a
26-
[`OutputVar`](https://clima.github.io/ClimaAnalysis.jl/dev/var/). Any preprocessing is done
26+
[`OutputVar`](https://clima.github.io/ClimaAnalysis.jl/stable/var/). Any preprocessing is done
2727
in the function which includes unit conversion and shifting the dates.
2828

2929
```julia

docs/src/tutorials/calibration/minimal_working_example.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ ensemble_kalman_process = EKP.EnsembleKalmanProcess(
7676
# We are now ready to carry out the inversion. At each iteration, we get the ensemble from the last iteration, apply
7777
# Ozark_LatentHeatFlux(params) to each ensemble member, and apply the Kalman update to the ensemble.
7878

79-
# Can be multithreaded, see https://clima.github.io/EnsembleKalmanProcesses.jl/dev/parallel_hpc/
79+
# Can be multithreaded, see https://clima.github.io/EnsembleKalmanProcesses.jl/stable/parallel_hpc/
8080
ClimaLand_out = []
8181
for i in 1:N_iterations # This will run the model N_ensemble * N_iterations times
8282
params_i = EKP.get_ϕ_final(prior, ensemble_kalman_process)

docs/src/tutorials/integrated/snowy_land_fluxnet_tutorial.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ LAI = ClimaLand.prescribed_lai_modis(
8686
# # Setup the integrated model
8787

8888
# We want to simulate the canopy-soil-snow system together, so the model type
89-
# [`LandModel`](https://clima.github.io/ClimaLand.jl/dev/APIs/ClimaLand/#Integrated-Land-Model-Types-and-methods)
89+
# [`LandModel`](https://clima.github.io/ClimaLand.jl/stable/APIs/ClimaLand/#Integrated-Land-Model-Types-and-methods)
9090
# is chosen. Here we use the highest level model constructor, which uses default parameters,
9191
# and parameterizations, for the soil, snow, and canopy models.
9292

0 commit comments

Comments
 (0)