question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accumulating generic fields (not just runoff) using FlowAccumulator

See original GitHub issue

Hi 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:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexLippcommented, Oct 21, 2020

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 grid mg with topographic elevation defined. Additionally, we consider a field incise which is lowering rate defined at all nodes in model grid (which could be calculated, for example, using Fastscape component)


from landlab.components.flow_accum.flow_accum_bw import find_drainage_area_and_discharge

frr = FlowAccumulator(mg, 'topographic__elevation',  flow_director='D8')
frr.run_one_step()  

a,cum_sed_flux = find_drainage_area_and_discharge(mg.at_node['flow__upstream_node_order'],
                             mg.at_node['flow__receiver_node'],
                             runoff = incise) 

Will try and get on to defining a generic accumulator function at some point… at the moment AGU looms large!

0reactions
AlexLippcommented, Oct 26, 2020

Awesome. thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Component to do FlowAccumulation with the FlowDirectors
Provides the FlowAccumulator component which accumulates flow and ... Optionally, spatially variable runoff can be set either by the model grid field ......
Read more >
Introduction to the FlowAccumulator - | notebook.community
The FlowAccumulator uses the direction and proportion of flow moving between each node and (optionally) water runoff to calculate drainage area and ...
Read more >
landlab.components.FlowAccumulator Example - Program Talk
The runoff generator converts rain into runoff. This runoff is then accumulated into surface water discharge (:math:`Q`) and used by channel erosion ...
Read more >
Landlab v2.0: A software package for Earth surface dynamics
When a field is stored on the grid, Landlab enforces characteristics such as the number of elements and provides the ability to use...
Read more >
Revised 2/17 LOCKHEED MARTIN SPACE SYSTEMS ...
G. Where field verification is not possible, conditions shown on the record drawings that could result in design conflicts, such as seismic ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found