# NOT RUN {
# The dataRetrieval package is not required by MGBT algorithms.
opts <- options(scipen=7)
opar <- par(no.readonly=TRUE)
par(mgp=c(3,0.5,0), las=1) # going to tick inside, change some parameters
names <- c("08167000 Guadalupe River at Comfort, Tex.")
stations <- c("08167000"); LOT <- c(3110)
maxs <- c(525000); lego <- c(1940)
PKS <- new.env()
for(station in "08167000") {
message("Pulling peaks for ",station)
data <- dataRetrieval::readNWISpeak(station, convertType=FALSE)
data <- splitPeakCodes(MGBT::makeWaterYear(data))
assign(station, data, PKS)
}
# This example should run fine though the resulting curves will end in 2015 because
# this is the declared ending year of 2015. Data points after 2015 will be shown
# but the FFQ values will be the values plotted. Yes, other return periods are shown
# here and dealt with internally, but only the 2, 10, 100, and 500 are drawn.
FFQ <- data.frame(site_no="08167000", final_water_yr=2015,
Q002= 3692, Q005= 21000, Q010= 40610, Q025= 69740,
Q050=91480, Q100=111600, Q200=129400, Q500=149200)
# Now compute the offsets associated with those given above.
OFFSET <- plotFFQevol(PKS, lot=LOT, finalquas=FFQ)
# Notice the plotFFQevol() is called twice. One call is to compute the
# offsets, and the next is to use them and make a pretty plot.
plotFFQevol(PKS, lot=LOT, finalquas=FFQ, log10offsets=OFFSET,
maxs=maxs, mins=rep(0,length(maxs)), names=names,
lego=lego, logyaxs=FALSE, edgeyrs=c(1940,2020), usewyall=TRUE)
# Now a change up, lets say these values are good through the year 1980, and yes,
# these are the same values shown above.
FFQ$final_water_yr <- 1980
OFFSET <- plotFFQevol(PKS, lot=LOT, finalquas=FFQ) # compute offsets
# Now using auxeyr=2020, will trigger the evolution through time and the results in
# 1980 will match these given in the FFQ. One will see (presumably for many years
# after 2017) the crossing of the 500 year to the 100 year in about 1993.
plotFFQevol(PKS, lot=LOT, finalquas=FFQ, log10offsets=OFFSET,
maxs=maxs, mins=rep(0,length(maxs)), names=names, auxeyr=2020,
lego=lego, logyaxs=FALSE, edgeyrs=c(1940,2020), usewyall=FALSE)
# Now back to the original FFQ but in log10 space and plotPeaks().
FFQ$final_water_yr <- 2017
OFFSET <- plotFFQevol(PKS, lot=LOT, finalquas=FFQ) # compute offsets
# Now using logyaxs=TRUE and some other argument changes
plotFFQevol(PKS, lot=LOT, finalquas=FFQ, log10offsets=OFFSET, title="",
maxs=maxs, mins=rep(0,length(maxs)), names=names, auxeyr=2020,
lego=NULL, logyaxs=TRUE, edgeyrs=c(1890,2020), usewyall=TRUE,
showfinalyr=FALSE)
options(opts) # restore the defaults
par(opar) # restore the defaults
# }
Run the code above in your browser using DataLab