Skip to contents

Fill year-season-fishery slices in an age-frequency array when positive catch exists but the sliced age-frequency vector is empty. Replacement age frequencies are weighted averages of nearby non-empty donor years from the same season and fishery, normalised to sum to one.

Usage

repair_af_slices_weighted(
  catch_ysf,
  af_ysfa,
  N = 3L,
  p = 1L,
  eps = 1e-12,
  expand_if_empty = TRUE,
  verbose = TRUE
)

Arguments

catch_ysf

A 3D numeric array of observed catch by year, season, and fishery. Dimension order can differ if dimnames identify Year, Season, and Fishery; otherwise the function infers dimensions from their sizes.

af_ysfa

A 4D numeric array of sliced age frequencies by year, season, fishery, and age.

N

Integer search window, in years on either side of the empty slice, used to find donor years.

p

Numeric distance exponent for inverse-distance donor weighting. p = 1 gives weights proportional to 1 / distance.

eps

Numeric tolerance below which a catch or age-frequency sum is treated as zero.

expand_if_empty

Logical; if no donors are found inside the N year window, search all non-empty years from the same season and fishery.

verbose

Logical; print a message with the number of repaired slices.

Value

A list with:

af_ysfa

The repaired age-frequency array.

repaired

A data.frame listing repaired slices.

catch_dim_map

Integer positions of year, season, and fishery in catch_ysf.