Skip to content

Commit 62b8ca1

Browse files
committed
Merge branch 'master' into feat/kinwave_floodplain
2 parents 58fdc01 + 80692fe commit 62b8ca1

15 files changed

Lines changed: 114 additions & 93 deletions

Wflow.spdx.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,12 +1165,12 @@
11651165
]
11661166
},
11671167
{
1168-
"name": "DelimitedFiles",
1169-
"SPDXID": "SPDXRef-DelimitedFiles-8bb1440f-4735-579b-a4ab-409b98df4dab",
1170-
"versionInfo": "1.9.1",
1168+
"name": "PropertyDicts",
1169+
"SPDXID": "SPDXRef-PropertyDicts-f8a19df8-e894-5f55-a973-672c1158cbca",
1170+
"versionInfo": "0.2.1",
11711171
"supplier": "NOASSERTION",
11721172
"originator": "NOASSERTION",
1173-
"downloadLocation": "git+https://github.com/JuliaData/DelimitedFiles.jl.git@9e2f36d3c96a820c678f2f1f1782582fcf685bae",
1173+
"downloadLocation": "git+https://github.com/JuliaCollections/PropertyDicts.jl.git@a6b4c12d38387a4382fa53b8a6591f9c219add16",
11741174
"filesAnalyzed": true,
11751175
"packageVerificationCode": {
11761176
"packageVerificationCodeValue": "75953b0316ba1232a2fbba58bf6fb27d9a676e39"

Wflow/src/io.jl

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ const mover_params = (
4242
"land_surface_water__potential_evaporation_volume_flux",
4343
)
4444

45+
# Map domain name to regular expression for matching with standard name or model path
46+
const domain_parameter_map = Dict{String, Regex}(
47+
"reservoir" => r"reservoir|routing.river_flow.boundary_conditions.reservoir",
48+
"river" => r"river|floodplain|routing.river_flow",
49+
"drain" => r"land_drain|routing.subsurface_flow.boundaries.drain",
50+
)
51+
4552
function routing_with_reservoirs(model)
4653
(; config) = model
4754
return config.model.reservoir__flag
@@ -675,34 +682,16 @@ end
675682

676683
function get_reducer_func(col, domain, args...)
677684
(; parameter) = col
678-
if occursin("reservoir", parameter)
679-
reducer_func = reducer(
680-
col,
681-
domain.reservoir.network.reverse_indices,
682-
domain.land.network.indices,
683-
args...,
684-
)
685-
elseif occursin("river", parameter) || occursin("floodplain", parameter)
686-
reducer_func = reducer(
687-
col,
688-
domain.river.network.reverse_indices,
689-
domain.land.network.indices,
690-
args...,
691-
)
692-
elseif occursin("drain", parameter)
693-
reducer_func = reducer(
694-
col,
695-
domain.drain.network.reverse_indices,
696-
domain.land.network.indices,
697-
args...,
698-
)
685+
(; indices) = domain.land.network
686+
if startswith(parameter, domain_parameter_map["reservoir"])
687+
reducer_func =
688+
reducer(col, domain.reservoir.network.reverse_indices, indices, args...)
689+
elseif startswith(parameter, domain_parameter_map["river"])
690+
reducer_func = reducer(col, domain.river.network.reverse_indices, indices, args...)
691+
elseif startswith(parameter, domain_parameter_map["drain"])
692+
reducer_func = reducer(col, domain.drain.network.reverse_indices, indices, args...)
699693
else
700-
reducer_func = reducer(
701-
col,
702-
domain.land.network.reverse_indices,
703-
domain.land.network.indices,
704-
args...,
705-
)
694+
reducer_func = reducer(col, domain.land.network.reverse_indices, indices, args...)
706695
end
707696
end
708697

Wflow/src/sediment/erosion/erosion_process.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Rainfall erosion model based on EUROSEM.
1919
- `interception` (interception [m s⁻¹])
2020
- `waterlevel` (water level [m])
2121
- `soil_detachability` (soil detachability [kg J⁻¹])
22-
- `eurosem_exponent` (EUROSEM exponent [-])
22+
- `eurosem_exponent` (EUROSEM exponent [mm-1])
2323
- `canopy_height` (canopy height [m])
2424
- `canopy_gap_fraction` (canopy gap fraction [-])
2525
- `soilcover_fraction` (soil cover fraction [-])

Wflow/src/utils.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,13 @@ function active_indices(
9898
return indices, reverse_indices
9999
end
100100

101+
"Get active indices of `key` (standard name or model path) by prefix string matching."
101102
function active_indices(domain::Domain, key::AbstractString)::Vector{CartesianIndex{2}}
102-
if occursin("reservoir", key)
103+
if startswith(key, domain_parameter_map["reservoir"])
103104
return domain.reservoir.network.indices_outlet
104-
elseif occursin("river", key) || occursin("floodplain", key)
105+
elseif startswith(key, domain_parameter_map["river"])
105106
return domain.river.network.indices
106-
elseif occursin("drain", key)
107+
elseif startswith(key, domain_parameter_map["drain"])
107108
return domain.drain.network.indices
108109
else
109110
return domain.land.network.indices

Wflow/test/run_sbm.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@
7474
["time", "layer", "river_gauge__count", "temp_bycoord", "temp_byindex"]
7575
end
7676

77+
@testset "NetCDF grid output" begin
78+
ds = model.writer.grid_writer.output_dataset
79+
land_inds = model.domain.land.network.indices
80+
river_inds = model.domain.river.network.indices
81+
reservoir_inds = model.domain.reservoir.network.indices_outlet
82+
@test ds["time"][1] == DateTime("2000-01-02T00:00:00")
83+
@test mean(ds["ustorelayerdepth"][land_inds, 1, 1]) 1.6280833
84+
@test mean(ds["satwaterdepth"][land_inds, 1]) 428.79132
85+
@test mean(ds["snow"][land_inds, 1]) 0.038019713
86+
@test mean(ds["q_av_land"][land_inds, 1]) 0.00066952046f0
87+
@test mean(ds["q_land_to_river"][land_inds, 1]) 7.3739284f-5
88+
@test mean(ds["ssf_to_river"][land_inds, 1]) 83.955956
89+
@test mean(ds["storage_reservoir"][reservoir_inds, 1]) 3.700436e7
90+
@test mean(ds["q_av_river"][river_inds, 1]) 0.14963673f0
91+
end
92+
7793
@testset "First timestep: interception" begin
7894
(; interception) = model.land
7995

Wflow/test/run_sbm_gwf_piave.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@
6060
]
6161
@test maximum(soil.variables.exfiltration_saturated_water) 2.5641140612390893e-6
6262
@test soil.variables.exfiltration_saturated_water[17] == 0.0
63-
@test mean(river_flow.variables.q_average) 30.071991490895094
63+
@test mean(river_flow.variables.q_average) 30.071952652807262
6464
@test maximum(river_flow.variables.q_average) 117.48258852034441
6565
@test soil.variables.total_storage[7503] 0.4729217078886107
66-
@test soil.variables.total_storage[17] 0.8174107029296707 # river cell
66+
@test soil.variables.total_storage[17] 0.8174041514679893 # river cell
6767
end
6868

6969
Wflow.run_timestep!(model)
@@ -86,20 +86,20 @@
8686
@test reservoir.variables.outflow_average
8787
[3.2489840968665207, 9.467087432483991, 38.61905891069846]
8888
@test soil.variables.exfiltration_saturated_water[27:33] [
89-
4.450632579987645e-7,
90-
2.1330559140556994e-8,
91-
1.9144110026163764e-7,
92-
1.3173453594410016e-7,
93-
3.326227288442264e-7,
94-
2.107184034329379e-7,
95-
2.2676935706227792e-7,
89+
4.4499663949920836e-7,
90+
2.1324849628191906e-8,
91+
1.9141341039545324e-7,
92+
1.3171472423984984e-7,
93+
3.3262272882838675e-7,
94+
2.1071840342472223e-7,
95+
2.2674083769260248e-7,
9696
]
9797
@test maximum(soil.variables.exfiltration_saturated_water) 3.877067765823678e-6
9898
@test soil.variables.exfiltration_saturated_water[17] == 0.0
99-
@test mean(river_flow.variables.q_average) 36.80765857144827
100-
@test maximum(river_flow.variables.q_average) 141.84332548772514
99+
@test mean(river_flow.variables.q_average) 36.807481985571734
100+
@test maximum(river_flow.variables.q_average) 141.8432828094925
101101
@test soil.variables.total_storage[7503] 0.4634074094243159
102-
@test soil.variables.total_storage[17] 0.8395331546043192 # river cell
102+
@test soil.variables.total_storage[17] 0.8395068501994309 # river cell
103103
end
104104

105105
Wflow.close_files(model; delete_output = false)

Wflow/test/run_sbm_piave.jl

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616

1717
idx = 1:3:28
1818
@test q_demand[idx] [
19-
227.38262076140597,
20-
197.77826932854217,
21-
267.02912980712193,
22-
155.28759918931823,
23-
155.82292184228206,
24-
143.33475478513975,
25-
115.38260642480303,
26-
100.99725841800637,
27-
166.27201893591504,
28-
103.1045884698738,
19+
227.38262011461978,
20+
197.7764252053005,
21+
267.0195222513418,
22+
155.26689185747682,
23+
155.7833207888182,
24+
143.31261663946606,
25+
115.37288585606876,
26+
100.99592421900839,
27+
166.27459603785587,
28+
103.10860102357384,
2929
]
3030
@test q_[idx] [
3131
230.50830652411622,
@@ -40,16 +40,16 @@
4040
108.08518587596184,
4141
]
4242
@test riv_storage_demand[idx] [
43-
61262.15586688514,
44-
56031.22324367828,
45-
61373.56490076488,
46-
48073.00601232394,
47-
50574.8858099468,
48-
42730.438661308515,
49-
40760.706597408636,
50-
38426.54099045719,
51-
43466.61231827235,
52-
38558.90224961908,
43+
61262.14656138796,
44+
56030.678213839215,
45+
61376.61248402287,
46+
48067.710266972324,
47+
50569.606041068684,
48+
42727.79363371966,
49+
40759.80869303904,
50+
38426.760161782266,
51+
43467.15893205079,
52+
38559.695784094336,
5353
]
5454
@test riv_storage[idx] [
5555
61902.31987942963,
@@ -64,16 +64,16 @@
6464
38512.97533866192,
6565
]
6666
@test ssf_storage_demand[idx] [
67-
148920.45317987585,
68-
145035.32705296585,
69-
143981.91015223257,
70-
140540.61889193894,
71-
138341.04974891624,
72-
135225.98687730395,
73-
132350.44182452557,
74-
129525.55864517286,
75-
129529.58758586958,
76-
127504.02426822705,
67+
148919.6495880998,
68+
145033.4702126483,
69+
143967.11148222588,
70+
140525.72997799006,
71+
138330.5949371187,
72+
135219.02660928076,
73+
132344.29857001666,
74+
129519.82362007826,
75+
129523.35618003459,
76+
127497.15699663045,
7777
]
7878
@test ssf_storage[idx] [
7979
148907.47777948846,
@@ -149,8 +149,8 @@ end
149149
1.6261642209308662e-7,
150150
]
151151
@test maximum(soil.variables.exfiltration_saturated_water) 2.710099850205676e-6
152-
@test mean(river_flow.variables.q_average) 60.35958015226597
153-
@test maximum(river_flow.variables.q_average) 235.44682290212157
152+
@test mean(river_flow.variables.q_average) 60.35956987813754
153+
@test maximum(river_flow.variables.q_average) 235.44680181139788
154154
end
155155

156156
Wflow.run_timestep!(model)
@@ -180,8 +180,8 @@ end
180180
1.6873503884561887e-7,
181181
]
182182
@test maximum(soil.variables.exfiltration_saturated_water) 2.498618226159136e-6
183-
@test mean(river_flow.variables.q_average) 56.22490708883267
184-
@test maximum(river_flow.variables.q_average) 227.21143082238987
183+
@test mean(river_flow.variables.q_average) 56.22484066832971
184+
@test maximum(river_flow.variables.q_average) 227.21136189801825
185185
end
186186

187187
Wflow.close_files(model; delete_output = false)

Wflow/test/sbm_config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ subsurface_water__volume_flow_rate = "ssf_av"
146146
land_surface_water__volume_flow_rate = "q_av_land"
147147
land_surface_water__depth = "h_land"
148148
land.interception.variables.canopy_storage = "canopystorage"
149+
land_surface_water__to_river_volume_flow_rate = "q_land_to_river"
150+
subsurface_water__to_river_volume_flow_rate = "ssf_to_river"
149151

150152
[output.netcdf_scalar]
151153
path = "output_scalar_moselle.nc"

Wflow/test/sbm_gwf_piave_demand_config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ soil_surface_water__vertical_saturated_hydraulic_conductivity = "KsatVer"
9292
soil_water__vertical_saturated_hydraulic_conductivity_scale_parameter = "f"
9393
land_water_allocation_area__count = "allocation_areas_admin2"
9494
land_surface_water__withdrawal_fraction = "frac_sw_used"
95-
soil_water__vertical_saturated_hydraulic_conductivity_factor = "kvfrac"
95+
soil_layer_water__vertical_saturated_hydraulic_conductivity_factor = "kvfrac"
9696
irrigated_paddy_area__count = "paddy_irrigation_areas"
9797
irrigated_non_paddy_area__count = "nonpaddy_irrigation_areas"
9898
model_constant_boundary_condition__hydraulic_head = "constant_head"

Wflow/test/sbm_piave_demand_config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ soil_surface_water__vertical_saturated_hydraulic_conductivity = "KsatVer"
9292
soil_water__vertical_saturated_hydraulic_conductivity_scale_parameter = "f"
9393
land_water_allocation_area__count = "allocation_areas_admin2"
9494
land_surface_water__withdrawal_fraction = "frac_sw_used"
95-
soil_water__vertical_saturated_hydraulic_conductivity_factor = "kvfrac"
95+
soil_layer_water__vertical_saturated_hydraulic_conductivity_factor = "kvfrac"
9696
irrigated_paddy_area__count = "paddy_irrigation_areas"
9797
irrigated_non_paddy_area__count = "nonpaddy_irrigation_areas"
9898
subsurface_water__horizontal_to_vertical_saturated_hydraulic_conductivity_ratio.value = 100

0 commit comments

Comments
 (0)