README.md

CRDSutils Package

This R package is used to process, manage, and report liquid water sample isotope data generated using Picarro L21X0-i analyzers in the SIRFER lab at the University of Utah. Components may be reusable/portable to other labs; future versions will improve portability.

Setup

library(devtools)
install_github("SPATIAL-Lab/CRDSutils@*release")
library(CRDSutils)
write_config()

Installs the current release from GitHub.

The write_config function is an interactive tool that collects and saves configuration information.

File system setup should be as follows. Each of the first-order directory or file paths will be requested and saved by write_config.

Reduce Data from a CRDS Run

reduce("hids1234", "2022-01-01")

The high-level function reduce processes and calibrates data from a CRDS run, generates two reports, and optionally exports the data to the Waterisotopes Database (if configured in write_config, for authenticated users). The data reduction workflow is defined in a markdown file bundled with the package and follows these steps:

  1. The CRDS coordinator file and runfile for the instrument and date specified are identified and checked for consistency. Minor discrepancies (e.g., missing injections) are reported.
  2. Iteratively execute the Memory-Drift-Outlier cycle until no outlier data are detected.
  3. Fit memory correction parameters. Each injection's measured value is modeled as a weighted average of the true value for the current sample and the measured values of the previous 8 injections. These weights are the memory correction parameters, and are fit using numerical optimization to minimize the variance of replicate injections for samples and standards.
  4. Apply memory correction to all injections.
  5. Average the replicate injections for each sample or standard.
  6. Fit a smoothing spline to the averaged slrm values to model instrumental drift throughout the run. Degrees of freedom = ceiling(n/2), where n is the number of slrm measurements. For n < 4 no curve is fit. Drift corrections are plotted in the .html report.
  7. Apply drift correction to all measurements.
  8. Conduct outlier detection. Outliers are identified if either the H or O value of an injection is more than 3.5 σ from the mean value for that sample, where σ is calculated from all injections centered on their sample or standard means.
  9. If one or more outlier injections are identified, mark the injection with the highest Z-score for each isotope system (i.e., up to 2 injections per iteration) as an outlier to be excluded from further analyses and repeat the MDO operations. Outlier identification plots are printed in the .html report.
  10. Calibrate all data using the known and measured plrm values. 1,000 calibrated values are generated for each sample or slrm and are used to obtain a mean and uncertainty (1 σ) for that sample/slrm. For each iteration values are drawn at random from univariate normal distributions for:
  11. the measured sample or slrm value (distribution defined by the mean and standard deviation of the replicate injections),
  12. the measured plrm value (distribution defined by the mean and standard deviation of the replicate injections), and
  13. the calibrated known plrm value (mean and standard deviation determined during plrm calibration and reported in refFile).
  14. Evaluate data reduction metrics and sample uncertainty against QC criteria documented in refFile, and set an "ignore" flag for either all samples or individual samples if the data reduction metrics or sample uncertainty (respectively) don't meet those criteria.
  15. Print a cross-plot of sample H and O isotope values, QC summary table, and sample value table to the .html data reduction report.
  16. Save data reduction results and information in an .xlsx file.
  17. Export data reduction results and corrected/calibrated data to the Waterisotopes Database, if configured.

Generate a Data Report

report("22-060")

This high-level function can be used to generate a data report containing results for samples associated with a given JOBNUM (or any secondary ID) and analyzed in one or more CRDS runs. Reports are saved in one of several formats (see help page), and the processing steps vary with format. In general, data associated with the job are identified, retrieved, and compiled, possibly along with reference material or QC data associated with the runs in which the samples were analyzed. These are then formatted and written to .xlsx or .csv files.

All versions of the report currently require an authenticated connection to the Waterisotopes Database; future versions of the package will support report generation from the .xlsx data reduction reports without a database connection.



SPATIAL-Lab/CRDSutils documentation built on Dec. 12, 2024, 3:23 a.m.