Creates a graph of warm or cold events as per the second row of Figure 3 in Hobday et al. (2016).
event_line(data, x = t, y = temp, min_duration = 5, spread = 150,
metric = "int_cum", start_date, end_date)
The function receives the output from the detect
function.
This column is expected to contain a vector of dates as per the
specification of make_whole
. If a column headed t
is present in
the dataframe, this argument may be ommitted; otherwise, specify the name of
the column with dates here.
This is a column containing the measurement variable. If the column
name differs from the default (i.e. temp
), specify the name here.
The minimum duration that an event has to for it to qualify as a marine heat wave or marine cold spell.
The the number of days leading and trailing the largest event
(as per metric
) detected within the time period specified by
start_date
and end_date
. The default is 150 days.
One of the following options: int_mean
, int_max
, int_var
,
int_cum
, int_mean_rel_thresh
, int_max_rel_thresh
, int_var_rel_thresh
,
int_cum_rel_thresh
, int_mean_abs
, int_max_abs
, int_var_abs
,
int_cum_abs
, int_mean_norm
, int_max_norm
, rate_onset
, rate_decline
.
Partial name matching is currently not supported so please specify the metric
name precisely. The default is int_cum
.
The start date of a period of time within which the largest
event (as per metric
) is retrieved and plotted. This may not necessarily
correspond to the biggest event of the specified metric within the entire
data set. To plot the biggest event within the whole time series, make sure
start_date
and end_date
straddle this event, or simply specify
the start and end dates of the full time series given to detect
.
The end date of a period of time within which the largest
event (as per metric
) is retrieved and plotted. See start_date
for additional information.
The function will return a line plot indicating the climatology,
threshold and temperature, with the hot or cold events that meet the
specifications of Hobday et al. (2016) shaded in as appropriate. The plotting
of hot or cold events depends on which option is specified in detect
.
The top event detect during the selected time period will be visible in a
brighter colour. This function differs in use from geom_flame
in that it creates a stand alone figure. The benefit of this being
that one must not have any prior knowledge of ggplot2 to create the figure.
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
# NOT RUN {
ts_dat <- make_whole(sst_WA)
res <- detect(ts_dat, climatology_start = "1983-01-01",
climatology_end = "2012-12-31")
# }
# NOT RUN {
event_line(res, spread = 200, metric = "int_cum",
start_date = "2010-10-01", end_date = "2011-08-30")
# }
Run the code above in your browser using DataLab