Skip to content

Conversation

ph-kev
Copy link
Member

@ph-kev ph-kev commented Aug 27, 2025

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 using toml_dict. Furthermore, the parameters for the P model is now in the TOML file.

@ph-kev ph-kev changed the title More usage of ClimaParams [WIP] More usage of ClimaParams Aug 27, 2025
@ph-kev ph-kev force-pushed the kp/params branch 7 times, most recently from 0be5955 to d5d046c Compare August 28, 2025 20:14
@ph-kev ph-kev force-pushed the kp/params branch 3 times, most recently from 89aba76 to ec4f5d5 Compare September 4, 2025 20:23
Comment on lines 74 to 76
SoilCO2ModelParameters(toml_dict::CP.AbstractTOMLDict; kwargs...)
SoilCO2ModelParameters has two constructors: float-type and toml dict based.
SoilCO2ModelParameters provides a constructor using the TOML dict.
Copy link
Member Author

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.

Copy link
Member

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).

Copy link
Member

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. )

Comment on lines 372 to 368
function FarquharParameters(
toml_dict::CP.AbstractTOMLDict,
is_c3::Union{AbstractFloat, ClimaCore.Fields.Field};
Vcmax25 = 5e-5,
Vcmax25 = toml_dict["Vcmax25"],
Copy link
Member Author

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.

Copy link
Member

@kmdeck kmdeck Sep 8, 2025

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

Copy link
Member

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

Comment on lines 352 to 346
TOML dict based constructor supplying default values for the
BeerLambertParameters struct. Additional parameter values can be directly set
via kwargs.
Copy link
Member Author

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

@ph-kev
Copy link
Member Author

ph-kev commented Sep 4, 2025

I think I covered everything that needed to be done, but there might be some small things that I missed.

@ph-kev ph-kev changed the title [WIP] More usage of ClimaParams More usage of ClimaParams Sep 4, 2025
Copy link
Member

@juliasloan25 juliasloan25 left a 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

@ph-kev ph-kev marked this pull request as ready for review September 6, 2025 16:10
terms.
"""
function SoilCanopyModel{FT}(;
toml_dict::CP.AbstractTOMLDict,
Copy link
Member

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?

Copy link
Member Author

@ph-kev ph-kev Sep 11, 2025

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.

Copy link
Member

Choose a reason for hiding this comment

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

I believe @kmdeck is talking about this one. We're planning to remove this type of constructor soon, but while we still have them it would be good for them to remain consistent with each other

) 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)
Copy link
Member

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.

Copy link
Member

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= )?

Copy link
Member

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)

Copy link
Member Author

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.

Copy link
Member

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,

Copy link
Member

@kmdeck kmdeck left a 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)

@kmdeck kmdeck mentioned this pull request Sep 17, 2025
31 tasks
@ph-kev ph-kev enabled auto-merge (squash) September 17, 2025 21:07
@ph-kev ph-kev disabled auto-merge September 17, 2025 21:51
@ph-kev ph-kev merged commit fa3ee9d into main Sep 17, 2025
14 of 16 checks passed
@ph-kev ph-kev deleted the kp/params branch September 17, 2025 22:24
JuliaTagBot pushed a commit to JuliaRegistries/General that referenced this pull request Oct 16, 2025
- 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
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move pmodel parameters to toml Make sure earth_param_set being passed correctly in EnergyHydrology constructor

3 participants