API

Parameter dictionaries

CLIMAParameters.ParamDictType
ParamDict(data::Dict, override_dict::Union{Nothing,Dict})

Structure to hold information read-in from TOML file, as well as a parametrization type FT.

Uses the name to search

Fields

  • data: dictionary representing a default/merged parameter TOML file

  • override_dict: either a nothing, or a dictionary representing an override parameter TOML file

File parsing and parameter logging

User facing functions:

CLIMAParameters.create_toml_dictFunction
create_toml_dict(FT;
    override_file,
    default_file,
)

Creates a ParamDict{FT} struct, by reading and merging upto two TOML files or Julia Dicts with override information taking precedence over default information.

CLIMAParameters.get_parameter_valuesFunction
get_parameter_values(
    pd::AbstractTOMLDict,
    names::Union{String,Vector{String}},
    component::String
)

get_parameter_values(
    pd::AbstractTOMLDict,
    name_map::Union{Dict, Vector{Pair}, NTuple{N, Pair}, Vararg{Pair}},
    component::String
)

Given a toml dict and a list of parameter names, returns a NamedTuple of the parameters and their values. If a component is specified, the parameter is logged as being used in that component.

Instead of a list of parameter names, this can take an iterable mapping from parameter names to variable names in code. Then, this function retrieves all parameters from the long names and returns a NamedTuple where the keys are the variable names.

CLIMAParameters.get_tagged_parameter_valuesFunction
get_tagged_parameter_values(pd::AbstractTOMLDict, tag::AbstractString)
get_tagged_parameter_values(pd::AbstractTOMLDict, tags::Vector{AbstractString})

Returns a list of name-value Pairs of the parameters with the given tag(s).

CLIMAParameters.get_tagged_parameter_namesFunction
get_tagged_parameter_names(pd::AbstractTOMLDict, tag::AbstractString)
get_tagged_parameter_names(pd::AbstractTOMLDict, tags::Vector{AbstractString})

Returns a list of the parameters with a given tag.

CLIMAParameters.fuzzy_matchFunction
fuzzy_match(s1::AbstractString, s2::AbstractString)

Takes two strings and checks them for equality. This strips punctuation [' ', '_', '*', '.', ',', '-', '(', ')'] and removes capitalization.

CLIMAParameters.log_parameter_informationFunction
log_parameter_information(
    pd::AbstractTOMLDict,
    filepath;
    strict::Bool = false
)

Writes the parameter log file at filepath; checks that override parameters are all used.

If strict = true, errors if override parameters are unused.

CLIMAParameters.write_log_fileFunction
write_log_file(pd::AbstractTOMLDict, filepath)

Writes a log file of all used parameters of pd at the filepath. This file can be used to rerun the experiment.

CLIMAParameters.merge_toml_filesFunction
merge_toml_files(filepaths; override)

Parses and merges all of the given TOML filepaths and returns them as a Dict. This allows a toml_dict to be constructed from multiple TOML files. By default, non-unique TOML entries are not allowed, but this can be changed by setting override = true.

CLIMAParameters.create_parameter_structFunction
create_parameter_struct(
    toml_dict,
    param_struct_type,
    name_map,
    nested_structs = (;),
)

Constructs the parameter struct from the TOML dictionary. If the parameter struct has nested parameter structs, they must be passed. Floating type is inherited from the TOML dictionary.

This is fairly rigid and makes a few assumptions:

  • The parameter struct has a constructor that takes keyword arguments
  • The parameter struct's first type parameter is the floating point type
  • All nested parameter structs are given.