case_tv: Write time varying casefiles to the disk

Description Usage Arguments Author(s) Examples

View source: R/case-write.R

Description

Use R code to write arguments to the disk, which will later be used in a ss3sim simulation.

Usage

1
2
3
case_tv(species, parameter, perc_change, outfile, dir_out = "cases",
  dir_models = system.file("models", package = "ss3models"),
  nyears = 100, verbose = FALSE)

Arguments

species

A vector of species, for which a unique case file will be generated.

parameter

A character value specifying the parameter to add deviates to. The argument must match the parameter name exactly.

perc_change

A vector of percents, which will be used to add deviates to the parameter specified in parameter. A percentage must be supplied for every year in the model.

outfile

A character value specifying the case letter and number used to save the file.

dir_out

A character value specifying the directory to save the outfile to.

dir_models

The path where the models are stored, such that file.path(dir_models, species, "om", "ss3.ctl") leads to valid ss3.ctl operating model files.

nyears

The length time-series included in the model. The length of perc_change must equal nyears.

verbose

Useful for debugging to print output to screen. Default is FALSE.

Author(s)

Peter Kuriyama

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
temp_path <- file.path(tempdir(), "cod")
dir.create(temp_path, showWarnings = FALSE)

d <- system.file("extdata", package = "ss3sim")

om <- file.path(d, "models", "cod-om")
ig <- file.copy(om, temp_path, recursive = TRUE)
ig <- file.rename(file.path(temp_path, "cod-om"), file.path(temp_path, "om"))
filenames <- dir(file.path(temp_path, "om"), full.names = TRUE)
ig <- file.rename(filenames, gsub("codOM\\.|ss\\.", "ss3.", filenames))

verify_input(file.path(temp_path, "om"), type = "om")
ig <- file.rename(file.path(temp_path, "om", "om.ctl"),
  file.path(temp_path, "om", "ss3.ctl"))

case_tv(species = "cod", parameter = "NatM_p_1_Fem_GP_1",
perc_change = rep(0.5, 100), outfile = "G1",
dir_out = temp_path, dir_models = gsub("/cod", "", temp_path),
nyears = 100, verbose = TRUE)
unlink(temp_path, recursive = TRUE)

ss3sim documentation built on Nov. 9, 2019, 1:06 a.m.