Skip to contents

Converts length frequencies to age frequencies by assigning length-bin centers to age intervals derived from cohort-specific mean lengths.

Usage

get_sliced_afs(data, lf_data)

Arguments

data

A list containing model data passed to MakeADFun. Must include: n_lf (integer, number of length frequency observations), n_age (integer, number of age classes), age_a (numeric vector of age classes), lf_year (integer vector of years), lf_season (integer vector of seasons), and length_mu_ysa (3D array of mean length-at-age by year, season, and age).

lf_data

A data.frame containing length frequency data. Must include columns for Fishery, Year, N, and additional columns representing length bins with numeric column names.

Value

A list with two components:

lf_slices

A matrix of dimensions n_lf x (number of length bins) containing the age bin assignments for each length bin.

af_sliced

A matrix of dimensions n_lf x n_age containing the sliced age frequencies, with column names corresponding to age classes.

Details

Rows of lf_data must be in exactly the same order as data$lf_year and data$lf_season; this helper does not join or reorder them. The lf_slices matrix stores the underlying integer codes returned by cut(), whereas af_sliced has labeled age columns. Empty inputs and non-increasing mean lengths are not supported.