Skip to content

Commit 1586564

Browse files
Merge pull request #37 from ConnectedSystems/param-desc
Add user-facing descriptions of model parameters
2 parents 2daea9d + 69dff81 commit 1586564

File tree

9 files changed

+125
-93
lines changed

9 files changed

+125
-93
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,18 @@ To display an overview of a node or network:
172172
julia> node
173173
Name: 406219 [IHACRESBilinearNode]
174174
Area: 1985.73
175-
┌──────────────┬───────────┬─────────────┬─────────────┐
176-
│ Parameter │ Value │ Lower Bound │ Upper Bound │
177-
├──────────────┼───────────┼─────────────┼─────────────┤
178-
│ d │ 84.280210.0550.0
179-
│ d2 │ 2.422410.000110.0
180-
│ e │ 0.8129590.11.5
181-
│ f │ 2.579280.013.0
182-
│ a │ 5.923380.110.0
183-
│ b │ 0.09899260.0010.1
184-
│ storage_coef │ 1.861341.0e-1010.0
185-
│ alpha │ 0.7279051.0e-51.0
186-
└──────────────┴───────────┴─────────────┴─────────────┘
175+
┌──────────────┬───────────┬─────────────┬─────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
176+
│ Parameter │ Value │ Lower Bound │ Upper Bound │ Description │
177+
├──────────────┼───────────┼─────────────┼─────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
178+
│ d │ 84.280210.0550.0 Catchment moisture deficit threshold, higher values indicate the catchment can hold more water before generating runoff. │
179+
│ d2 │ 2.422410.000110.0 Scaling factor (d*d2) which creates a second threshold, changing the shape of effective rainfall response. │
180+
│ e │ 0.8129590.11.5 PET conversion factor, controls the rate of evapotranspiration losses, converts temperature to PET. │
181+
│ f │ 2.579280.013.0 Plant stress threshold, controls at what moisture deficit plants begin to experience stress. │
182+
│ a │ 5.923380.110.0 Quickflow storage coefficient, where higher values lead to faster quickflow response. │
183+
│ b │ 0.09899260.0010.1 Slowflow storage coefficient, lower values lead to slower baseflow recession. │
184+
│ storage_coef │ 1.861341.0e-1010.0 Groundwater interaction factor, controling how water is exchanged with deeper groundwater. │
185+
│ alpha │ 0.7279051.0e-51.0 Effective rainfall scaling factor, partitions rainfall into runoff. │
186+
└──────────────┴───────────┴─────────────┴─────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
187187
```
188188

189189
### Network specification

docs/src/examples/node_creation.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,39 @@ user-defined values.
77
using Streamfall
88

99
hymod_node = create_node(SimpleHyModNode, "410730", 129.2)
10+
# Name: 410730 [SimpleHyModNode]
11+
# Area: 129.2
12+
# ┌───────────┬───────┬─────────────┬─────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────┐
13+
# │ Parameter │ Value │ Lower Bound │ Upper Bound │ Description │
14+
# ├───────────┼───────┼─────────────┼─────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────┤
15+
# │ Sm_max │ 250.0 │ 1.0 │ 500.0 │ Maximum soil storage capacity. │
16+
# │ B │ 1.0 │ 0.0 │ 2.0 │ Controls how quickly the catchment becomes saturated as rainfall accumulates. │
17+
# │ alpha │ 0.2 │ 0.0 │ 1.0 │ The split between quick and slow flow components. Higher values direct more water through quickflow. │
18+
# │ Kf │ 0.5 │ 0.1 │ 0.9999 │ Quickflow recession. │
19+
# │ Ks │ 0.05 │ 0.001 │ 0.1 │ Slowflow recession. │
20+
# └───────────┴───────┴─────────────┴─────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────┘
1021

1122
# Hymod parameters ("hy_" prefix is simply to avoid any variable name conflicts)
12-
hy_Sm_max = 250.0
13-
hy_B = 1.0
14-
hy_alpha = 0.2
15-
hy_Kf = 0.5
16-
hy_Ks = 0.05
23+
hy_Sm_max = 370.0
24+
hy_B = 0.5
25+
hy_alpha = 0.3
26+
hy_Kf = 0.25
27+
hy_Ks = 0.25
1728

1829
# Update parameters
1930
update_params!(hymod_node, hy_Sm_max, hy_B, hy_alpha, hy_Kf, hy_Ks)
31+
32+
# The "Value" column indicates model parameters have been updated.
33+
print(hymod_node)
34+
# Name: 410730 [SimpleHyModNode]
35+
# Area: 129.2
36+
# ┌───────────┬───────┬─────────────┬─────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────┐
37+
# │ Parameter │ Value │ Lower Bound │ Upper Bound │ Description │
38+
# ├───────────┼───────┼─────────────┼─────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────┤
39+
# │ Sm_max │ 370.0 │ 1.0 │ 500.0 │ Maximum soil storage capacity. │
40+
# │ B │ 0.5 │ 0.0 │ 2.0 │ Controls how quickly the catchment becomes saturated as rainfall accumulates. │
41+
# │ alpha │ 0.3 │ 0.0 │ 1.0 │ The split between quick and slow flow components. Higher values direct more water through quickflow. │
42+
# │ Kf │ 0.25 │ 0.1 │ 0.9999 │ Quickflow recession. │
43+
# │ Ks │ 0.25 │ 0.001 │ 0.1 │ Slowflow recession. │
44+
# └───────────┴───────┴─────────────┴─────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────┘
2045
```

