calc_stage2age: Approximating the true numbers at age within each box,...

View source: R/calc_stage2age.R

calc_stage2ageR Documentation

Approximating the true numbers at age within each box, functional group and time step.

Description

Will be called in the run_truth file, and requires inputs from load_nc for the "Nums" variable, and the load_biolprm.

Usage

calc_stage2age(nums_data, biolprm, yoy, fgs, runprm)

Arguments

dir

The directory of the atlantis model output, where the default is getwd().

Value

A data.frame in long format with the following coumn names: Species, timestep, polygon, agecl, and atoutput (i.e., variable). This is the same as the input Nums data frame however, agecl will be TRUE numbers by age class – just named the same as the input to ensure make it work with the other functions

Author(s)

Emma E Hodgson and Kelli Faye Johnson

See Also

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

Examples

## Not run: 
dir <- system.file("extdata", "SETAS_Example", package = "atlantisom")
file_nc="outputs.nc"
fgs=load_fgs(dir = dir, "Functional_groups.csv")
file_init="Initial_condition.nc"
bps=load_bps(dir = dir, "Functional_groups.csv", file_init)
select_groups="Demersal_S_Fish"
select_variable="Nums"
box.info=load_box(dir = dir, file_bgm="Geography.bgm")
bboxes=get_boundary(box.info)
#when calc_stage2age is run, it will need to have the nums
#data frame, the YOY, the runprm and the bioprm already read in:
nums_data <- load_nc(dir = dir,
                     file_nc="outputs.nc",
                     bps=bps, fgs=fgs, select_groups=select_groups,
                     select_variable = "Nums",
                     check_acronyms = TRUE, bboxes = bboxes)
biolprm <- load_biolprm(dir, file_biolprm="Biology.prm")
YOY <- load_yoy(dir, file_yoy="outputsYOY.txt")
runprm <- load_runprm(dir, file_runprm="Run_settings.xml")
# aggregate across layers and polygons but not ages
nums_agg <- aggregate(nums_data$atoutput,
                       by=list(species = nums_data$species,
                               time = nums_data$time,
                               agecl = nums_data$agecl),
                       sum)
nums_agg <- data.frame(species = nums_agg$species,
                       time = nums_agg$time, agecl = nums_agg$agecl,
                       polygon = NA, layer = NA,
                       atoutput = nums_agg$x)
test <- calc_stage2age(nums_agg, biolprm, YOY, fgs, runprm)
rm(test)

## End(Not run)

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