flux
is a convenience wrapper for the other two functions that should be the best for most users.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")
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"CH4"
, "N2O"
or "CO2"
. Defaults to "CH4"
. This argument determines the molar weight that is used imin.a
x
giving different range limits for each chamber placement (for instance obtrange.lim
it might occur that there are NA values (when there are no calibration measurements to support a regular measurement - for details see
x
and columns
for details.flux.odae
. See details and value.flux.conv
. When flux rate estimation is carried out using flux
it is derived from the data tables.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
:
M
is just forwarded).r2.qual
is fulfilled.range.lim
. In case range.check = FALSE
, flux
is automatically returned as 0.nrmse.lim
is fulfilled (i.e. if the nrmse of the best model <= nrmse.lim).=>
nomba.=>
fl.dat
that is also the object returned by flux.odae
are:lm
. It builds the basis for the calculation of the flux rate via flux.conv
.plot.flux
and plot.fluss
.data.frame
with the original data provided according to arguments x
and columns
.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.
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.
conz.prep
, flux.calib
, gflux
, plot.fluss
## 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