3737
3838"""
3939 Topo_water, sinks, pits, bnds = waterflows(Topo::GeoData;
40- flowdir_fn=WhereTheWaterFlows.d8dir_feature, feedback_fn=nothing, drain_pits=true, bnd_as_sink=true)
40+ flowdir_fn=WhereTheWaterFlows.d8dir_feature, feedback_fn=nothing, drain_pits=true, bnd_as_sink=true,
41+ rainfall = nothing)
4142
42- Takes a GMG GeoData object of a topographic map and routes water through the grid. We add a number of
43+ Takes a GMG GeoData object of a topographic map and routes water through the grid. Optionally,
44+ you can specify `rainfall` in which case we accumulate the rain as specified in this 2D array instead of the cellarea.
45+ This allows you to, for example, sum, up water if you have variable rainfall in the area.
46+ The other options are as in the `waterflows` function of the package `WhereTheWaterFlows`.
4347
4448Example
4549===
@@ -60,9 +64,15 @@ GeoData
6064```
6165
6266"""
63- function waterflows (Topo:: GeoData , flowdir_fn= WhereTheWaterFlows. d8dir_feature; feedback_fn= nothing , drain_pits= true , bnd_as_sink= true )
67+ function waterflows (Topo:: GeoData , flowdir_fn= WhereTheWaterFlows. d8dir_feature; feedback_fn= nothing , drain_pits= true , bnd_as_sink= true , rainfall = nothing )
6468
6569 cellarea = cell_area (Topo)
70+ cellarea_m2 = cellarea
71+ if ! isnothing (rainfall)
72+ @assert typeof (rainfall) == Array{Float64,2 }
73+ cellarea = rainfall
74+ end
75+
6676 dem = Topo. depth. val[:,:,1 ]
6777
6878 area = zeros (Float64,size (Topo. depth. val))
@@ -75,6 +85,6 @@ function waterflows(Topo::GeoData, flowdir_fn= WhereTheWaterFlows.d8dir_feature;
7585 area[:,:,1 ], slen[:,:,1 ], dir[:,:,1 ], nout[:,:,1 ], nin[:,:,1 ], sinks, pits, c[:,:,1 ], bnds = waterflows (dem, cellarea, flowdir_fn;
7686 feedback_fn= feedback_fn, drain_pits= drain_pits, bnd_as_sink= bnd_as_sink)
7787
78- Topo_water = addfield (Topo,(;area, slen, dir, nout, nin, c ))
88+ Topo_water = addfield (Topo,(;area, slen, dir, nout, nin, c, cellarea_m2 ))
7989 return Topo_water, sinks, pits, bnds
8090end
0 commit comments