Learn R Programming

RmarineHeatWaves (version 0.14.1)

detect: Detect Marine Heat Waves and Marine Cold Spells.

Description

Applies the Hobday et al. (2016) marine heat wave definition to an input time series of temperature along with a daily date vector.

Usage

detect(data, climatology_start = 1983, climatology_end = 2012, pctile = 90, window_half_width = 5, smooth_percentile = TRUE, smooth_percentile_width = 31, min_duration = 5, join_across_gaps = TRUE, max_gap = 2, max_pad_length = 3, cold_spells = FALSE)

Arguments

data
A data frame with three columns. They are headed doy, which is the Julian day running from 1 to 366, but modified so that the day-of-year (doy) vector for non-leap-years runs 1...59 and then 61...366. For leap years the 60th day is February 29. The date column is a vector of dates of class Date, while temp is the temperature. Data of the appropriate format are created by the function make_whole, but your own data can be supplied if they meet the criteria specified by make_whole.
climatology_start
The first full year from which the (varying by day-of-year) seasonal cycle and extremes threshold are calculated (full being 366 days if leap year, else 365 days). Note that a default value is provided but that it may not be suitable for your own data. Default is 1983.
climatology_end
The last full year up to which the seasonal cycle and extremes threshold are calculated. Default is 2012 (but see comment above).
pctile
Threshold percentile (%) for detection of extreme values. Default is 90th percentile for marine heat waves and 10th percentile for marine cold spells.
window_half_width
Width of sliding window about day-of-year (to one side of the center day-of-year) used for the pooling of values and calculation of climatology and threshold percentile. Default is 5 days, which gives a window width of 11 days centered on the 6th day of the series of 11 days.
smooth_percentile
Full width of moving average window for smoothing climatology and threshold. Default is 31 days.
smooth_percentile_width
Boolean switch selecting whether to smooth the climatology and threshold percentile timeseries with a moving average of width smooth_percentile. Default is TRUE.
min_duration
Minimum duration for acceptance of detected MHWs. Default is 5 days.
join_across_gaps
Boolean switch indicating whether to join MHWs which occur before/after a short gap as specified by max_gap. Default is TRUE.
max_gap
Maximum length of gap allowed for the joining of MHWs. Default is 2 days.
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.
cold_spells
Boolean specifying if the code should detect cold events instead of heat events. Default is FALSE.

Value

The function will return a list of two components, clim and event, which are the climatology and MHW (or MCS) events, respectively. The climatology contains the full time series of daily temperatures, as well as the the seasonal climatology, the threshold and various aspects of the events that were detected:The events are summarised using a range of event metrics:int_max_rel_thresh, int_mean_rel_thresh, int_var_rel_thresh, and int_cum_rel_thresh are as above except relative to the threshold (e.g., 90th percentile) rather than the seasonal climatology.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 seasonal climatology or threshold.int_max_norm and int_mean_norm are as above except units are in multiples of threshold exceedances, i.e., a value of 1.5 indicates the event intensity (relative to the climatology) was 1.5 times the value of the threshold (relative to climatology, i.e., threshold - climatology.)Note that rate_onset and rate_decline will return NA or NaN when the event occurs at the start or end of time series. This may be particularly evident when the function is applied to large gridded data sets. Although the other metrics do not contain any errors and provide sensible values, please take this into account in its interpretation.

Details

  1. This function assumes that the input time series consists of continuous daily values with few missing values. Time ranges which start and end part-way through the calendar year are supported. The accompanying function make_whole aids in the preparation of a time series that is suitable for use with detect, although this may also be accomplished 'by hand' as long as the criteria are met as discussed in the documentation to make_whole.
  2. It is recommended that a climatology period of at least 30 years is specified in order to capture decadal thermal periodicities. Currently the function will only compute climatologies starting from 1 January of the specified climatology_start and ending on 31 December of the specified climatology_end. Even one day short of a full year (i.e. 365 day during non-leap years and 366 days during leap years) at the beginning/end of the climatology period will cause the function to fail. This may be changed in future versions of the function.
  3. This function supports leap years. This is done by ignoring Feb 29s for the initial calculation of the climatology and threshold. The values for Feb 29 are then linearly interpolated from the values for Feb 28 and Mar 1.
  4. The calculation of onset and decline rates assumes that the events 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.
  5. For the purposes of event detection, any missing temperature values not interpolated over (through optional max_pad_length) will be set equal to the seasonal climatology. This means they will trigger the end/start of any adjacent temperature values which satisfy the event definition criteria.
  6. If the code is used to detect cold events (coldSpells = TRUE), then it works just as for heat waves except that events are detected as deviations below the (100 - pctile)th percentile (e.g., the 10th instead of 90th) for at least 5 days. Intensities are reported as negative values and represent the temperature anomaly below climatology.

The original Python algorithm was written by Eric Oliver, Institute for Marine and Antarctic Studies, University of Tasmania, Feb 2015, and is documented by Hobday et al. (2016). The marine cold spell option was implemented in version 0.13 (21 Nov 2015) of the Python module as a result of our preparation of Schlegel et al. (submitted), wherein the cold events receive a brief overview.

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

Schlegel, R. W., Oliver, C. J., Wernberg, T. W., Smit, A. J. (in press). Coastal and offshore co-occurrences of marine heatwaves and cold-spells. Progress in Oceanography.

Examples

Run this code
t_dat <- make_whole(sst_WA)
res <- detect(t_dat, climatology_start = 1983, climatology_end = 2012)
# show a portion of the climatology:
res$clim[1:10, ]
# show some of the heat waves:
res$event[1:5, 1:10]

Run the code above in your browser using DataLab