Skip to content

Commit 73fc396

Browse files
committed
Make bnd_as_pits=true default. Bump version.
1 parent 4e750a3 commit 73fc396

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "WhereTheWaterFlows"
22
uuid = "ea906314-1493-4d22-a0af-f886a20c9fba"
33
authors = ["Mauro Werder <[email protected]>"]
4-
version = "0.2.1"
4+
version = "0.3.0"
55

66
[deps]
77
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

src/WhereTheWaterFlows.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ kwargs:
174174
- drain_pits -- whether to route through pits (true)
175175
- maxiter -- maximum iterations of the algorithm (1000)
176176
- calc_streamlength -- whether to calculate stream length (true)
177-
- bnd_as_pits (false) -- whether the domain boundary and NaNs should be pits,
177+
- bnd_as_pits (true) -- whether the domain boundary and NaNs should be pits,
178178
i.e. adjacent cells can drain into them,
179179
or whether to ignore them.
180180
@@ -193,7 +193,7 @@ Returns
193193
- bnds -- boundaries between catchments. The boundary to the exterior/NaNs is not in here.
194194
"""
195195
function waterflows(dem, cellarea=ones(size(dem));
196-
maxiter=1000, calc_streamlength=true, drain_pits=true, bnd_as_pits=false)
196+
maxiter=1000, calc_streamlength=true, drain_pits=true, bnd_as_pits=true)
197197
area, slen, dir, nout, nin, pits = _waterflows(d8dir_feature(dem, bnd_as_pits)..., cellarea; maxiter=maxiter, calc_streamlength=calc_streamlength)
198198
c, bnds = catchments(dir, pits, bnd_as_pits)
199199
if drain_pits

test/runtests.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ end
177177
@test pits ==CartesianIndex{2}[CartesianIndex(1, 1), CartesianIndex(3, 1), CartesianIndex(1, 3), CartesianIndex(1, 4)]
178178

179179
# non default cellarea
180-
area, _ = WWF.waterflows(dem, fill(10.0, size(dem)))
180+
area, _ = WWF.waterflows(dem, fill(10.0, size(dem)), bnd_as_pits=false)
181181
@test area == [10.0 10.0 50.0 10.0; 10.0 10.0 10.0 10.0; 50.0 30.0 20.0 10.0]
182182
end
183183

184184
@testset "DEM: peaks2" begin
185185
xs, dem = peaks2()
186186
ys = xs
187187
@test size(dem)==(length(xs), length(ys))
188-
area, slen, dir, nout, nin, pits, c, bnds = WWF.waterflows(dem, drain_pits=false);
188+
area, slen, dir, nout, nin, pits, c, bnds = WWF.waterflows(dem, drain_pits=false, bnd_as_pits=false);
189189
#plotarea_dem(xs, ys, dem, area, pits)
190190
@test length(pits) == 6
191191
@test maximum(slen)==67
@@ -195,7 +195,7 @@ end
195195
@test sum(diff(c[:])) == 5
196196
@test sort(unique(c))[[1,end]] ==[1,6]
197197

198-
area, slen, dir, nout, nin, pits, c, bnds = WWF.waterflows(dem, drain_pits=true);
198+
area, slen, dir, nout, nin, pits, c, bnds = WWF.waterflows(dem, drain_pits=true, bnd_as_pits=false)
199199
# plotarea_dem(xs, ys, dem, area, pits)
200200
@test length(pits) == 4
201201
@test maximum(slen)==118
@@ -312,7 +312,7 @@ end
312312
xs = -1.5:dx:1
313313
ys = -0.5:dx:3.0
314314
dem = dem1.(xs, ys', withpit=true)
315-
area, slen, dir, nout, nin, pits = WWF.waterflows(dem)
315+
area, slen, dir, nout, nin, pits = WWF.waterflows(dem, bnd_as_pits=false)
316316
demf = WWF.fill_dem(dem, pits, dir)
317317
@test sum(demf.-dem) 2.1499674517313414
318318
@test sum(demf.-dem .> 0) == 5
@@ -323,7 +323,7 @@ end
323323
(xs, ys), dem = dem_one_point()
324324
mask = .!isnan.(dem)
325325
#should not error
326-
area, slen, dir, nout, nin, pits = WWF.waterflows(dem, drain_pits=true)
326+
area, slen, dir, nout, nin, pits = WWF.waterflows(dem, drain_pits=true, bnd_as_pits=false)
327327
@test mask[pits[1]]
328328
@test length(pits)==1
329329
#@test all(getindex.(Ref(mask), pits).==0) # tests that there are no interior pits left
@@ -334,7 +334,7 @@ end
334334
(xs, ys), dem = dem_two_points()
335335
mask = .!isnan.(dem)
336336
#should not error
337-
area, slen, dir, nout, nin, pits = WWF.waterflows(dem, drain_pits=true)
337+
area, slen, dir, nout, nin, pits = WWF.waterflows(dem, drain_pits=true, bnd_as_pits=false)
338338
@test mask[pits[1]]
339339
@test mask[pits[2]]
340340
@test length(pits)==2
@@ -345,7 +345,7 @@ end
345345
(xs, ys), dem = dem_patho1()
346346
mask = .!isnan.(dem)
347347
#should not error
348-
area, slen, dir, nout, nin, pits = WWF.waterflows(dem, drain_pits=true)
348+
area, slen, dir, nout, nin, pits = WWF.waterflows(dem, drain_pits=true, bnd_as_pits=false)
349349
@test length(pits)==2
350350
area, slen, dir, nout, nin, pits = WWF.waterflows(dem, drain_pits=true, bnd_as_pits=true)
351351
@test all(getindex.(Ref(mask), pits).==0)
@@ -357,7 +357,7 @@ end
357357
# also mask border points
358358
mask[1,:] .= false; mask[end,:] .= false; mask[:,1] .= false; mask[:,end] .= false
359359
# should not have a pit in the interior
360-
area, slen, dir, nout, nin, pits = WWF.waterflows(dem, drain_pits=true)
360+
area, slen, dir, nout, nin, pits = WWF.waterflows(dem, drain_pits=true, bnd_as_pits=false)
361361
@test all(getindex.(Ref(mask), pits).==0)
362362
area, slen, dir, nout, nin, pits = WWF.waterflows(dem, drain_pits=true, bnd_as_pits=true)
363363
@test all(getindex.(Ref(mask), pits).==0)

0 commit comments

Comments
 (0)