calc_age2length: Calculate length from ages

View source: R/calc_age2length.R

calc_age2lengthR Documentation

Calculate length from ages

Description

Calculate length composition in 1 cm bins from Atlantis output (st)age data Uses numbers at age, plus weight at age, and weight-length relationships to generate size comps

Usage

calc_age2length(
  structn,
  resn,
  nums,
  biolprm,
  fgs,
  maxbin = 150,
  CVlenage = 0.1,
  remove.zeroes = TRUE
)

Arguments

structn

A data.frame containing the structural nitrogen per functional-group ("species") per timestep, ageclass, layer and polygon. The data.frame has to origininate from load_nc using select_variable = "StructN".

resn

A data.frame containing the reserve nitrogen per functional-group ("species") per timestep, ageclass, layer and polygon. The data.frame has to origininate from load_nc using select_variable = "ResN".

nums

A data.frame containing the numbers per functional-group ("species") per timesetp, ageclass, layer and polygon. The data.frame has to origininate from load_nc using select_variable = "Nums".

biolprm

A list of biological parameters available from the [...]_Biol.prm file, as read in by load_biolprm.

fgs

A data frame created by load_fgs that reads in the csv file containing functional group names, usually "functionalGroups.csv".

maxbin

The upper length (cm) bin applied to all species sampled. The default value is 150. Optionally, a data.frame can be supplied for multiple species with different species lengths: Columns are: species: the species name. Matches names in species maxlenbin: the upper length (cm) bin applied to that species

CVlenage

The variability in length at age (same for all species) The default value is 0.1. Optionally, a data.frame can be supplied for multiple species with different CV of length at age: Columns are: species: the species name. Matches names in species cvlenage: the variability in length at age for that species

remove.zeroes

Logical asking whether to only return numbers at length for combinations of species, age, box, depth, etc that have numbers>0. The default value is TRUE.

Value

A list containing three data.frames, mulen (mean length at age), muweight (mean weight at age), and natlength (numbers at length). natlength is in the same format as other dataframes in the atlantisom package except has two additional columns to include the length bin information.

Author(s)

Gavin Fay

See Also

Other calc functions: calc_Z(), calc_avgwtstage2age(), calc_biomass_age(), calc_biomass_pool(), calc_pred_cons(), calc_pred_diet(), calc_stage2age(), calc_timestep2time()

Examples

## Not run: 
directory <- system.file("extdata", "SETAS_Example", package = "atlantisom")
load(file.path(directory, "outputsrun_truth.RData"))
# WARNING: EXTREMELY LONG RUN TIME for all species at full model resolution!
# even one species has a long run time; this works but takes minutes to return
result$structn <- result$structn[result$structn$species == "Demersal_S_Fish",]
result$resn <- result$resn[result$resn$species == "Demersal_S_Fish",]
result$nums <- result$nums[result$nums$species == "Demersal_S_Fish",]
lenout <- calc_age2length(
  structn=result$structn, resn=result$resn, nums=result$nums,
  biolprm = result$biolprm, fgs = result$fgs,
  CVlenage = 0.1, remove.zeroes=TRUE)
str(lenout)
rm(lenout)

## End(Not run)

r4atlantis/atlantisom documentation built on Nov. 12, 2023, 2:59 a.m.