% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/climate_functions.R
\name{dm_daily_clim}
\alias{dm_daily_clim}
\title{Daily climate summaries for dendrometer analyses}
\usage{
dm_daily_clim(
  clim_df,
  mean_vars = NULL,
  min_vars = NULL,
  max_vars = NULL,
  sum_vars = NULL,
  median_vars = NULL,
  lag_vars = NULL,
  lagmean_vars = NULL,
  lagsum_vars = NULL,
  lag_days = c(1, 3, 7)
)
}
\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}{Character vector of variables to summarize by mean.}

\item{min_vars}{Character vector of variables to summarize by minimum.}

\item{max_vars}{Character vector of variables to summarize by maximum.}

\item{sum_vars}{Character vector of variables to summarize by sum.}

\item{median_vars}{Character vector of variables to summarize by median.}

\item{lag_vars}{Character vector of summarized daily climate columns for
which simple lagged values should be computed, e.g.
\code{c("VPD_max", "SWC_mean")}.}

\item{lagmean_vars}{Character vector of summarized daily climate columns for
which antecedent means should be computed, e.g.
\code{c("Tair_mean", "VPD_mean")}.}

\item{lagsum_vars}{Character vector of summarized daily climate columns for
which antecedent sums should be computed, e.g.
\code{c("P_sum", "Rad_sum")}.}

\item{lag_days}{Integer vector giving lag/antecedent window sizes in days,
e.g. \code{c(1, 3, 7)}.}
}
\value{
A tibble of class \code{"daily_clim"} with one row per day.
}
\description{
Computes daily climate summaries from climate time series so they can be
related to daily dendrometer summaries from \code{daily.data()}.

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()}.

In addition to same-day climate summaries, the function can also compute
lagged and antecedent daily climate features from the summarized daily series:
\itemize{
  \item lagged values (e.g. previous 1 or 3 days)
  \item antecedent means over previous \code{n} days
  \item antecedent sums over previous \code{n} days
}
}
\details{
Lagged and antecedent features are calculated from the already summarized
daily climate columns. For example, if \code{VPD} is included in
\code{max_vars}, the daily summary column will be \code{VPD_max}. If this
column is listed in \code{lag_vars} and \code{lag_days = 1}, then the
additional column \code{VPD_max_lag_1d} is created.

Antecedent means and sums exclude the current day. For example:
\deqn{x\_lagmean\_3d(t) = mean(x_{t-3}, x_{t-2}, x_{t-1})}
\deqn{x\_lagsum\_7d(t) = sum(x_{t-7}, \ldots, x_{t-1})}
}
\examples{
\donttest{
data(ktm_clim_hourly)
clim_day <- dm_daily_clim(
  ktm_clim_hourly,
  mean_vars = c("temp", "VPD", "RH"),
  max_vars  = c("VPD"),
  sum_vars  = c("prec"),
  lag_vars = c("VPD_max", "temp_mean"),
  lagmean_vars = c("temp_mean", "VPD_mean", "RH_mean"),
  lagsum_vars = c("prec_sum"),
  lag_days = c(1, 3, 7)
)
head(clim_day, 5)
}

}
