
Calculate rolling Degree Heating Months
calculate_dhm.RdImplements the monthly heat-stress algorithm used by Mason, Bozec and Mumby (2025) and the supplied reference MATLAB script. Monthly SST anomalies above an externally defined MMM are accumulated over three or four months.
Usage
calculate_dhm(
sst,
mmm,
window = 3L,
threshold = 0,
input = c("monthly", "daily"),
conversion = c("none", "weekly_4", "weekly_4.35"),
alignment = c("matlab_previous", "right"),
output = c("rolling", "annual_max"),
incomplete = c("missing", "matlab_zero"),
min_month_coverage = 1,
filename = "",
overwrite = FALSE,
wopt = list()
)Arguments
- sst
Monthly or daily SST
terra::SpatRaster.- mmm
A one-layer externally defined Maximum Monthly Mean raster aligned with
sst. For the Mason comparison this is the 1985–2000 observational MMM, not an MMM estimated from the evaluation period.- window
Rolling accumulation window in months, normally
3or4.- threshold
Minimum anomaly above MMM required for inclusion. The reference DHM uses
0; its sensitivity analysis also used1.- input
Input resolution,
"monthly"or"daily".- conversion
Output conversion.
"none"returns degree C-months;"weekly_4"and"weekly_4.35"convert to approximate degree C-weeks.- alignment
"matlab_previous"assigns the previous complete window to the following month, exactly matchingCalculate_DHW_or_DHM.m."right"assigns a window to its final included month.- output
Return the monthly
"rolling"series or"annual_max".- incomplete
"missing"marks dates without a complete history asNA."matlab_zero"reproduces the MATLAB script's zero-initialized DHP matrix exactly.- min_month_coverage
For daily input, the minimum fraction of expected daily values required for a monthly mean.
- filename
Optional output filename.
- overwrite
Overwrite an existing output file.
- wopt
Write options passed to
terra::writeRaster().
Value
A rolling monthly or annual-maximum terra::SpatRaster.
References
Mason, R.A.B., Bozec, Y.-M. & Mumby, P.J. (2025), Nature Geoscience 18, 120–123. doi:10.1038/s41561-024-01635-7