Calculate Yearly Means for Event Metrics.
block_average(data, x = t, y = temp, report = "full")
Accepts the data returned by 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.
Specify either full
or partial
. Selecting full
causes
the report to contain NAs for any years in which no events were detected
(except for count
, which will be zero in those years), while partial
reports only the years wherein events were detected. The default is full
.
The function will return a data frame of the averaged (or aggregate) metrics. It includes the following:
The year over which the metrics were averaged.
Seawater temperature for the specified year [deg. C].
The minimum temperature for the specified year [deg. C].
The maximum temperature for the specified year [deg. C].
The number of events per year.
The average duration of events per year [days].
The average event "mean intensity" in each year [deg. C].
The average event "maximum (peak) intensity" in each year [deg. C].
The average event "intensity variability" in each year [deg. C].
The average event "cumulative intensity" in each year [deg. C x days].
Average event onset rate in each year [deg. C / days].
Average event decline rate in each year [deg. C / days].
Total number of events days in each year [days].
Total cumulative intensity over all events in each year [deg. C x days].
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.)
This function needs to be provided with the full output from the detect
function. Note that the yearly averages are calculted only for complete years
(i.e. years that start/end part-way through the year at the beginning or end
of the original time series are removed from the calculations).
This function differs from the python implementation of the function of the
same name (i.e., blockAverage
, see https://github.com/ecjoliver/marineHeatWaves)
in that we only provide the ability to calculate the average (or aggregate)
event metrics in 'blocks' of one year, while the python version allows
arbitrary (integer) block sizes.
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_Med)
# res <- detect(ts_dat, climatology_start = "1983-01-01",
# climatology_end = "2012-12-31")
# out <- block_average(res)
# summary(glm(count ~ year, out, family = "poisson"))
# }
# NOT RUN {
plot(out$year, out$count, col = "salmon", pch = 16,
xlab = "Year", ylab = "Number of events")
lines(out$year, out$count)
# }
Run the code above in your browser using DataLab