USGS-R / drb-gw-hw-model-prep

Code repo to prepare groundwater and headwater-related datasets for modeling river temperature in the Delaware River Basin
Other
0 stars 3 forks source link

Process CATCHMENT ("CAT") NHDv2 attributes to NHM-scale #49

Closed lekoenig closed 2 years ago

lekoenig commented 2 years ago

This PR addresses the third task in issue https://github.com/USGS-R/drb-gw-hw-model-prep/issues/40, and adds one target and one function that correspond to the catchment-scale NHDv2 attributes. In this PR, we use the catchment aggregation operations (e.g. area-weighted mean; length-weighted mean, etc.) defined in 1_fetch/in/nhdv2_attributes_from_sciencebase.csv to reprocess the CAT-level NHDv2 attributes to the NHM catchment-scale.

The output of p2_nhdv2_attr_catchment is a nested list that contains two data frames for each SB dataset: 1) the reprocessed data (which has 459 rows, one for each PRMS_segid); and 2) a diagnostics table that indicates how many of the contributing NHD values were NA. We used the diagnostics tables in inland salinity and so I'm including them here as well. In the next PR, we will combine the upstream and catchment processed data into one data frame, and pull out and join the individual diagnostics tables.

Here's an example of the BASIN_CHARACTERISTICS data:

> tar_load(p2_nhdv2_attr_catchment)
> dim(p2_nhdv2_attr_catchment[[14]]$data)
[1] 459   6
> head(p2_nhdv2_attr_catchment[[14]]$data)
# A tibble: 6 x 6
  PRMS_segid AREASQKM_PRMS LENGTHKM_PRMS CAT_STRM_DENS_area_wtd CAT_BASIN_SLOPE_area_wtd CAT_STREAM_SLOPE_length_wtd
  <chr>              <dbl>         <dbl>                  <dbl>                    <dbl>                       <dbl>
1 1_1                65.0          13.6                   0.21                      23.6                      0     
2 10_1                5.47          2.08                  0.38                      23.2                      0.01  
3 11_1                5.94          1.82                  0.31                      17.1                      0     
4 111_1              41.6          10.6                   0.26                      18.7                      0.02  
5 112_1             271.          104.                    0.385                     16.5                      0.0158
6 113_1              21.1           9.58                  0.456                     14.7                      0.0232
>

The function process_catchment_nhdv2_attr() is again taken from the inland salinity repo. I'm requesting a review to put another set of eyes on this function and make sure it suits our needs for groundwater, but suggest capping a review at ~1 hr. I'm hoping for a review by 10/3 so that we can close this issue by the time you head out for AL, but please let me know if you'll need more time.

lekoenig commented 2 years ago

Thanks for taking a look at this, @msleckman!