Skip to content

Runoff area weighted

Hariharan, Jayaram Athreya requested to merge runoff-area-weighted into main

PR adds the following functions:

  • calculate_geometric_runoff: Function to calculate the area weighted runoff for a specific geometry using a set of runoff values (contained in a list of dataframes for each site) and a weights matrix with the area weights for each site.

  • _get_date_range: Helper function to calculate the date range for the area weighted runoff.

  • identify_sites_for_location: Helper function that can be applied to the weights matrix to extract the list of sites with non-zero weights for a specified spatial geometry. Would be used to help one identify the relevant sites to query NWIS and get streamflow for a given spatial geometry as opposed to querying all of the sites available.

  • calculate_multiple_geometric_runoff: Wrapper function that enables the calculation of runoff values for multiple spatial geometries. This is something that can be used if interested in multiple regions.

The PR also includes unit tests for these functions and adds them to the documentation. Note: a "test" weights matrix is added here called "demo_weights.json" that was used to develop and test the new functionality, as well as the script used to create that JSON file.

The "test" weight table looks like:

               AL        NY        MN        WI
7108900  0.000000  0.156733  0.103813  0.045871
7103980  0.021847  0.078724  0.010249  0.256500
1646500  0.038747  0.000000  0.004102  0.193629

The geometries (can be States, HUCs, or anything) are columns, and each row is a site ID (represented as an integer). This is the expected format of the weights table, although the functions can certainly be adjusted to accommodate another format or layout.

Graphical Schematic of Weights -> Area Weighted Runoff Workflow:


Edited by Hariharan, Jayaram Athreya

Merge request reports