简体   繁体   中英

flux or gasfluxes package usage in R

So I am very new to R and I have collected greenhouse gas samples from chambers installed in soils. Now I have obtained the raw data from GC (in ppm) for gas concentration for CO2, CH4 and N2O. I want to calculate the flux using flux or gasfluxes package in R. I am not sure how to do that exactly and how to arrange the data properly for that... I couldn't find any tutorial regarding this package on internet. Any help/suggestions would be highly appreciated.

These are are the variables I have

Treatment, Time (min), Gas conc. (ppm), Volume of chamber, Area of chamber, Temperature (C) inside the chamber.

Thanks

Here is what I typically do:

setwd("E:/.../.../")
library(gasfluxes)

DT <- fread("input.csv")

#calculate mass concentrations, example for N2O in ppb --> µg N / m³
# M = 28 g/mol
#Vm = 22.4 L/mol
DT[, N2O := Cmol * 28 * 273.15 / 22.4 / (273.15 + temp)]

Chamber volume should be in m³, area in m², closing times in h. Usually I have also columns for treatment, plot and date.

#flux calculation --> µg N / m² / h
fluxes <- gasfluxes(DT, 
                 methods = c("linear", "robust linear", "HMR"), 
                 .id = c("treatment", "plot", "date"),
                 .V = "V", .A = "A", .times = "time", .C = "N2O")

#select fluxes
fluxes[, c("flux", "flux.se", "flux.p", "method") := list(robust.linear.f0,
                                                       robust.linear.f0.se,
                                                       robust.linear.f0.p,
                                                       "robust linear")]
fluxes[!is.finite(flux), c("flux", "flux.se", "flux.p", "method") := list(linear.f0,
                                                                       linear.f0.se,
                                                                       linear.f0.p,
                                                                       "linear")]

fluxes[is.finite(HMR.f0) & HMR.AIC < linear.AIC & HMR.kappa < 20, 
        c("flux", "flux.se", "flux.p", "method") := list(HMR.f0,
                                                         HMR.f0.se,
                                                         HMR.f0.p,
                                                         "HMR")]
fluxes[!is.finite(flux), method := "error"]

Note that the decision HMR.kappa < 20 depends on units, is a bit arbitrary and requires more research and would possibly need to be adjusted for number of concentration-time points per flux and soil properties.

Edit 2020-08-04:

This is not up-to-date anymore. Please refer to the package vignette which shows the approach from Hüppi et al. (2018).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM