-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_all_scripts.R
70 lines (54 loc) · 2.54 KB
/
run_all_scripts.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Reproducible workflow to generate results and figures related to
# "Nearest neighbor bootstrap for generating influent time series for water treatment"
# author: William Raseman
# clear environment
rm(list=ls())
# load libraries
# library(beepr) # to notify when simulation is done
# load user-defined functions for each step of the workflow
load("./lib/import_clean.RData")
load("./lib/create_ts.RData")
load("./lib/visualize_ts.RData")
load("./lib/simulate_kNN.RData")
load("./lib/visualize_statistics.RData")
# simulation parameters
nsims <- 2500
## note: to check results, try using 50 simulations for reduced computational time
innov <- TRUE
data.type <- "sw"
# Generate Manuscript Figures
## step 1 - import and clean influent water quality data
import_clean()
## step 2 - create complete, monthly time series
create_ts()
## step 3 - visualize time series dataset
### note: generates figure 1
visualize_ts()
## step 4 - generate ensembles of synethetic water quality time series using k-NN algorithm
set.seed(101) # set pseudorandom seed for reproducibile simulations
simulate_kNN(nsims=nsims, innov=innov, threshold=c(TRUE, FALSE, TRUE, TRUE), data.type=data.type)
### note: temperature, total organic carbon, and alkalinity constrained to
### be non-negative (variables 1, 3, and 4) via 'threshold' input
## step 5 - visualize statistics of observed and simulated data
### note: generates figures 2 - 6
visualize_statistics(innov=innov, data.type=data.type)
# Generate Supporting Information Figures
## simulate water quality with random innovations disabled
set.seed(101) # set pseudorandom seed for reproducibile simulations
simulate_kNN(nsims=nsims, innov=FALSE, data.type=data.type)
### note: generates figure S1
visualize_statistics(innov=FALSE, data.type=data.type)
## simulate temperature and precipitation with random innovations enabled
set.seed(101) # set pseudorandom seed for reproducibile simulations
simulate_kNN(nsims=nsims, innov=TRUE, threshold=c(TRUE, TRUE), data.type="mine")
### note: generates figures S2, S4 and S5
### note: temperature and precipitation constrained to
### be non-negative (variables 1 and 2) via 'threshold' input
visualize_statistics(innov=TRUE, data.type="mine")
## simulate temperature and precipitation with random innovations enabled
set.seed(101) # set pseudorandom seed for reproducibile simulations
simulate_kNN(nsims=nsims, innov=FALSE, threshold=c(TRUE, TRUE), data.type="mine")
### note: generates figures S3
visualize_statistics(innov=FALSE, data.type="mine")
# notify when script is done
# beep(sound = "mario")