Simulates survey set locations from a population generated by sim_distribution(). Often used prior to running sim_survey().

sim_sets(
  sim,
  subset_cells,
  n_sims = 1,
  trawl_dim = c(1.5, 0.02),
  min_sets = 2,
  set_den = 2/1000,
  resample_cells = FALSE
)

Arguments

sim

A simulation object returned by sim_distribution().

subset_cells

A logical expression to filter elements of the survey grid. Can reference columns like x, y, depth, cell, division, strat, or year (e.g., cell < 100 or year == 3).

n_sims

Number of survey simulations to generate.

trawl_dim

Numeric vector specifying trawl width and distance (same units as the grid).

min_sets

Minimum number of sets per stratum.

set_den

Set density (number of sets per unit area).

resample_cells

Logical. If TRUE, allows resampling of grid cells. Note: allowing resampling may introduce bias, since depletion is applied at the cell level.

Value

A data.table containing details of each survey set location.

Examples

# \donttest{
sim <- sim_abundance(ages = 1:5, years = 1:5) |>
  sim_distribution(grid = make_grid(res = c(20, 20)))

# Define different sets for early and later years
standard_sets <- sim_sets(sim, year <= 2, set_den = 2 / 1000)
reduced_sets <- sim_sets(sim, year > 2 & !cell %in% 1:100, set_den = 1 / 1000)
sets <- rbind(standard_sets, reduced_sets)
sets$set <- seq(nrow(sets))  # Ensure each set has a unique ID

survey <- sim_survey(sim, custom_sets = sets)

plot_survey(survey, which_year = 3, which_sim = 1)
#> No trace type specified:
#>   Based on info supplied, a 'scatter' trace seems appropriate.
#>   Read more about this trace type -> https://plotly.com/r/reference/#scatter
# }