-
Notifications
You must be signed in to change notification settings - Fork 14
More usage of ClimaParams #1385
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
Conversation
0be5955
to
d5d046c
Compare
89aba76
to
ec4f5d5
Compare
SoilCO2ModelParameters(toml_dict::CP.AbstractTOMLDict; kwargs...) | ||
SoilCO2ModelParameters has two constructors: float-type and toml dict based. | ||
SoilCO2ModelParameters provides a constructor using the TOML dict. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what parameters to expose to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is OK as is (nothing exposed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(but then removing the kwargs..., right? I believe we had discussed that being too ambigious to users. )
function FarquharParameters( | ||
toml_dict::CP.AbstractTOMLDict, | ||
is_c3::Union{AbstractFloat, ClimaCore.Fields.Field}; | ||
Vcmax25 = 5e-5, | ||
Vcmax25 = toml_dict["Vcmax25"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what parameters to expose to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be in the toml dict. It can be set via kwarg (but not have a default - in which case maybe making it required is better?), or we can set the default from the domain by reading in the parameter map. (Spatially varying params should not be in the toml dict)
it should have the same type as is_c3, and should be treated the same as is_c3 (see earlier comment) in terms of kwarg vs required arg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is OK to only expose is_c3 and Vcmax25
TOML dict based constructor supplying default values for the | ||
BeerLambertParameters struct. Additional parameter values can be directly set | ||
via kwargs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what parameters should be to exposed to the user
I think I covered everything that needed to be done, but there might be some small things that I missed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple comments but this looks good!
As far as which parameters to expose to users, we can keep the same ones we had exposed previously. As far as I understand, this PR doesn't change which parameters are exposed - it changes how the defaults are set, but users can still overwrite the defaults via kwargs.
Also, in experiments/long_runs/low_res_snowy_land_rh.jl
, setup_model
should take in toml_dict
instead of earth_param_set
here
src/integrated/soil_canopy_model.jl
Outdated
terms. | ||
""" | ||
function SoilCanopyModel{FT}(; | ||
toml_dict::CP.AbstractTOMLDict, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is an equivalent method for LandModel (takes component types and args) - should that be updated too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is
function LandModel{FT}(
forcing,
LAI,
toml_dict::CP.AbstractTOMLDict,
domain::Union{
ClimaLand.Domains.Column,
ClimaLand.Domains.SphericalShell,
ClimaLand.Domains.HybridBox,
},
Δt;
with some more keyword arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/standalone/Vegetation/Canopy.jl
Outdated
) where {FT <: AbstractFloat} | ||
(; is_c3, Vcmax25) = photosynthesis_parameters | ||
parameters = FarquharParameters(FT, is_c3; Vcmax25, sc, pc) | ||
parameters = FarquharParameters(toml_dict, is_c3; Vcmax25, sc, pc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be FarquharParameters(toml_dict, is_c3, Vcmax25; sc, pc) instead? We dont have a default value of Vcmax25.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errr sorry, we do (we get it from the domain). So actually, since we do the same for is_c3, should this be
FarquharParameters(domain, toml_dict; is_c3 = , Vcmax25 = , sc = , pc= )?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry i was a little confused. it looks like we are doing the right thing, the FarquharParameters constructor is just a little confusing (not sure why is_c3 is not kwarg when the others are)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make is_c3
a keyword argument. I am also not sure why is_c3
is not a keyword argument, but I am guessing it is because it also accepts a ClimaCore.Fields.Field
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have gotten confused when refactoring the parameters structs and written the constructor like this. I think is_c3
can be a kwarg for FarquharParameters like it is for PModel further down in the file -
is_c3 = clm_photosynthesis_parameters(domain.space.surface).is_c3,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi Kevin! Thanks for making these changes - it looks like a lot of work.
It all looks good, I left a few comments.
I have a couple questions
What is the general philosophy behind parameter structs, and can we unify this across components?
- Do we basically support two methods for Parameter() structs? one taking the toml (or the toml and domain, with a subset of parameters allowing explicit kwarg overrides), and one taking all parameters by kwarg? I saw this for snow. or do different parameter structs allow different things? It seems like a future goal might be to unify these
- Are required arguments (not in the toml) passed in as kwarg or regular arg? for photosynthesis, we handled is_c3 and vcmax25 differently
- Are the only required arguments or unset kwargs the spatially varying parameters?
Other questions:
- Are the model constructors also using the toml dict uniformly now?
- A lot of our experiment scripts still make the earth_param_set from the toml_dict. Is this required? or should the earth_param_set be constructed internally?
(We dont have to answer these questions to merge this)
- Registering package: ClimaLand - Repository: https://github.com/CliMA/ClimaLand.jl - Created by: @kmdeck - Version: v1.0.0 - Commit: 9e7c36dbf3ecda80e887cdcf40e16a4f73875341 - Reviewed by: @kmdeck - Reference: CliMA/ClimaLand.jl@9e7c36d#commitcomment-168088679 - Description: Clima's Land Model - Release notes: <!-- BEGIN RELEASE NOTES --> ````` Version 1.0.0 corresponds to the version of the code used in Deck et al., 2025 "ClimaLand: A Land Surface Model Designed to Enable Data-Driven Parameterizations" Breaking changes: - Move the area indices and rooting depth to the biomass component PR[#1388](CliMA/ClimaLand.jl#1388) - Model constructors should use toml dict PR[#1385](CliMA/ClimaLand.jl#1385) - All callbacks are now constructed with `IntervalBasedCallback`, which uses ClimaDiagnostics for scheduling. PR[#1380](CliMA/ClimaLand.jl#1380) - `FrequencyBasedCallback` renamed to `IntervalBasedCallback` - `NonInterpSavingCallback` can no longer be constructed with a vector of times to save at. Instead, the callback can be constructed with one of the following methods ```julia # recommended constructors saving_cb = NonInterpSavingCallback(start_date, stop_date, callback_period) # OR saving_cb = NonInterpSavingCallback(t0, tf, callback_period) saved_values = saving_cb.affect!.saved_values # saved_values NamedTuple automatically constructed ``` - `DriverUpdateCallback` can no longer be constructed with a vector of update times. Instead, it can now be constructed with `DriverUpdateCallback(updatefunc, update_period, t0)`. - The `LandSimulation` construtor now expects `updateat` to be the update period instead of a vector of times. - `CheckpointCallback` signature is changed to `CheckpointCallback(checkpoint_period, output_dir, t0; model, dt = nothing)` - `NaNCheckCallback` signature changed to `NaNCheckCallback(nancheck_period, t0; dt = nothing, mask = nothing)` - The `ReportCallback` constructor no longer accepts the number of steps between reports as an argument. The function signature is now `ReportCallback(period, t0; dt = nothing)` ````` <!-- END RELEASE NOTES --> <!-- bf0c69308befbd3ccf2cc956ac8a46712550b79fc9bfb5e4edf8f833f05f4c18b06eddad8845b45beb9f45c2b8020dd6eb666ae78c72497a59d58c33c452e6b2dff9b00dadb18993afea6667fe3a3ec8492421bd78cb91c435240ee4350353951f044acc8659fcda48806027eaae546980e2c8c49a0bca0f1d7a154a8d04317666c4af53472288de936c9e56a2ec60c4c1f53db844def2c66789bb180148f6c06d00de40a27dca05e5270e1d86ef8982a2433a2d4bdef2694354a76e3db9bdd1602d04bbd41d93b6cdb58f3e5bd464ee59343856b49c6572d6875ec8604acc1f -->
closes #1374, closes #1270
This PR removes the constructor for parameters that takes in
FT
and replace them if they did not exist already with constructor usingtoml_dict
. Furthermore, the parameters for the P model is now in the TOML file.