R code for @apeyton_smith above/below wetting experiment. This pipeline starts with reading CO2/CH4 data as downloaded from the Picarro analyzer, processes it, computes mass-normalized fluxes and cumulative respired C, does some QC, and generates figures and statistics.
This code makes heavy use of the dplyr package. All scripts write log files that include dates, package and R version numbers, diagnostics, etc. They are designed to be run in numerical order.
0-functions.R
Loads required libraries and provides support functions for all the other scripts, including
printlog()
- a time-stamped output functionsave_plot()
- saves a ggplot figure into the OUTPUT_DIR
directorysave_data()
- saves a data frame to CSV, optionally gzip'd, into the OUTPUT_DIR
directoryread_csv()
- reads a CSV file, optionally gzip'd1-data.R
Reads all raw Picarro data from a specified directory, concatenates it all together, and writes the resulting data frame to a rawdata.csv.gz
file.
2-summarize.R
This is the heart of the pipeline. It performs the following major steps:
DATETIME
field, converting the Picarro timestamps from UTC to Pacific Coast timeMPVPosition
) to actual experiment cores. A number of minor cleanup operations are performed on the map data, and a figure is generated for QC purposes (to help identify mis-assigned or missing cores, for example)dplyr
pipeline: (i) for each sample, find the minimum CO2 and CH4 concentrations observed within the first MAX_MINCONC_TIME
seconds; (ii) find the maximum concentration of each gas that occurs after the minimum, but before MAX_MAXCONC_TIME
seconds; (iii) compute the mean DATETIME
, number of observations, etc.; (iv) using the date information and the valve number, match the sample to a row in the valve mapelapsed_minutes
across samples. Basically each core has a STARTDATETIME
assigned to it in the valve map, and we compute how many minutes have elapsed since thensummarydata.csv
3-fluxes.R
This script computes actual carbon fluxes by gas.
elapsed_minutes
, the cumulative emission for each gasfluxdata.csv
4-plots.R
This script makes a variety of plots: QC plots, histograms of the computed fluxes, flux comparisons broken down by various factors. It also prints a naive statistical summary, fitting a linear model using WETTING
, STRUCTURE
, etc.