Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Attributes

Attributes are TOML like values. They can be one of the following types:

Type NameRust TypeDescription
BoolboolBoolean values (true or false)
StringRStringQuoted String Values
Integeri64Integer values (numbers)
Floatf64Float values (numbers with decimals)
DateDateDate (yyyy-mm-dd formatted)
TimeTimeTime (HH:MM, HH:MM:SS formatted)
DateTimeDateTimeDate and Time separed by or T
ArrayRVec<Attribute>List of any attribute values
Table/AttrMapAttrMapKey Value pairs of any attribute values

You can write attributes directly into the task system to assign them, use them in functions. You can also load attributes from a file into the env/node/network.

Following are some example values that are evaluated as literal values (themselves).

true
"string value"
12.21

Results:

true

"string value"

12.21

Please note that, the date and time by themselves are not valid in a tasks file. While they are valid attributes in a “.toml” file or while parsing attributes, in a task file they are interpreted as integer expression and integer range.

2024-12-21
12:24
12:04:24

Results:

1991

[12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]

[12, 16, 20, 24]

You can assign attribute values to variable names. We will discuss nodes and network later, but let’s assign environmental values:

env.river = "Ohio River"
env.river

Results:

"Ohio River"

Besides writing them in the code directly, you can also load attributes from a file. Example Attribute File that can be loaded:

river = "Ohio River"
outlet = "Smithland Lock and Dam"
outlet_is_gage = true
outlet_site_no = ""
streamflow_start = 1930-06-07
mean_streamflow = 123456.0
obs_7q10 = 19405.3
nat_7q10 = 12335.9
num_dams_gages = 2348

Here loading the files we can see only ohio has the attributes loaded

 network load_file("./data/mississippi.net")
node[ohio] load_attrs("./data/attrs/{NAME}.toml")
nodesmap.outlet

Results:

{
  "lower-mississippi" = <None>,
  red = <None>,
  arkansas = <None>,
  missouri = <None>,
  "upper-mississippi" = <None>,
  ohio = "Smithland Lock and Dam",
  tenessee = <None>
}

With plugins, you can load attributes from different file types.