Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add boundaries argument to run_sdmtmb() and add new area to boundaries_data #32

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions R/calc_index_areas.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion R/run_sdmtmb.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,6 +25,7 @@ run_sdmtmb <- function(dir_main = getwd(),
family,
formula,
n_knots = 500,
boundaries = boundaries_data["Coastwide"],
...) {
# Checks
stopifnot(inherits(family, "family"))
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion data-raw/boundaries_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Binary file modified data/boundaries_data.rda
Binary file not shown.
9 changes: 9 additions & 0 deletions man-roxygen/boundaries.R
Original file line number Diff line number Diff line change
@@ -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.
26 changes: 23 additions & 3 deletions man/run_sdmtmb.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/sanity_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.