# NOT RUN {
# Create a temporary folder for the output and set the working directory:
# Create a temporary folder for the output and set the working directory:
temp_path <- file.path(tempdir(), "ss3sim-base-example")
dir.create(temp_path, showWarnings = FALSE)
wd <- getwd()
setwd(temp_path)
on.exit(setwd(wd), add = TRUE)
# Find the data in the ss3sim package:
d <- system.file("extdata", package = "ss3sim")
om <- file.path(d, "models", "cod-om")
em <- file.path(d, "models", "cod-em")
case_folder <- file.path(d, "eg-cases")
# Pull in file paths from the package example data:
d <- system.file("extdata", package = "ss3sim")
om_dir <- file.path(d, "models", "cod-om")
em_dir <- file.path(d, "models", "cod-em")
a <- get_caseargs(folder = file.path(d, "eg-cases"),
case_files = list(F = "F",
D = c("index", "lcomp", "agecomp"),
E = "E"),
scenario = "F0-D0-E0-cod")
ss3sim_base(iterations = 1,
scenarios = "F0-D0-E0-cod",
f_params = a$F,
index_params = a$index,
lcomp_params = a$lcomp,
agecomp_params = a$agecomp,
tv_params = a$tv_params,
estim_params = a$E,
om_dir = om_dir,
em_dir = em_dir)
unlink("F0-D0-E0-cod", recursive = TRUE) # clean up
# Or, create the argument lists directly in R and skip the case file setup:
F0 <- list(years = 1:100,
fisheries = 1,
fvals = c(rep(0, 25), rep(0.114, 75)))
index1 <- list(fleets = 2, years = list(seq(62, 100, by = 2)),
sds_obs = list(0.1))
lcomp1 <- list(fleets = c(1, 2), Nsamp = list(100, 100),
years = list(26:100, seq(62, 100, by = 2)),
lengthbin_vector = NULL, cpar = c(1, 1))
agecomp1 <- list(fleets = c(1, 2), Nsamp = list(100, 100),
years = list(26:100, seq(62, 100, by = 2)),
agebin_vector = NULL, cpar = c(1, 1))
E0 <- list(natM_type = NULL, natM_n_breakpoints = NULL, natM_lorenzen = NULL,
natM_val = NULL,
par_name = c("LnQ_base_Fishery", "NatM_p_1_Fem_GP_1"),
par_int = c(NA, NA), par_phase = c(-1, -1), forecast_num = 0)
ss3sim_base(iterations = 1,
scenarios = "D1-E0-F0-cod", #name as desired
f_params = F0,
index_params = index1,
lcomp_params = lcomp1,
agecomp_params = agecomp1,
estim_params = E0,
om_dir = om,
em_dir = em)
unlink("D1-E0-F0-cod", recursive = TRUE) # clean up
# }
Run the code above in your browser using DataLab