library(magrittr)
ling_imm <- g3_stock(c(species = 'ling', 'imm'), seq(20, 156, 4)) %>% g3s_age(3, 10)
ling_mat <- g3_stock(c(species = 'ling', 'mat'), seq(20, 156, 4)) %>% g3s_age(5, 15)
igfs <- g3_fleet('igfs')
igfs_landings <-
structure(expand.grid(year=1990:1994, step=2, area=1, total_weight=1),
area_group = list(`1` = 1))
# Generate a fleet predation action using g3_suitability_exponentiall50
predate_action <- g3a_predate_fleet(
igfs,
list(ling_imm, ling_mat),
suitabilities = list(
ling_imm = g3_suitability_exponentiall50(
g3_parameterized('lln.alpha', by_stock = 'species'),
g3_parameterized('lln.l50', by_stock = 'species')),
ling_mat = g3_suitability_exponentiall50(
g3_parameterized('lln.alpha', by_stock = 'species'),
g3_parameterized('lln.l50', by_stock = 'species'))),
catchability = g3a_predate_catchability_totalfleet(
g3_timeareadata('igfs_landings', igfs_landings)))
# You can use g3_eval to directly calculate values for a stock:
g3_eval(
g3_suitability_exponentiall50(alpha = 0.2, l50 = 60),
stock = g3_stock('x', seq(0, 100, 10)) )
## Plots
suit_plot <- function (
suit_f,
stock = g3_stock('x', seq(0, 100, 5)),
predator_length = 140,
cols = rainbow(5) ) {
par(mar = c(2,2,2,2), cex.main = 1)
for (a in seq_along(cols)) curve(
g3_eval(
suit_f,
a = a,
stock = stock,
predator_length = predator_length )[x %/% g3_stock_def(stock, 'dl')[[1]] + 1],
from = min(g3_stock_def(stock, 'minlen')),
to = max(g3_stock_def(stock, 'minlen')),
col = cols[[a]],
main = deparse1(sys.call()[[2]]), xlab = "", ylab = "",
add = (a != 1) )
}
suit_plot(g3_suitability_exponentiall50(alpha = ~a * 0.1, l50 = 50))
suit_plot(g3_suitability_andersen(0, log(2), 1, p3 = ~a * 0.1, 0.1, 140))
suit_plot(g3_suitability_andersen(0, log(2), 1, 0.1, p4 = ~a * 0.1, 140))
suit_plot(g3_suitability_gamma(alpha = ~2 + a * 0.1, beta = 1, gamma = 40))
suit_plot(g3_suitability_exponential(0, ~0.01 * a, 0, 1))
suit_plot(g3_suitability_straightline(alpha = 0.1, beta = ~0.01 * a))
suit_plot(g3_suitability_constant(~a * 0.1))
suit_plot(g3_suitability_richards(0, 0.05, 0, 1, ~0.1 * a))
Run the code above in your browser using DataLab