Skip to contents

Matching a dataframe of continuously measured gas concentration data with measurement metadata from another dataframe. Measurements are paired with their metadata based on datetime. Extra variables in both dataframes are kept in the output.

Usage

flux_match(
  raw_conc,
  field_record,
  startcrop = 10,
  measurement_length = 220,
  ratio_threshold = 0.5,
  time_diff = 0,
  datetime_col = "datetime",
  conc_col = "conc",
  start_col = "start"
)

Arguments

raw_conc

dataframe of CO2 concentration measured continuously. Has to contain at least a datetime column in ymd_hms format and a gas concentration column as double.

field_record

dataframe recording which measurement happened when. Has to contain at least a column containing the start of each measurement, and any other column identifying the measurements.

startcrop

how many seconds should be discarded at the beginning of the measurement

measurement_length

length of the measurement (in seconds) from the start specified in the field_record

ratio_threshold

ratio (number of concentration measurement compared to length of measurement in seconds) below which the data should be flagged as too little

time_diff

time difference (in seconds) between the two datasets. Will be added to the datetime column of the raw_conc dataset. For situations where the time was not synchronized correctly.

datetime_col

datetime column in raw_conc (dmy_hms format)

conc_col

concentration column in raw_conc

start_col

start column in field_record (dmy_hms format)

Value

a dataframe with concentration measurements, corresponding datetime, flux ID, measurements start and end, flags in case of no data or low number of data, and any variables present in one of the inputs.

Examples

data(co2_df_short, record_short)
flux_match(co2_df_short, record_short)
#> # A tibble: 1,251 × 13
#>    f_datetime          temp_air temp_soil f_conc   PAR turfID       type 
#>    <dttm>                 <dbl>     <dbl>  <dbl> <dbl> <chr>        <chr>
#>  1 2022-07-28 23:43:35    NA         NA     447. NA    156 AN2C 156 ER   
#>  2 2022-07-28 23:43:36     7.22      10.9   447.  1.68 156 AN2C 156 ER   
#>  3 2022-07-28 23:43:37    NA         NA     448. NA    156 AN2C 156 ER   
#>  4 2022-07-28 23:43:38    NA         NA     449. NA    156 AN2C 156 ER   
#>  5 2022-07-28 23:43:39    NA         NA     449. NA    156 AN2C 156 ER   
#>  6 2022-07-28 23:43:40    NA         NA     450. NA    156 AN2C 156 ER   
#>  7 2022-07-28 23:43:41    NA         NA     451. NA    156 AN2C 156 ER   
#>  8 2022-07-28 23:43:42    NA         NA     451. NA    156 AN2C 156 ER   
#>  9 2022-07-28 23:43:43    NA         NA     453. NA    156 AN2C 156 ER   
#> 10 2022-07-28 23:43:44    NA         NA     453. NA    156 AN2C 156 ER   
#> # ℹ 1,241 more rows
#> # ℹ 6 more variables: f_start <dttm>, f_end <dttm>, f_fluxID <fct>,
#> #   f_n_conc <int>, f_ratio <dbl>, f_flag_match <chr>