37
37
38
38
"""
39
39
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)
41
42
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`.
43
47
44
48
Example
45
49
===
@@ -60,9 +64,15 @@ GeoData
60
64
```
61
65
62
66
"""
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 )
64
68
65
69
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
+
66
76
dem = Topo. depth. val[:,:,1 ]
67
77
68
78
area = zeros (Float64,size (Topo. depth. val))
@@ -75,6 +85,6 @@ function waterflows(Topo::GeoData, flowdir_fn= WhereTheWaterFlows.d8dir_feature;
75
85
area[:,:,1 ], slen[:,:,1 ], dir[:,:,1 ], nout[:,:,1 ], nin[:,:,1 ], sinks, pits, c[:,:,1 ], bnds = waterflows (dem, cellarea, flowdir_fn;
76
86
feedback_fn= feedback_fn, drain_pits= drain_pits, bnd_as_sink= bnd_as_sink)
77
87
78
- Topo_water = addfield (Topo,(;area, slen, dir, nout, nin, c ))
88
+ Topo_water = addfield (Topo,(;area, slen, dir, nout, nin, c, cellarea_m2 ))
79
89
return Topo_water, sinks, pits, bnds
80
90
end
0 commit comments