Skip to content

Use ClimaParams instead of hard coded values #1298

@ph-kev

Description

@ph-kev

For doing calibration, there are instances where you want to calibrate a parameter, but the parameter is a hard coded value. For example, in the current land calibration pipeline, there are parameters that we need to create a variable for, so that it can be overwritten.

# Set up parameters
p_names = collect(keys(params))
p_values = [params[name]["value"] for name in p_names]
params = (; zip(Symbol.(p_names), p_values)...)
(;
# pc,
# sc,
# K_sat_plant,
# a,
# h_leaf,
# α_snow,
# α_soil_dry_scaler,
# τ_leaf_scaler,
# α_leaf_scaler,
# α_soil_scaler,
α_0,
Δα,
k,
beta_snow,
x0_snow,
gamma_snow,
beta_0,
# beta_min,
z0_snow,
) = params

This is not feasible in the long term and it would be better to transition to using ClimaParams for storing and loading parameters.

Proposed solution

Instead of hardcoding values in the code, we can instead hardcode the values in a TOML file. This would look something like this:

[beta_snow]
value = 0.7
description = "Snow parameter for ZenithAngleAlbedoModel from some paper" # optional
tag = "snow" # optional

Then, you can create a TOML dict from it using ClimaParams.create_toml_dict and load the parameters from this instead. See ClimaParams documentation for more information.

For calibration, we can use ClimaParams.merge_toml_files to merge the TOML file from ClimaCalibrate and the TOML for the land parameters. Furthermore, this can significantly reduces the amount of the code used for the model interface or forward model as one of the reason that it can't reuse snowy_land.jl is because there is no functionality to override parameters.

Alternative solution

One other solution is to put all the parameters in ClimaParams. This might not be a good idea, because if any parameter ever need to be changed, then you need to go to ClimaParams, update it, make a new release, and update ClimaParams in ClimaLand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions