Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for short and long soil_params names in config #100

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions configs/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
## Configuration File
Example configuration files are provided in this directory. To build and run the given examples see the instructions [here](https://github.com/NOAA-OWP/cfe/blob/master/INSTALL.md). A detailed description of the parameters for model configuration (i.e., initialize/setup) is provided below. The asterisk (*) denotes calibratable parameters.
Example configuration files are provided in this directory.
To build and run the given examples see the instructions [here](https://github.com/NOAA-OWP/cfe/blob/master/INSTALL.md).
A detailed description of the parameters for model configuration (i.e., initialize/setup) is provided below.
> [!NOTE]
> The asterisk (*) denotes calibratable parameters.
> Note, calibratable parameters are passed via BMI using the _name next to the asterisk_.

| Variable | Datatype | Limits | Units | Role | Process | Description |
| -------- | -------- | ------ | ----- | ---- | ------- | ----------- |
| forcing_file | *char* | 256 | | filename | | path to forcing inputs csv; set to `BMI` if passed via `bmi.set_value*()` |
| soil_params.depth | *double* | | meters [m]| state | | soil depth |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency, we should follow the same style for soil_params.depth as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In an ideal world, I would have added short forms of all of the soil_params, but I couldn't for soil_params.expon because expon already exists... so, I only added short forms for calibratable parameters. @ajkhattak, thoughts on how to get around this?

Copy link
Contributor

@ajkhattak ajkhattak Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I see what you mean... Let's discuss it with other folks. I would suggest something like

soil_param_name (e.g., soil_storage)
gw_param_name (e.g., gw_storage)

since the parameter expon is used in both soil and groundwater reservoirs, so following the above, we use
soil_expon and gw_expon.

we can update the names for calibratable parameters too, so they are consistent with their names in the config file.

@SnowHydrology @hellkite500

| *soil_params.b | *double* | | | state | | beta exponent on Clapp-Hornberger (1978) soil water relations |
| *soil_params.satdk | *double* | | meters/second [m s-1] | state | | saturated hydraulic conductivity |
| *soil_params.satpsi | *double* | | meters [m] | state | | saturated capillary head |
| *soil_params.slop | *double* | | meters/meters [m/m]| state | | this factor (0-1) modifies the gradient of the hydraulic head at the soil bottom. 0=no-flow. |
| *soil_params.smcmax | *double* | | meters/meters [m/m] | state | | saturated soil moisture content |
| soil_params.b or *b | *double* | | | state | | beta exponent on Clapp-Hornberger (1978) soil water relations |
| soil_params.satdk or *satdk | *double* | | meters/second [m s-1] | state | | saturated hydraulic conductivity |
| soil_params.satpsi or *satpsi | *double* | | meters [m] | state | | saturated capillary head |
| soil_params.slop or *slope | *double* | | meters/meters [m/m]| state | | this factor (0-1) modifies the gradient of the hydraulic head at the soil bottom. 0=no-flow. |
| soil_params.smcmax or *maxsmc | *double* | | meters/meters [m/m] | state | | saturated soil moisture content |
| soil_params.wltsmc | *double* | | meters/meters [m/m] | state | | wilting point soil moisture content |
| soil_params.expon | *double* | | | parameter_adjustable | | optional; defaults to `1.0` |
| soil_params.expon_secondary | *double* | | | parameter_adjustable | | optional; defaults to `1.0` |
Expand All @@ -20,7 +25,7 @@ Example configuration files are provided in this directory. To build and run the
| alpha_fc | *double* | | | parameter_adjustable | | field capacity |
| soil_storage| *double* | | meters/meters [m/m] | parameter_adjustable | | initial condition for soil reservoir - it is the water in the soil as a decimal fraction of maximum soil water storage (smcmax * depth) for the initial timestep |
| K_nash | *int* | | | parameter_adjustable | | number of Nash lf reservoirs (optional, defaults to 2, ignored if storage values present) |
| *K_lf | *double* | | | parameter_adjustable | | Nash Config param - primary reservoir |
| K_lf or *Klf | *double* | | | parameter_adjustable | | Nash Config param - primary reservoir |
| nash_storage | *double* | | | parameter_adjustable | | Nash Config param - secondary reservoir |
| giuh_ordinates | *double* | | | parameter_adjustable | | Giuh ordinates in dt time steps |
| num_timesteps | *int* | | | time_info | | set to `1` if `forcing_file=BMI` |
Expand Down
23 changes: 23 additions & 0 deletions configs/cat_89_bmi_config_cfe_unit_test_alt_names.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
forcing_file=BMI
soil_params.depth=2.0[m]
b=4.05[]
satdk=0.00000338[m s-1]
satpsi=0.355[m]
slope=1.0[m/m]
maxsmc=0.439[m/m]
wltsmc=0.066[m/m]
soil_params.expon=1.0[]
soil_params.expon_secondary=1.0[]
max_gw_storage=0.25[m]
Cgw=1.8e-05[m h-1]
expon=6.0[]
gw_storage=0.125[m/m]
alpha_fc=0.33[]
soil_storage=0.585626[m/m]
K_nash=0.03[]
K_lf=0.01[]
nash_storage=0.0,0.0
giuh_ordinates=0.06,0.51,0.28,0.12,0.03
num_timesteps=1
verbosity=2
surface_partitioning_scheme=Schaake
20 changes: 10 additions & 10 deletions src/bmi_cfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,12 @@ int read_init_config_cfe(const char* config_file, cfe_state_struct* model)
}
continue;
}
if (strcmp(param_key, "soil_params.bb") == 0 || strcmp(param_key, "soil_params.b") == 0) {
if (strcmp(param_key, "b") == 0 || strcmp(param_key, "soil_params.bb") == 0 || strcmp(param_key, "soil_params.b") == 0) {
model->NWM_soil_params.bb = strtod(param_value, NULL);
is_soil_params__bb_set = TRUE;
continue;
}
if (strcmp(param_key, "soil_params.satdk") == 0) {
if (strcmp(param_key, "satdk") == 0 || strcmp(param_key, "soil_params.satdk") == 0) {
model->NWM_soil_params.satdk = strtod(param_value, NULL);
is_soil_params__satdk_set = TRUE;
// Check if units are present and print warning if missing from config file
Expand All @@ -561,7 +561,7 @@ int read_init_config_cfe(const char* config_file, cfe_state_struct* model)
}
continue;
}
if (strcmp(param_key, "soil_params.satpsi") == 0) {
if (strcmp(param_key, "satpsi") == 0 || strcmp(param_key, "soil_params.satpsi") == 0) {
model->NWM_soil_params.satpsi = strtod(param_value, NULL);
is_soil_params__satpsi_set = TRUE;
// Check if units are present and print warning if missing from config file
Expand All @@ -572,7 +572,7 @@ int read_init_config_cfe(const char* config_file, cfe_state_struct* model)
}
continue;
}
if (strcmp(param_key, "soil_params.slope") == 0 || strcmp(param_key, "soil_params.slop") == 0) {
if (strcmp(param_key, "slope") == 0 || strcmp(param_key, "soil_params.slope") == 0 || strcmp(param_key, "soil_params.slop") == 0) {
model->NWM_soil_params.slop = strtod(param_value, NULL);
is_soil_params__slop_set = TRUE;
// Check if units are present and print warning if missing from config file
Expand All @@ -583,7 +583,7 @@ int read_init_config_cfe(const char* config_file, cfe_state_struct* model)
}
continue;
}
if (strcmp(param_key, "soil_params.smcmax") == 0 || strcmp(param_key, "soil_params.maxsmc") == 0) {
if (strcmp(param_key, "maxsmc") == 0 || strcmp(param_key, "soil_params.smcmax") == 0 || strcmp(param_key, "soil_params.maxsmc") == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have maxsmc but not smcmax, they are used interchangeably, so better to add it as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I only added maxsmc because that is the name of the calibratable parameter. I thought including a short form name would be more confusing. I guess alternatively we could change the calibratable parameter name to smcmax?

model->NWM_soil_params.smcmax = strtod(param_value, NULL);
is_soil_params__smcmax_set = TRUE;
// Check if units are present and print warning if missing from config file
Expand All @@ -594,7 +594,7 @@ int read_init_config_cfe(const char* config_file, cfe_state_struct* model)
}
continue;
}
if (strcmp(param_key, "soil_params.wltsmc") == 0) {
if (strcmp(param_key, "wltsmc") == 0 || strcmp(param_key, "soil_params.wltsmc") == 0) {
model->NWM_soil_params.wltsmc = strtod(param_value, NULL);
is_soil_params__wltsmc_set = TRUE;
// Check if units are present and print warning if missing from config file
Expand Down Expand Up @@ -671,7 +671,7 @@ int read_init_config_cfe(const char* config_file, cfe_state_struct* model)
continue;
}

if (strcmp(param_key, "soil_params.alpha_fc") == 0 || strcmp(param_key, "alpha_fc") == 0) {
if (strcmp(param_key, "alpha_fc") == 0 || strcmp(param_key, "soil_params.alpha_fc") == 0) {
model->NWM_soil_params.alpha_fc = strtod(param_value, NULL);
is_alpha_fc_set = TRUE;
continue;
Expand Down Expand Up @@ -701,7 +701,7 @@ int read_init_config_cfe(const char* config_file, cfe_state_struct* model)
is_K_nash_set = TRUE;
continue;
}
if (strcmp(param_key, "K_lf") == 0) {
if (strcmp(param_key, "Klf") == 0 || strcmp(param_key, "K_lf") == 0) {
model->K_lf = strtod(param_value, NULL);
is_K_lf_set = TRUE;
continue;
Expand Down Expand Up @@ -905,7 +905,7 @@ int read_init_config_cfe(const char* config_file, cfe_state_struct* model)
}
if (is_K_lf_set == FALSE) {
#if CFE_DEBUG >= 1
printf("Config param 'K_lf' not found in config file\n");
printf("Config param 'K_lf' or 'Klf' not found in config file\n");
#endif
return BMI_FAILURE;
}
Expand Down Expand Up @@ -2004,7 +2004,7 @@ static int Set_value_at_indices (Bmi *self, const char *name, int * inds, int le
return BMI_FAILURE;
memcpy(ptr, src, var_item_size * len);

if (strcmp (name, "maxsmc") == 0 || strcmp (name, "alpha_fc") == 0 || strcmp (name, "wltsmc") == 0 || strcmp (name, "maxsmc") == 0 || strcmp (name, "b") == 0 || strcmp (name, "slope") == 0 || strcmp (name, "satpsi") == 0 || strcmp (name, "Klf") == 0 || strcmp (name, "satdk") == 0){
if (strcmp (name, "maxsmc") == 0 || strcmp (name, "alpha_fc") == 0 || strcmp (name, "wltsmc") == 0 || strcmp (name, "b") == 0 || strcmp (name, "slope") == 0 || strcmp (name, "satpsi") == 0 || strcmp (name, "Klf") == 0 || strcmp (name, "satdk") == 0){

cfe_state_struct* cfe_ptr = (cfe_state_struct *) self->data;
init_soil_reservoir(cfe_ptr);
Expand Down