View source: R/load_detailed_diet_comp.R
load_detailed_diet_comp | R Documentation |
DetaileDietCheck.txt
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.
load_detailed_diet_comp(dir = getwd(), file_diet, fgs)
dir |
The directory of the atlantis model output, where the
default is |
file_diet |
A character value, specifying the file name of the
|
fgs |
A data frame created by |
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
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.
Sarah Gaichas
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()
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.