diff --git a/DESCRIPTION b/DESCRIPTION index 9384207..10b2b54 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: nwfscDiag Type: Package Title: Generate standard NWFSC assessment diagnostics -Version: 2.0 +Version: 1.1.0 Author: Chantel Wetzel Maintainer: Chantel Wetzel Description: Package that can automates diagnositics for SS3 models by running jitters, retrospective, and profiles. diff --git a/R/get_settings.R b/R/get_settings.R index f0af39a..2d3482a 100644 --- a/R/get_settings.R +++ b/R/get_settings.R @@ -27,13 +27,13 @@ get_settings <- function(settings = NULL, verbose = FALSE) { profile_details = NULL, version = "3.30", exe = "ss", + verbose = FALSE, # Jitter Settings extras = "-nohess", Njitter = 100, show_in_console = TRUE, printlikes = FALSE, - verbose = FALSE, jitter_fraction = 0.05, jitter_init_values_src = NULL, @@ -59,8 +59,6 @@ get_settings <- function(settings = NULL, verbose = FALSE) { whichruns = NULL, prior_check = FALSE, read_like = TRUE, - exe = "ss", - verbose = TRUE, init_values_src = 0 ) diff --git a/R/profile_wrapper.R b/R/profile_wrapper.R index 907ad95..1a43d6b 100644 --- a/R/profile_wrapper.R +++ b/R/profile_wrapper.R @@ -25,10 +25,6 @@ profile_wrapper <- function(mydir, model_settings){ # plyr and dplyr. round_any <- function(x, accuracy, f = round){ f(x / accuracy) * accuracy} - - OS <- "Mac" # don't know the version$os info for Mac - if(length(grep("linux", version$os)) > 0) OS <- "Linux" - if(length(grep("mingw", version$os)) > 0) OS <- "Windows" # figure out name of executable based on 'exe' input which may contain .exe if(length(grep(".exe", tolower(file.path(mydir, model_settings$base_name)))) == 1) { @@ -39,12 +35,8 @@ profile_wrapper <- function(mydir, model_settings){ exe <- paste(model_settings$exe, ifelse(OS == "Windows", ".exe", ""), sep="") } # check whether exe is in directory - if(OS == "Windows") { - if(!exe %in% list.files(file.path(mydir, model_settings$base_name))) - stop("Executable ", exe, " not found in ", file.path(mydir, model_settings$base_name)) - } else { - if(!exe %in% list.files(file.path(mydir, model_settings$base_name))) - stop("Executable ", exe, " not found in ", file.path(mydir, model_settings$base_name)) + if(!exe %in% list.files(file.path(mydir, model_settings$base_name))) { + stop("Executable ", exe, " not found in ", file.path(mydir, model_settings$base_name)) } N <- nrow(model_settings$profile_details) @@ -73,17 +65,9 @@ profile_wrapper <- function(mydir, model_settings){ if (!file.exists(file.path(profile_dir, "control.ss_new"))) { orig_dir <- getwd() setwd(profile_dir) - command <- paste(model_settings$model, model_settings$extras) - if(OS != "windows") { - command <- paste( "./", command, sep="") - } - cat("Running model in directory:", getwd(), "\n") - cat("Using the command: '", command, "'\n", sep="") - if(OS == "windows" & !model_settings$systemcmd){ - shell(cmd = command) - } else { - system(command) - } + r4ss::run(dir = profile_dir, + exe = model_settings$exe, + extras = model_settings$extras) setwd(orig_dir) } diff --git a/R/retro_wrapper.R b/R/retro_wrapper.R index 9bde71e..34bc1cd 100644 --- a/R/retro_wrapper.R +++ b/R/retro_wrapper.R @@ -62,7 +62,6 @@ retro_wrapper <- function(mydir, model_settings) { dir = retro_dir, oldsubdir = model_settings$oldsubdir, newsubdir = model_settings$newsubdir, - subdirstart = "retro", years = model_settings$retro_yrs, overwrite = model_settings$overwrite, exe = model_settings$exe, diff --git a/R/run_diagnostics.R b/R/run_diagnostics.R index ee08917..5bb23d2 100644 --- a/R/run_diagnostics.R +++ b/R/run_diagnostics.R @@ -15,24 +15,14 @@ run_diagnostics <- function(mydir, model_settings ){ # Check for Report file model_dir <- file.path(mydir, paste0(model_settings$base_name)) - OS <- "Mac" # don't know the version$os info for Mac - if(length(grep("linux", version$os)) > 0) OS <- "Linux" - if(length(grep("mingw", version$os)) > 0) OS <- "Windows" if (!file.exists(file.path(model_dir, "Report.sso"))) { orig_dir <- getwd() setwd(model_dir) - command <- paste(model_settings$exe, model_settings$extras) - if(OS != "windows") { - command <- paste( "./", command, sep="") - } cat("Running model in directory:", getwd(), "\n") - cat("Using the command: '", command, "'\n", sep="") - if(OS == "windows" & !model_settings$systemcmd){ - shell(cmd = command) - } else { - system(command) - } + run(dir = model_dir, + exe = model_settings$exe, + extras = model_settings$extras) setwd(orig_dir) }