You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/multiscale/multiscale_considerations.md
+48-22Lines changed: 48 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,39 +83,65 @@ Instead of a [`ModelList`](@ref), it takes an MTG and a mapping. The optional `m
83
83
84
84
## Multi-scale output data structure
85
85
86
-
The output structure, like the mapping, is a Julia `Dict` structure indexed by scale. In each scale, another `Dict` maps variables to their values per timestep, per node. This makes the structure a little bulkier and a little more verbose to inspect than in single-scale, but the general usage is similar. Multiscale Tree Graph nodes are also added to the output data, as a `:node` entry.
86
+
87
+
The output structure, like the mapping, is a Julia `Dict` structure indexed by the scale name. Values are a per-scale `Vector{NamedTuple}` which lists the requested variables for every node at that scale, for every timestep in the simulation. Timestep and Multiscale Tree Graph nodes are also added to the output data, as a `:timestep`and a `:node` entry.
88
+
89
+
This dictionary structure makes the outputs as-is a little more verbose to inspect than in single-scale, but the general usage is similar, and it is both compact, and fast to convert to a `Dict{String, DataFrame}` which can make queries easier.
90
+
91
+
!!! note
92
+
Some of the mapped variables -those that map from scalar to vector- will not be added to the outputs to save some memory and space since they are redundant.
93
+
87
94
88
95
To illustrate, here's an example output from part 3 of the Toy plant tutorial, zeroing in on a variable at the "Root" scale: [Fixing bugs in the plant simulation](@ref):
89
96
90
97
```julia
91
98
julia> outs
92
99
93
-
Dict{String, Dict{Symbol, Vector}} with 5 entries:
As more roots get added in this simulation, the vectors expand to list the values of all the nodes for every variable for every timestep.
122
+
Values are more complex to query than in a single-scale simulation since the indexing isn't straightforward to map to a timestep:
123
+
124
+
```julia
125
+
julia> [Pair(outs["Root"][i][:timestep], outs["Root"][i][:carbon_root_creation_consumed]) for i in1:length(outs["Root"])]
126
+
3257-element Vector{Pair{Int64, Float64}}:
127
+
1=>50.0
128
+
1=>50.0
129
+
2=>50.0
130
+
2=>50.0
131
+
2=>50.0
132
+
⋮
133
+
365=>50.0
134
+
365=>50.0
135
+
365=>50.0
136
+
365=>50.0
137
+
365=>50.0
138
+
365=>50.0
139
+
365=>50.0
140
+
365=>50.0
141
+
365=>50.0
142
+
```
143
+
144
+
Converting to a dictionary of DataFrame objects can make such queries easier to write.
119
145
120
146
!!! warning
121
147
Currently, the `:node` entry only shallow copies nodes. The `:node` values at each scale for every timestep actually reflect the final state of the node, meaning attribute values may not correspond to the value at that timestep. You may need to output these values via a dedicated model to keep track of them properly.
Copy file name to clipboardExpand all lines: docs/src/multiscale/multiscale_example_3.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -244,13 +244,19 @@ Depth = 3
244
244
245
245
There is one quirk you may have noticed when inspecting the data : when a root expands, the new root is immediately active, and some models may act on it immediately... including the root growth model. Meaning this new root may also sprout another root in the same timestep, and so on.
246
246
247
-
You can notice this by looking at the simulation's state after the first timestep:
247
+
You can notice this by looking at the simulation's state during the first two timesteps:
248
248
249
249
```@example usepkg
250
250
outs = run!(mtg, mapping, first(meteo_day, 2))
251
-
nodes_per_timestep = outs["Root"][:node]
252
-
root_lengths_per_timestep = [length(nodes_per_timestep[i]) for i in 1:length(nodes_per_timestep)]
0 commit comments