Accumulating generic fields (not just runoff) using FlowAccumulator
See original GitHub issueHi all,
LandLab v1 had a function find_drainage_area_and_discharge
as part of the FlowAccumulator component which allowed discharge at any point in a catchment to be calculated, given a variable runoff across the model grid.
A very helpful (possibly unintended) use for this function, which colleagues and I made use of, is that it can be used to accumulate any generic variable that enters a drainage network. For example, if you feed the function (in place of the runoff
argument) a bedrock_incision
array, it then outputs the cumulative sediment flux at any point in the landscape (as the discharge
output of the tuple). This has been a very useful functionality for us!
However, this specific function has been removed as part of LandLab2. To produce the same results, it is now necessary to instantiate a new FlowAccumulator for every different field you want to accumulate (sediment flux, pollutant etc…), and then run it one step. This involves overwriting a field (surface_water__discharge
) at every point, which throws a warning (albeit not an error). The major issue with this is that this whole process is around 50x slower than the method using LandLab1. For our purposes we need to able to run this many many times, and as such this reduction in speed is essentially breaking.
My main request/question is whether it is possible to reintroduce the find_drainage_area_and_discharge
function that takes variable runoff, but doesn’t involve instantiating a new FlowAccumulator everytime. In otherwords, a way to calculate discharge given variable run-off for an already existing drainage network. Alternatively, is it possible to implement a generic accumulate_field
function which takes as input a raster map of values and then accumulates them along the flowpaths. This is useful, as stated, for calculating cumulative sediment fluxes, but I can imagine uses for any number of things which travel along drainage networks.
I was going to try defining such a function myself for LandLab2 but, looking at the source code, the original function in LandLab1 is basically just a call to something called _accumulate_bw
which appears imported from a library called .cfuncs
which I can’t find the source of.
Additionally, if there is a way to do this using LandLab2 components that I’m not aware of, please let me know! I have hunted around but to no avail…
I’m keen to upgrade fully to LandLab2 because of increased functionality (specifically the better stream profiling) and to stay aligned with the community but I can’t find a way to efficiently implement this ‘generic accumulator’ which is essential for what I’m trying to do. Currently I have LandLab2 and LandLab1 in separate environments for separate, but switching between them is not ideal!
Cheers! Alex
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Ok, yup I can confirm the function still works as intended. Will close this issue now.
Code snippet to give example of how to generate cumulative sediment flux using the
find_drainage_area_and_discharge
function below. Assumes model gridmg
with topographic elevation defined. Additionally, we consider a fieldincise
which is lowering rate defined at all nodes in model grid (which could be calculated, for example, using Fastscape component)Will try and get on to defining a generic accumulator function at some point… at the moment AGU looms large!
Awesome. thanks!