dm_epoch_extract: Build an epoch table around event times

View source: R/dm_sea.R

dm_epoch_extractR Documentation

Build an epoch table around event times

Description

Builds a long-format epoch table by extracting climate values before and after event times.

The optional Year and DOY arguments allow the user to restrict which events are included in the superposed epoch analysis. The full climate table is retained for lag extraction so that values before and after selected events are still available.

Usage

dm_epoch_extract(
  events,
  clim,
  vars = "all",
  lag_before = 24,
  lag_after = 24,
  step = 1,
  unit = c("hours", "days", "mins"),
  agg_fun = "mean",
  var_funs = NULL,
  Year = NULL,
  DOY = NULL,
  restrict_null_to_window = TRUE
)

Arguments

events

Output of [dm_event_times()] or a data frame containing an event_time column.

clim

Climate data frame. The first column must contain timestamps.

vars

Climate variables to use, or "all".

lag_before

Number of lag steps before the event.

lag_after

Number of lag steps after the event.

step

Step size in units.

unit

One of "hours", "days", or "mins".

agg_fun

Aggregation function applied to all climate variables when var_funs is not supplied.

var_funs

Optional named vector or named list of aggregation functions for each variable.

Year

Optional numeric vector of calendar years to include in the SEA. Events whose event_time falls outside these years are removed before epoch extraction.

DOY

Optional numeric vector of length one or two giving the day-of-year window to include in the SEA. If length one, only that DOY is retained. If length two, the inclusive range is retained. Cross-year DOY windows are supported, for example DOY = c(300, 60).

restrict_null_to_window

Logical. If TRUE, null anchor times in [dm_epoch_test()] are sampled only from the same Year/DOY window. The full climate table is still retained for extracting lag_before and lag_after windows. Default is TRUE.

Value

An object of class c("dm_epoch", "dm_epoch_extract").

Examples


# events <- dm_event_times(zg, event = "GRO_start")
# ep <- dm_epoch_extract(
#   events = events,
#   clim = climate,
#   vars = c("Rain", "temp", "vpd"),
#   Year = c(2022, 2023, 2024),
#   DOY = c(100, 300),
#   lag_before = 24,
#   lag_after = 24,
#   unit = "hours"
# )



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