Learn R Programming

ALFAM2 (version 4.2.14)

alfami: Emissions Inventory Calculations of Ammonia Emission from Field-Applied Manure

Description

A wrapper and higher-level analysis for the alfam2 function for emissions inventory applications. This function is under development and not currently exported! Warning: The API will likely change in the coming months.

Usage

alfami(
  dat, 
  pars = ALFAM2::alfam2pars03, 
  time.name,
  app.tan.name = 'app.tan',
  time.incorp = NULL,
  eventkey = NULL,
  aggkey = NULL,
  uncert = NULL,
  pars.uncert = ALFAM2::alfam2pars03var,
  uncert.settings = NULL,
  nu = 100,
  cl = 0.8,
  seed = NULL,
  quiet = FALSE,
  ...
)

Value

A list with six elements, each a data frame with predicted emission and calculated TAN application, but with various additional variables and aggregated in different ways. See vignette.

Arguments

dat

data frame containing predictor variable values. The data frame must include at least the elapsed (cumulative) time since manure was applied in hours at which emission should be evaluated, and the quantity of total ammoniaical nitrogen (TAN) applied in t (metric tonnes). (Other units could be used but should match parameter units and will affect the units of output.) Typically other predictor variables are included. See the vignette for more information.

pars

A named numeric vector (or a list of vectors) with model parameters (secondary parameters). Three parameter sets are provided with the package: alfam2pars01, alfam2pars02 and alfam2pars03, with alfam2pars03 recommended. See alfam2pars for details. Note that the function could be called with pars = alfam2pars03 (omitting the ALFAM2:: bit) but for clarity and safety, and to avoid a package check problem, the package name is included by default. See details for more information.

time.name

name of column in dat that contains cumulative time since manure was applied (h) for evalution of emission.

app.tan.name

name of column in dat with total ammoniaical nitrogen (TAN) application (t)

time.incorp

passed to, so as in, alfam2: either name of column in dat that contains time at which incorporation occurred (h), or length-one numeric value giving time that incorporation occurred (h). Omit if there was no incorporation or if incorporation is not a predictor variable. Optional.

eventkey

name of column containing a unique key application event key. Unlike alfam2, each row is otherwise considered a separate application event.

aggkey

name of column or columns that should be used for aggregation of TAN application and emission. Character vector.

uncert

use to include uncertainty based on model parameters ("pars"), input variables ("vars"), both (c("pars", "vars")), or none (NULL). Character vector.

pars.uncert

set of parameter sets to use for model uncertainty. Unusual to specify; use default.

uncert.settings

data frame with uncertainty settings for uncertainty in input variables (when 'vars' is included in pars.uncert), with these columns: pvar (predictor variable name), rel (relative, absolute, or centered uncertainty), dist.type (normal or uniform distribution), sd (distribution standard deviation), min (uniform distribution minimum), max (uniform distribution maximum).

nu

number of uncertainty iterations.

cl

confidence level.

seed

integer seed for uncertainty iterations. Use for reproducing results. Length-one integer vector.

quiet

set to TRUE to suppress some messages.

...

additional optional arguments to alfam2.

Author

Sasha D. Hafner

Details

This function simplifies emission calculations for inventory purposes and can estimate uncertainty from both model input variables and parameter values and aggregate TAN application and emission results. Actual emission calculations are made using alfam2(). The name of the function comes from 'ALFAM' and emissions inventory.

References

The AlFAM2 project website. https://projects.au.dk/alfam/

See Also

alfam2 alfam2pars03var alfam2pars

Examples

Run this code
if (FALSE) {
dat <- data.frame(zone = c('north', 'north', 'south', 'east', 'west'),
		  sector = c(1, 2, 1, 1, 1),
		  man.source = c('cattle', 'pig', 'cattle', 'cattle', 'pig'),
		  man.dm = c(7, 4, 6.5, 6.5, 4),
		  man.ph = c(7.0, 7.2, 6.9, 7.5, 7.4),
		  app.mthd = c(rep('trailing hose', 4), 'broadcast'),
		  wind.sqrt = sqrt(c(2.2, 2.1, 4.0, 3.7, 4.0)),
		  air.temp = c(12, 8, 8, 15, 14),
		  time.h = 168,
		  TAN.app.tot = c(2000, 1500, 80, 4300, 25))

dat


ei <- alfami(dat, time.name = 'time.h', app.tan.name = 'TAN.app.tot', aggkey = 'zone')

ei$emistot
ei$emisagg
}
# See vignette for more examples and explanation. Run:
# vignette("ALFAM2-inventory")

Run the code above in your browser using DataLab