R/write_Gmacs_InputFiles.R
write_Gmacs_InputFiles.Rd
Function to write all the input files for a specific/multiple stock(s) for a given version of Gmacs.
write_Gmacs_InputFiles(
stock = NULL,
Stock_NameFiles = NULL,
dir_InputFiles = NULL,
dir_WriteFiles = NULL,
CatchDF_format = NULL,
SurveyDF_format = NULL,
SizeFreqDF_format = NULL,
cleanup = NULL,
dir_TPL = NULL,
Gmacs_Version = NULL,
verbose = NULL
)
(character vector)- names of the stock to consider. This matches the name of stock-specific input file folder.
(list)- named list (the names corresponding to the
stock
) with the names for the new input files to write. See details for
more information about the structure of that list.
(path)- path to the folder containing the input files for each stock.
(path)- path to the repertory(ies) where to write the new
input files. This(ese) folder(s) hold(s) the stock-specific folder named as
in the stock
argument. See the details section.
(integer)- the format of the Catch data frame in the 'model.dat' file. By default, the function considers the one specified in the data file but this can be overwritten using this argument. Values: 0;1.
(integer)- the format of the survey data frame in the 'model.dat' file. By default, the function considers the one specified in the data file but this can be overwritten using this argument. Values: 0;1.
(integer)- the format of the size frequency data frame in the 'model.dat' file. By default, the function considers the one specified in the data file but this can be overwritten using this argument. Values: 0;1.
flag to delete old input files in the dir_InputFiles
folder after writing the new ones.
(path)- path to the folder holding the "gmacs.tpl" file which will be used to run the stock assessments with these input files.
(character)- the version number of Gmacs.
This has to be in the form X.YY.ZZ
. If NULL
, the dir_TPL
path has to be provided.
(logical)- if TRUE
, report the writing process (useful
for debugging).
The Stock_NameFiles list is a named list of length length(stock)
and
holds for each stock the following object:
$datfileName_New
the name used to save the new 'model.dat' file.
$ctlfileName_New
the name used to save the new 'model.ctl' file.
$prjfileName_New
the name used to save the new 'model.prj' file.
$model_name
the name of the stock assessment model for the stock (e.g., 'model_16_0').
$Ass_year
the year in which these input files (in terms of model configuration, data,...) were used to assess the stock.
When multiple repertories are provided for the dir_WriteFiles
argument,
the function will write the input files in each of these folders.
if (FALSE) {
#' fsep <- .Platform$file.sep
# Load packages ----
library(gmr)
library(magrittr)
# Name of the folder in the Testing_Version folder of the version being developed
# Gmacs_Ver <-"Gmacs_2_10_01"
Gmacs_Ver <-"Gmacs_2_10_01"
# Set directories ----
Dir_Dvpt_Vers <- file.path(here::here(), "Dvpt_Version", "build", fsep = fsep)
dir_test <- file.path(here::here(), "Testing_Versions", Gmacs_Ver)
dir_InputFiles <- file.path(dirname(dir_test), "Stock_Input_files", Gmacs_Ver, fsep = fsep)
# Stock of interest input files names ----
# This also includes the model name (\code{model_name}) and the year of
# assessment (\code{Ass_year})
EAG <- list(
datfileName_New = "EAG_21_1.dat",
ctlfileName_New = "EAG_21_1.ctl",
prjfileName_New = "EAG_21_1.prj",
model_name = "model_21_1e",
Ass_year = 2021
)
WAG <- list(
datfileName_New = "WAG_21_1.dat",
ctlfileName_New = "WAG_21_1.ctl",
prjfileName_New = "WAG_21_1.prj",
model_name = "model_21_1e",
Ass_year = 2021
)
SNOW_crab <- list(
datfileName_New = "snow_21.dat",
ctlfileName_New = "snow_21.ctl",
prjfileName_New = "snow_21.prj",
model_name = "model_21_g",
Ass_year = 2021
)
BBRKC <- list(
datfileName_New = "bbrkc_21_1.dat",
ctlfileName_New = "bbrkc_21_1.ctl",
prjfileName_New = "bbrkc_21_1.prj",
model_name = "model_21_1",
Ass_year = 2021
)
SMBKC <- list(
datfileName_New = "sm_22.dat",
ctlfileName_New = "sm_22.ctl",
prjfileName_New = "sm_22.prj",
model_name = "model_16_0",
Ass_year = 2021
)
# Make a list of these stock-specific lists
Stock_models <- list(
EAG = EAG,
WAG = WAG,
SNOW_crab = SNOW_crab,
BBRKC = BBRKC,
SMBKC = SMBKC
)
write_Gmacs_InputFiles(
stock = c("EAG", "WAG", "SMBKC", "BBRKC"),
Stock_NameFiles = Stock_models,
verbose = FALSE,
dir_WriteFiles = NULL,
CatchDF_format = NULL,
SurveyDF_format = NULL,
SizeFreqDF_format = NULL,
cleanup = TRUE,
dir_TPL = NULL,
Gmacs_Version = "2.01.M.10",
dir_InputFiles = dir_InputFiles
)
}