BigMallardBOOT <- function(metdata=BigMallard_prec_pet,lakedata=BigMallard_vol,metdata21=ESTmonprpet1921to2017) { # To make plots, BigMallardRun(), you can leave () blank and run the defaults # metdata contains monthly precip and pet for water years 1991-2016 # lakedata contains annual lake level and volume for the end of water years 1991-2016 # no missing values allowed! # Get working directory WD <- getwd() # ************* append climate division data to the end of the Big Mallard Marsh metdata ************ metdataxx <- as.matrix(metdata21[,c(1,2,5,6)]) row.names(metdataxx) <- NULL namesxx <- names(metdata) metdata <- as.matrix(metdata) row.names(metdata) <- NULL metdataxx <- data.frame(rbind(metdata,metdataxx)) names(metdataxx) <- namesxx mprec <- metdataxx$prec mpet <- metdataxx$pet # ************************************* alev <- lakedata$elev avol <- lakedata$vol/1000000 # Determine elevation/volume relation eft <- c(1820.7, 1822.7, 1825.7, 1827.7, 1829.7, 1832.7, 1835.7) vmcf <- c(0,5, 97, 214, 350, 582, 838) evcoefs <- summary(nls(vmcf~a*(eft-1820.7)^b,start=list(a=2,b=2)))$coef xxtmp <- seq(1820.7, 1835.7,0.1); yytmp <- evcoefs[1]*(xxtmp-1820.7)^evcoefs[2] # replace volumes with computed values from equation wyr <- 1991:2016 nyrs <- 26 for (i in 1:nyrs) { avol[i] <- bigmalvol(alev[i])} # compute quarterly precip and pet from monthly data and plot it qprec <- apply(matrix(mprec,ncol=3,byrow=T),1,sum) qpet <- apply(matrix(mpet,ncol=3,byrow=T),1,sum) dyrqtr <- 1991+ seq(0.5,103.5,1)/4 # Ready to fit the water balance model. The parameters are estimated by # minimizing the rmse between the estimated and observed annual volume # changes, subject to parameter constraints. Parameter defmax is the maximum # deficit (in inches), which is also the holding capacity of the basin # feeding the lake. Parameter barea is the basin area, expressed as a multiple # of the reference lake area. The reference lake area for Big Mallard Marsh is # the lake area at the spill elevation (see code for bigmalwatbal) # used weights to block out number 6 for 1997, we have a very large volume change between 1996 and 1997 obsvolchng <- avol[2:nyrs] obsvoldif <- (avol[-1] - avol[-nyrs]) tmpout <- nls(obsvolchng~bigmalwatbal(qprec,qpet,avol,barea,3.5),algorithm="port",lower=c(5), upper=c(6),start=list(barea=5.5),weights=c(rep(1,5),1,rep(1,19))) barea <- summary(tmpout)$coef[1] maxdef <- 3.5 estvolchng <- bigmalwatbal(qprec,qpet,avol,barea,3.5) estvoldif <- estvolchng - c(avol[1],estvolchng[-(nyrs-1)]) nyrs <- 25 ; pkfirst <- seq(1,nyrs*4,4) rho <- as.character(round(cor.test(estvoldif,obsvoldif)$estimate,3)) bias <- as.character(round(mean(obsvoldif-estvoldif),2)) rmse <- as.character(round(mean((obsvoldif-estvoldif)^2)^0.5,2)) bch1 <- as.character(round(barea,2)); bch2 <- as.character(round(maxdef,2)) ## Plots estimated vs. observed lake volumes #Create JPEG jpeg(paste(getwd(),"/BigMallard_Est_Obs.jpg", sep = ""), height = 5, width = 5, units = "in", res = 300) #svg(paste(getwd(),"/BigMallard_Est_Obs.svg", sep = ""), height = 5, width = 5) #postscript(paste(getwd(),"/BigMallard_Est_Obs.eps", sep = ""), height = 5, width = 5) plot(watbalxx$dqtrxx,watbalxx$vest*22.9568753,type="l",cex=0.6,xlim=c(1990,2020),ylim=c(0,1200*22.9568753), col = "red", ylab="Lake volume (Acre-feet)", xlab = "Year", tck = 0.05, las = 1, cex.axis = 0.8, xaxs = "i", yaxs = "i") points(wyr+1,avol*22.9568753,cex=1,lwd=1.5) mtext(side=3,line=-1,"Big Mallard Marsh") mtext(side = 3, line = -2, cex = 0.8, paste("rho =", rho)) dev.off() ### long-term simulations estvolxx <- bigmalwatbal1(qprec,qpet,avol,barea,3.5,nyrs=123) nyrs <- 122 plot(watbalxx$dqtrxx,watbalxx$vest,type="l", col = "red", ylim = c(0,1200), ylab = "Lake Volume (MCF)", xaxs = "i", xlim = c(1940,2017)) estvolchng <- bigmalwatbal(qprec,qpet,avol,barea,3.5,prmult=1) points(watbalxx$dqtrxx,watbalxx$vest,type="l", col="black") mtext(side=3,line=1,"Big Mallard Long-term simulation using climate division data") #Create PDF pdf(paste(getwd(),"/BigMallard_Long.pdf", sep = ""), width = 9, height = 7) #svg(paste(getwd(),"/BigMallard_Long.svg", sep = ""), width = 9, height = 7) #postscript(paste(getwd(),"/BigMallard_Long.eps", sep = ""), width = 9, height = 7) ### Start of bootstrapping plot nboot <- 1000 # number of bootstrap simulations estvolxx <- bigmalwatbal1(qprec,qpet,avol,barea,3.5,nyrs=123) nyrs <- 122 pkr <- watbalxx$dqtrxx > 1940 options(scipen = 10) plot(watbalxx$dqtrxx[pkr],watbalxx$vest[pkr]*22.9568753,type="l", col = "purple", ylim = c(0,1000*22.9568753), ylab = "Lake volume, acre-feet", xlab = "Year", tck = 0.05, las = 1, cex.axis = 0.8, xlim = c(1940,2100), xaxs = "i", yaxs = "i", xaxt = "n") axis(1, at = c(1940, 1992, 2016, 2040, 2067), tck = 0.05, cex.axis = 0.8) axis(1, at =c(2020, 2025, 2030, 2035), tck = 0.02, cex.axis = 0.6, padj = -3) #mtext(side=3,line=1,"Big Mallard Marsh Long-term Simulation") mycol <- c("black", "blue", "cyan", "chartreuse2") ##### Use bigmalbootvols saved dataframe. Uncomment lines below if first time running script. ## Bootstrapping ## keep the same initial climate inputs (first 26 years) but bootstrap random segments onto the end ## first, replace 30's drought (30-39) with repeat of 1921-29 to reduce weight # qprec[(36*4+1):(46*4)] <- qprec[(26*4+1):(36*4)] # qpet[(36*4+1):(46*4)] <- qpet[(26*4+1):(36*4)] # # nboot <- 1000 # simvols <- matrix(nrow=75*4,ncol=nboot) # for (isim in 1:nboot) { # qprecboot <- rep(NA,76*4) # qpetboot <- rep(NA,76*4) # qprecboot[1:(26*4)] <- qprec[1:(26*4)] # qpetboot[1:(26*4)] <- qpet[1:(26*4)] # randur <- floor(runif(1)*49)+1 # ranyr <- 19+floor(runif(1)*78) # eyrs <- 97-ranyr # if(eyrs= qpet[k]+petlag) { preclag <- qprec[k]-qpet[k]-petlag petlag <- 0 } else if (qprec[k]>=qpet[k]) { preclag <- 0 petlag <- petlag - (qprec[k]-qpet[k]) } else { preclag <- 0 petlag = min(petlag + 1.0*(qpet[k] - qprec[k]),sscap) } qgw[k] <- cgwloss*max(v0-vgwloss,0) qin[k] <- 0 storx <- storx-cleakx*exp(-2*(1-storx/(maxstorx+1)))*storx+qin[k] if(storx>maxstorx) { qinlag[k] <- (storx-maxstorx) + cgainx*maxstorx storx <- storx-qinlag[k] } else { qinlag[k] <- cgainx*exp(-2*(1-storx/(maxstorx+1)))*storx storx <- storx-qinlag[k] } qin[k] <- qinlag[k] qout[k] <- 0 vest[k] <- max(v0 + qin[k] - evest[k] - qgw[k] - qout[k],0) qout[k] <- qout[k]+qgw[k] elest[k] <- bigmalelev(vest[k]) ; aest[k] <- bigmalarea(elest[k]) v0 <- vest[k]; e0 <- bigmalelev(v0); a0 <- bigmalarea(e0) } # quarter 2 (JFM) # no surface inflow or outflow # no ET, no change in deficit # carry over precipitation if (j==2) { evest[k] <- (1.5*qpet[k]-qprec[k])*bigmalarea(e0+5) evest[k] <- min(evest[k],v0) defout[k] <- petlag preclag <- preclag+qprec[k] qgw[k] <- cgwloss*max(v0-vgwloss,0) qin[k] <- 0 storx <- storx-cleakx*exp(-2*(1-storx/(maxstorx+1)))*storx+qin[k] if(storx>maxstorx) { qinlag[k] <-(storx-maxstorx) + cgainx*maxstorx storx <- storx-qinlag[k] } else { qinlag[k] <- cgainx*exp(-2*(1-storx/(maxstorx+1)))*storx storx <- storx-qinlag[k] } qin[k] <- qinlag[k] qout[k] <- 0 vest[k] <- max(v0 + qin[k] - evest[k] - qgw[k] - qout[k],0) qout[k] <- qout[k]+qgw[k] elest[k] <- bigmalelev(vest[k]) ; aest[k] <- bigmalarea(elest[k]) v0 <- vest[k]; e0 <- bigmalelev(v0); a0 <- bigmalarea(e0) } # quarter 3 (AMJ) # compute surface inflow and outflow # update storage deficit (petlag) # Note that computed outflow us one-half of the volume above the spill elevation. # The rest of the excess volume remains until the next time step (accounts for # for time it takes to raise the lake above spill elevation and for # the water to flow out of the outlet) # if (j==3) { evest[k] <- (1.5*qpet[k]-qprec[k])*bigmalarea(e0+5) evest[k] <- min(evest[k],v0) qgw[k] <- cgwloss*max(v0-vgwloss,0) cumprec <- qprec[k] + preclag defout[k] <- petlag if(cumprec >= qpet[k] + petlag) { qin[k] <- max(b2*amax-bigmalarea(e0+5),0)*(cumprec-qpet[k]-petlag) petlag <- 0 } else if (cumprec >= qpet[k]) { qin[k] <- 0 petlag <- petlag - (cumprec-qpet[k]) } else { qin[k] <- 0 petlag = min(petlag + 1.0*(qpet[k] - cumprec),sscap) } storx <- storx-cleakx*exp(-2*(1-storx/(maxstorx+1)))*storx+qin[k] if(storx>maxstorx) { qinlag[k] <- (storx-maxstorx) + cgainx*maxstorx storx <- storx-qinlag[k] } else { qinlag[k] <- cgainx*exp(-2*(1-storx/(maxstorx+1)))*storx storx <- storx-qinlag[k] } qin[k] <- qinlag[k]+0*qin[k] qout[k] <- 0.5*max(0,v0+qin[k]-evest[k]-qgw[k]-vspl) vest[k] <- max(v0 + qin[k] - evest[k] - qgw[k] - qout[k],0) qout[k] <- qout[k]+qgw[k] elest[k] <- bigmalelev(vest[k]) ; aest[k] <- bigmalarea(elest[k]) v0 <- vest[k]; e0 <- bigmalelev(v0); a0 <- bigmalarea(e0) } # quarter 4 (JAS) # Same as quarter 3, except all of the excess volume above # the spill elevation is assumed to become outflow, leaving the # lake volume equal to or less than the spill volume at the end # of the water year. if (j==4) { evest[k] <- (1.0*qpet[k]-qprec[k])*bigmalarea(e0+5) evest[k] <- min(evest[k],v0) qgw[k] <- cgwloss*max(v0-vgwloss,0) cumprec <- qprec[k] defout[k] <- petlag if(cumprec >= qpet[k] + petlag) { qin[k] <- max(b2*amax-bigmalarea(e0+5),0)*(cumprec-qpet[k]-petlag) petlag <- 0 } else if (cumprec >= qpet[k]) { qin[k] <- 0 petlag <- petlag - (cumprec-qpet[k]) } else { qin[k] <- 0 petlag = min(petlag + 1.0*(qpet[k] - cumprec),sscap) } storx <- storx-cleakx*exp(-2*(1-storx/(maxstorx+1)))*storx+qin[k] if(storx>maxstorx) { qinlag[k] <- (storx-maxstorx) + cgainx*maxstorx storx <- storx-qinlag[k] } else { qinlag[k] <- cgainx*exp(-2*(1-storx/(maxstorx+1)))*storx storx <- storx-qinlag[k] } qin[k] <- qinlag[k] +0*qin[k] qout[k] <- 1.0*max(0,v0+qin[k]-evest[k]-qgw[k]-vspl) vest[k] <- max(v0 + qin[k] - evest[k] - qgw[k] - qout[k],0) qout[k] <- qout[k]+qgw[k] elest[k] <- bigmalelev(vest[k]) ; aest[k] <- bigmalarea(elest[k]) v0 <- vest[k]; e0 <- bigmalelev(v0); a0 <- bigmalarea(e0) } } } # For model diagnostic plots, save the quarterly water balance variables in a # dataframe called watbalxx. Note the double assignment arrow, which means the # dataframe is saved in the workspace when the function is done. dqtrxx <- 1992+seq(0,nyrs*4-1,1)/4 yrxx <- floor(dqtrxx) qtrxx <- (dqtrxx-floor(dqtrxx))*4 +1 watbalxx <<- data.frame(yrxx,qtrxx,dqtrxx,elest,aest,vest,qin,qout,evest,qgw,defout) # Function output consists of the fitted annual lake volume changes for each water year # print(qinaccum) # plot(dqtrxx,qinlag,type="l") ; abline(h=600) ; abline(h=1200) volannual <- c(v0save,vest[seq(4,nyrs*4,4)]) volannual <- volannual[-1] # volannual[-1] - volannual[-(nyrs+1)] volannual } ############### ############### ############### bigmalwatbal1 <- function(qprec,qpet,avol,barea,defmax,cfdgq= 0,cgwleak=0,prmult=1.0,etmult=1.0,nyrs=26) { b2 <- barea ; b1 <- cgwleak ; sscap <- defmax/12 ; b3 <- cfdgq # nyrs <- 26 # Adjust precipitation upward to account for undercatch during snowy months qprec[seq(1,nyrs*4,4)] <- qprec[seq(1,nyrs*4,4)]*1.1 qprec[seq(2,nyrs*4,4)] <- qprec[seq(2,nyrs*4,4)]*1.2 qprec[seq(3,nyrs*4,4)] <- qprec[seq(3,nyrs*4,4)]*1.1 qprec[seq(4,nyrs*4,4)] <- qprec[seq(4,nyrs*4,4)]*1.0 # Apply adjustments to potential ET to approximate actual ET qpet[seq(1,nyrs*4,4)] <- qpet[seq(1,nyrs*4,4)]*0.4 qpet[seq(2,nyrs*4,4)] <- qpet[seq(2,nyrs*4,4)]*0 qpet[seq(3,nyrs*4,4)] <- qpet[seq(3,nyrs*4,4)]*0.3 qpet[seq(4,nyrs*4,4)] <- qpet[seq(4,nyrs*4,4)]*.8 # Multiply inputs by optional factors (used for sensitivity analysis) qprec <- qprec*prmult qpet <- qpet*etmult # initialize storage variables # v0 is lake volume for the beginning of wyr 1992 # prec0 and pet0 are precipitation for qtr 4, wyr 1991 v0 <- avol[1] ; v0save <- v0 e0 <- bigmalelev(v0) a0 <- bigmalarea(e0) prec0 <- qprec[4] ; pet0 <- qpet[4] # strip off first year of precip and pet data and convert to units of ft qprec <- qprec[-c(1:4)]/12 qpet <- qpet[-c(1:4)]/12 # set spill elevation, volume, and area espl <- 1834.5 #assuming elevation of 1836 strip of land separating from Barnes Lake vspl <- bigmalvol(espl) aspl <- bigmalarea(espl) emin <- 1820.7 amax <- aspl vmax <- vspl # initialize quarterly water balance variables, including estimated # lake volume (vest), surface inflow volume (qin), # lake area (aest), lake elevation (elest), net lake evaporation (evest), groundwater # loss (qgw), surface outflow volume (qout), and storage deficit (defout) ##### nyrs <- 25 nyrs <- nyrs-1 vest <- rep(NA,nyrs*4) qin <- rep(NA,nyrs*4) aest <- rep(NA,nyrs*4) elest <- rep(NA,nyrs*4) evest <- rep(NA,nyrs*4) qgw <- rep(NA,nyrs*4) qout <- rep(NA,nyrs*4) defout <- rep(NA,nyrs*4) # Ready to compute water balance variables # i is the year, j is the quarter, and k is the cumulative time index # petlag is the left-over storage deficit carried from one quarter to the next # preclag is the residual fall/winter (quarters 1 and 2) precipitation that # remains in frozen storage until the following spring (qtr 3) # Initialize petlag and preclag for the first quarter (OND of WY1992) petlag <- sscap ; preclag <- 0 qinlag <- rep(NA,nyrs*4) storx <- 0 maxstorx <- 400 cgainx <- 0.1 cleakx <- 0.0 cgwloss <- 0.1 vgwloss <- 750 for (i in 1:nyrs) { for (j in 1:4) { k <- (i-1)*4 + j # quarter 1 (OND) # no surface inflow or outflow # carry over excess precipitation, if any if (j==1) { evest[k] <- (1.5*qpet[k]-qprec[k])*bigmalarea(e0+5) evest[k] <- min(evest[k],v0) defout[k] <- petlag if(qprec[k] >= qpet[k]+petlag) { preclag <- qprec[k]-qpet[k]-petlag petlag <- 0 } else if (qprec[k]>=qpet[k]) { preclag <- 0 petlag <- petlag - (qprec[k]-qpet[k]) } else { preclag <- 0 petlag = min(petlag + 1.0*(qpet[k] - qprec[k]),sscap) } qgw[k] <- cgwloss*max(v0-vgwloss,0) qin[k] <- 0 storx <- storx-cleakx*exp(-2*(1-storx/(maxstorx+1)))*storx+qin[k] if(storx>maxstorx) { qinlag[k] <- (storx-maxstorx) + cgainx*maxstorx storx <- storx-qinlag[k] } else { qinlag[k] <- cgainx*exp(-2*(1-storx/(maxstorx+1)))*storx storx <- storx-qinlag[k] } qin[k] <- qinlag[k] qout[k] <- 0 vest[k] <- max(v0 + qin[k] - evest[k] - qgw[k] - qout[k],0) qout[k] <- qout[k]+qgw[k] elest[k] <- bigmalelev(vest[k]) ; aest[k] <- bigmalarea(elest[k]) v0 <- vest[k]; e0 <- bigmalelev(v0); a0 <- bigmalarea(e0) } # quarter 2 (JFM) # no surface inflow or outflow # no ET, no change in deficit # carry over precipitation if (j==2) { evest[k] <- (1.5*qpet[k]-qprec[k])*bigmalarea(e0+5) evest[k] <- min(evest[k],v0) defout[k] <- petlag preclag <- preclag+qprec[k] qgw[k] <- cgwloss*max(v0-vgwloss,0) qin[k] <- 0 storx <- storx-cleakx*exp(-2*(1-storx/(maxstorx+1)))*storx+qin[k] if(storx>maxstorx) { qinlag[k] <-(storx-maxstorx) + cgainx*maxstorx storx <- storx-qinlag[k] } else { qinlag[k] <- cgainx*exp(-2*(1-storx/(maxstorx+1)))*storx storx <- storx-qinlag[k] } qin[k] <- qinlag[k] qout[k] <- 0 vest[k] <- max(v0 + qin[k] - evest[k] - qgw[k] - qout[k],0) qout[k] <- qout[k]+qgw[k] elest[k] <- bigmalelev(vest[k]) ; aest[k] <- bigmalarea(elest[k]) v0 <- vest[k]; e0 <- bigmalelev(v0); a0 <- bigmalarea(e0) } # quarter 3 (AMJ) # compute surface inflow and outflow # update storage deficit (petlag) # Note that computed outflow us one-half of the volume above the spill elevation. # The rest of the excess volume remains until the next time step (accounts for # for time it takes to raise the lake above spill elevation and for # the water to flow out of the outlet) # if (j==3) { evest[k] <- (1.5*qpet[k]-qprec[k])*bigmalarea(e0+5) evest[k] <- min(evest[k],v0) qgw[k] <- cgwloss*max(v0-vgwloss,0) cumprec <- qprec[k] + preclag defout[k] <- petlag if(cumprec >= qpet[k] + petlag) { qin[k] <- max(b2*amax-bigmalarea(e0+5),0)*(cumprec-qpet[k]-petlag) petlag <- 0 } else if (cumprec >= qpet[k]) { qin[k] <- 0 petlag <- petlag - (cumprec-qpet[k]) } else { qin[k] <- 0 petlag = min(petlag + 1.0*(qpet[k] - cumprec),sscap) } storx <- storx-cleakx*exp(-2*(1-storx/(maxstorx+1)))*storx+qin[k] if(storx>maxstorx) { qinlag[k] <- (storx-maxstorx) + cgainx*maxstorx storx <- storx-qinlag[k] } else { qinlag[k] <- cgainx*exp(-2*(1-storx/(maxstorx+1)))*storx storx <- storx-qinlag[k] } qin[k] <- qinlag[k]+0*qin[k] qout[k] <- 0.5*max(0,v0+qin[k]-evest[k]-qgw[k]-vspl) vest[k] <- max(v0 + qin[k] - evest[k] - qgw[k] - qout[k],0) qout[k] <- qout[k]+qgw[k] elest[k] <- bigmalelev(vest[k]) ; aest[k] <- bigmalarea(elest[k]) v0 <- vest[k]; e0 <- bigmalelev(v0); a0 <- bigmalarea(e0) } # quarter 4 (JAS) # Same as quarter 3, except all of the excess volume above # the spill elevation is assumed to become outflow, leaving the # lake volume equal to or less than the spill volume at the end # of the water year. if (j==4) { evest[k] <- (1.0*qpet[k]-qprec[k])*bigmalarea(e0+5) evest[k] <- min(evest[k],v0) qgw[k] <- cgwloss*max(v0-vgwloss,0) cumprec <- qprec[k] defout[k] <- petlag if(cumprec >= qpet[k] + petlag) { qin[k] <- max(b2*amax-bigmalarea(e0+5),0)*(cumprec-qpet[k]-petlag) petlag <- 0 } else if (cumprec >= qpet[k]) { qin[k] <- 0 petlag <- petlag - (cumprec-qpet[k]) } else { qin[k] <- 0 petlag = min(petlag + 1.0*(qpet[k] - cumprec),sscap) } storx <- storx-cleakx*exp(-2*(1-storx/(maxstorx+1)))*storx+qin[k] if(storx>maxstorx) { qinlag[k] <- (storx-maxstorx) + cgainx*maxstorx storx <- storx-qinlag[k] } else { qinlag[k] <- cgainx*exp(-2*(1-storx/(maxstorx+1)))*storx storx <- storx-qinlag[k] } qin[k] <- qinlag[k] +0*qin[k] qout[k] <- 1.0*max(0,v0+qin[k]-evest[k]-qgw[k]-vspl) vest[k] <- max(v0 + qin[k] - evest[k] - qgw[k] - qout[k],0) qout[k] <- qout[k]+qgw[k] elest[k] <- bigmalelev(vest[k]) ; aest[k] <- bigmalarea(elest[k]) v0 <- vest[k]; e0 <- bigmalelev(v0); a0 <- bigmalarea(e0) } } } # For model diagnostic plots, save the quarterly water balance variables in a # dataframe called watbalxx. Note the double assignment arrow, which means the # dataframe is saved in the workspace when the function is done. dqtrxx <- 1896+seq(0,nyrs*4-1,1)/4 yrxx <- floor(dqtrxx) qtrxx <- (dqtrxx-floor(dqtrxx))*4 +1 watbalxx <<- data.frame(yrxx,qtrxx,dqtrxx,elest,aest,vest,qin,qout,evest,qgw,defout) # Function output consists of the fitted annual lake volume changes for each water year volannual <- c(v0save,vest[seq(4,nyrs*4,4)]) volannual <- volannual[-1] volannual } ################################################################################# ### These are the functions for computing lake volumes and areas for ### Big Mallard Marsh ################################################################################# bigmalvol <- function(elev) { # computes lake volume (million cubic ft) given elevation elev <- max(elev,1820.7) vol <- 6.52*(elev-1820.7)^1.8 vol } bigmalarea <- function(elev) { # computes lake area (million sq. ft) given elevation elev <- max(elev,1820.7) area <- 11.74*(elev-1820.7)^0.8 area } bigmalelev <- function(vol) { # computes lake elevation given volume vol <- max(vol,0) elev=1820.7+(vol/6.52)^(1/1.8) elev }