Skip to content

Commit a7748da

Browse files
committed
Add RMSEVariable struct
This commit adds a struct called `RMSEVariable` which hold all the information necessary for comparing the root mean square errors between different models across different categories for a single variable.
1 parent 6e540bd commit a7748da

8 files changed

+500
-0
lines changed

NEWS.md

+47
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,53 @@ plot_bias_on_globe!(fig, sim_var, obs_var)
276276
CairoMakie.save("myfigure.pdf", fig)
277277
```
278278

279+
### RMSEVariable
280+
281+
To facilitate analysis of root mean squared errors (RMSEs) over different models and
282+
categories (e.g., seasons) for a single variable of interest, `RMSEVariable` is introduced in
283+
this release. See the examples below of constructing a `RMSEVariable` using a short name, a
284+
vector of model names, a vector of categories, and a dictionary mapping model names to units
285+
or a string of the name of the unit.
286+
287+
```julia
288+
import ClimaAnalysis
289+
290+
rmse_var = ClimaAnalysis.RMSEVariable("ta", ["ACCESS-CM2", "ACCESS-ESM1-5"])
291+
rmse_var = ClimaAnalysis.RMSEVariable(
292+
"ta",
293+
["ACCESS-CM2", "ACCESS-ESM1-5"],
294+
Dict("ACCESS-CM2" => "K", "ACCESS-ESM1-5" => "K"),
295+
)
296+
rmse_var = ClimaAnalysis.RMSEVariable(
297+
"ta",
298+
["ACCESS-CM2", "ACCESS-ESM1-5"],
299+
["DJF", "MAM", "JJA", "SON", "ANN"],
300+
Dict("ACCESS-CM2" => "K", "ACCESS-ESM1-5" => "K"),
301+
)
302+
# Convenience functions if models all share the same unit
303+
rmse_var = ClimaAnalysis.RMSEVariable(
304+
"ta",
305+
["ACCESS-CM2", "ACCESS-ESM1-5"],
306+
"K",
307+
)
308+
rmse_var = ClimaAnalysis.RMSEVariable(
309+
"ta",
310+
["ACCESS-CM2", "ACCESS-ESM1-5"],
311+
["DJF", "MAM", "JJA", "SON", "ANN"],
312+
"K",
313+
)
314+
rmse_var = ClimaAnalysis.RMSEVariable(
315+
"ta",
316+
["ACCESS-CM2", "ACCESS-ESM1-5"],
317+
["DJF", "MAM", "JJA", "SON", "ANN"],
318+
ones(2, 5),
319+
"K",
320+
)
321+
```
322+
323+
A `RMSEVariable` can be inspected using `model_names`, `category_names`, and `rmse_units`
324+
which provide the model names, the category names, and the units respectively.
325+
279326
## Bug fixes
280327

281328
- Increased the default value for `warp_string` to 72.

docs/make.jl

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ makedocs(;
3030
"Home" => "index.md",
3131
"OutputVars" => "var.md",
3232
"Visualizing OutputVars" => "visualize.md",
33+
"RMSEVariables" => "rmse_var.md",
3334
"APIs" => "api.md",
3435
"How do I?" => "howdoi.md",
3536
],

docs/src/api.md

+15
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@ Var.global_mse
6767
Var.global_rmse
6868
```
6969

70+
## Leaderboard
71+
```@docs
72+
Leaderboard.RMSEVariable
73+
Leaderboard.RMSEVariable(short_name, model_names::Vector{String})
74+
Leaderboard.RMSEVariable(short_name, model_names::Vector{String}, units::Dict)
75+
Leaderboard.RMSEVariable(short_name, model_names::Vector{String}, category_names::Vector{String}, units::Dict)
76+
Leaderboard.RMSEVariable(short_name::String, model_names::Vector{String}, category_names::Vector{String}, RMSEs, units::Dict)
77+
Leaderboard.RMSEVariable(short_name, model_names::Vector{String}, units::String)
78+
Leaderboard.RMSEVariable(short_name, model_names::Vector{String}, category_names::Vector{String}, units::String)
79+
Leaderboard.RMSEVariable(short_name::String, model_names::Vector{String}, category_names::Vector{String}, RMSEs, units::String)
80+
Leaderboard.model_names
81+
Leaderboard.category_names
82+
Leaderboard.rmse_units
83+
```
84+
7085
## Utilities
7186

