Skip to content

Commit

Permalink
new functions and revisions for reading input files from Neil Klaer
Browse files Browse the repository at this point in the history
relates to issue #138 and #140, also incrementing package to 1.31.0
  • Loading branch information
iantaylor-NOAA committed May 9, 2018
1 parent c3109fd commit adeba65
Show file tree
Hide file tree
Showing 17 changed files with 2,892 additions and 191 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,14 +1,14 @@
Package: r4ss
Type: Package
Title: R Code for Stock Synthesis
Version: 1.30.2
Date: 2018-03-08
Version: 1.31.0
Date: 2018-05-09
Author: Ian G. Taylor, Ian J. Stewart, Allan C. Hicks, Tommy M. Garrison,
Andre E. Punt, John R. Wallace, Chantel R. Wetzel, James T. Thorson,
Yukio Takeuchi, Kotaro Ono, Cole C. Monnahan, Christine C. Stawitz,
Z. Teresa A'mar, Athol R. Whitten, Kelli F. Johnson, Robbie L. Emmet,
Sean C. Anderson, Gwladys I. Lambert, Megan M. Stachura,
Andrew B. Cooper, Andi Stephens, Neil Klaer, and Carey R. McGilliard
Andrew B. Cooper, Andi Stephens, Neil L. Klaer, and Carey R. McGilliard
Maintainer: Ian G. Taylor <Ian.Taylor@noaa.gov>
Depends:
R (>= 2.10.0)
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Expand Up @@ -19,7 +19,10 @@ export(SS_profile)
export(SS_read_summary)
export(SS_readctl)
export(SS_readctl_3.24)
export(SS_readctl_3.30)
export(SS_readdat)
export(SS_readdat_2.00)
export(SS_readdat_3.00)
export(SS_readdat_3.24)
export(SS_readdat_3.30)
export(SS_readforecast)
Expand Down
73 changes: 58 additions & 15 deletions R/SS_readctl.R
@@ -1,11 +1,11 @@
#' read control file from SS
#'
#'
#' Read Stock Synthesis control file into list object in R. This function is a
#' wrapper which calls either SS_readctl_3.24 or SS_readctl_3.30 (not yet written).
#' This setup allows those functions to be cleaner (if somewhat redundant)
#' than a single function that attempts to do everything.
#'
#'
#'
#'
#' @param file Filename either with full path or relative to working directory.
#' @param version SS version number. Currently only "3.24" or "3.30" are supported,
#' either as character or numeric values (noting that numeric 3.30 = 3.3).
Expand All @@ -21,21 +21,24 @@
#' explicitly available in control file
#' @param Ngenders number of genders in the model. This information is also not
#' explicitly available in control file
#' @param Npopbins number of population bins in the model. This information is also not
#' explicitly available in control file and this information is only required if length based
#' @param Npopbins number of population bins in the model. This information is
#' also not explicitly available in control file and this information is only
#' required if length based
#' maturity vector is directly supplied (Maturity option of 6), and not yet tested
#' @param Nfleet number of fisheries in the model. This information is also not
#' explicitly available in control file
#' @param Nsurveys number of survey fleets in the model. This information is also not
#' explicitly available in control file
#' @param N_tag_groups number of tag release groups in the model. This information is also not
#' explicitly available in control file
#' @author Ian G. Taylor, Yukio Takeuchi
#' @param DatFile read datfile list for additional information for version 3.30
#' and above
#' @param N_tag_groups number of tag release groups in the model.
#' This information is also not explicitly available in control file
#' @author Ian G. Taylor, Yukio Takeuchi, Neil L Klaer
#' @export
#' @seealso \code{\link{SS_readctl_3.24}}, \code{\link{SS_readdat}},
#' \code{\link{SS_readdat_3.24}}

SS_readctl <- function(file, version="3.24", verbose=TRUE,echoall=FALSE,
SS_readctl <- function(file, ctlversion="3.24", verbose=TRUE,echoall=FALSE,
## Parameters that are not defined in control file
nseas=4,
N_areas=1,
Expand All @@ -44,16 +47,39 @@ SS_readctl <- function(file, version="3.24", verbose=TRUE,echoall=FALSE,
Npopbins=NA,
Nfleet=2,
Nsurveys=2,
N_tag_groups=NA){
DatFile=NA,
N_tag_groups=NA,
N_CPUE_obs=NA){

# wrapper function to call old or new version of SS_readctl

# automatic testing of version number could be added here in the future
# see SS_readdat for example attempt


nver=as.numeric(substring(ctlversion,1,4))

if(verbose) cat("Char version is ", ctlversion, "\n")
if(verbose) cat("Numeric version is ", nver, "\n")

# call function for SS version 2.00
if(nver<3){

stop("Function SS_readctl_2.00 has not been written yet")

}

# call function for SS version 3.00
if((nver>=3)&&(nver<3.2)){

stop("Function SS_readctl_3.00 has not been written yet")

}

# call function for SS version 3.24
if(version=="3.24"){ # should work whether "version" is character or numeric
if((nver>=3.2)&&(nver<3.3)){

ctllist <- SS_readctl_3.24(file = file,
ctlversion = ctlversion,
verbose = verbose,
echoall = echoall,
nseas = nseas,
Expand All @@ -63,12 +89,29 @@ SS_readctl <- function(file, version="3.24", verbose=TRUE,echoall=FALSE,
Npopbins = Npopbins,
Nfleet = Nfleet,
Nsurveys = Nsurveys,
N_tag_groups = N_tag_groups)
N_tag_groups = N_tag_groups,
N_CPUE_obs = N_CPUE_obs)

}

# call function for SS version 3.30
if(version=="3.30" | version==3.3){ # turns out 3.30 != "3.30" in R
stop("Function SS_readctl_3.30 has not been written yet")
if(nver>=3.3){

ctllist <- SS_readctl_3.30(file = file,
ctlversion = ctlversion,
verbose = verbose,
echoall = echoall,
nseas = nseas,
N_areas = N_areas,
Nages = Nages,
Ngenders = Ngenders,
Npopbins = Npopbins,
Nfleet = Nfleet,
Nsurveys = Nsurveys,
DatFile = DatFile,
N_tag_groups = N_tag_groups,
N_CPUE_obs = N_CPUE_obs)

}

# return the result
Expand Down

0 comments on commit adeba65

Please sign in to comment.