dm_subdaily_clim: Subdaily climate features for dendrometer analyses

View source: R/climate_functions.R

dm_subdaily_climR Documentation

Subdaily climate features for dendrometer analyses

Description

Computes rolling-window and lagged climate features at subdaily resolution for direct linkage with point-level dendrometer outputs such as ZG_phase and SC_phase.

The input can be a standardized climate object returned by read.climate(), a raw data frame, or a valid file path accepted by read.climate().

Usage

dm_subdaily_clim(
  clim_df,
  mean_vars = NULL,
  sum_vars = NULL,
  lag_vars = NULL,
  roll_hours = c(3, 6, 24),
  lag_hours = c(1, 3, 6, 24)
)

Arguments

clim_df

Climate input. This can be:

  • a standardized object returned by read.climate()

  • a raw data frame with a time column in the first column or in a column named TIME

  • a valid file path readable by read.climate()

mean_vars

Variables for rolling means.

sum_vars

Variables for rolling sums.

lag_vars

Variables for lagged features.

roll_hours

Numeric vector of rolling-window sizes in hours. Fractional values are allowed, e.g. 0.5 for 30 minutes.

lag_hours

Numeric vector of lag sizes in hours. Fractional values are allowed, e.g. 0.25 for 15 minutes.

Details

The function learns the temporal resolution automatically from the median time step in the TIME column. It works with hourly as well as minute-resolution data (for example 60-, 30-, 15-, 10-, or 5-minute data).

Rolling windows and lags are provided in hours and may be fractional:

  • 0.25 = 15 minutes

  • 0.5 = 30 minutes

  • 1 = 1 hour

  • 3 = 3 hours

If the user requests a rolling window or lag that is smaller than the inferred climate resolution, the function stops with an error.

If a requested window is not an exact multiple of the inferred resolution, it is rounded to the nearest number of time steps and a warning is issued.

Value

A tibble of class "subdaily_clim" with timestamp-level climate features added. The inferred temporal resolution in hours is stored in attr(x, "resolution_hours").

Examples


data(ktm_clim_hourly)

clim_sub <- dm_subdaily_clim(
  ktm_clim_hourly,
  mean_vars = c("temp", "VPD", "RH"),
  sum_vars  = c("prec"),
  lag_vars  = c("temp", "VPD", "RH"),
  roll_hours = c(1, 3, 6, 24),
  lag_hours  = c(1, 3, 6, 24)
)

head(clim_sub)
attr(clim_sub, "resolution_hours")


dendRoAnalyst documentation built on May 20, 2026, 5:07 p.m.