diff --git a/DESCRIPTION b/DESCRIPTION index 55096df..f54b77d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,7 +40,7 @@ Remotes: cran/assertive.types@master, r4ss/r4ss@main, ss3sim/ss3sim@main +Config/roxygen2/version: 8.0.0 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -Config/roxygen2/version: 8.0.0 diff --git a/NAMESPACE b/NAMESPACE index ba45aae..c5dad6d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -31,6 +31,7 @@ importFrom(r4ss,SS_writedat) importFrom(r4ss,SS_writeforecast) importFrom(r4ss,SS_writestarter) importFrom(ss3sim,get_results_all) +importFrom(ss3sim,get_results_iter) importFrom(ss3sim,get_results_scenario) importFrom(stats,na.omit) importFrom(tidyr,gather) diff --git a/R/MS_functions.R b/R/MS_functions.R index 411bc5c..8f5a216 100644 --- a/R/MS_functions.R +++ b/R/MS_functions.R @@ -484,7 +484,7 @@ get_no_EM_catch_df <- function(OM_dir, yrs, MS = "last_yr_catch") { # TODO: figure out what values should go here; probably not 0. Fcast_rec_line <- grep("^# Fcast_recruitments:$", par) + 1 par[Fcast_rec_line] <- paste0(rep(0, fore[["Nforecastyrs"]]), collapse = " ") - # # Forecast implementation error parameters were included in earlier SS3 version + # # Forecast implementation error parameters were included in earlier SS3 version # # whether specified by the user or not. These changes are not needed in 3.30.24. # Fcast_impl_err_line <- grep("^# Fcast_impl_error:$", par) + 1 # par[Fcast_impl_err_line] <- paste0(rep(0, fore[["Nforecastyrs"]]), collapse = " ") @@ -622,7 +622,7 @@ Interim <- function(EM_out_dir = NULL, EM_init_dir = NULL, temp_forecast[, 1] <- (Reference_dat[["endyr"]] + 1 - forecast_adjust):(Reference_dat[["endyr"]] + Reference_forecast[["Nforecastyrs"]]) colnames(temp_forecast) <- c("year", "recdev") Reference_par[["recdev_forecast"]] <- as.data.frame(temp_forecast) - # # Forecast implementation error parameters were included in earlier SS3 version + # # Forecast implementation error parameters were included in earlier SS3 version # # whether specified by the user or not. These changes are not needed in 3.30.24. # temp_impl_error <- matrix(0, nrow = (Reference_forecast[["Nforecastyrs"]]), ncol = 2) # temp_impl_error[, 1] <- (Reference_dat[["endyr"]] + 1):(Reference_dat[["endyr"]] + Reference_forecast[["Nforecastyrs"]]) @@ -839,7 +839,6 @@ Interim <- function(EM_out_dir = NULL, EM_init_dir = NULL, ) - if (!is.null(sample_struct)) { sample_struct_sub <- lapply(sample_struct, function(df, y) df[df[, 1] %in% y, ], diff --git a/R/develop_OMs.R b/R/develop_OMs.R index 98a9190..74a4055 100644 --- a/R/develop_OMs.R +++ b/R/develop_OMs.R @@ -170,7 +170,8 @@ develop_OMs <- function( } else { recdev_name <- "recdev2" } - new_parfile[[recdev_name]][, "recdev"] <- parfile[[recdev_name]][, + new_parfile[[recdev_name]][, "recdev"] <- parfile[[recdev_name]][ + , "recdev" ] diff --git a/R/develtools.R b/R/develtools.R index e48f6a1..1391e6f 100644 --- a/R/develtools.R +++ b/R/develtools.R @@ -79,7 +79,7 @@ test_no_par <- function(orig_mod_dir, new_mod_dir) { } #' function for package developers to update SS3 input files -#' +#' #' @param dir_models directory containing the model input files update_ss3_version <- function(dir_models = "inst/extdata/models") { @@ -88,7 +88,7 @@ update_ss3_version <- function(dir_models = "inst/extdata/models") { # get current executable dir_exe <- r4ss::get_ss3_exe(dir = tempdir()) - + # run with current SS3 version without estimation for (i in 1:length(models)) { r4ss::run( diff --git a/R/initOM.R b/R/initOM.R index 7e35003..a592714 100644 --- a/R/initOM.R +++ b/R/initOM.R @@ -243,7 +243,6 @@ create_OM <- function(OM_out_dir, dat[["catch"]] <- new_catch - default_F <- F_list[["F_rate"]][F_list[["F_rate"]][, "year"] == dat[["endyr"]], c("year", "seas", "fleet", "F")] new_F_rate <- rbind(F_list[["F_rate"]][, c("year", "seas", "fleet", "F")], F_list[["F_rate_fcast"]][, c("year", "seas", "fleet", "F")]) rownames(new_F_rate) <- c(F_list[["F_rate"]][, c("name")], F_list[["F_rate_fcast"]][, c("name")]) diff --git a/R/single_extend_OM.R b/R/single_extend_OM.R index 2a7ed26..f4032e2 100644 --- a/R/single_extend_OM.R +++ b/R/single_extend_OM.R @@ -374,8 +374,7 @@ add_OM_devs <- function(ctl, dat, parlist, timeseries, future_om_dat) { stop("Something is wrong, the number of temp selection parameters is not correct. This is likely a code bug not user error :(") } - if ((tv_size_length + tv_age_length + tv_age_length) == 0) { - } else if (!is.null(ctl[["dirichlet_parms"]])) { + if ((tv_size_length + tv_age_length + tv_age_length) == 0) {} else if (!is.null(ctl[["dirichlet_parms"]])) { insert_row <- which(names(ctl) == "dirichlet_parms") } else if (!is.null(ctl[["age_selex_parms"]])) { insert_row <- which(names(ctl) == "age_selex_parms") diff --git a/R/utils.R b/R/utils.R index bc327c6..d730a83 100644 --- a/R/utils.R +++ b/R/utils.R @@ -226,8 +226,6 @@ clean_init_mod_files <- function(OM_out_dir, EM_out_dir = NULL, MS = "EM", endyr <- OM_dat[["endyr"]] - - # get years in range function get_yrs_in_range <- function(list_name, dat, styr, endyr) { df <- dat[[list_name]] diff --git a/man/get_F.Rd b/man/get_F.Rd index f4d494a..c259b6d 100644 --- a/man/get_F.Rd +++ b/man/get_F.Rd @@ -19,7 +19,7 @@ function know which order the fleets appear in the model.} \value{ a list containing: F_df, a long dataframe with F by year, Era, Seas, and fleet; F_rate, a data frame with F for the time frame of the model -only by year, Seas, and fleet, ordered as the ss.par file expects; init_F, +only by year, Seas, and fleet, ordered as the ss3.par file expects; init_F, a named vector of initial F values by Season and fleet, ordered (and named) as SS expects; and F_rate_fcast, a dataframe of forecasted F by year, Seas, and fleet, ordered as SS would expect in F_rate. diff --git a/man/get_data_file.Rd b/man/get_data_file.Rd new file mode 100644 index 0000000..cf322c6 --- /dev/null +++ b/man/get_data_file.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{get_data_file} +\alias{get_data_file} +\title{Locate the SS3 data file(s) associated with a model run.} +\usage{ +get_data_file(dir, file_type = c("all", "input", "expected", "bootstrap")) +} +\arguments{ +\item{dir}{Directory containing the SS3 model files.} + +\item{file_type}{Which type of output file to look for. Supported values +are \code{all}, \code{input}, \code{expected}, and \code{bootstrap}.} +} +\value{ +The first matching data file name in the requested priority order, +or \code{NULL} if no matching file is present. +} +\description{ +The helper recognizes both legacy and current output layouts, including +\code{data.ss_new}, \code{data_echo.ss_new}, \code{data_expval.ss}, and \code{data_boot_001.ss}. +} diff --git a/man/get_ss_par_file.Rd b/man/get_ss_par_file.Rd new file mode 100644 index 0000000..bbfc757 --- /dev/null +++ b/man/get_ss_par_file.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{get_ss_par_file} +\alias{get_ss_par_file} +\title{Locate the SS3 parameter file used by a model run.} +\usage{ +get_ss_par_file(dir) +} +\arguments{ +\item{dir}{Directory containing the SS3 model files.} +} +\value{ +A character string giving the full path to the parameter file. +} +\description{ +This helper prefers the current \code{ss3.par} filename when present and falls +back to the legacy \code{ss.par} name for older model directories. +} diff --git a/man/run_OM.Rd b/man/run_OM.Rd index e0e78ed..21ebffe 100644 --- a/man/run_OM.Rd +++ b/man/run_OM.Rd @@ -33,7 +33,7 @@ SS_readdat is equivalent to specifying nboot = 1.} \item{debug_par_run}{If set to TRUE, and the run fails, a new folder called error_check will be created, and the model will be run from control start -values instead of ss.par. The 2 par files are then compared to help debug +values instead of ss3.par. The 2 par files are then compared to help debug the issue with the model run. Defaults to TRUE.} \item{sample_catch}{Should catch be sampled or fixed at the OM values? diff --git a/tests/testthat/test-future_om.R b/tests/testthat/test-future_om.R index c1c9f1e..cd66a86 100644 --- a/tests/testthat/test-future_om.R +++ b/tests/testthat/test-future_om.R @@ -678,7 +678,6 @@ test_that("Tests a model with env link using historical values", { }) - test_that("Setting seeds works as intended", { # check replicate option works ext_files <- system.file(package = "SSMSE")