calculate_biomass_spatial: Calculate spatially explicit biomass (in [t]) for each group...

Description Usage Arguments Value Examples

View source: R/calculate-biomass-spatial.R

Description

Calculate spatially explicit biomass time series for each group and ageclass within our model. Data is read in from 'output[...].nc'. Biomass for age-based groups is calculated as (StructN [mgN] + ResN [mgN]) * Numbers [individuals]. Biomass for non age-based groups is calculated as N [mgN] * volume [m^3] (sediment-dz [m] / volume [m^3] for epibenthic groups). mgN is converted to t based on the stettings in the biol.prm file. Simulation time steps are converted to time in years based on output timesteps given in run.prm.

Usage

1
calculate_biomass_spatial(nums, sn, rn, n, vol_dz, bio_conv, bps)

Arguments

nums

Dataframe with information about numbers for age-based groups. Should be generated with load_nc.

sn

Dataframe with information about structural nitrogen for age-based groups. Should be generated with load_nc.

rn

Dataframe with information about reserve nitrogen for age-based groups. Should be generated with load_nc.

n

Dataframe with information about nitrogen for non-ge-based groups. Should be generated with load_nc.

vol_dz

Dataframe with information about volume and layer height per polygon. Should be generated with load_nc_physics.

bio_conv

Numeric value to transform weight in mg N to tonnes. Should be generated with get_conv_mgnbiot.

bps

Vector of character strings giving the complete list of epibenthic functional groups (Only present in the sediment layer). The names have to match the column 'Name' in the 'functionalGroups.csv' file. Should be generated with load_bps.

Value

Dataframe with columns 'species', 'agecl', 'polygon', 'layer', 'time'. Biomass in [t] is stored in column 'atoutput'.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 1. Using built in datasets.
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")
init <- file.path(d, "INIT_VMPA_Jan2015.nc")
bps <- load_bps(fgs = fgs, init = init)

bio_conv <- get_conv_mgnbiot(prm_biol = prm_biol)

df <- calculate_biomass_spatial(nums = ref_nums, sn = ref_structn, rn = ref_resn, n = ref_n,
                                vol_dz = ref_vol_dz, bio_conv = bio_conv, bps = bps)

# 2. Read in dataframes from existing Atlantis simulation.
bboxes <- get_boundary(boxinfo = load_box(file.path(d, "VMPA_setas.bgm")))
nc_gen <- file.path(d, "outputSETAS.nc")
prm_run <- file.path(d, "VMPA_setas_run_fishing_F_Trunk.prm")

groups_age <- c("Planktiv_S_Fish", "Pisciv_S_Fish")
groups_rest <- c("Cephalopod", "Megazoobenthos", "Diatom", "Lab_Det", "Ref_Det")

nums <- load_nc(nc = nc_gen, bps = bps, fgs = fgs,
                select_groups = groups_age, select_variable = "Nums",
                prm_run = prm_run, bboxes = bboxes)
sn <- load_nc(nc = nc_gen, bps = bps, fgs = fgs,
              select_groups = groups_age, select_variable = "StructN",
              prm_run = prm_run, bboxes = bboxes)
rn <- load_nc(nc = nc_gen, bps = bps, fgs = fgs,
              select_groups = groups_age, select_variable = "ResN",
              prm_run = prm_run, bboxes = bboxes)
n <- load_nc(nc = nc_gen, bps = bps, fgs = fgs,
             select_groups = groups_rest, select_variable = "N",
             prm_run = prm_run, bboxes = bboxes)
vol <- load_nc_physics(nc = nc_gen, select_physics = c("volume", "dz"),
                       prm_run = prm_run, bboxes = bboxes, aggregate_layers = FALSE)

df <- calculate_biomass_spatial(nums = nums, sn = sn, rn = rn, n = n, vol_dz = vol,
                                bio_conv = bio_conv, bps = bps)

# 3. Read in dataframes from existing Atlantis simulation with Map().
vars <- list("Nums", "StructN", "ResN", "N")
grps <- list(groups_age, groups_age, groups_age, groups_rest)
dfs <- Map(load_nc, select_variable = vars, select_groups = grps,
           MoreArgs = list(nc = nc_gen, bps = bps, fgs = fgs,
                           prm_run = prm_run, bboxes = bboxes))

df <- calculate_biomass_spatial(nums = dfs[[1]], sn = dfs[[2]], rn = dfs[[3]], n = dfs[[4]],
                                vol_dz = vol, bio_conv = bio_conv, bps = bps)

alketh/atlantistools documentation built on Oct. 30, 2021, 5:46 a.m.