dm_add_climate: Add climate information to dendrometer outputs

View source: R/dm_add_climate.R

dm_add_climateR Documentation

Add climate information to dendrometer outputs

Description

A single helper function that adds climate information to outputs from daily.data(), phase.zg(), or phase.sc().

Depending on the class of x and the selected scale, the function:

  • joins daily climate to daily.data() output

  • joins climate summaries to phase windows in ZG_cycle or SC_cycle

  • joins subdaily climate features to point-level ZG_phase or SC_phase

Usage

dm_add_climate(
  x,
  clim,
  scale = c("auto", "daily", "phase", "subdaily"),
  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),
  sub_mean_vars = NULL,
  sub_sum_vars = NULL,
  sub_lag_vars = NULL,
  roll_hours = c(3, 6, 24),
  lag_hours = c(1, 3, 6, 24),
  suffix = "_phase"
)

Arguments

x

Object returned by daily.data(), phase.zg(), or phase.sc().

clim

Climate input. This can be:

  • a standardized object returned by read.climate()

  • a raw climate data frame

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

  • a daily climate table returned by dm_daily_clim()

  • a subdaily climate-feature table returned by dm_subdaily_clim()

scale

Character string controlling how climate is attached. One of "auto", "daily", "phase", or "subdaily".

  • For daily_output, only "daily" is supported.

  • For ZG_output and SC_output, "phase" adds climate summaries to ZG_cycle/SC_cycle, while "subdaily" adds timestamp-level climate to ZG_phase/SC_phase.

mean_vars, min_vars, max_vars, sum_vars, median_vars

Climate variables to summarize by mean, minimum, maximum, sum, or median. These are used by dm_daily_clim() and dm_join_phase_clim().

lag_vars, lagmean_vars, lagsum_vars

Variables used by dm_daily_clim() to build lagged and antecedent daily climate features.

lag_days

Integer vector of lag/antecedent windows in days for dm_daily_clim().

sub_mean_vars, sub_sum_vars, sub_lag_vars

Variables used by dm_subdaily_clim() to build rolling and lagged subdaily features.

roll_hours, lag_hours

Numeric vectors of rolling-window and lag sizes in hours for dm_subdaily_clim().

suffix

Suffix appended to climate summaries added by dm_join_phase_clim().

Value

The same biological object with climate information added.

Examples


data(nepa17)
data(gf_nepa17)
data(ktm_clim_hourly)

# daily.data() output + daily climate
dd <- daily.data(df = nepa17[1:1000, ], TreeNum = 1)
dd_clim <- dm_add_climate(
  dd,
  ktm_clim_hourly,
  scale = "daily",
  mean_vars = c("temp", "VPD", "RH"),
  max_vars  = c("temp", "VPD"),
  sum_vars  = c("prec")
)
head(dd_clim)

# phase.zg() output + phase-window climate
zg <- phase.zg(df = gf_nepa17[1:800, ], TreeNum = 1)
zg_clim <- dm_add_climate(
  zg,
  ktm_clim_hourly,
  scale = "phase",
  mean_vars = c("temp", "VPD", "RH"),
  max_vars  = c("temp", "VPD"),
  sum_vars  = c("prec")
)
head(zg_clim$ZG_cycle)

# phase.sc() output + point-level subdaily climate
sc <- phase.sc(df = gf_nepa17[1:800, ], TreeNum = 1, smoothing = 12)
sc_point <- dm_add_climate(
  sc,
  ktm_clim_hourly,
  scale = "subdaily",
  sub_mean_vars = c("temp", "VPD", "RH"),
  sub_sum_vars  = c("prec"),
  sub_lag_vars  = c("temp", "VPD", "RH"),
  roll_hours = c(1, 3, 6, 24),
  lag_hours  = c(1, 3, 6, 24)
)
head(sc_point$SC_phase)



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