Wflow.jl
Wflow.jl copied to clipboard
ENH: run a subset of a wflow model
Not sure if this is possible but I have a very large wflow model and for some runs, I'm only interested in small tributaries.
I wondered if it was possible to then run wflow for just the tributaries by applying some kind of masking rather than having to use hydromt to clip the tributaries first.
What I tried:
- derive a gauge and subcatch map for my tributaries
- in [input] set subcatchment="subcatch_tributaries" (for masking my tributaries)
- create a pit boolean map for my gauges_tributaries: pits_tributaries
- use in [model] pits= True and in [input] pits = "pits_tributaries"
I was using the exe of 0.6.2 and got the following error:
ERROR: DimensionMismatch("array could not be broadcast to match destination")
Stacktrace:
[1] check_broadcast_shape
@ .\broadcast.jl:540 [inlined]
[2] check_broadcast_axes
@ .\broadcast.jl:543 [inlined]
[3] check_broadcast_axes
@ .\broadcast.jl:546 [inlined]
[4] instantiate
@ .\broadcast.jl:284 [inlined]
[5] materialize!
@ .\broadcast.jl:871 [inlined]
[6] materialize!
@ .\broadcast.jl:868 [inlined]
[7] update_until_recharge(model::Wflow.Model{NamedTuple{(:land, :river, :reservoir, :lake, :index_river, :frac_toriver), Tuple{NamedTuple{(:graph, :upstream_nodes, :subdomain_order, :topo_subdomain, :indices_subdomain, :order, :indices, :reverse_indices, :xl, :yl, :slope), Tuple{Graphs.SimpleGraphs.SimpleDiGraph{Int64}, Vector{Vector{Int64}}, Vector{Vector{Int64}}, Vector{Vector{Int64}}, Vector{Vector{Int64}}, Vector{Int64}, Vector{CartesianIndex{2}}, Matrix{Int64}, Vector{Float64}, Vector{Float64}, Vector{Float64}}}, NamedTuple{(:graph, :indices, :reverse_indices, :upstream_nodes, :subdomain_order, :topo_subdomain, :indices_subdomain, :order), Tuple{Graphs.SimpleGraphs.SimpleDiGraph{Int64}, Vector{CartesianIndex{2}}, Matrix{Int64}, Vector{Vector{Int64}}, Vector{Vector{Int64}}, Vector{Vector{Int64}}, Vector{Vector{Int64}}, Vector{Int64}}}, NamedTuple{(:indices_outlet, :indices_coverage, :reverse_indices), Tuple{Vector{CartesianIndex{2}}, Vector{Vector{CartesianIndex{2}}}, Matrix{Int64}}}, Tuple{}, Vector{Int64}, Vector{Float64}}}, NamedTuple{(:subsurface, :land, :river), Tuple{Wflow.LateralSSF{Float64}, Wflow.SurfaceFlow{Float64, Nothing, Nothing}, Wflow.SurfaceFlow{Float64, Wflow.SimpleReservoir{Float64}, Nothing}}}, Wflow.SBM{Float64, 4, 5}, Wflow.NCReader, Wflow.Writer, Wflow.SbmModel})
@ Wflow C:\Users\svc-teamcity-ansible\.julia\packages\Wflow\rKnvl\src\sbm_model.jl:450
[8] update(model::Wflow.Model{NamedTuple{(:land, :river, :reservoir, :lake, :index_river, :frac_toriver), Tuple{NamedTuple{(:graph, :upstream_nodes, :subdomain_order, :topo_subdomain, :indices_subdomain, :order, :indices, :reverse_indices, :xl, :yl, :slope), Tuple{Graphs.SimpleGraphs.SimpleDiGraph{Int64}, Vector{Vector{Int64}}, Vector{Vector{Int64}}, Vector{Vector{Int64}}, Vector{Vector{Int64}}, Vector{Int64}, Vector{CartesianIndex{2}}, Matrix{Int64}, Vector{Float64}, Vector{Float64}, Vector{Float64}}}, NamedTuple{(:graph, :indices, :reverse_indices, :upstream_nodes, :subdomain_order, :topo_subdomain, :indices_subdomain, :order), Tuple{Graphs.SimpleGraphs.SimpleDiGraph{Int64}, Vector{CartesianIndex{2}}, Matrix{Int64}, Vector{Vector{Int64}}, Vector{Vector{Int64}}, Vector{Vector{Int64}}, Vector{Vector{Int64}}, Vector{Int64}}}, NamedTuple{(:indices_outlet, :indices_coverage, :reverse_indices), Tuple{Vector{CartesianIndex{2}}, Vector{Vector{CartesianIndex{2}}}, Matrix{Int64}}}, Tuple{}, Vector{Int64}, Vector{Float64}}}, NamedTuple{(:subsurface, :land, :river), Tuple{Wflow.LateralSSF{Float64}, Wflow.SurfaceFlow{Float64, Nothing, Nothing}, Wflow.SurfaceFlow{Float64, Wflow.SimpleReservoir{Float64}, Nothing}}}, Wflow.SBM{Float64, 4, 5}, Wflow.NCReader, Wflow.Writer, Wflow.SbmModel})
Seems like init goes well so maybe in the end could be just the forcing that are not masked well? If so seems like a maybe small change to enable this type of run :)
Can you share the model setup (including a small subset of the forcing data (large wflow model)), so we can reproduce the issue?