ck_warm_spell: Warm Spell Days (Series-Quantile Approximation)

View source: R/temperature.R

ck_warm_spellR Documentation

Warm Spell Days (Series-Quantile Approximation)

Description

Count the number of days in warm spells, where a warm spell is defined as at least six consecutive days with Tmax above the threshold quantile of the full input series. This is a quick approximation driven by a single series-wide quantile, and does not require a reference period.

Usage

ck_warm_spell(tmax, dates, threshold = 0.9, period = "annual")

Arguments

tmax

Numeric vector of daily maximum temperatures (degrees C).

dates

Date vector of the same length as tmax.

threshold

Numeric. Quantile threshold (default 0.9, i.e. 90th percentile).

period

Character. Aggregation period: "annual" (default) or "monthly".

Details

For the canonical ETCCDI WSDI definition (1961-1990 calendar-day base, six-day spell rule), use ck_wsdi().

Value

A data frame with columns period, value, index, and unit.

Examples

dates <- as.Date("2024-01-01") + 0:364
set.seed(42)
tmax <- rnorm(365, mean = 20, sd = 5)
ck_warm_spell(tmax, dates)

climatekit documentation built on May 9, 2026, 5:08 p.m.