mauro3 / WhereTheWaterFlows.jl

Hydrolocial water flow routing on digital elevation models
MIT License
16 stars 3 forks source link

New Drainpits algo #30

Closed mauro3 closed 5 months ago

mauro3 commented 5 months ago

Perf improvements are ok:

On master 24a938467957587b2de222434122 (seems to scale roughly as dof^2)

size(dem) = (1768, 2475)
 24.184546 seconds (9.74 M allocations: 1.362 GiB, 1.27% gc time)

size(dem) = (2501, 3501)
 90.270202 seconds (20.45 M allocations: 2.835 GiB, 1.03% gc time, 0.74% compilation time)

size(dem) = (3572, 5001)
369.134222 seconds (39.85 M allocations: 5.763 GiB, 0.69% gc time)

This PR (seems to scale roughly linearly with dof)

size(dem) = (1768, 2475)
  4.662908 seconds (9.30 M allocations: 1.318 GiB, 0.63% gc time)

size(dem) = (2501, 3501)
  9.670854 seconds (18.67 M allocations: 2.682 GiB, 6.49% gc time)

size(dem) = (3572, 5001)
 21.115851 seconds (38.14 M allocations: 5.534 GiB, 8.55% gc time)

size(dem) = (5001, 7001)                                                                        
 46.553710 seconds (74.83 M allocations: 10.953 GiB, 13.48% gc time)                            

size(dem) = (10001, 14001)
243.772434 seconds (299.55 M allocations: 44.433 GiB, 38.09% gc time)

With a DEM with LOTS of pits:

using WhereTheWaterFlows
if !(@isdefined WWF)
    const WWF = WhereTheWaterFlows
end

"An artificial DEM"
function ele(x, y; withpit=false, randfac=0.0)
    out = - (x^2 - 1)^2 - (x^2*y - x - 1)^2 + 6 + 0.1*x + 3*y
    if withpit
        out -= 2*exp(-(x^2 + y^2)*50)
    end
    out += randfac*randn()
    return out<0 ? 0.0 : out
end
dx = 0.001*0.7
xs = -1.5:dx:1
ys = -0.5:dx:3.0
dem = ele.(xs, ys', randfac=0.1, withpit=true);
@show size(dem)
@time area, slen, dir, nout, nin, sinks, pits, c, bnds  = WWF.waterflows(dem, drain_pits=true);

This is on top of PR #29

codecov-commenter commented 5 months ago

Codecov Report

Attention: Patch coverage is 94.40994% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 87.74%. Comparing base (24a9384) to head (e36e54d).

Files Patch % Lines
src/WhereTheWaterFlows.jl 95.33% 7 Missing :warning:
src/postproc.jl 81.81% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #30 +/- ## ========================================== - Coverage 91.27% 87.74% -3.53% ========================================== Files 2 2 Lines 321 351 +30 ========================================== + Hits 293 308 +15 - Misses 28 43 +15 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.