Skip to contents

Creates an input design matrix for sensitivity analysis where non-parameter inputs (met, IC, soil, etc.) are held constant while parameters vary one-at-a-time across quantiles. This differs from ensemble design where all inputs vary together.

Usage

generate_OAT_SA_design(settings, sa_samples = NULL)

Arguments

settings

PEcAn settings object. See details for required elements.

sa_samples

Optional. Pre-loaded SA samples (named list with one element per PFT, each a matrix with quantiles as rows and traits as columns). If NULL (default), samples are generated via get.parameter.samples.

Value

list with component X: a data.frame with columns for each input type and one row per SA run. Non-parameter columns are all 1 (constant).

Details

## Settings requirements

This function directly uses:

  • settings$outdir - Output directory path for samples.Rdata

  • settings$pfts - List of PFTs (extracts posterior.files)

  • settings$ensemble$samplingspace - Input types to include in design

When sa_samples = NULL, settings is passed to get.parameter.samples which additionally requires:

  • settings$sensitivity.analysis - SA quantile configuration

  • settings$database$bety - Database connection (optional)

  • settings$host$name - Host name for dbfile.check (optional)

## OAT design logic For sensitivity analysis, we must isolate the effect of each parameter by holding all other inputs constant. The param column contains sequential indices (1, 2, 3, ...) matching the SA run order in write.sa.configs. All other columns (met, ic, soil, etc.) are set to 1, meaning the first input file is always used.

Note on internal dependencies

If sa_samples is NULL we hand off to get.parameter.samples(), which does the work of finding and loading parameter distributions.

In practice it: - uses pft$posterior.files directly when it is defined (an Rdata file with post.distns or prior.distns), - otherwise figures out an output directory from pft$outdir or, if needed, via pft$posteriorid in the database, - then looks in that directory for post.distns.Rdata, falling back to prior.distns.Rdata, - and, for MCMC posteriors, looks up trait.mcmc*.Rdata linked to the same posteriorid or a trait.mcmc.Rdata file in that directory.

Author

Akash B V

Examples

if (FALSE) { # \dontrun{
# Generate SA design for a multi-site run
sa_design <- generate_OAT_SA_design(settings)

# View the design matrix
print(sa_design$X)
#   param met ic soil
# 1     1   1  1    1   # Median run
# 2     2   1  1    1   # trait1 @ q=2.3%
# 3     3   1  1    1   # trait1 @ q=15.9%
# 4     4   1  1    1   # trait1 @ q=84.1%
# ...

# With pre-loaded sa_samples (skips get.parameter.samples call)
load("samples.Rdata")
sa_design <- generate_OAT_SA_design(settings, sa_samples = sa.samples)
} # }