From afed72279cb1a922fd7a4f44f13b9d867ad4d9e1 Mon Sep 17 00:00:00 2001 From: Ian Taylor <4992918+iantaylor-NOAA@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:09:07 -0700 Subject: [PATCH 1/2] add boundaries argument to run_sdmtmb() - move Roxygen description to template and - run devtools::document() which modified sanity_data.Rd --- R/calc_index_areas.R | 10 +--------- R/run_sdmtmb.R | 5 ++++- man-roxygen/boundaries.R | 9 +++++++++ man/run_sdmtmb.Rd | 26 +++++++++++++++++++++++--- man/sanity_data.Rd | 2 +- 5 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 man-roxygen/boundaries.R diff --git a/R/calc_index_areas.R b/R/calc_index_areas.R index 4613493..b09cd2e 100644 --- a/R/calc_index_areas.R +++ b/R/calc_index_areas.R @@ -14,15 +14,7 @@ #' #' @inheritParams format_data #' @inheritParams diagnose -#' @param boundaries A named list of northern and southern boundaries for a -#' set of areas. The list can contain as many areas as you would like but -#' it must contain at least one area and each area must be a vector of two -#' real numbers specified in decimal degrees. The order of the areas only -#' matters if you care what order they are plotted because the names will -#' be turned into factors. The default value uses a data object called -#' `boundaries_data`, which is a list of several areas along the U.S. West -#' Coast, including a coastwide area going from the northern Washington -#' border to the southern California border. +#' @template boundaries #' @export #' @author Kelli F. Johnson #' @seealso diff --git a/R/run_sdmtmb.R b/R/run_sdmtmb.R index a0ad417..b71448f 100644 --- a/R/run_sdmtmb.R +++ b/R/run_sdmtmb.R @@ -8,6 +8,7 @@ #' mesh that is created by {INLA}. More knots is not always better. The #' default is to use 500 knots. Future work will look at specifying a #' threshold distance between points rather than number of knots. +#' @template boundaries #' @param ... Optional arguments passed to [sdmTMB::sdmTMB()]. Note that users #' cannot pass `anisotropy` or `sdmTMBcontrol` because both of these are set #' internal to this function, where `anisotropy = TRUE` because the coastline @@ -24,6 +25,7 @@ run_sdmtmb <- function(dir_main = getwd(), family, formula, n_knots = 500, + boundaries = boundaries_data["Coastwide"], ...) { # Checks stopifnot(inherits(family, "family")) @@ -141,7 +143,8 @@ run_sdmtmb <- function(dir_main = getwd(), data = data_truncated, fit = fit, prediction_grid = grid, - dir = dir_index + dir = dir_index, + boundaries = boundaries ) # Add diagnostics diff --git a/man-roxygen/boundaries.R b/man-roxygen/boundaries.R new file mode 100644 index 0000000..e5c0ba5 --- /dev/null +++ b/man-roxygen/boundaries.R @@ -0,0 +1,9 @@ +#' @param boundaries A named list of northern and southern boundaries for a +#' set of areas. The list can contain as many areas as you would like but +#' it must contain at least one area and each area must be a vector of two +#' real numbers specified in decimal degrees. The order of the areas only +#' matters if you care what order they are plotted because the names will +#' be turned into factors. The default value uses a data object called +#' `boundaries_data`, which is a list of several areas along the U.S. West +#' Coast, including a coastwide area going from the northern Washington +#' border to the southern California border. diff --git a/man/run_sdmtmb.Rd b/man/run_sdmtmb.Rd index f0c748e..ea4c4b6 100644 --- a/man/run_sdmtmb.Rd +++ b/man/run_sdmtmb.Rd @@ -4,7 +4,15 @@ \alias{run_sdmtmb} \title{Run \code{\link[sdmTMB:sdmTMB]{sdmTMB::sdmTMB()}}} \usage{ -run_sdmtmb(dir_main = getwd(), data, family, formula, n_knots = 500, ...) +run_sdmtmb( + dir_main = getwd(), + data, + family, + formula, + n_knots = 500, + boundaries = boundaries_data["Coastwide"], + ... +) } \arguments{ \item{dir_main}{A string specifying a path where results will be saved. The @@ -22,8 +30,10 @@ and effort. Additional columns can be present such as depth.} \code{\link[sdmTMB:families]{censored_poisson()}}, \code{\link[sdmTMB:families]{gamma_mix()}}, \code{\link[sdmTMB:families]{lognormal_mix()}}, -\code{\link[sdmTMB:families]{student()}}, and -\code{\link[sdmTMB:families]{tweedie()}}. Supports the delta/hurdle models: +\code{\link[sdmTMB:families]{student()}}, +\code{\link[sdmTMB:families]{tweedie()}}, and +\code{\link[sdmTMB:families]{gengamma()}}. +Supports the delta/hurdle models: \code{\link[sdmTMB:families]{delta_beta()}}, \code{\link[sdmTMB:families]{delta_gamma()}}, \code{\link[sdmTMB:families]{delta_gamma_mix()}}, @@ -44,6 +54,16 @@ mesh that is created by {INLA}. More knots is not always better. The default is to use 500 knots. Future work will look at specifying a threshold distance between points rather than number of knots.} +\item{boundaries}{A named list of northern and southern boundaries for a +set of areas. The list can contain as many areas as you would like but +it must contain at least one area and each area must be a vector of two +real numbers specified in decimal degrees. The order of the areas only +matters if you care what order they are plotted because the names will +be turned into factors. The default value uses a data object called +\code{boundaries_data}, which is a list of several areas along the U.S. West +Coast, including a coastwide area going from the northern Washington +border to the southern California border.} + \item{...}{Optional arguments passed to \code{\link[sdmTMB:sdmTMB]{sdmTMB::sdmTMB()}}. Note that users cannot pass \code{anisotropy} or \code{sdmTMBcontrol} because both of these are set internal to this function, where \code{anisotropy = TRUE} because the coastline diff --git a/man/sanity_data.Rd b/man/sanity_data.Rd index 81f15c9..5cac4d0 100644 --- a/man/sanity_data.Rd +++ b/man/sanity_data.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sanity_data.r +% Please edit documentation in R/sanity_data.R \name{sanity_data} \alias{sanity_data} \title{Creates a data frame of information from \code{\link[sdmTMB:sanity]{sdmTMB::sanity()}}} From 646e277b9346cd3e4202324c809e15bb6b9f9e87 Mon Sep 17 00:00:00 2001 From: Ian Taylor <4992918+iantaylor-NOAA@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:10:17 -0700 Subject: [PATCH 2/2] add "North of 46deg 53.3min" to boundaries_data --- data-raw/boundaries_data.R | 5 ++++- data/boundaries_data.rda | Bin 282 -> 338 bytes 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/data-raw/boundaries_data.R b/data-raw/boundaries_data.R index c95c1e9..1208f1c 100644 --- a/data-raw/boundaries_data.R +++ b/data-raw/boundaries_data.R @@ -11,7 +11,10 @@ boundaries_data <- list( "South of Cape Mendocino" = c(40.166667, southern_CA), # For sablefish "North of Monterey Bay" = c(southern_BC, 36.00), - "South of Monterey Bay" = c(36.00, southern_CA) + "South of Monterey Bay" = c(36.00, southern_CA), + # Boundary used in some tribal U&A calculations + "North of 46deg 53.3min" = c(southern_BC, 46.888333), + "South of 46deg 53.3min" = c(46.888333, southern_CA) ) usethis::use_data( diff --git a/data/boundaries_data.rda b/data/boundaries_data.rda index 0add3ff5e3a82056f7b577c582697f7026cd0d74..19bd5cf14aa8ad707dbd93d8752dd49e18911764 100644 GIT binary patch literal 338 zcmV-Y0j>T*T4*^jL0KkKS(}vn!TAA~QxJO{6Td!F0AUp^`HA#X<7Em16=^++A|3OO4R1 z#=_xAiw5TI#mIypAd4-@=)oXi2GCq-4PpxmgSxeAj|mig#VJZbPV*bk)09s6(c^O? z0(F7$ayO9Dc^2L_dqUBAh5lP0D^@0D5kYf&c&j literal 282 zcmV+#0pD zsSqlO5?Ejl5y$$(6=zW?bznEK0;JFpWanywj(l*J3A36DpqQ88pn+xy1ep*7*b9?1 zJS~lbB{Cs}6S?rLKs|{8v|A=rAu+{xaH4{$9prd#8A#M|5}XA@U~k{T3Wr%*)~MZH z43lG)LV1^o&Z$seUmhDlr6~Z6B+hul9cUa>nnIvBu3NB1B%{V7DMvXhkb=UG g4?-%DNUE!J!uVT!fN~Rv