Learn R Programming

atlantistools

atlantistools is a data processing and visualisation tool for R, which helps to process output from Atlantis models within R. Using atlantistools makes sure that Atlantis users use the same input/output file structure which facilitates intra and inter model comparisons.

Installation

Install from CRAN:

install.packages("atlantistools")

Install the development version from Github using devtools.

# install.packages(devtools)
devtools::install_github("alketh/atlantistools")

It is highly recommended to install the package with the vignettes:

devtools::install_github("alketh/atlantistools", build_vignettes = TRUE)
vignette("package-demo", package = "atlantistools")

You can customise the build in vignettes to automate the simulate model - check output cycle during model calibration. Currently there are 4 vignettes available.

  1. model-preprocess.Rmd
  2. model-calibration.Rmd
  3. model-calibration-species.Rmd
  4. model-comparison.Rmd

In order to use the vignettes please make sure to use the latest version of RStudio (https://www.rstudio.com/products/RStudio/). In addition you need to install pandoc (http://pandoc.org/installing.html) and LaTex (I recommend MikTex, http://miktex.org/download) on your system. Depending on the LaTex package compendium you selected you might need to install the following additional LaTex packages to create pdfs: url, fancyvrb, framed and titling. You should be prompted in doing so when you try to create your first pdf.

The vignettes can be used one after another. In most cases you need to preprocess the output of your atlantis simulation first with model-preprocess.Rmd. You should save the output as an intermediate R-object to save time during model calibration. Afterwards you can knit the calibration vignettes to produce the summary pdf files.

library("knitr")
library("rmarkdown")

preprocessed <- T

if (preprocessed) {
  load("preprocess-north-sea.rda", verbose = T)
} else {
  render(input = "z:/R_codes/model-preprocess.Rmd", 
         output_file = "model-preprocess.html")
  save(result, file = "preprocess-north-sea.rda")
}

render(input = "z:/R_codes/model-calibration.Rmd", 
       output_file = "model-calibration-ns.pdf")

render(input = "z:/R_codes/model-calibration-species.Rmd", 
       output_file = "model-calibration-ns-species.pdf")

Copy Link

Version

Install

install.packages('atlantistools')

Monthly Downloads

44

Version

0.4.3

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Alexander Keth

Last Published

August 16th, 2017

Functions in atlantistools (0.4.3)

check_growth

This function is used to check the individual growth per group over time.
combine_ages

Combine ageclasses to juvenile and adult stanza according to age at maturity.
change_avail

Change the availability matrix to simplify automated ATLANTIS calibrations.
change_prm

Change biological parameterfile to simplify automated ATLANTIS calibrations.
calculate_consumed_biomass

Calculate the consumed biomass in [t] of prey j by predator i.
calculate_spatial_overlap

Calculate 3d overlap of predator groups with their prey over time using Schoener Index.
change_prm_cohort

Change biological parameterfile for parameters which expect multiple values.
check_df_names

Function to check the names of a dataframe.
agg_data

Aggregate data using dplyr functionality.
calculate_biomass_spatial

Calculate spatially explicit biomass (in [t]) for each group and ageclass per timestep.
custom_grid

Utility functions used for various plotting routines within atlantistools.
extract_prm

Extract values for Atlantis parameters from the biological parameter file.
get_boundary

Get boundary boxes from Atlantis box information.
get_colpal

Create discrete color palette used in plots.
convert_relative_initial

Calculate relative timeseries using the initial value as benchmark.
convert_time

Convert timestep to actual time!
get_ids_fishbase

Extract fishbase IDs using the package "rfishbase" to generate species specific fishbase URLs
convert_bgm

Transform data from bgm-file to map dataframe.
convert_factor

Function to convert any column with information about functional groups to a factor whose levels use the LongName of the functional groups file.
get_conv_mgnbiot

Extract conversion factor used to transform data from nitrogen in mg to biomass in tonnes.
get_diet_fishbase

Extract reference for diet information from http:://www.fishbase.se
load_nc

Load Atlantis outputfiles (netcdf)
load_nc_physics

Load Atlantis outputfiles (netcdf)
load_txt

Function to load various txt files from Atlantis simulations
%>%

Pipeoperator
prm_to_df

Extract parameters from the biological parameter file and transform them to a dataframe.
fishbase_data

fishbase_data
flip_layers

Flip layers for visualization.
get_groups

Collection of similar functions which get specific columns from the Atlantis functionalGroups.csv
get_growth_fishbase

Extract growth parameters from http:://www.fishbase.se.
get_maturity_fishbase

Extract maturity parameters from http:://www.fishbase.se.
load_dietmatrix

Extract the dietmatrix from the biological parameterfile
load_fgs

Load the functional group file
plot_add_range

Low level plotting function to add range of observed values to time series plots.
ref_agemat

agemat.
ref_dietmatrix

Dietmatrix.
ref_dm

Dietcheck.
load_bps

Extracts the names of the epibenthic biomasspools from the initial conditions file.
load_dietcheck

Read in the atlantis dietcheck.txt file and perform some basic data transformations.
plot_diet

Plot contribution of diet contents for each functional group.
plot_diet_bec_dev

Plot contribution of diet contents for each functional group.
preprocess

preprocess
preprocess_txt

Preprocess dataframes loaded in with load_txt()
ref_bio_cons

Consumed biomass.
scan_prm

Scan character vector for specific flag!
scan_reference_fishbase

Scan list of references for character string for fish species
combine_groups

Combine values from different groups if specific groups only have a low contribution to the overall value.
combine_runs

This function is used to combine model output from different simulations!
get_ref_fishbase

Extract the bibliographic info from www.fishbase.org.
load_box

Load the box specification file for an Atlantis scenario
plot_bar

Function to plot relative contribution of biomass and numbers per cohort.
plot_spatial_box

Visualize the spatial distribution per species and stanza combination.
plot_spatial_overlap

Plot spatial overlap.
ref_bio_sp

Spatial biomass.
ref_growth

Growth.
ref_n

Nitrogen.
ref_to_bibkey

Convert reference to bib-tex-key.
ref_vol

Volume.
ref_vol_dz

Volume and dz.
sc_init

Sanity check initial conditions file
load_init

This function is used to read in data from the initial conditions file.
load_init_age

This function loads weight at age data (in mgN) from the initial conditions file.
plot_add_box

Low level plotting function to add sudo confidence range to calibration plots.
plot_add_polygon_overview

Add spatial representation of polygon layout to a ggplot2 object.
plot_line

Function to plot time series of atlantis ncdf output.
plot_rec

Plot recruitment.
load_rec

Load information for SSB and Recruits from an Atlantis model run.
load_spec_mort

Load mortality information from outputSpecificPredMort.txt
plot_boxes

Plot layout of boxes!
ref_nums

Numbers at age data.
ref_physics

Physical variables.
ref_resn

Reserve nitrogen.
plot_consumed_biomass

Circle diagram to visualize the consumed biomass for the whole system.
plot_spatial_ts

Visualize the spatial distribution per species and stanza combination.
plot_species

Create species specific overview plot.
ref_eat

Eat.
ref_grazing

Grazing.
ref_structn

Structural nitrogen.
str_split_twice

Extract numeric values from string.
theme_atlantis

Customized theme used in all plots.