Attributes
Attributes are TOML like values. They can be one of the following types:
Type Name | Rust Type | Description |
---|---|---|
Bool | bool | Boolean values (true or false ) |
String | RString | Quoted String Values |
Integer | i64 | Integer values (numbers) |
Float | f64 | Float values (numbers with decimals) |
Date | Date | Date (yyyy-mm-dd formatted) |
Time | Time | Time (HH:MM , HH:MM:SS formatted) |
DateTime | DateTime | Date and Time separed by or T |
Array | RVec<Attribute> | List of any attribute values |
Table/AttrMap | AttrMap | Key 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.
If you want to assign a attribute inside the task system, you can do it like this:
env.river = "Ohio River"
env.river
Results:
"Ohio River"
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")
node.outlet
Results:
{
lower-mississippi = <None>,
upper-mississippi = <None>,
missouri = <None>,
arkansas = <None>,
red = <None>,
ohio = "Smithland Lock and Dam",
tenessee = <None>
}
With plugins, you can load attributes from different file types.