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

Write output tables for Annual Sum (total water depth per water year) #13

Open
ChristinaB opened this issue Oct 19, 2018 · 0 comments
Open

Comments

@ChristinaB
Copy link
Contributor

ChristinaB commented Oct 19, 2018

Water year = Oct 1- Sept 30

Sum 1: For each drainage, sum daily variable by water year.
Results: Rows years; Columns Drainage

Sum 2: For each Sum1, average annual sum for each variable
Results: Rows Drainage; Columns 1 value per drainage

Here is example code in R:

`yearlySummary_Precipitation_in.txt` <- Precipitation_in.txt %>%
  # group by TimeStep and Month
  select(-c(TimeStep, yyyymmdd, year, day)) %>%
  melt(., id.vars = c('month', 'water_year'), variable.name = 'Drainages', value.name = 'Precipitation') 
  
  # calculate total by month, wateryear, and drainage
  group_by(month, water_year, Drainages) %>%
  summarise(sumByMonthByWateryearByDrainage = sum(Precipitation)) %>%
 
# calculate mean by wateryear, and drainage
  group_by(water_year, Drainages) %>%
  summarise(meanByWateryearByDrainage = sum(sumByMonthByWateryearByDrainage)) %>%
 
# calculate mean 
  group_by(water_year) %>%
  mutate(meanByWateryear = mean(meanByWateryearByDrainage),
  
# reformat the table to wide for each DrainageID
  dcast(., water_year + meanByWateryear ~ Drainages, value.var = 'meanByWateryearByDrainage') %>%
  data.table()`

Variables= Precip, ET, Recharge (Rd), Upwelling (r3), Return flow

and User Withdrawal

Slight change for users, group by user type

loop through user = 1:6

User Sum 1: For each drainage, sum daily variable by water year.
Results: Rows years; Columns Drainage, append Source Mixing ID, ReturnFlowID

User Sum 2: For each Sum1, average annual sum for each variable
Results: Rows Drainage; Columns 1 value per drainage, append Source Mixing ID, ReturnFlowID

print user withdrawal for each user type


`test_summary_wtryr <- UserWithdrawal_gpd.txt %>% 
    select(subset_usercols) %>%
    select(-c(TimeStep, yyyymmdd, month, year, day)) %>%
    melt(., id.vars = c('water_year'), variable.name = 'UserIDs', value.name = 'UserWithdrawal') %>%
    group_by(water_year, UserIDs) %>%
    summarise(annualUserWithdrawal = sum(UserWithdrawal))

test_usersWithdrawal_wtryr <- test_users %>%
  merge(., test_summary_wtryr, by='UserIDs')

fwrite(test_usersWithdrawal_wtryr, paste0(getwd(),'/AverageWithdrawalwateryearly_gpy_sourcesummary.txt'), sep = '\t', row.names = F, col.names = T, append = F)`

Ideal future outcome: Annual average sum of water depth
Total P, ET, Rd, R2 per drainage
Total of user Groundwater withdrawal per drainage
Total of user Surface water withddrawal per drainage
Total return flow per drainage

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

No branches or pull requests

1 participant