fastscape-lem / fastscapelib

A C++/Python library of efficient algorithms for landscape evolution modeling
http://fastscapelib.readthedocs.io
GNU General Public License v3.0
36 stars 6 forks source link

integrate Richdem as a library #81

Closed feefladder closed 3 years ago

feefladder commented 3 years ago

perhaps a wild shot, but to me it seems that Richdem is quite robust, fast and similar in functionality to what is implemented here. Would it be possible/beneficial to add it either here, or as possible references in the higher-level python code?

benbovy commented 3 years ago

Hi @Joeperdefloep. Yeah richdem has a lot of great features and implements many efficient algorithms for topographic and hydrologic analysis.

While there is some overlap with richdem, fastscapelib is focused more on Landscape Evolution Models (LEMs), which have specific needs, e.g.,

Although I haven't looked in-depth at richdem yet, I'm not sure that we could just reuse it to address those needs in an optimal way.

Another specificity of fastscapelib is its tight integration with the xtensor library, which provides n-d array containers inspired by NumPy (among much more). xtensor also allows writing bindings in other languages pretty easily (Python for now, but we could also extend it to R or Julia).

I don't think fastscapelib will ever provide an implementation for all the algorithms available in richdem, but it's a nice complement IMO. We actually did reuse richdem here (see https://github.com/fastscape-lem/fastscapelib/pull/41/commits/a0ff7977952d32dbb362c9bc1a8197c260299f8d in #41, work in progress).

feefladder commented 3 years ago

Hi @benbovy, thanks for your quick reply! I have not used fastscapelib yet, even though it looks great. I used Richdem in a course where we implemented a Morgan-Morgan-Finney (MMF) erosion model. It was far from a beautiful implementation, but I think I can call a process from a (Python) xarray. I will have a course about Erosion processes and modelling in 4 weeks, so will become more active on this subject then. What I thought it could be used for is here:

* operations like computing flow directions and accumulation are repeated a lot of time during a simulation

Since it provides many different algorithms for doing exactly that: computing flow directions and accumulation. So in my mind, it would be possible to call a richdem accumulation/flow direction algorithm from fastscapelib/fastscape if you have a regular, 2d grid.

Maybe this is a too narrow use-case, or it should be used as an example, but it feels like an easy addition?

benbovy commented 3 years ago

So in my mind, it would be possible to call a richdem accumulation/flow direction algorithm from fastscapelib/fastscape if you have a regular, 2d grid.

Yes it should be possible to do that. Since #68 there is a flexible system that allows creating new flow routers in fastscapelib that could then be used for computing erosion processes. However, reusing richdem would be here limited to 2-d raster grid with non-periodic boundary conditions, as I don't think that richdem's implementations could support other grids / boundary conditions.

fastscapelib has some built-in routers that don't have those limitations. There's already the single flow router (D4 or D8 for raster grids) and I'll add soon the equivalent of the Quinn algorithm for multiple flow directions.

Same thing for algorithms to resolve flow routing in closed depressions: priority-flood depression filling algorithms are already available in fastscapelib (grid agnostic implementation) and #41 will add a new one that is efficient particularly in the context of LEMs.

used Richdem in a course where we implemented a Morgan-Morgan-Finney (MMF) erosion model. It was far from a beautiful implementation, but I think I can call a process from a (Python) xarray.

You might want to have a look at xarray-simlab if you want to build models and use it with xarray :)

feefladder commented 3 years ago

Thank you very much for your responses, apologies if my additions we not of much use. I am indeed now getting to grips with xarray-simlab :).

benbovy commented 3 years ago

Your feedback and additions are helpful! Thanks!