get_values_from_sw2: Extract values, determine time series, and assign time steps...

View source: R/Functions_Supporting.R

get_values_from_sw2R Documentation

Extract values, determine time series, and assign time steps to groups based on an rSOILWAT2 output as generated by rSFSW2

Description

Extract values, determine time series, and assign time steps to groups based on an rSOILWAT2 output as generated by rSFSW2

Usage

get_values_from_sw2(
  id_scen,
  path,
  name_sw2_run,
  group_by_month,
  first_month_of_year,
  sw2_tp,
  sw2_out,
  sw2_var,
  varnames_are_fixed = TRUE,
  zipped_runs = FALSE
)

Arguments

id_scen

An integer value. The climate scenario ID as generated by rSFSW2.

path

A character string. The directory path where rSFSW2 stored the rSOILWAT2 output, by default “3_Runs”.

name_sw2_run

A character string. The rSFSW2 name identifying a run, i.e., the full experimental label x site name. The folder name within path.

group_by_month

An integer vector of length 12. The group IDs of each month. If no grouping is requested, then provide, e.g., rep(0, 12).

first_month_of_year

An integer value. The number of the month ⁠[1-12]⁠ when the "year" should start, e.g., 10 for a "water-year" that starts in October. Note: the first and last year are incomplete and will be discarded if first_month_of_year is not 1.

sw2_tp

A character string. One of the rSOILWAT2 output time slots. Note: currently, only “Month” and “Day” are implemented.

sw2_out

A character vector. One (or multiple) of the rSOILWAT2 output groups. These will be recycled if sw_var is longer.

sw2_var

A character vector. One (or multiple) of the column names of the output group(s) corresponding to the sw2_out.

varnames_are_fixed

A logical value. If TRUE, then sw2_var is taken literally. Otherwise, sw2_var are interpreted as regular expressions (and may thus return multiple columns).

zipped_runs

A logical value. Describes whether name_sw2_run is a zip archive or a regular folder.

Value

A list with three elements:

  • vals A list with one element for each sw2_var. Each element is a vector of values for that sw2_var, if varnames_are_fixed is TRUE; otherwise, a vector or matrix where columns represent all the SOILWAT2 output corresponding to that sw2_var interpreted as regular expression. The length of vectors (or the number of rows) corresponds to the number time steps requested by sw2_tp.

  • year A vector of calendar years for each time step.

  • groups_by_time A vector of group ID, based on group_by_month, for each time step.


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