alfam2 {ALFAM2} | R Documentation |
Predict Ammonia Emission from Field-Applied Manure
Description
An implementation of the ALFAM2 model for predicting ammonia emission from field-applied manure. The model is described in Hafner et al. (2019).
Usage
alfam2(
dat,
pars = ALFAM2::alfam2pars03,
add.pars = NULL,
app.name = 'TAN.app',
time.name = 'ct',
time.incorp = NULL,
group = NULL,
center = c(app.rate = 40,
man.dm = 6.0,
man.tan = 1.2,
man.ph = 7.5,
air.temp = 13,
wind.2m = 2.7,
wind.sqrt = sqrt(2.7),
crop.z = 10),
pass.col = NULL,
incorp.names = c('incorp', 'deep', 'shallow'),
prep.dum = TRUE,
prep.incorp = TRUE,
add.incorp.rows = FALSE,
check = TRUE,
warn = TRUE,
value = 'emis',
conf.int = NULL,
pars.ci = ALFAM2::alfam2pars03var,
n.ci = NULL,
var.ci = 'er',
...)
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, and the application rate of total ammoniaical nitrogen (TAN) in kg/h. (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 details section below and the vignette for more information. |
pars |
A numeric vector (or a list of vectors) with model parameters (secondary parameters). Three parameter sets are provided with the package: |
add.pars |
additional parameter values that will extend or overwrite the |
app.name |
name of column in |
time.name |
name of column in |
time.incorp |
either name of column in |
group |
name of column in |
center |
numeric vector with means for centering.
Generally should not be changed by users, because parameter values depend on particular centering values, and nonsense predictions can result from changes to even a single centering value.
Set to |
pass.col |
character vector with name(s) of column(s) in |
incorp.names |
character vector with name(s) of column(s) in |
prep.dum |
if |
prep.incorp |
if |
add.incorp.rows |
function will add additional rows that exactly match the incorporation time(s) (no more than one per level of |
check |
should the function check inputs, including for |
warn |
set to |
value |
type of output.
Set to |
conf.int |
confidence interval setting.
Default ( |
pars.ci |
matrix or data frame of parameter sets for confidence interval calculations.
See |
n.ci |
number of parameter sets to use. Defaults to total number available. |
var.ci |
calculate confidence intervals for these variables. Calculation is done separately by variable and time interval. |
... |
additional optional arguments as length-one vectors that set values of fixed predictor variables. See examples. |
Details
Names and units (matching units is essential) for numerical predictors are:
app.rate.ni
manure application rate, but not for injection (
app.mthd = "os"
orapp.mthd = "cs"
) in t/haman.dm
slurry dry matter, percentage of fresh matter
man.ph
slurry pH, pH units
air.temp
air temperature, degress C
wind.2m
wind speed measured (or adjusted to) 2 m height, m/s
rain.rate
rainfall rate, mm/h
See the vignette for more details.
Categorical predictor variables can be entered as binary dummy variables or left as character or factors.
The alfam2
function automatically creates the dummy variables from from three categorical variables (this can be turned off with prep.dum = FALSE
):
app.mthd
application method,
bc
for broadcast,ts
for trailing hose,os
for open slot injection, andcs
for closed slot injection
(and see examples and vignette for aliases)
man.source
type (source) of manure,
pig
for pig, otherwise assumed to cattle or other (reference)incorp
incorporation, either
shallow
ordeep
(change in levels would require change inincorp.names
as well as parameter values)
For parameter set values, see the alfam2pars02
, alfam2pars02
, or alfam2pars03
objects.
Users are responsible for checking that input variable values are not beyond limits of measurement data used for parameter estimation. For parameter set 3, recommended limits are: DM 1-15% DM, pH 5.5-9.0, air temperature 0-30 deg. C, wind speed 0-10 m/s, rainfall rate 0-2.5 mm/h, and duration 0-168 h.
Value
By default, a data frame with the same number of rows as dat
(unless add.incorp.rows = TRUE
).
First column is time.name
column from input data dat
.
Defaults for following columns are:
dt
interval duration (time step)
f0
f0 parameter
r1
r1 parameter
r2
r2 parameter
r3
r3 parameter
r4
r4 parameter
r5
r5 parameter
f
fast pool size at
ct
(kg/ha)s
slow pool size at
ct
(kg/ha)j
average NH3 flux in interval (kg/ha-h)
jinst
instantaneous NH3 flux at given time (kg/ha-h)
ei
interval emission (kg/ha)
e
cumulative emission (from time = 0 to
ct
) (kg/ha)er
relative cumulative emission (fraction of applied TAN)
If prep.dum
is used, additional dummy variable columns will also be returned.
And if a grouping variable is used via group
, this column will be included as well.
Any columns listed in pass.cols
will also be returned.
If value = 'incorp'
is used, the function will return intermediate data processed for incorporation but without emission predictions.
See vignette.
Author(s)
Sasha D. Hafner, Christoph Haeni, Roland Fuss
References
Hafner, S.D., Pacholski, A., Bittman, S., Carozzi, M., Chantigny, M., Genermont, S., Haeni, C., Hansen, M., Huijsmans, J., Kupper, T., Misselbrook, T., Neftel, A., Nyord, T., Sommer, S. 2019. A flexible semi-empirical model for estimating ammonia volatilization from field-applied slurry. Atmospheric Environment 199 474-484. doi:10.1016/j.atmosenv.2018.11.034
Hafner, S.D., Nyord, T., Sommer, S.G., Adamsen, A.P.S. 2021. Estimation of Danish emission factors for ammonia from field-applied liquid manure for 1980 to 2019. Danish Centre for Food and Agriculture, Aarhus University, Aarhus, Denmark. Report no. 2021-0251862. https://pure.au.dk/portal/files/223538048/EFreport23092021.pdf
Hafner, S.D., Kamp, J.N., Pedersen, J., 2024. Experimental and model-based comparison of wind tunnel and inverse dispersion model measurement of ammonia emission from field-applied animal slurry. Agricultural and Forest Meteorology 344, 109790. doi:10.1016/j.agrformet.2023.109790
The AlFAM2 project website. https://projects.au.dk/alfam/
Examples
# Example 1
# Create predictor variable data
dat1 <- data.frame(ctime = 0:12*4, TAN.app = 100, man.dm = 8, air.temp = 15,
app.mthd = 'trailing shoe')
# Run model, using default parameter values
pred1 <- alfam2(dat1, app.name = 'TAN.app', time.name = 'ctime')
pred1
plot(e ~ ctime, data = pred1, type = 'o')
# For fixed variables (same for all rows), they can be given as optional argument.
dat1b <- data.frame(ctime = 0:12*4)
# Run model, using default parameter values
pred1b <- alfam2(dat1b, app.name = 'TAN.app', time.name = 'ctime',
TAN.app = 100, man.dm = 8, air.temp = 15, app.mthd = 'trailing shoe')
all.equal(pred1, pred1b)
# Example 2
# Add incorporation (can occur at any time)
dat2 <- dat1
dat2$incorp <- 'deep'
dat2$t.incorp <- 3.5
dat2
pred2 <- alfam2(dat2, app.name = 'TAN.app', time.name = 'ctime', time.incorp = 't.incorp')
# Note change in r3
pred2
lines(e ~ ctime, data = pred2, type = 'o', col = 'red')
# Example 3
# Time step doesn't matter
dat3 <- data.frame(ctime = c(0, 48), TAN.app = 100, man.dm = 8, air.temp = 15,
app.mthd = 'trailing shoe')
pred3 <- alfam2(dat3, app.name = 'TAN.app', time.name = 'ctime')
lines(e ~ ctime, data = pred3, type = 'o', col = 'blue')
# Example 4
# Incorporation does not need to occur at end of interval
dat4 <- dat3
dat4$incorp <- 'deep'
dat4$t.incorp <- 4
pred4 <- alfam2(dat4, app.name = 'TAN.app', time.name = 'ctime', time.incorp = 't.incorp')
lines(e ~ ctime, data = pred4, type = 'o', col = 'orange')
# Incorporation time can be numeric also (not very practical for groups)
alfam2(dat4, app.name = 'TAN.app', time.name = 'ctime', time.incorp = 4)
# To see incorporation time in output, use add.incorp.rows
alfam2(dat4, app.name = 'TAN.app', time.name = 'ctime', time.incorp = 4,
add.incorp.rows = TRUE)
# Example 5
# Function accepts multiple groups
# Also shown here: some aliases for the different application methods
dat5 <- data.frame(field.plot = 1:5, ctime = 48, TAN.app = 100, man.dm = 5, air.temp = 15,
app.mthd = c('bc', 'th', 'ts', 'os', 'cs'), t.incorp = 4)
pred5 <- alfam2(dat5, app.name = 'TAN.app', time.name = 'ctime', group = 'field.plot',
time.incorp = 't.incorp')
pred5
# See vignette for more examples and explanation. Run:
# vignette("ALFAM2-start")