-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimp_utils.R
More file actions
45 lines (42 loc) · 1.52 KB
/
imp_utils.R
File metadata and controls
45 lines (42 loc) · 1.52 KB
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
# imp_utils.R
# Supporting functions for analyzing impoundments.
#
#' fn_plot_impoundment_flux Function: Plot water fluxes and balance info for an impoundment
#' @description Generates a plot of Qin, Qout, percent storage remaining and demand
#' @param dat a zoo series with all relevant columns
#' @param pur_col Percent use remaining column
#' @param Qin_col Inflow column
#' @param Qout_col Outflow column
#' @param wd_col Withdrawal column
#' @param legend_on Should legend be included on plot?
#' @return plot object
#' @export fn_plot_impoundment_flux
fn_plot_impoundment_flux <- function(
dat, pur_col = 'pct_use_remain',
Qin_col = 'Qin', Qout_col = 'Qout',
wd_col = 'demand',
legend_on = TRUE
) {
ymn <- 1
ymx <- 100
# par(mar = c(5,5,2,5))
graphics::par(mar = c(8.8,5,0.5,5))
plot(
dat[,pur_col] * 100.0,
ylim=c(ymn,ymx),
ylab="Reservoir Usable Storage (%)",
xlab=paste("Model Flow Period",min(index(dat)),"to",max(index(dat)))
)
graphics::par(new = TRUE)
plot(dat[,Qin_col],col='blue', axes=FALSE, xlab="", ylab="")
graphics::lines(dat[,Qout_col],col='green')
graphics::lines(dat[,wd_col] * 1.547,col='red')
graphics::axis(side = 4)
graphics::mtext(side = 4, line = 3, 'Flow/Demand (cfs)')
if (legend_on == TRUE) {
graphics::legend("bottom",inset=-0.36, xpd=TRUE, c("Reservoir Usable Storage","Inflow","Outflow","Demand"),
col = c("black", "blue", "green","red"),
lty = c(1,1,1,1),
bg='white',cex=0.8)
}
}