Learn R Programming

RmarineHeatWaves (version 0.14.1)

exceedence: Detect consecutive days in exceedence of a given threshold.

Description

Detect consecutive days in exceedence of a given threshold.

Usage

exceedence(data, threshold = 20, below = FALSE, min_duration = 5, join_across_gaps = TRUE, max_gap = 2, max_pad_length = 3)

Arguments

data
A data frame with at least the two following columns: a date column which is a vector of dates of class Date, and a temp column, which is the temperature on those given dates. The function will not accurately detect consecutive days of temperatures in exceedence of the threshold if missing days of data are not filled in with NA. Data of the appropriate format are created by the function make_whole, but your own data may be used directly if they meet the given criteria.
threshold
The static threshold used to determine how many consecutive days are in exceedence of the temperature of interest. Default is 20 degrees.
below
Default is FALSE. When set to TRUE, consecutive days of temperature below the threshold variable are calculated. When set to FALSE, consecutive days above the threshold variable are calculated.
min_duration
Minimum duration that temperatures must be in exceedence of the threshold variable. Default is 5 days.
join_across_gaps
A TRUE/ FALSE statement that indicates whether or not to join consecutive days of temperatures in exceedence of the threshold across a small gap between groups before/after a short gap as specified by max_gap. Default is TRUE.
max_gap
The maximum length of the gap across which to connect consecutive days in exceedence of the threshold when join_across_gaps is TRUE.
max_pad_length
Specifies the maximum length of days over which to interpolate (pad) missing data (specified as NA) in the input temperature time series; i.e., any consecutive blocks of NAs with length greater than max_pad_length will be left as NA. Set as an integer. Default is 3 days.

Value

The function will return a list of two components. The first being threshold, which shows the daily temperatures and on which specific days the given threshold was exceeded. The second component of the list is exceedence, which shows a medley of statistics for each discrete group of days in exceedence of the given threshold. Note that any additional columns left in the data frame given to this function will be output in the threshold component of the output. For example, if one uses make_whole to prepare a time series for analysis and leaves in the doy column, this column will appear in the output.The information shown in the threshold component is:The individual exceedences are summarised using the following metrics:int_max_abs, int_mean_abs, int_var_abs, and int_cum_abs are as above except as absolute magnitudes rather than relative to the threshold.

Details

  1. This function assumes that the input time series consists of continuous daily temperatures, with few missing values. The accompanying function make_whole aids in the preparation of a time series that is suitable for use with exceedence, although this may also be accomplished 'by hand' as long as the criteria are met as discussed in the documentation to make_whole.
  2. Future versions seek to accomodate monthly and annual time series, too.
  3. The calculation of onset and decline rates assumes that exceedence of the threshold started a half-day before the start day and ended a half-day after the end-day. This is consistent with the duration definition as implemented, which assumes duration = end day - start day + 1.
  4. For the purposes of exceedence detection, any missing temperature values not interpolated over (through optional max_pad_length) will remain as NA. This means they will trigger the end of an exceedence if the adjacent temperature values are in exceedence of the threshold.
  5. If the function is used to detect consecutive days of temperature under the given theshold, these temperatures are then taken as being in exceedence below the threshold as there is no antonym in the English language for 'exceedence'.

This function is based largely on the detect function found in this package, which was ported from the Python algorithm that was written by Eric Oliver, Institute for Marine and Antarctic Studies, University of Tasmania, Feb 2015, and is documented by Hobday et al. (2016).

References

Hobday, A.J. et al. (2016). A hierarchical approach to defining marine heatwaves, Progress in Oceanography, 141, pp. 227-238, doi:10.1016/j.pocean.2015.12.014

Examples

Run this code
t_dat <- make_whole(sst_WA)
res <- exceedence(t_dat, threshold = 25)
# show first ten days of daily data:
res$threshold[1:10, ]
# show first five exceedences:
res$exceedence[1:5, ]

Run the code above in your browser using DataLab