Matching continuously measured fluxes with measurement IDs and meta data
Source:R/flux_match.R
flux_match.Rd
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,
datetime_col,
start_col,
conc_col,
startcrop,
measurement_length,
ratio_threshold = 0.5,
time_diff = 0
)
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.
- datetime_col
datetime column in raw_conc (dmy_hms format)
- start_col
start column in field_record (dmy_hms format)
- conc_col
concentration column in raw_conc
- 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.
Value
a dataframe with concentration measurements, corresponding datetime,
flux ID (f_fluxid
), measurements start (f_start
) and end (f_end
),
flags in case of no data or low number of data (f_flag_match
),
the number of datapoints per measurement (f_n_conc
),
the ratio of number of datapoints over the length of each measurement
in seconds (f_ratio
), and any variables present in one of the inputs.
Examples
data(co2_df_short, record_short)
flux_match(co2_df_short, record_short, datetime, start, conc, startcrop = 10,
measurement_length = 180)
#> # A tibble: 1,020 × 14
#> datetime temp_air temp_soil 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,010 more rows
#> # ℹ 7 more variables: start <dttm>, f_start <dttm>, f_end <dttm>,
#> # f_fluxid <fct>, f_n_conc <int>, f_ratio <dbl>, f_flag_match <chr>