AMextract: Annual maximum extraction

View source: R/All.R

AMextractR Documentation

Annual maximum extraction

Description

Extracts the annual maximum peaks (with other options) from a data.frame which has dates (or POSIXct) in the first column and variable in the second.

Usage

AMextract(
  x,
  func = NULL,
  Calendar = FALSE,
  Trunc = TRUE,
  Plot = TRUE,
  Title = "Hydrological annual maximum sequence",
  Ylabel = "Magnitude"
)

Arguments

x

a data.frame with dates (or POSIXct) in the first column and variable in the second

func

A user chosen function to extract statistics other than maximums.

Calendar

logical. If FALSE, the hydrological year maximums are returned. If TRUE, the calendar year maximums are returned.

Trunc

logical with a default of TRUE. When true the beginning and end of the data.frame are first truncated so that it starts and ends at the start and end of the hydrological year (or Calendar year if Calendar = TRUE).

Plot

a logical argument with a default of TRUE. If TRUE the extracted annual maximum is plotted

Title

Title of the plot when. Default is "Hydrological annual maximum sequence"

Ylabel

Label for the y axis. Default is "Annual maximum quantiles"

Details

The peaks are extracted based on the UK hydrological year (unless Calendar = TRUE), which starts October 1st and ends September 30th. If Trunc = TRUE, partial years (non-full years from the beginning and end) are removed, otherwise the maximum value may not be the true annual maximum of the year. If there are NAs for full years in the data, an -Inf or NA will be returned for that year. The default is to extract maximums but the user can use the func argument to choose other statistics (mean or sum for example). Note that if the data has a sub-daily resolution, it is first aggregated to a daily resolution (with a 09:00 start) before the extraction. For example, the maximum for each day is extracted, then the annual maximums are extracted.

Value

a data.frame with columns; WaterYear and AM. By default AM is the annual maximum sample, but will be any statistic used as the func argument.

Author(s)

Anthony Hammond

Examples

#Extract the Thames AMAX daily mean flow and display the first six rows
ThamesAM <- AMextract(ThamesPQ[,c(1,3)])
head(ThamesAM)
#Extract the annual rainfall totals and change the plot labels accordingly
ThamesAnnualP <- AMextract(ThamesPQ[,1:2], func = sum, Title = "", Ylab = "Rainfall (mm)")

UKFE documentation built on Nov. 6, 2023, 1:07 a.m.

Related to AMextract in UKFE...