View source: R/process_tdl_cycle_polynomial.R
process_tdl_cycle_polynomial | R Documentation |
Uses the 12C and 13C signal from the calibration lines of a tunable diode laser (TDL) to determine correction factors and apply them to the sample lines. Applicable for a system with two or more reference tanks whose 12C and 13C concentrations are known beforehand.
process_tdl_cycle_polynomial(
tdl_cycle,
poly_order,
reference_tanks,
reference_tank_time_points = NA,
valve_column_name = 'valve_number',
raw_12c_colname = 'Conc12C_Avg',
raw_13c_colname = 'Conc13C_Avg'
)
tdl_cycle |
An |
poly_order |
The order of the polynomial to fit, where 1 indicates a linear fit, 2
indicates a quadratic fit, etc. This argument will be passed to
|
reference_tanks |
A list where each element is a list with three named elements: |
reference_tank_time_points |
Either |
valve_column_name |
The name of the column in |
raw_12c_colname |
The name of the column in |
raw_13c_colname |
The name of the column in |
This function applies a simple correction to the measured values of 12C and 13C. This correction is based on the fact that each reference tank has both a true concentration (which is known beforehand) and a measured concentration (from the TDL) of each isotope. Using this information, it is possible to perform a polynomial fit of true vs. measured concentrations; in other words, it is possible to identify a polynomial function that determines true concentrations from measured ones. This function can then be applied to tanks whose concentration is not known beforehand; in this case, it provides an estimate of the true concentration, otherwise referred to as a calibrated value.
When making dynamic TDL measurements, concentrations from some of the
reference valves may be logged at multiple time points. In this case, it is
typical to take an average value from a subset of them.
process_tdl_cycle_polynomial
can handle this situation when its
reference_tank_time_points
input argument is not NA
.
This function assumes that tdl_cycle
represents a single TDL
measurement cycle. To process multiple cycles at once, this function is often
used along with by.exdf
and consolidate
.
A list with two elements:
tdl_data
: An exdf
object containing the original content
of tdl_cycle
and several new columns:
'calibrated_12c'
, 'calibrated_13c'
, 'total_CO2'
,
and 'delta_C13'
.
calibration_parameters
: An exdf
object describing the
fitted polynomial coefficients.
# Example 1: An example of a `reference_tank_time_points` list for a situation
# where there are just two reference valves (1 and 3)
reference_tank_time_points <- list(
list(valve = 1, start = 101, end = 300), # Take an average of time points 101 - 300 for valve 1
list(valve = 3, start = 201, end = 300) # Take an average of time points 201 - 300 for valve 3
)
# Example2 : reading a TDL file that is included with the PhotoGEA package,
# identifying its measurement cycles, and then processing them.
tdl_file <- read_gasex_file(
PhotoGEA_example_file_path('tdl_sampling_1.dat'),
'TIMESTAMP'
)
# This is a large file; for this example, we will truncate to just the first
# 200 rows so it runs faster
tdl_file <- tdl_file[seq_len(200), , TRUE]
# Identify TDL cycles
tdl_file <- identify_tdl_cycles(
tdl_file,
valve_column_name = 'valve_number',
cycle_start_valve = 20,
expected_cycle_length_minutes = 2.7,
expected_cycle_num_valves = 9,
timestamp_colname = 'TIMESTAMP'
)
# Process TDL cycles; note that the reference tank concentrations used in this
# example are not accurate, so the results are not meaningful
processed_tdl <- consolidate(by(
tdl_file,
tdl_file[, 'cycle_num'],
process_tdl_cycle_polynomial,
poly_order = 1,
reference_tanks = list(
list(valve = 23, conc_12C = 70.37507124, conc_13C = 0.754892652),
list(valve = 26, conc_12C = 491.1854149, conc_13C = 5.269599965)
)
))
# The output is a list of two exdf objects
names(processed_tdl)
# The calibration parameters include the coefficients of the polynomial fit for
# each cycle
colnames(processed_tdl$calibration_parameters)
# The processed TDL data includes new columns for the calibrated CO2
# concentrations
colnames(processed_tdl$tdl_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.