-
Notifications
You must be signed in to change notification settings - Fork 6
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
WIP: build basic toml format #57
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Open
I've added support for julia> paramset = DefaultParameterSet()
DefaultParameterSet()
julia> paramset.M_d
0.02897
julia> paramset.R
8.3144598 This means that you can also use julia> (;M_d, R) = paramset
DefaultParameterSet()
julia> M_d
0.02897 |
Moved to new branch |
bors bot
added a commit
that referenced
this pull request
May 18, 2022
62: [WIP] pilot parameter refactor r=odunbar a=odunbar ## Purpose of this PR Relating to issues #57 Provides a toml format for other packages to use. Currently see - PR [83](CliMA/Thermodynamics.jl#83) on `Clima/Thermodynamics` - PR [55](CliMA/CloudMicrophysics.jl#55) on `Clima/CloiudMicrophysics` Also we can now write **re-readable** log files ## In this PR - Documentation! See the latest documentor build below. - New wrapper ```ParamDict{FT}```around dictionary read from toml. Currently parametric on one type of all the values, provided when it is built (default is `Float64`). Construction: ```julia create_parameter_struct(override_filepath, default_filepath; dict_type="alias",value_type=Float64) # builds with override and custom default provided create_parameter_struct(override_filepath ; dict_type="alias",value_type=Float64) # builds, overriding the default from CLIMAParameters create_parameter_struct(; dict_type="alias",value_type=Float64) # builds using only default in CLIMAParameters ``` - Automated parameter logging on reading parameter values: (can do multiple parameters at once). At the call of this function, the type is enforced on the return values. ```julia get_parameter_values!(pd::ParamDict, names, component; log_component=true) #logs component in pd get_parameter_values(pd::ParamDict,names) # no logging in pd ``` - writing the re-readable log file in `log_parameter_information(pd::ParamDict,filepath)`. Example parameter tested in `CloudMicrophysics.jl`: ```toml # initial parameter file [molar_mass_water] alias = "molmass_water" value = 0.01801528 type = "float" ``` In this test, a copy of the parameters was created and stored in (1) Thermodynamics, (2) the general CloudMicrophysics, and (3) the specific 1-moment-based Microphysics scheme. Indeed the logfile shows this information below ```toml # log file [molar_mass_water] alias = "molmass_water" value = 0.01801528 type = "float" used_in = ["Thermodynamics", "CloudMicrophysicsParameters", "Microphysics_1M_Parameters"] ``` The `log_parameter_information(pd::ParamDict,filepath; warn_else_error="warn")` will also throw warnings if a parameter is in the override file, but unused in the simulation. This works as parameters from the override file are checked for whether they have gained a "used_in" tag, if not found then an this is logged as a warning or error - From PR #65, reading of array-type parameters - From PR #68, reading and writing for calibration tools ### TODO - still using alias based structs - still based on float, and array-of-float parameters Co-authored-by: odunbar <[email protected]>
Can we close this one @simonbyrne? |
Superseded by #62 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Basic example: