Skip to contents

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

Usage

flux_calc(
  slopes_df,
  slope_col,
  datetime_col,
  temp_air_col,
  chamber_volume,
  atm_pressure,
  plot_area,
  f_fluxid = f_fluxid,
  conc_unit,
  flux_unit,
  cols_keep = c(),
  cols_ave = c(),
  tube_volume,
  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 (in ppms^(-1) or ppbs^(-1))

datetime_col

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

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

atm_pressure

atmospheric pressure, 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 or ppb

flux_unit

unit in which the calculated flux will be mmol outputs fluxes in mmol * m^(-2)*h^(-1); micromol outputs fluxes in micromol * m^(-2)*h^(-1)

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.

tube_volume

volume of the tubing in L, can also be a column in case it is a variable

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 columns in cols_ave.

fit_type

(optional) model used in flux_fitting, exponential, quadratic or linear. Will be automatically filled if slopes_df was produced using flux_quality.

Value

a dataframe containing flux IDs, datetime of measurements' starts, fluxes in mmol*m^(-2)h^(-1) or micromolm^(-2)*h^(-1) (f_flux) according to flux_unit, temperature average for each flux in Kelvin (f_temp_ave), the total volume of the setup for each measurement (f_volume_setup), the model used in flux_fitting, any column specified in cols_keep, any column specified in cols_ave with their value averaged over the measurement after cuts and discarding NA.

Examples

data(slopes0)
flux_calc(slopes0,
f_slope,
datetime,
temp_air,
conc_unit = "ppm",
flux_unit = "mmol",
chamber_volume = 24.5,
tube_volume = 0.075,
atm_pressure = 1,
plot_area = 0.0625)
#> Cutting data according to 'keep_arg'...
#> Averaging air temperature for each flux...
#> Calculating fluxes...
#> R constant set to 0.082057
#> Concentration was measured in ppm
#> Fluxes are in mmol/m2/h
#> # A tibble: 6 × 7
#>   f_fluxid f_slope f_temp_air_ave datetime            f_volume_setup f_flux
#>      <dbl>   <dbl>          <dbl> <dttm>                       <dbl>  <dbl>
#> 1        1   1.56            7.31 2022-07-28 23:43:35           24.6   95.6
#> 2        2   0.853           7.38 2022-07-28 23:47:22           24.6   52.4
#> 3        3   0.303           7.46 2022-07-28 23:52:10           24.6   18.6
#> 4        4   1.13            7.77 2022-07-28 23:59:32           24.6   69.4
#> 5        5   1.46            7.71 2022-07-29 00:03:10           24.6   89.9
#> 6        6   0.426           7.75 2022-07-29 00:06:35           24.6   26.2
#> # ℹ 1 more variable: f_model <chr>