knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The UKFE package offers a range of functions that can produce plots. Some of these help visualise data prior to analysis, while others plot results. Examples can be seen throughout the other articles. The examples in this article are from the functions' help files; these also contain further details about each function.
We will start by loading the UKFE package:
library(UKFE)
The following functions can be used to plot annual maxima (AMAX) and peaks over threshold (POT) data:
AMplot(): Produces a bar plot of AMAX data.# Get an AMAX sample and plot AMplot(GetAM(58002))
POTextract() and POTt(): Plot a hydrograph with POT data shown. Note that these functions extract the data and then plot as a handy by-product. They cannot be used to plot POT data once extracted.# Extract POT flows for the Thames at Kingston (NRFA gauge 39001) and plot. Note that # the indexing 'ThamesPQ[, c(1, 3)]' is necessary because the date is in the first # column of the 'ThamesPQ' data frame and the flow is in the third. ThamesQPOT <- POTextract(ThamesPQ[, c(1, 3)], thresh = 0.9, Plot = TRUE)
# Extract POT rainfall for the Thames at Kingston (NRFA gauge 39001) and plot. Note that # the indexing 'ThamesPQ[, 1:2]' is necessary because the date is in the first column # of the 'ThamesPQ' data frame and the rainfall is in the second. ThamesPPOT <- POTt(ThamesPQ[, 1:2], threshold = 0.95, div = 14, Plot = TRUE)
HydroPlot(): Plots concurrent precipitation and discharge from a time series, with a choice of date range (defaulting to all the data).# Plot the 2013 water year precipitation and discharge for the Thames at Kingston # (NRFA gauge 39001), adjusting the closeness of the precipitation and discharge # on the y-axis to 1.8. HydroPlot(ThamesPQ, From = "2013-10-01", To = "2014-09-30", adj.y = 1.8)
MonthlyStats(): Derives monthly statistics from a time series. There is an option to plot these.# Calculate the mean flows for each month for the Thames at Kingston (NRFA gauge 39001) # and set the plot title using the 'main' argument QMonThames <- MonthlyStats(ThamesPQ[, c(1, 3)], Stat = mean, ylab = "Discharge (m3/s)", main = "Thames at Kingston monthly mean flow", Plot = TRUE)
# Calculate the monthly sums of rainfall for the Thames at Kingston and set the plot # title using the 'main' argument PMonThames <- MonthlyStats(ThamesPQ[, c(1, 2)], Stat = sum, ylab = "Rainfall (mm)", main = "Thames at Kingston monthly rainfall", Plot = TRUE)
BFI(): Calculates the baseflow index from a daily mean flow series and plots the flow time series (black) and the associated baseflow (red).# Calculate the BFI from daily discharge at Kingston upon Thames (which is in the # third column of the 'ThamesPQ' data) BFI(ThamesPQ[, 3])
FlowSplit(): Separates baseflow from runoff (intended for event-scale rather than long-term flow series). Plots the flow time series in black and the baseflow in red.# Extract a wet six-month period at the Thames at Kingston (NRFA gauge 39001) during # the 2006-2007 water year (flow is in the third column of ThamesPQ) ThamesQ <- subset(ThamesPQ[, c(1, 3)], Date >= "2006-11-04" & Date <= "2007-05-06") # Apply the flow split with default settings QSplit <- FlowSplit(ThamesQ$Q)
DesHydro(): Extracts a mean hydrograph from a flow series. # Extract a design hydrograph from the Thames at Kingston (NRFA gauge 39001) daily # mean flow and print the resulting hydrograph ThamesDesHydro <- DesHydro(ThamesPQ[, c(1, 3)], EventSep = 10, N = 10)
FlowDurationCurve(): Plots flow duration curves for a single flow series or from multiple flow series. These can be winter, summer or annual curves.# Plot a flow duration curve for the Thames at Kingston (NRFA gauge 39001) using # data from Oct 2000 to Sep 2015 FlowDurationCurve(ThamesPQ[, c(1, 3)])
Rating(): Optimises a power law rating equation from observed discharge and stage and plots the resulting rating curve.# Make up some flow (Q) and stage data to act as gaugings Q <- c(177.685, 240.898, 221.954, 205.55, 383.051, 154.061, 216.582) Stage <- c(1.855, 2.109, 2.037, 1.972, 2.574, 1.748, 2.016) Observations <- data.frame(Q, Stage) # Apply the rating function Rating(Observations)
DDFImport() and DDFExtract(): Plot depth-duration-frequency curves. The former imports the depth-duration-frequency 2013 or 2022 results from XML files from either the FEH Web Service or the NRFA Peak Flow Dataset. The latter derives depth-duration-frequency curves from a rainfall time series (assuming that the AMAX data follow a GEV distribution).# Extract 15-minute rainfall from the St Ives (Cambridgeshire) rain gauge StIves <- tryCatch( GetDataEA_Rain(WISKI_ID = "179365", Period = "15Mins", From = "2022-01-01", To = "2025-01-31"), error = function(e) NULL ) if (!is.null(StIves) && nrow(StIves) > 0) { DDFExtract(StIves) } else { message("Environment Agency API did not return data; skipping plot generation.") }
The following functions can be used to plot results from functions used in Flood Estimation Handbook (FEH) Statistical or Revitalised Flood Hydrograph (ReFH) analyses. Examples can be seen in the respective articles.
DiagPlots()ERPlot()
EVPlot() and EVPlotAdd()
EVPool()
Uncertainty()ReFH()Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.