load_detailed_diet_comp: Load Atlantis diet composition by box and layer from...

View source: R/load_detailed_diet_comp.R

load_detailed_diet_compR Documentation

Load Atlantis diet composition by box and layer from DetaileDietCheck.txt

Description

Imports the DetaileDietCheck.txt output file from an Atlantis run and converts the file from wide format to long, where there are seven columns: (predator) species, age class, time in days, polygon, layer, diet composition in tons (assuming flagdietcheck=1), and prey (species). Only non-zero values for diet compostion are included.

Usage

load_detailed_diet_comp(dir = getwd(), file_diet, fgs)

Arguments

dir

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

file_diet

A character value, specifying the file name of the DetailedDietCheck.txt output file from Atlantis (or see above). This file is read with data.table::fread(), so it can be compressed with a .gz suffix, or uncompressed as a .txt file. If is.null(dir), then file_diet can be the full file path or a file in your current working directory, or the file_diet will be appended to dir using file.path.

fgs

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

Details

NOTE: DetaileDietCheck.txt is extremely large. We recommend working with it compressed and using the following pre-processing steps at the command line to remove the all-0 rows: Execute in terminal from the directory with the .gz file in it: zcat < [...]DetailedDietCheck.txt.gz | awk 'NR > 1{s=0; for (i=6;i<=NF;i++) s+=$i; if (s!=0)print}' | gzip > DetDiet.gz On linux it would just be zcat filename; macOS needs zcat < filename to work. The awk statement is saying after the header row (NR>1), sum up the values from column 6 to the last column and keep the row if they are >0. The last pipe sends the new file to a zip file. The column names will be lost, so strip them from the file and cat back together: zcat < [...]DetailedDietCheck.txt.gz | head -n1 | gzip > DetDietHead.gz cat DetDietHead.gz DetDiet.gz > [...]DetDiet.gz Then use [...]DetDiet.gz as your input to this function

Value

Returns a data frame of the data to be exported to the AtlantisOM list object. The atoutput column is diet in tons and there is an extra column identifying the prey that makes up that proportion of species (predator) diet.

Author(s)

Sarah Gaichas

See Also

Other load functions: load_agebioind(), load_bioind(), load_biolprm(), load_boxarea(), load_box(), load_bps(), load_catch(), load_diet_comp(), load_fgs(), load_fisheries(), load_meta(), load_nc_annage(), load_nc_catchtons(), load_nc(), load_runprm(), load_yoy()

Examples

## Not run: 
d <- system.file("extdata", "SETAS_Example", package = "atlantisom")
file_diet <- grep("DetailedDietCheck", dir(d), value = TRUE)
fgs <- load_fgs(dir = d, "Functional_groups.csv")
temp <- load__detailed_diet_comp(dir = d, file_diet = file_diet, fgs = fgs)
rm(temp)

## End(Not run)

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