docs/src/primer.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The spec takes the following form:
3535
# The node type which defines which model is used for this node
3636
# In this case, it is the IHACRES with the bilinear formulation of the CMD module
3737
node_type: IHACRESBilinearNode
38-
area: 130.0 # subcatchment area in km^2 (from BoM)
38+
area: 130.0 # subcatchment area in km^2 (from the Australian Bureau of Meteorology)
3939

4040
# This spec defines a single node system
4141
# so it has no nodes upstream (inlets) or downstream (outlets)
@@ -76,18 +76,18 @@ Node 1
7676
--------
7777
Name: 410730 [IHACRESBilinearNode]
7878
Area: 130.0
79-
┌──────────────┬───────┬─────────────┬─────────────┐
80-
│ Parameter │ Value │ Lower Bound │ Upper Bound │
81-
├──────────────┼───────┼─────────────┼─────────────┤
82-
│ d │ 200.0 │ 10.0 │ 550.0 │
83-
│ d2 │ 2.0 │ 0.0001 │ 10.0 │
84-
│ e │ 1.0 │ 0.1 │ 1.5 │
85-
│ f │ 0.8 │ 0.01 │ 3.0 │
86-
│ a │ 0.9 │ 0.1 │ 10.0 │
87-
│ b │ 0.1 │ 0.001 │ 0.1 │
88-
│ storage_coef │ 2.9 │ 1.0e-10 │ 10.0 │
89-
│ alpha │ 0.95 │ 1.0e-5 │ 1.0 │
90-
└──────────────┴───────┴─────────────┴─────────────┘
79+
┌──────────────┬───────┬─────────────┬─────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
80+
│ Parameter │ Value │ Lower Bound │ Upper Bound │ Description │
81+
├──────────────┼───────┼─────────────┼─────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
82+
│ d │ 200.0 │ 10.0 │ 550.0 │ Catchment moisture deficit threshold, higher values indicate the catchment can hold more water before generating runoff. │
83+
│ d2 │ 2.0 │ 0.0001 │ 10.0 │ Scaling factor (d*d2) which creates a second threshold, changing the shape of effective rainfall response. │
84+
│ e │ 1.0 │ 0.1 │ 1.5 │ PET conversion factor, controls the rate of evapotranspiration losses, converts temperature to PET. │
85+
│ f │ 0.8 │ 0.01 │ 3.0 │ Plant stress threshold, controls at what moisture deficit plants begin to experience stress. │
86+
│ a │ 0.9 │ 0.1 │ 10.0 │ Quickflow storage coefficient, where higher values lead to faster quickflow response. │
87+
│ b │ 0.1 │ 0.001 │ 0.1 │ Slowflow storage coefficient, lower values lead to slower baseflow recession. │
88+
│ storage_coef │ 2.9 │ 1.0e-10 │ 10.0 │ Groundwater interaction factor, controling how water is exchanged with deeper groundwater. │
89+
│ alpha │ 0.95 │ 1.0e-5 │ 1.0 │ Effective rainfall scaling factor, partitions rainfall into runoff. │
90+
└──────────────┴───────┴─────────────┴─────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
9191
```
9292

9393

src/Nodes/DamNode.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Base.@kwdef mutable struct DamNode{P,A<:AbstractFloat} <: NetworkNode
3131
area::A
3232

3333
max_storage::A
34-
storage_coef::P = Param(0.5, bounds=(0.00001, 10.0))
34+
storage_coef::P = Param(0.5, bounds=(0.00001, 10.0), desc="Storage coefficient.")
3535

3636
# Dam storage volume to level
3737
calc_dam_level::Function = c_dam_level

src/Nodes/GR4J/GR4JNode.jl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,10 @@ Base.@kwdef mutable struct GR4JNode{P,A<:AbstractFloat} <: GRNJNode
7171
const area::A
7272

7373
# Parameters
74-
# x1 : maximum capacity of the production store (mm) (> 0)
75-
# x2 : groundwater exchange coefficient (mm) (value < and > 0 possible)
76-
# x3 : one day ahead maximum capacity of the routing store (mm, > 0)
77-
# x4 : time base of unit hydrograph UH1 (days, > 0.5)
78-
X1::P = Param(350.0, bounds=(1.0, 1500.0))
79-
X2::P = Param(0.0, bounds=(-10.0, 5.0))
80-
X3::P = Param(40.0, bounds=(1.0, 500.0))
81-
X4::P = Param(0.5, bounds=(0.5, 10.0))
74+
X1::P = Param(350.0, bounds=(1.0, 1500.0), desc="Maximum soil water storage capacity.")
75+
X2::P = Param(0.0, bounds=(-10.0, 5.0), desc="Water exchange with deeper groundwater and adjacent catchments.")
76+
X3::P = Param(40.0, bounds=(1.0, 500.0), desc="Maximum capacity of one day ahead of routing store, controls the baseflow component.")
77+
X4::P = Param(0.5, bounds=(0.5, 10.0), desc="Time base of quickflow controlling the timing and shape of hydrograph.")
8278

8379
# stores
8480
p_store::Vector{A} = [0.0]
@@ -226,10 +222,13 @@ end
226222
Update parameters for GR4J.
227223
"""
228224
function update_params!(node::GR4JNode, X1::Float64, X2::Float64, X3::Float64, X4::Float64)::Nothing
229-
node.X1 = Param(X1, bounds=node.X1.bounds)
230-
node.X2 = Param(X2, bounds=node.X2.bounds)
231-
node.X3 = Param(X3, bounds=node.X3.bounds)
232-
node.X4 = Param(X4, bounds=node.X4.bounds)
225+
param_pairs = zip([:X1, :X2, :X3, :X4], [X1, X2, X3, X4])
226+
227+
# First item will always be the set value, so it can be skipped
228+
for (p, v) in param_pairs
229+
param = getfield(node, p)
230+
setfield!(node, p, Param(v; (keys(param)[2:end] .=> values(param)[2:end])...))
231+
end
233232

234233
return nothing
235234
end

src/Nodes/HyMod/HyModNode.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ Base.@kwdef mutable struct SimpleHyModNode{P,A<:AbstractFloat} <: HyModNode
2525
const area::A
2626

2727
# parameters
28-
Sm_max::P = Param(250.0, bounds=(1.0, 500.0))
29-
B::P = Param(1.0, bounds=(0.0, 2.0))
30-
alpha::P = Param(0.2, bounds=(0.0, 1.0))
31-
Kf::P = Param(0.5, bounds=(0.1, 0.9999))
32-
Ks::P = Param(0.05, bounds=(0.001, 0.1))
28+
Sm_max::P = Param(250.0, bounds=(1.0, 500.0), desc="Maximum soil storage capacity.")
29+
B::P = Param(1.0, bounds=(0.0, 2.0), desc="Controls how quickly the catchment becomes saturated as rainfall accumulates.")
30+
alpha::P = Param(0.2, bounds=(0.0, 1.0), desc="The split between quick and slow flow components. Higher values direct more water through quickflow.")
31+
Kf::P = Param(0.5, bounds=(0.1, 0.9999), desc="Quickflow recession.")
32+
Ks::P = Param(0.05, bounds=(0.001, 0.1), desc="Slowflow recession.")
3333

3434
# stores
3535
Sm::Array{A} = [0.0]
@@ -173,11 +173,13 @@ end
173173
Update parameters for HyMod.
174174
"""
175175
function update_params!(node::HyModNode, Sm_max::F, B::F, alpha::F, Kf::F, Ks::F) where {F<:Float64}
176-
node.Sm_max = Param(Sm_max, bounds=node.Sm_max.bounds::Tuple)
177-
node.B = Param(B, bounds=node.B.bounds::Tuple)
178-
node.alpha = Param(alpha, bounds=node.alpha.bounds::Tuple)
179-
node.Kf = Param(Kf, bounds=node.Kf.bounds::Tuple)
180-
node.Ks = Param(Ks, bounds=node.Ks.bounds::Tuple)
176+
param_pairs = zip([:Sm_max, :B, :alpha, :Kf, :Ks], [Sm_max, B, alpha, Kf, Ks])
177+
178+
# First item will always be the set value, so it can be skipped
179+
for (p, v) in param_pairs
180+
param = getfield(node, p)
181+
setfield!(node, p, Param(v; (keys(param)[2:end] .=> values(param)[2:end])...))
182+
end
181183
end
182184

183185
function update_state!(

0 commit comments

Comments
 (0)