Learn R Programming

tidyextreme (version 1.0.0)

calculate_SDII: Calculate Simple Daily Intensity Index (SDII)

Description

Calculates the mean precipitation amount on wet days (\(\geq\) 1 mm), following ETCCDI definition SDII.

Usage

calculate_SDII(
  df,
  frequency = "daily",
  time_col = NULL,
  prcp_col = NULL,
  precip_col = NULL,
  wet_threshold = 1
)

Value

A data.frame with columns: year, SDII, wet_days, total_prcp

Arguments

df

Data frame with precipitation data

frequency

Temporal frequency: "daily" or "hourly" (string)

time_col

Name of the time column (string). Must be in a format recognizable by lubridate (e.g., Date for daily data, POSIXct for hourly data). Recommended formats: - Daily: YYYY-MM-DD (e.g., "2023-01-15") - Hourly: YYYY-MM-DD HH:MM:SS (e.g., "2023-01-15 14:30:00")

prcp_col

Name of precipitation column (daily data) (string)

precip_col

Name of precipitation column (hourly data) (string)

wet_threshold

Threshold for wet day in mm (default: 1)

Examples

Run this code
# Daily precipitation data
daily_prcp <- data.frame(
  date = seq(as.Date("2000-01-01"), as.Date("2002-12-31"), by = "day"),
  rainfall = pmax(0, rgamma(1096, shape = 0.5, scale = 10))
)

# Calculate Simple Daily Intensity Index
calculate_SDII(
  df = daily_prcp,
  frequency = "daily",
  time_col = "date",
  prcp_col = "rainfall"
)

# With custom wet threshold (5mm instead of 1mm)
calculate_SDII(
  df = daily_prcp,
  frequency = "daily",
  time_col = "date",
  prcp_col = "rainfall",
  wet_threshold = 5
)

Run the code above in your browser using DataLab