dm_event_climate: Extract climate at and before phase events

View source: R/events_phase_plots.R

dm_event_climateR Documentation

Extract climate at and before phase events

Description

Extracts climate at event times and summarizes climate in windows preceding those events. Event times can be phase starts, phase ends, or Max.twd.time for phase.zg() output.

Usage

dm_event_climate(
  x,
  clim_df,
  event = c("phase_start", "phase_end", "max_twd"),
  phase = "all",
  windows = c(0, 1, 3, 6, 12, 24, 48),
  mean_vars = NULL,
  max_vars = NULL,
  min_vars = NULL,
  sum_vars = NULL,
  median_vars = NULL,
  instant_vars = NULL,
  instant_match = c("nearest", "previous", "next")
)

Arguments

x

Output of phase.zg() or phase.sc().

clim_df

Subdaily climate input. This can be a standardized climate object from read.climate(), a raw climate data frame, or a valid climate file path.

event

One of "phase_start", "phase_end", or "max_twd".

phase

Phase selector. For ZG_output: "all", "TWD", or "GRO". For SC_output: "all", "Shrinkage", "Expansion", or "Increment".

windows

Numeric vector of antecedent windows in hours, e.g. c(0, 1, 3, 6, 12, 24, 48). A value of 0 extracts climate at the event time.

mean_vars, max_vars, min_vars, sum_vars, median_vars

Climate variables to summarize in antecedent windows.

instant_vars

Climate variables to extract at the exact event time. If NULL, all selected variables are used.

instant_match

Matching rule for event-time extraction: "nearest", "previous", or "next".

Value

A tibble with one row per event and climate summaries in the requested antecedent windows.

Examples


data(gf_nepa17)
data(ktm_clim_hourly)

zg <- phase.zg(df = gf_nepa17[1:800, ], TreeNum = 1)

evt_zg <- dm_event_climate(
  zg,
  ktm_clim_hourly,
  event = "phase_start",
  phase = "all",
  windows = c(0, 1, 3, 6, 12, 24),
  mean_vars = c("temp", "VPD", "RH"),
  max_vars  = c("temp", "VPD"),
  sum_vars  = c("prec")
)

head(evt_zg)

evt_maxtwd <- dm_event_climate(
  zg,
  ktm_clim_hourly,
  event = "max_twd",
  windows = c(0, 1, 3, 6, 12, 24),
  mean_vars = c("temp", "VPD", "RH"),
  max_vars  = c("VPD"),
  sum_vars  = c("prec")
)

head(evt_maxtwd)


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