Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add calculation of upstream salt #47

Merged
merged 3 commits into from
Feb 8, 2024
Merged

Add calculation of upstream salt #47

merged 3 commits into from
Feb 8, 2024

Conversation

lindsayplatt
Copy link
Owner

Including all upstream salt as an additional attribute. Note that the download of catchments is still failing for one group of NHD COMIDs and I have chosen to just skip for now. I am working through the issues here: DOI-USGS/nhdplusTools#376.

There is now an additional attribute in the p3_static_attributes target called attr_roadSaltCumulative which represents the aggregate salt for the current site's catchment and all of the catchments upstream from it.

Below are some snapshots of the new upstream data compared to the catchment-only salt. Note that for these plots, I first filtered any site where upstream was missing. There are 11 sites where cumulative is the same as catchment roadSalt, meaning they are the headwaters reach (ratio == 1 in the histogram). Most sites have less than half of the cumulative upstream salt applied in their individual catchment, which is expected.

image

image

@lindsayplatt
Copy link
Owner Author

Ope, meant to put the code for these

library(targets)
library(tidyverse)

tar_load(p2_attr_roadSalt)

p2_attr_roadSalt %>% 
  filter(!is.na(attr_roadSaltCumulative)) %>% 
  rename(`Catchment Salt` = attr_roadSalt,
         `Upstream Salt` = attr_roadSaltCumulative) %>% 
  pivot_longer(-site_no, names_to = 'salt_calc') %>% 
  ggplot() +
  geom_histogram(aes(value, fill = salt_calc)) +
  facet_grid(salt_calc ~ .) +
  theme_bw()

p2_attr_roadSalt %>% 
  filter(!is.na(attr_roadSaltCumulative)) %>% 
  mutate(ratio = attr_roadSalt / attr_roadSaltCumulative) %>% filter(ratio == 1)
  ggplot() +
  geom_histogram(aes(ratio)) + 
  xlab('Ratio of catchment salt to total cumulative upstream') +
  theme_bw()

@lindsayplatt lindsayplatt merged commit 62df30e into main Feb 8, 2024
lindsayplatt added a commit that referenced this pull request Feb 8, 2024
lindsayplatt added a commit that referenced this pull request Feb 8, 2024
oops, forgot to commit this change with #47!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant