nefsc.Rmd
# Get rid of memory limits -----------------------------------------------------
options(future.globals.maxSize = 1 * 1024^4) # Allow up to 1 TB for globals
# Install Libraries ------------------------------------------------------------
# Here we list all the packages we will need for this whole process
# We'll also use this in our works cited page.
PKG <- c(
"surveyresamplr",
"dplyr",
"tidyr",
"purrr",
"ggplot2",
"future.callr",
"flextable",
"sdmTMB"
)
pkg_install <- function(p) {
if (!require(p, character.only = TRUE)) {
install.packages(p)
}
require(p, character.only = TRUE)
}
base::lapply(unique(PKG), pkg_install)
### Define study species -------------------------------------------------------
spp_list <-
data.frame(
srvy = "NWA_SPRING",
common_name = c(
"Atlantic herring", "black sea bass", "Atlantic cod",
"American lobster", "longfin squid", "mackerel",
"monkfish", "red hake", "scup",
"sea scallop", "silver hake", "summer flounder",
"winter flounder"
),
file_name0 = c(
"AtlanticHerring", "BlackSeaBass", "Cod",
"Lobster", "LongfinSquid", "Mackerel",
"Monkfish", "RedHake", "Scup",
"SeaScallop", "SilverHake", "SummerFlounder",
"WinterFlounder"
),
filter_lat_lt = NA,
filter_lat_gt = NA,
filter_depth = NA,
model_fn = "total_catch_wt_kg ~ 0 + factor(year)",
model_family = "delta_gamma",
model_anisotropy = TRUE,
model_spatiotemporal = "iid, iid"
) |>
dplyr::mutate(
file_name = gsub(pattern = " ", replacement = "_", x = (tolower(common_name)))
)
spp_list <- spp_list[1:3, ]
### Load grid data -------------------------------------------------------------
grid_yrs <- replicate_df(surveyresamplr::noaa_nefsc_pred_grid_depth, "year", unique(catch$year))
### Variables ------------------------------------------------------------------
seq_from <- 0.2
seq_to <- 1.0
seq_by <- 0.2
tot_dataframes <- 13
replicate_num <- 3
# Set directories --------------------------------------------------------------
wd <- paste0(here::here(), "/vignettes/")
dir_out <- paste0(wd, "output/")
dir_final <- paste0(dir_out, "NWA_SPRING_0results/")
### Load survey data -----------------------------------------------------------
catch <- surveyresamplr::noaa_nefsc_catch |> dplyr::filter(srvy == "FALL")
### Variables ------------------------------------------------------------------
srvy <- "NWA_SPRING"
### Run ------------------------------------------------------------------------
purrr::map(
1:nrow(spp_list),
~ clean_and_resample(spp_list[.x, ],
catch, seq_from, seq_to, seq_by,
tot_dataframes, replicate_num, grid_yrs, dir_out,
test = TRUE
)
)
### Plot indices --------------------------------------------------------------
out <- plot_results(srvy = srvy, dir_out = dir_out, dir_final = dir_final)
out$plotsParameter output:
# Set directories --------------------------------------------------------------
wd <- paste0(here::here(), "/vignettes/")
dir_out <- paste0(wd, "output/")
dir_final <- paste0(dir_out, "NWA_FALL_0results/")
### Load survey data -----------------------------------------------------------
catch <- surveyresamplr::noaa_nefsc_catch %>% dplyr::filter(srvy == "FALL") # pulled data again to get 2024
### Variables ------------------------------------------------------------------
srvy <- "NWA_FALL"
### Run ------------------------------------------------------------------------
purrr::map(
1:nrow(spp_list),
~ clean_and_resample(spp_list[.x, ],
catch, seq_from, seq_to, seq_by,
tot_dataframes, replicate_num, grid_yrs, dir_out,
test = TRUE
)
)
### Plot indices --------------------------------------------------------------
out <- plot_results(srvy = srvy, dir_out = dir_out, dir_final = dir_final)
out$plotsParameter output: