Converts CO2 measurements from gas analyzer data into standardized units, with options for temperature correction. It can process both single measurements and vectors of measurements.
The function implements standard gas analysis conversions and can optionally apply temperature corrections using a Q10 = 2 approach (metabolic rate doubles for every 10°C increase).
Usage
convert_unit_co2(
co2_value,
flow_rate,
unit_flowrate = "mL/min",
unit_input_co2 = "umol/mol",
unit_output_time = "h",
unit_output_vol = "mL",
from_temperature = NULL,
to_temperature = NULL
)
Arguments
- co2_value
Numeric vector. The differential CO2 value(s) from gas analyzer (default in μmol/mol or ppm)
- flow_rate
Numeric. The flow rate of gas though the system.
- unit_flowrate
Character. Flow rate unit, either "mL/min" or "mL/h". Default: "mL/min"
- unit_input_co2
Character. Input CO2 unit, either "uM/M" or "umol/mol" (both equivalent to ppm). Default: "umol/mol"
- unit_output_time
Character. Desired time unit for the output rate, one of "s", "min", or "h". Default: "min"
- unit_output_vol
Character. Desired volume unit for the output, either "mL" or "uL". Default: "mL"
- from_temperature
Numeric. Source temperature in Celsius. Only required if metabolic temperature correction is desired (must be provided with to_temperature).
- to_temperature
Numeric. Optional target temperature in Celsius. Must be provided together with from_temperature if temperature correction is desired.
Details
The function performs the following conversions:
Converts CO2 measurements from ppm (μmol/mol) to fractions
Optionally applies temperature correction using Q10 = 2
Converts to desired output units (μL conversion is direct volume conversion)
Temperature correction uses the formula: correction_factor = 10^((to_temperature - from_temperature) * (log10(2)/10))
References
Temperature correction method based on standard Q10 = 2 approach, where metabolic rate doubles for every 10°C increase in temperature.
Examples
# Basic usage
convert_unit_co2(
co2_value = 100,
flow_rate = 1300,
unit_output_time = "h",
unit_output_vol = "uL"
)
#> [1] 7800
# With temperature correction
convert_unit_co2(
co2_value = 100,
flow_rate = 200,
from_temperature = 17, # Experiment temperature
to_temperature = 25, # Standard temperature
unit_output_vol = "uL",
unit_output_time = "min"
)
#> [1] 34.82202
# Processing a sequence of measurements
co2_values <- c(95, 98, 100, 103, 99)
convert_unit_co2(
co2_value = co2_values,
flow_rate = 200,
unit_output_vol = "mL",
unit_output_time = "min"
)
#> [1] 0.0190 0.0196 0.0200 0.0206 0.0198