R/flukeOM.R

Defines functions flukeOM

# This script contains the operating model function: flukeOM

# TO DO:
  # search for ??? outstanding comments/issues

#' @title Generate operating model data
#'
#' @description
#'
#'
#' @param Catch A vector of catches for each of 3 fleets in the order: recreational catch, recreational discards, combined commercial catch & discards, no default.
#' @param N_abund A vector of abundance at age at the start of the year (t), no default.
#' @param meanR The mean historic recruitment which is constant in each simulation and is not updated by the operating model
#' @param R_devs A vector of historic recruitment deviations which are updated by the operating model throughout each simulation
# #' @param PopLat A vector of latitudes for historic centers of gravity for the population(1993-2017 to match with MRIP data used in fishermenresponse.R)
# #' # ??? may be missing parameters for thermalhabitat() # update after ICES ???
#'
#' @return A list containing the following:
#' Operating model biomass for year t,
#' Operating model biomass at age 0-7+ for year t
#' Operating model projected abundance for age 0-7+ in year t+1
#' Updated vector of operating model recruitment deviations
#' Operating model projected recruitment in year t+1
#' Survey total biomass in year t
#' Survey observation error in year t
#'
# #' Proportion for habitat availability by state
#'
#' @family operating model functions
#'
#' @examples
#'

flukeOM <- function(Catch = NULL,
                    N_abund = NULL,
                    meanR = NULL,
                    R_devs = NULL,
                    PopLat = NULL){

  # Generate biomass, abundance, recruitment projections to year t+1
  OMstock <- truestocksize(Catch = Catch,
                              N_abund = N_abund,
                              meanR = meanR,
                              OMR_dev = R_devs[length(R_devs)])

  # Generate survey biomass in year t
  OMsurvey <- dosurveys(N_abund = N_abund)

  #
  # # Calculate thermal habitat availability and OM biomass availability by state
  # # habitatOutput <- thermalhabitat() # ??? needs updating after ICES,
  # # for now the following placeholder generates a new population center of gravity based on a 0.9km/yr mvmt rate north (Peretti & Thorson 2019) see also Data_Formatting.R for timeseries ???
  # UpdatePopLat <- c(PopLatitude, PopLatitude[length(PopLatitude)] + 0.9)
  #
  #
  return(list(OM_Biomass = OMstock$OM_Bio, # Operating model total biomass for year t
              OM_Biomass_at_age = OMstock$bio_at_age, # Operating model biomass at age 0-7+ for year t ??? this isn't required for calculations but may be useful if some policies (e.g. min size) impact specific age classes more than others
              OM_Abundance = OMstock$OM_Nabundproj, # Operating model abundance at age 0-7+ projection for year t+1
              OM_Rdevs = c(R_devs, OMstock$OM_Rdevproj), # Updated vector of operating model recruitment deviations (input with newly calculated deviation for most recent year appended)
              OM_Rupdate = OMstock$OM_Rproj, # Operating model projected recruitment in year t+1
              OM_Survey = OMsurvey$OM_Survey, # Survey biomass in year t
              OM_SurveyError = OMsurvey$OM_surveyError, # Observation error of survey biomass in year t
  #             OM_PopLat = UpdatePopLat))
  #             # HabitatAvailable = habitatOutput$thermalhabitat)) # after ICES update this ???
}
ahart1-r-packages/flukeclimatemse documentation built on Oct. 6, 2020, 2:48 a.m.