Update runoff weight mtx param 2
This MR introduces a new small function to convert the tabular df of weights into matrix in order to perform runoff.calculate_geometric_runoff()
. This is introduced bc we recently learned that the original data source for the geometric weights used by WW come from a tabular dataset (not a matrix) involving 4 cols : site_id
, geom_id
, prop_basin
, prop_geom
(geom == huc). We want to stay consistent with that and should expect the user to have off hand, a df such as this with weight values.
However, the runoff calc function expects a matrix to perform the row-wise multiplication of runoff. As such, we decided to add a simple df to matrix conversion fun to be used as a pre-processing step before calculating runoff (just like runoff.identify_sites_from_weights()
).
Note: This function was initially intended to be placed within runoff.calculate_geometric_runoff()
as an internal fun, but later decided to keep it outside.
I've attached a notebook for the reviewer to use to test the function and calc runoff. In the notebook, I pull nwis data from dataretrieval, which is required for calculating runoff. df_to_matrix_mr.ipynb
Reviewer: Please review the changes and the addition of the function runoff.convert_df_to_matrix()
and let me know if it works or if you run into issues. Please review any formatting or linters issues as well. Can also test with a different df, such huc_bas_pct.txt
which was used for WW by Xiaodong. Input data will be send directly.
Finally, please note that this notebook worked for me previously, but this morning I encountered an TypeError that I haven't yet successfully debugged :
TypeError: convert_df_to_matrix() got an unexpected keyword argument 'wght_in_geom_col'
. Let me know if you encounter this.
- Pipeline will be edited and cleaned after review.