7287
For development and not

docs/src/rmse_var.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# `RMSEVariable`s
2+
3+
`RMSEVariable`s contain all the information needed to process and compare root mean squared
4+
errors (RMSEs) between different models and categories (e.g., seasons) for a single variable
5+
of interest.
6+
7+
`ClimaAnalysis` provides several constructors for making a `RMSEVariable`. For all
8+
constructors, a short name and a vector of model names must be provided. If units are not
9+
provided, then each model will have no unit which denotes the missing unit. See the examples
10+
below where the constructor can take in a short name, a vector of model names, a vector of
11+
categories, and a dictionary mapping model names to units or a string of the name of the
12+
unit.
13+
14+
```@example rmse_var
15+
import ClimaAnalysis
16+
17+
rmse_var = ClimaAnalysis.RMSEVariable("ta", ["ACCESS-CM2", "ACCESS-ESM1-5"])
18+
rmse_var = ClimaAnalysis.RMSEVariable(
19+
"ta",
20+
["ACCESS-CM2", "ACCESS-ESM1-5"],
21+
Dict("ACCESS-CM2" => "K", "ACCESS-ESM1-5" => "K"),
22+
)
23+
rmse_var = ClimaAnalysis.RMSEVariable(
24+
"ta",
25+
["ACCESS-CM2", "ACCESS-ESM1-5"],
26+
["DJF", "MAM", "JJA", "SON", "ANN"],
27+
Dict("ACCESS-CM2" => "K", "ACCESS-ESM1-5" => "K"),
28+
)
29+
rmse_var = ClimaAnalysis.RMSEVariable(
30+
"ta",
31+
["ACCESS-CM2", "ACCESS-ESM1-5"],
32+
["DJF", "MAM", "JJA", "SON", "ANN"],
33+
ones(2, 5),
34+
Dict("ACCESS-CM2" => "K", "ACCESS-ESM1-5" => "K"),
35+
)
36+
# Convenience functions if models all share the same unit
37+
rmse_var = ClimaAnalysis.RMSEVariable(
38+
"ta",
39+
["ACCESS-CM2", "ACCESS-ESM1-5"],
40+
"K",
41+
)
42+
rmse_var = ClimaAnalysis.RMSEVariable(
43+
"ta",
44+
["ACCESS-CM2", "ACCESS-ESM1-5"],
45+
["DJF", "MAM", "JJA", "SON", "ANN"],
46+
"K",
47+
)
48+
rmse_var = ClimaAnalysis.RMSEVariable(
49+
"ta",
50+
["ACCESS-CM2", "ACCESS-ESM1-5"],
51+
["DJF", "MAM", "JJA", "SON", "ANN"],
52+
ones(2, 5),
53+
"K",
54+
)
55+
56+
nothing # hide
57+
```
58+
59+
The `RMSEVariable` can be inspected using `model_names`, `category_names`, and `rmse_units`
60+
which provide the model names, the category names, and the units respectively.
61+
62+
```@repl rmse_var
63+
ClimaAnalysis.model_names(rmse_var)
64+
ClimaAnalysis.category_names(rmse_var)
65+
ClimaAnalysis.rmse_units(rmse_var)
66+
```

src/ClimaAnalysis.jl

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ include("Var.jl")
1010
@reexport using .Var
1111
include("Sim.jl")
1212
@reexport using .Sim
13+
include("Leaderboard.jl")
14+
@reexport using .Leaderboard
1315

1416
include("Visualize.jl")
1517
@reexport using .Visualize

0 commit comments

Comments
 (0)