fnc_write_agg_depr: Function to aggregate and write data from automated...

View source: R/fnc_write_agg_depr.R

fnc_write_agg_deprR Documentation

Function to aggregate and write data from automated LWFB90-Runs

Description

LWFBrook90 creates a lot of output files. In order to keep data storage to a minimum, both run_LWFB90 and run_multisite_LWFB90 provide an output_fun - argument that can be used to reduce the output and directly write it to a database. This is what this function is made for.
In comparison to fnc_write, which only reduces the columns returned by run_LWFB90 (see help page), this function enables aggregation over vegperiod and monthly, plus a more detailed selection of drought indices. See detail section.

IMPORTANT: FOR RUNNING THIS AGGREGATE FUNCTION, output in run_multiside_LWFB90 MUST BE SET TO A df.output AS SET BY THE CODE IN THE EXAMPLE SECTION
The function writes .rds files with the desired output for each point. fnc_write_to_sql can be used to convert these files into a SQLite-DB. This "step-in-between" is necessary because SQLite does not support parallel writing.

Usage

fnc_write_agg_depr(
  x,
  aggr_tp,
  col_select_day = NA,
  col_select_mon = NA,
  col_select_vp = NA,
  col_select_yr = NA,
  dir_name = NA
)

Arguments

x

one of the intermediate producs of run_LWFB90 or run_multisite_LWFB90, which is further processed internally. Can't be adjusted.

aggr_tp

a string containing the desired aggregation time period. Can be daily, monthly, vegper, yearly, or any combination of the four (i.e. monthly_vegper). The latter does all terms that are detectable within the string.

col_select_day

a string containing the desired columns from the daily-aggregation (see details)

col_select_mon

a string containing the desired columns from the monthly-aggregation (see details)

col_select_vp

a string containing the desired columns from the vegperiod-aggregation (see details)

col_select_yr

a string containing the desired columns from the yearly-aggregation (see details)

dir_name

directory for tmp files, if NA as in default, results are returned to console

Value

Returns the desired output to .rds files

Output column selection

IT IS HIGHLY RECOMMENDED TO MAKE A SUBSELECTION, OR THERE WILL BE A LOT (>100) OF COLUMNS. For a complete list of possible output types plus description, see "U:/db_brook90_output/whh_db_documentation"

Examples

# setting for df.output:
df.output <- set_outputLWFB90()
df.output[,] <- 0L
df.output[c("Abov", "Evap", "Flow", "Swat"), c("Day")] <- 1

# for full example, see help page of ?fnc_write_to_sql


rhabel/modLWFB90 documentation built on Nov. 21, 2024, 3:28 a.m.