% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/climate_functions.R
\name{dm_subdaily_clim}
\alias{dm_subdaily_clim}
\title{Subdaily climate features for dendrometer analyses}
\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{
\item{clim_df}{Climate input. This can be:
\itemize{
  \item a standardized object returned by \code{read.climate()}
  \item a raw data frame with a time column in the first column or in a
        column named \code{TIME}
  \item a valid file path readable by \code{read.climate()}
}}

\item{mean_vars}{Variables for rolling means.}

\item{sum_vars}{Variables for rolling sums.}

\item{lag_vars}{Variables for lagged features.}

\item{roll_hours}{Numeric vector of rolling-window sizes in hours.
Fractional values are allowed, e.g. \code{0.5} for 30 minutes.}

\item{lag_hours}{Numeric vector of lag sizes in hours.
Fractional values are allowed, e.g. \code{0.25} for 15 minutes.}
}
\value{
A tibble of class \code{"subdaily_clim"} with timestamp-level climate
features added. The inferred temporal resolution in hours is stored in
\code{attr(x, "resolution_hours")}.
}
\description{
Computes rolling-window and lagged climate features at subdaily resolution
for direct linkage with point-level dendrometer outputs such as
\code{ZG_phase} and \code{SC_phase}.

The input can be a standardized climate object returned by
\code{read.climate()}, a raw data frame, or a valid file path accepted by
\code{read.climate()}.
}
\details{
The function learns the temporal resolution automatically from the median
time step in the \code{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:
\itemize{
  \item \code{0.25} = 15 minutes
  \item \code{0.5} = 30 minutes
  \item \code{1} = 1 hour
  \item \code{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.
}
\examples{
\donttest{
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")
}
}
