R/makeDATRAS.R

Defines functions makeDATRAS

Documented in makeDATRAS

#' @title makeDATRAS
#' @description This function generates ICES DATRAS-compatible HH for a particular DFO region.
#' @param region default is \code{NULL}. This is the Canadian DFO region for which you want to
#' make the DATRAS files.  Valid regions are listed below, but initially, only "Mar" works (Jan, 2020)
#' \itemize{
#' \item \code{Mar}
#' \item \code{NFLD}
#' \item \code{Gulf}
#' \item \code{Que}
#' \item \code{Cen}
#' \item \code{Pac}
#' }
#' @param yr default is \code{NULL}. This specifies the year(s) for which you'd like to generate
#' HH files. Single years are fine, as are vectors (e.g. \code{c(2011,1015)}, \code{2015:2019})
#' @param survey default is \code{NULL}. This specifies the survey for which you'd like to generate
#' HH files.  This will be specific to the different regions.  Valid values for Maritimes are
#' \itemize{
#' \item \code{4X} - Type 1; Spring (i.e. months 1:4); 2008+; not strata 5Z* 
#' \item \code{GEORGES} - Type 1; Spring (i.e. months 1:4);  2008+; strata 5Z*
#' \item \code{SPRING} - Type 1; Spring (i.e. months 1:4); pre-2008; specific strata 
#' \item \code{4VSW}  - Type 1; Spring (i.e. months 1:4); 4VSW strata;  
#' \item \code{SUMMER} - Type 1; Summer (i.e. months 5:8); specific strata
#' \item \code{FALL} - Type 1; Fall (i.e. months 9:12)
#' }
#' @param csv default is \code{TRUE}.  If \code{TRUE}, csv files are generated for each HH code.
#' If \code{FALSE}, the output exists only in the resultant list.
#' @param cxn A valid Oracle connection object. This parameter allows you to 
#' pass an existing connection, reducing the need to establish a new connection 
#' within the function. If provided, it takes precedence over the connection-
#' related parameters.
#' @param data.dir  The default is \code{NULL}. Required for Maritimes HH files. This is the path
#' to your Mar.datawrangling rdata files
#' @param debug  The default is \code{F}. Setting this to TRUE will limit the 
#' results to a single set for a single species. 
#' @return a list containing (named) objects - 1 for each generated HH file
#' @family DATRAS
#' @author Mike McMahon, \email{Mike.McMahon@@dfo-mpo.gc.ca}
#' @export
#'
makeDATRAS<-function(region = NULL, yr=NULL, survey = NULL, csv=T,
                 cxn = NULL,
                 data.dir = NULL,
                 debug =F){
region <- toupper(region)
survey <- toupper(survey)
good <- c("NFLD", "MAR", "GULF","QUE", "CEN", "PAC")
if (!region %in% good)stop("Please provide a valid region")

switch(region,
       "NFLD" = NFLD_DATRAS(yr=yr, survey=survey,  csv=csv, debug = debug),
       "MAR" = Mar_DATRAS(yr=yr, survey=survey,  csv=csv,
                            cxn = cxn,
                            data.dir = data.dir,
                            usepkg = usepkg,
                            debug = debug),
       "GULF" = Gulf_DATRAS(yr=yr, survey=survey,  csv=csv, debug = debug),
       "QUE" = Que_DATRAS(yr=yr, survey=survey,  csv=csv, debug = debug),
       "CEN" = Cen_DATRAS(yr=yr, survey=survey,  csv=csv, debug = debug),
       "PAC" = Pac_DATRAS(yr=yr, survey=survey,  csv=csv, debug = debug)
       )
}
Maritimes/CanaDatras documentation built on April 5, 2025, 5:58 p.m.