-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdataprep.R
39 lines (25 loc) · 1.02 KB
/
dataprep.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Peak and decline of global groundwater resources
#
# Hassan Niazi, JGCRI USA, 2022
# Inputs: output of 900 GCAM runs, basin names and mappings
# load all packages ----
library(tidyverse)
# load data for post-processing and analysis ----
# groundwater
read_csv("groundwater_production_FINAL.csv") %>%
select(groundwater, scenario, year, value) %>%
filter(year != 1975) %>%
group_by(scenario, year) %>% summarise(value = sum(value)) %>%
summarise(max = max(value),
max_yr = .$year[which.max(value)],
taken = sum(value)) %>%
tidyr::separate(scenario, c("calib", "gw", "surf", "ssp", "gcm", "rcp")) %>%
mutate(ssp = gsub("ssp","SSP",ssp),
rcp=paste0("RCP",rcp),
rcp=gsub("p",".",rcp),
ssp_rcp = paste0(ssp, "_", rcp)) %>%
select(ssp_rcp, ssp, rcp, max, max_yr, calib, surf, gw) ->
gw_peaks_detailed
# surface water data
# pre-processing to prepare common data tables used while analysis and plotting ----
# groundwater peaks