Learn R Programming

flux (version 0.1-2)

flux: Estimate gas flux rates using dynamic closed chamber data

Description

The functions are used to prepare and carry out gas flux rate estimation with dynamic closed chamber data for one gas at a time. Either you can do the calculation in two steps or in just one single step. flux is a convenience wrapper for the other two functions that should be the best for most users.

Usage

flux(x, columns, M = "CH4", min.allowed = 3, max.nrmse = 0.1, 
nrmse.lim = 0.2, range.lim = 30, rl.backup = 30, r2.qual = 0.8, 
nomba = NULL, in.unit = "ppb", out.unit = "mg")

flux.odae(dat, min.allowed = 3, max.nrmse = 0.1, start = 1)

flux.conv(fl.dat, ch.area, M = "CH4", range.lim = 30, r2.qual = 0.8, nrmse.lim = 0.2, nomba = NULL, in.unit = "ppm", out.unit = "mg")

Arguments

x
A list with data tables as returned by conz.prep. Each table contains data for one chamber mesurement. Usually there will be identifying columns, date, time and time sequence columns, and columns containing the concentrations of the greenhous
columns
The columns that are used in the calculation process. They should represent in this sequence: gas concentration, closing time (of the chamber) in minutes, gas concentration quality flag (might be provided by your measurement device, if not just make it 0
M
Character string identifying the greenhouse gas for which concentration measurements are handled. Can be "CH4", "N2O" or "CO2". Defaults to "CH4". This argument determines the molar weight that is used i
min.allowed
Minimum number of concentration measurements that are allowed for the determination of the best model fit during the outlier detection and elimination (odae) procedure. Integer between 3 and the number of concentration measurements during one chamber plac
max.nrmse
The maximum acceptable normalized root mean square error for configurations with higher numbers of concentration measurements. Numeric value between 0 and 1. Defaults to 0.1. Above that value lower numbers of concentration measurements down to min.a
nrmse.lim
The main quality parameter for the model fit. The maximum acceptable normalized root mean square error. Numeric between 0 and 1. Default is 0.2. If the best fit for one chamber measurement is above this value, the function still returns a flux value for t
range.lim
The minimum range of the concentration measurements during one chamber placement. You can either give one numerical value or a numeric vector with the same length as x giving different range limits for each chamber placement (for instance obt
rl.backup
When a vector of range limits per chamber placement is obtained via range.lim it might occur that there are NA values (when there are no calibration measurements to support a regular measurement - for details see
r2.qual
Alternative quality parameter for the model fit. The minimum acceptable r2 of the best fitted model. Numeric between 0 and 1. Defaults to 0.8. A chamber measurement is not defined invalid when the value is below the quality setting. Instead, a quality fla
nomba
Quality setting: Sets the acceptable number of measurements below ambient. Defaults to the number of concentration measurements during one chamber placement. When one obs
in.unit
Input unit of the concentration measurements. Character string. Can be "ppm" or "ppb". Defaults to "ppm".)
out.unit
Output unit of the flux rate mass part. Character string. Can be "ng", "mug", "mg", or "g". Defaults to "mg". "mug" stands for "$\mu$g" because non-ascii characters are not allowed in functions.
dat
One data table for one chamber placement. See x and columns for details.
start
Sometimes several concentration samples are taken at time 0. If so, you can specifiy here which of those shall be taken for the flux estimation.
fl.dat
An object with the same structure as returned by flux.odae. See details and value.
ch.area
Chamber area. For historical reasons this can be specified separately in the function flux.conv. When flux rate estimation is carried out using flux it is derived from the data tables.

Value

  • flux returns an object of class fluss that is a two entry list.

    The second entry of that list is a data.frame with the estimated flux rates. The columns represent the entries in fluss of the single chamber measurements (see below) plus naming information according to the settings in the nmes argument of conz.prep.

    The first entry is itself a list of lists and data tables. It is called flux.res and is also the object that is returned by flux.conv. Each first level entry in this list contains the information for one chamber measurement. It is named according to the nmes-setting in conz.prep and contains the elements fluss (which is itself a list with the elements given below), fl.dat (equals the object returned by flux.odae; see below), and output.unit which provides information on the output mass unit of the flux rate that is handed over to the function plot.fluss.

    The elements of fluss:

  • ghgCharacter. The gas species for which the flux has been estimated (M is just forwarded).
  • fluxNumeric. Calculated flux rate in mass unit per m2 and hour.
  • r2.checkLogical. r2 quality flag telling whether the r2 quality setting given in r2.qual is fulfilled.
  • range.checkLogical. Range quality flag telling whether the range of the concentration measurements exceeded the quality range of the measurement device that has been specified in range.lim. In case range.check = FALSE, flux is automatically returned as 0.
  • nrmse.checkLogical. nrmse quality flag telling whether the nrmse quality setting given in nrmse.lim is fulfilled (i.e. if the nrmse of the best model <= nrmse.lim).
  • nomba.checkLogical. nomba quality flag telling whether the number of concentration measurements has been <= the="" setting="" in="" nomba.
  • r2The actual r2 of the best fitted model that has been used for flux caclulation.
  • nrmseThe actual nrmse of the best fitted model that has been used for flux caclulation.
  • The elements of fl.dat that is also the object returned by flux.odae are:
  • lm4fluxComplex object. The best fitting model as reported by lm. It builds the basis for the calculation of the flux rate via flux.conv.
  • row.selectInteger vector giving the indices of the rows of the data table that have been used to construct the best fitting model. This information is later used in the plotting functions plot.flux and plot.fluss.
  • orig.datdata.frame with the original data provided according to arguments x and columns.

encoding

UTF-8

Details

Typically it will be most convenient to use flux on objects returned by conz.prep (i.e. on lists of data tables that contain all necessary data per chamber measurement including supporting information). flux simply wraps flux.odae and flux.conv applied on lists of chamber measurement data tables into one function. Thus, the data of a one day field campaign or a year of chamber measurements can easily handled by simply running two functions (conz.prep and flux) consecutively per gas species. See example.

If the flux estimation is carried out in two steps it will typically be carried out on a list structure as returned by conz.prep. Therefore, it is used within a lapply call. For details see examples. However, the functions flux.odae and flux.conv are designed to be carried out on single data tables (data.frame) per chamber measurement.

First flux.odae is run. It simply tries to find the best model fit (for th etime being using linear regression) for the series of concentration measurements that are given in dat. This data.frame has to consist of five columns that give (in that order): gas concentration, closing time of the chamber in minutes, gas concentration quality flag, chamber volume, temperature within the chamber headspace during measurements (may change during chamber placement). See example data.

At the moment the optimization bases on linear regression. All possible models with n (= total number of concentration measurements per chamber placement) to min.allowed number of concentration measurements are fitted and the best fit is evaluated in a stepwise procedure. The normalized root mean square error is used as the quality criterion for the outlier detection and elimination procedure. All model fits with a nrmse <= max.nrmse are extracted and ranked according to the number of concentration measurements (decreasing) and to the nrmse (increasing). The first ranked model is stored along with the original data table and some other information. Therefore a model with e.g. a nrmse of 0.081 constructed from 5 concentration measurements wins against a model with a nrmse of 0.07 with only 4 concentration measurements. This reflects the idea that models with nrmse <= max.nrmse already represent a sufficient fit and do not have "outliers" that must be eliminated.

In case no model has a nrmse <= max.nrmse, the models are simply ranked according to their nrmse and the model with the lowest nrmse wins and is stored. In that way outliers are detected and exluded. flux.odae returns a complex object that contains most of the necessary information for the flux.conv function and also carries information that is later needed for the plot functions (plot.flux and plot.fluss).

The flux calculation is then carried out with the function flux.conv. It takes the object returned by flux.odae and additional information (chamber area, gas species, several quality settings and in- as well as output units) and calculates the flux rates. Further several quality checks (r2 check, range check, nrmse check, nomba check; for details see Value) are carried out and quality flags are reported along with the fluxes in the output. It is best when all quality flags are returned TRUE. Depending on the application quality requirements might vary. Therefore, we function rather report quality flags than excluding data.

References

Nakano T (2004) A comparison of regression methods for estimating soil-atmosphere diffusion gas fluxes by a closed-chamber technique. Soil Biology and Biochemistry 36: 107-113.

Forbrich I, Kutzbach L, Hormann A, Wilmking M (2010) A comparison of linear and exponential regression for estimating diffusive CH4 fluxes by closed-chambers in peatlands. Soil Biology and Biochemistry 42: 507-515.

See Also

conz.prep, flux.calib, gflux, plot.fluss

Examples

Run this code
## load example data
data(tt.pre)

## extract field concentration measurements
gcd <- tt.pre[tt.pre$sampletype_a=="P",]

## partition the data into data tables per chamber measurement
# first tell which columns of the data you want to carry on
columns <- c("date", "veg", "spot", "time_min", "temp_dC", "cham_area", 
"cham_vol", "CO2ppm", "CO2Code", "CH4ppb", "CH4Code", "N2Oppb", "N2OCode")
# then do the partitioning
gcd.parts <- conz.prep(gcd, columns, factors = c("date", "spot", "veg"), 
nmes = c("date", "veg", "spot"))

## calculate flux rates for methane
# first define CH4 range limit (alternatively use flux.calib)
CH4.lim <- 30
# do the flux rate estimation
flux.CH4 <- flux(gcd.parts, columns=c("CH4ppb", "time_min", "CH4Code", 
"cham_vol", "temp_dC", "cham_area"), M = "CH4")

## look at the results table
flux.CH4$flux.table

## plot the concentration-change-with-time-plots as kind of diagnostic
plot(flux.CH4, subs = NULL, dims = c(3,6))

Run the code above in your browser using DataLab