This function calculates the selectivity for each gear, species and size from
the gear parameters. It is called by setFishing() when the selectivity is
not set by the user. The returned array is initialised to zero, so
gear-species combinations that are not listed in gear_params(params) remain
zero. For each listed combination the function named in sel_func is called
with w = params@w, the corresponding species parameters, and the
selectivity parameters from the matching row in gear_params(params).
calc_selectivity(params)An array (gear x species x size) with the selectivity values
A MizerParams object
By default the selectivity is point-sampled at the grid nodes params@w,
i.e. at the left edge of each size bin. This is only first-order accurate in
the bin size when the selectivity is used in the finite-volume update of the
size spectrum. When the bin_average entry of the second_order_w() slot is
TRUE, each selectivity function is instead integrated over its size bin,
so that selectivity[g, i, j] holds the bin average
$$\bar S_{g,i,j} = \frac{1}{\Delta w_j} \int_{w_j}^{w_{j+1}} S_{g,i}(w)\, dw.$$
The integral is evaluated with a composite-midpoint rule on a log-spaced
sub-grid of each bin, mirroring the bin-integrated predation kernel. This
lifts the fishing mortality towards second order at no extra runtime cost
(the integration happens once here, the rate functions are unchanged). A
welcome side effect is that a knife-edge gear then gets the exact fraction of
the straddling bin that lies above the knife edge, removing a grid artefact.
params <- NS_params
str(calc_selectivity(params))
calc_selectivity(params)["Pelagic", "Herring", ]
Run the code above in your browser using DataLab