sens_apsimx: Sensitivity Analysis for APSIM Next Generation simulation

View source: R/sens_apsimx.R

sens_apsimxR Documentation

Sensitivity Analysis for APSIM Next Generation simulation

Description

It is a wrapper for running APSIM-X and evaluating different parameters values

Summary computes variance-based sensitivity indexes from an object of class ‘sens_apsim’

Print method for an object of class ‘sens_apsim’

Usage

sens_apsimx(
  file,
  src.dir = ".",
  parm.paths,
  convert,
  replacement,
  grid,
  soil.profiles,
  summary = c("mean", "max", "var", "sd", "none"),
  root,
  verbose = TRUE,
  cores = 1L,
  save = FALSE,
  ...
)

## S3 method for class 'sens_apsim'
summary(
  object,
  ...,
  formula,
  scale = FALSE,
  select = "all",
  warning = TRUE,
  verbose = TRUE
)

## S3 method for class 'sens_apsim'
print(x, ..., variables = FALSE, summary = FALSE)

Arguments

file

file name to be run (the extension .apsimx is optional)

src.dir

directory containing the .apsimx file to be run (defaults to the current directory)

parm.paths

absolute or relative paths of the coefficients to be evaluated. It is recommended that you use inspect_apsimx for this

convert

(logical) This argument is needed if there is a need to pass a vector instead of a single value. The vector can be passed as a character string (separated by spaces) and it will be converted to a numeric vector. It should be either TRUE or FALSE for each parameter.

replacement

TRUE or FALSE for each parameter. Indicating whether it is part of the ‘replacement’ component. Its length should be equal to the length or ‘parm.paths’.

grid

grid of parameter values for the evaluation. It can be a data.frame.

soil.profiles

list with soil profiles for replacement (see details.)

summary

whether to print the full summary of the grid simulations (default is FALSE)

root

root argument for edit_apsimx_replacement

verbose

whether to print to console results of summary

cores

number of cores to use for parallel evaluation

save

whether to save intermediate results. By default they will be saved as a ‘csv’ file using the name of the apsim file. This will replace ‘apsimx’ with ‘csv’. It is also possible to provide the file name here (for example: ‘Some_results.csv’).

...

additional arguments (none used at the moment)

object

object of class ‘sens_apsim’

formula

formula to be passed to analysis of variance. See formula.

scale

if all inputs are numeric it is better to scale them. The default is FALSE as some inputs might be characters or factors. In this case all inputs will be treated as factors in the sum of squares decomposition.

select

option for selecting specific variables in the APSIM output. It will be treated as a regular expression

warning

whether to issue a warning when applying this function to an object which has not been summarized

x

object of class ‘sens_apsim’

variables

whether to print APSIM output variables (default is FALSE)

Details

It is possible to provide a list of soil profiles for replacement in the simulations. In this case, the parameter path can be simply ‘soil.profile’ or ‘soil_profile’ if there is one single simulation. It can also be the path to ‘Soil’. In this case, the path should be something such as ‘Simulations.SimulationName.Soil’. ‘SimulationName’ should be replaced with the appropriate string.

In the grid, the column with name ‘soil.profile’ should contain integers that will be used to pick from the list of provided soil profiles. In this case it is possible to re-use them. For example, the values could be 1, 2, 3, etc. to select the corresponding soil profiles from the ‘soil.profiles’ list.

If the ‘cores’ argument is greater than 1, then the package future is required. It will first search for a future plan under options and if nothing is found it will chose an OS-appropriate plan and it uses the chosen number of cores for execution. Errors, messages and warnings are normally suppressed during parallel execution, so it is important to ensure that the simulations are constructed properly.

Suggested reading on the topic of sensitivity analysis:

Pianosa et al (2016). Sensitivity analysis of environmental models: A systematic review with practical workflow. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.envsoft.2016.02.008")}

Saltelli et al. . Global Sensitivity Analysis.

Value

object of class ‘sens_apsim’, but really just a list with results from the evaluations.

prints to console if verbose and returns a data frame

compact printing

Note

The summary function is stored as an attribute of the data frame ‘grid.sims’.

Examples


## See the vignette for examples



apsimx documentation built on Sept. 11, 2024, 5:42 p.m.