Extracts the diet matrix as long dataframe from the biological paremeter file of any ATLANTIS simulation.

load_dietmatrix(
  prm_biol,
  fgs,
  transform = TRUE,
  convert_names = FALSE,
  version_flag = 2
)

write_diet(dietmatrix, prm_biol, save_to_disc = TRUE)

Arguments

prm_biol

Character string giving the connection to the biological parameterfile. The filename usually contains biol_fishing and does end in .prm.

fgs

Character string giving the connection to the functional groups file. The filename usually contains Groups and does end in .csv.

transform

Boolean indicating if the returned dataframe is displayed in "long" (transform = TRUE, default) or "wide" (transform = FALSE) format. You should use the "wide" format in case you aim to change your diet matrix entries.

convert_names

Logical indicating if group codes are transformed to LongNames (TRUE) or not (default = FALSE).

version_flag

The version of ATLANTIS model. 1 for bec_dev, 2 for trunk. default is 2..

dietmatrix

Dataframe of the ATLANTIS dietmatrix generated with load_dietmatrix using transform = FALSE.

save_to_disc

Logical indicating if the resulting prm file should be overwritten (TRUE) or not (FALSE). Defaults to TRUE.

Value

dataframe of the availability matrix in long format with columns pred, pred_stanza (1 = juvenile, 2 = adult), prey_stanza, prey, avail, code.

Examples

# Can be applied to trunk models. d <- system.file("extdata", "setas-model-new-trunk", package = "atlantistools") prm_biol <- file.path(d, "VMPA_setas_biol_fishing_Trunk.prm") fgs <- file.path(d, "SETasGroupsDem_NoCep.csv") dm <- load_dietmatrix(prm_biol, fgs) head(dm, n = 10)
#> pred pred_stanza prey_stanza code prey avail prey_id #> 1 FPS 1 1 pPREY1FPS1 FPS 0.0000 1 #> 2 FPS 2 1 pPREY1FPS2 FPS 0.0000 1 #> 3 FPS 1 2 pPREY2FPS1 FPS 0.0000 1 #> 4 FPS 2 2 pPREY2FPS2 FPS 0.0000 1 #> 5 FVS 1 1 pPREY1FVS1 FPS 0.1000 1 #> 6 FVS 2 1 pPREY1FVS2 FPS 0.1000 1 #> 7 FVS 1 2 pPREY2FVS1 FPS 0.1200 1 #> 8 FVS 2 2 pPREY2FVS2 FPS 0.1200 1 #> 9 CEP 1 1 pPREY1CEP1 FPS 0.0002 1 #> 10 CEP 2 1 pPREY1CEP2 FPS 0.0004 1
# Use write_diet to update your existing parameterfile. dietmatrix <- load_dietmatrix(prm_biol, fgs, transform = FALSE) # Write is set to FALSE here for technical reasons. Make sure to set it to TRUE in case you # want to update your file. new_diet <- write_diet(dietmatrix, prm_biol, save_to_disc = FALSE) # And to bec-dev models. d <- system.file("extdata", "setas-model-new-becdev", package = "atlantistools") prm_biol <- file.path(d, "VMPA_setas_biol_fishing_New.prm") fgs <- file.path(d, "SETasGroups.csv") dm <- load_dietmatrix(prm_biol, fgs, version_flag = 1) head(dm, n = 10)
#> pred pred_stanza prey_stanza code prey avail prey_id #> 1 FPL 1 1 pPREY1FPL1 FPL 0 1 #> 2 FPL 2 1 pPREY1FPL2 FPL 0 1 #> 3 FPL 1 2 pPREY2FPL1 FPL 0 1 #> 4 FPL 2 2 pPREY2FPL2 FPL 0 1 #> 5 FPO 1 1 pPREY1FPO1 FPL 0 1 #> 6 FPO 2 1 pPREY1FPO2 FPL 0 1 #> 7 FPO 1 2 pPREY2FPO1 FPL 0 1 #> 8 FPO 2 2 pPREY2FPO2 FPL 0 1 #> 9 FPS 1 1 pPREY1FPS1 FPL 0 1 #> 10 FPS 2 1 pPREY1FPS2 FPL 0 1