View source: R/offset_correction.R
offset_correction | R Documentation |
A function for the correction of offsets in the whole gas-dataset. The basic assumption is that atmospheric values of these gases are fairly constant over long periods of time. If there are offsets in the atmospheric concentrations, then these are probably introduced via calibration differences or similar factors within the gas analysis. The time series is smoothed by subdividing the whole dataset per gas into homogeneous subsections (section). Mean values of the atmospheric concentrations are then calculated, or a linear model is fit against time. A correction factor is then calculated by dividing a target atmospheric value (gases_std) by the mean or the values predicted by the linear model. x_ppm values are then multiplied by that factor.
offset_correction(df, corr_map, gases, gases_std, depth_cal)
df |
(dataframe) The gasdata-dataframe. |
corr_map |
(dataframe) A dataframe of four columns
("gas","SAMPLE_NO","section","mode") mapping each pair of |
gases |
(vector, character) A vector containing the names of the gases to be corrected. Spelling must match gasdata$gas. |
gases_std |
(vector, numeric) A numeric vector with standard
concentrations of the gases in the atmosphere. Unit is fraction of Volume
(e.g. N2 = 0.78). Must match the order of |
depth_cal |
(character) A character (-vector) containing the value(s) of
|
df (dataframe)
Other gasdata:
balance_correction()
,
offset_subsetting()
{
data("gasdata")
library(dplyr)
gasdata <- gasdata %>%
mutate(depth_cat = ifelse(depth>0,"HU","MIN"),
SAMPLE_NO = row_number())
cmap <-
offset_subsetting(gasdata,
start = "2021-01-01",
end = "2022-01-01",
mode = "const")
offset_correction(gasdata,
corr_map = cmap,
gases = "CO2",
gases_std = 400e-6,
depth_cal = "HU")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.