flux_calc: Calculates ecosystem gas fluxes

View source: R/flux_calc.R

flux_calcR Documentation

Calculates ecosystem gas fluxes

Description

Calculates a flux based on the rate of change of gas concentration over time

Usage

flux_calc(
  slopes_df,
  slope_col,
  f_datetime = f_datetime,
  temp_air_col,
  chamber_volume = deprecated(),
  setup_volume,
  atm_pressure,
  plot_area,
  f_fluxid = f_fluxid,
  conc_unit,
  flux_unit,
  cols_keep = c(),
  cols_ave = c(),
  cols_sum = c(),
  cols_med = c(),
  cols_nest = "none",
  tube_volume = deprecated(),
  temp_air_unit = "celsius",
  f_cut = f_cut,
  keep_arg = "keep",
  cut = TRUE,
  fit_type = c()
)

Arguments

slopes_df

dataframe of flux slopes

slope_col

column containing the slope to calculate the flux

f_datetime

column containing the datetime of each gas concentration measurements in slopes_df. The first one after cutting will be kept as datetime of each flux in the output.

temp_air_col

column containing the air temperature used to calculate fluxes. Will be averaged with NA removed.

chamber_volume

[Deprecated] see setup_volume

setup_volume

volume of the flux chamber and instrument together in L, can also be a column in case it is a variable

atm_pressure

atmospheric pressure in atm, can be a constant (numerical) or a variable (column name)

plot_area

area of the plot in m^2, can also be a column in case it is a variable

f_fluxid

column containing the flux IDs

conc_unit

unit in which the concentration of gas was measured ppm, ppb, or ppt

flux_unit

desired units for the calculated fluxes. Has to be of the form amount/surface/time. Amount can be mol, mmol, umol, nmol or pmol. Time can be d (day), h (hour), mn (minute) or s (seconds). Surface can be m2, dm2 or cm2.

cols_keep

columns to keep from the input to the output. Those columns need to have unique values for each flux, as distinct is applied.

cols_ave

columns with values that should be averaged for each flux in the output. Note that NA are removed in mean calculation. Those columns will get the ⁠_ave⁠ suffix in the output.

cols_sum

columns with values for which is sum is provided for each flux in the output. Those columns will get the ⁠_sum⁠ suffix in the output.

cols_med

columns with values for which is median is provided for each flux in the output. Note that NA are removed in median calculation. Those columns will get the ⁠_med⁠ suffix in the output.

cols_nest

columns to nest in nested_variables for each flux in the output. Can be character vector of column names, "none" (default) selects none, or "all" selects all the column except those in cols_keep.

tube_volume

[Deprecated] see setup_volume

temp_air_unit

units in which air temperature was measured. Has to be either celsius (default), fahrenheit or kelvin.

f_cut

column containing cutting information

keep_arg

name in f_cut of data to keep

cut

if 'TRUE' (default), the measurements will be cut according to 'f_cut' before calculating fluxes. This has no influence on the flux itself since the slope is provided from flux_fitting, but it will influence the values of the variables in cols_ave, cols_cum, and cols_med.

fit_type

(optional) model used in flux_fitting. Will be automatically filled if slopes_df was produced using flux_fitting.

Value

a dataframe containing flux IDs, datetime of measurements' starts, fluxes in mmol * m-2 * h-1 or micromol * m-2 * h-1 (f_flux) according to flux_unit, temperature average for each flux in Kelvin (f_temp_ave), the model used in flux_fitting, any column specified in cols_keep, any column specified in cols_ave, cols_med or cols_sum with their values treated accordingly over the measurement after cuts, and a column nested_variables with the variables specified in cols_nest.

Examples

data(co2_conc)
slopes <- flux_fitting(co2_conc, conc, datetime, fit_type = "exp_zhao18")
flux_calc(slopes,
f_slope,
datetime,
temp_air,
conc_unit = "ppm",
flux_unit = "mmol/m2/h",
setup_volume = 24.575,
atm_pressure = 1,
plot_area = 0.0625)

fluxible documentation built on June 25, 2025, 1:08 a.m.