determine_sw2_sim_time: Prepare specified vs. requested time step 'data.frame'

View source: R/Functions_Supporting.R

determine_sw2_sim_timeR Documentation

Prepare specified vs. requested time step data.frame

Description

Prepare specified vs. requested time step data.frame

Usage

determine_sw2_sim_time(
  xt,
  req_years = NULL,
  sw2_tp = c("Day", "Month", "Year")
)

Arguments

xt

A two-dimensional object with columns Year, Month (if sw2_tp equals "Month"), and Day (if sw2_tp equals "Day"). Each row represents one time step according to sw2_tp.

req_years

An integer vector of Calendar years. If missing or NULL, then time steps contained in xt are used. If not missing and not NULL and different than years contained in xt, then time steps combined from requested and simulated are used.

sw2_tp

A character string. The daily, monthly, or yearly time step describing content of xt and determining the same output time step.

Value

A data.frame with four columns Year, Month, Day, mode. Rows represent daily, monthly, or yearly time steps that combine requested (if req_years was provided) and simulated (xt) time steps. mode is "nosim" if a time step was not simulated (but requested), "sim_keep" if a time step was simulated (and requested or req_years is missing), or "sim_discard" if a time step was simulated (but not requested).

Notes

The column Day contains day of year (and not day of month)!

Examples

 xty <- data.frame(Year = 1991:2020)
 determine_sw2_sim_time(xty, sw2_tp = "Year")
 determine_sw2_sim_time(xty, req_years = 1981:2010, sw2_tp = "Year")
 determine_sw2_sim_time(xty, req_years = 2011:2030, sw2_tp = "Year")


DrylandEcology/rSW2metrics documentation built on May 25, 2023, 10:38 a.m.