LTER Synthesis working group -- The Flux Gradient Project: Understanding the methane sink-source capacity of natural ecosystems
- Sparkle L. Malone, Assistant Professor, Yale University
- Jackie H. Matthes, Senior Scientist, Harvard University
lterwg-flux-gradient/
├── functions/ # Core analysis functions
│ ├── calc.*.R # Calculation functions
│ ├── flag.*.R # Quality control functions
│ ├── plot.*.R # Visualization functions
│ └── compile.*.R # Data processing functions
│
├── workflows/ # Complete analysis workflows
│ ├── flow.neon.data.*.R # Data acquisition workflows
│ ├── flow.calc.*.R # Flux calculation workflows
│ └── flow.*.R # Analysis workflows
│
├── exploratory/ # Preliminary analyses and development
│ └── ...
│
└── deprecated/ # Unused workflows and functions
- Column name should use snake case include units, last "_" proceeds units (i.e. var_molperm3)
- no "- or /" in column names
-
Clone this repository
git clone https://github.com/lter/lterwg-flux-gradient.git cd lterwg-flux-gradient -
Install required R packages
# Core packages install.packages(c("tidyverse", "neonUtilities", "rhdf5", "googledrive", "foreach", "doParallel", "lubridate", "ggplot2")) # Additional packages install.packages(c("gslnls", "terra", "sf", "ggh4x")) # If using BiocManager if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("rhdf5")
-
flow.neon.data.download.R: Workflow script that downloads NEON HDF5 (eddy covariance files) files for all sites and time periods of interest. ALSO downloads all required MET data products that are not in the bundled HDF5 file. -
flow.neon.data.unzip.R: Unzips all downloaded NEON data files. -
flow.neon.data.extract.R: Extracts and stacks downloaded and unzipped data into R objects for each data averaging interval, saved in their own RData file. These are currentlySITE_9min.Rdata(9-min/6-min concentrations),SITE_30min.Rdata(30-min met and flux data),SITE_1min.Rdata(1-min met data), andSITE_WS2D2min.Rdata(2D wind speed data), whereSITEis the NEON site code. Also extracts and saves site attributes from the HDF5 files intoSITE_attr.Rdata. Zips and uploads to Google Drive. For example,googledrive::drive_upload(media = path to the local file to upload, overwrite = T, path = googledrive::as_id("url to Drive folder")).flow.neon.data.download.R → flow.neon.data.unzip.R → flow.neon.data.extract.R → SITE_9min.Rdata, SITE_30min.Rdata, SITE_1min.Rdata, SITE_WS2D2min.Rdata, SITE_attr.Rdata (.zip equivalents uploaded to Google Drive)
-
flow.neon.data.format.conc.diffs.R&flow.neon.data.format.conc.diffs.30m.R: Downloads output fromflow.neon.data.extract.Rfrom Google Drive. Align the 9-min or 30-min concentration data among adjacent tower levels (and also the bottom-top levels).flow.neon.data.format.conc.diffs.Rinterpolates 30-min eddy flux and MET data to the 9-min/6-min concentrations, including but not limited to u*, ubar (profile), roughness length.flow.neon.data.format.conc.diffs.30m.Rconnects the nearest 9-min/6-min data to each 30-min eddy covariance measurement. Also derives kinematic water flux (LE -> w'q'), heat flux (w'T'), aerodynamic canopy height, displacement height, that are needed for the various methods. Differences the concentrations for CH4, CO2, and H2O for adjacent tower levels (and bottom-top). Saves output asSITE_aligned_conc_flux_9min.RDataandSITE_aligned_conc_flux_30min.RData. Zips and uploads to Google Drive. -
flow.download.aligned.conc.flux.R: Downloads output fromflow.neon.data.format.conc.diffs.Randflow.neon.data.format.conc.diffs.30m.Rfrom Google Drive and unzips them.SITE_9min.zip, SITE_30min.zip, SITE_1min.zip, SITE_WS2D2min.zip, SITE_attr.zip → flow.neon.data.format.conc.diffs.R → SITE_aligned_conc_flux_9min.RData (.zip equivalent uploaded to Google Drive) SITE_9min.zip, SITE_30min.zip, SITE_1min.zip, SITE_WS2D2min.zip, SITE_attr.zip → flow.neon.data.format.conc.diffs.30m.R → SITE_aligned_conc_flux_30min.RData (.zip equivalent uploaded to Google Drive) flow.download.aligned.conc.flux.R (downloads and unzips SITE_aligned_conc_flux_9min.zip, SITE_aligned_conc_flux_30min.zip, SITE_attr.zip)
-
flow.calc.flux.batch.R: Loads aligned concentration & flux data locally and calculates the fluxes using MBR (flow.calc.flag.mbr.batch.R), AE (flow.calc.flag.aero.batch.R), and WP (flow.calc.flag.windprof.batch.R) methods and adds quality flag columns, month, hour, residual, rmse for calculated fluxes. Saves output asSITE_AE_9min.Rdata,SITE_MBR_9min.RData, andSITE_WP_9min.Rdata. Zips and uploads to Google Drive, exceptSITE_AE_9min.zipwas not able to export to Google Drive soSITE_AE_9min.Rdatawas exported instead. -
flow.evaluation.dataframe.R: Loads flux calculations locally and standardizes the data format from the MBR, AE, and WP. This file uses the product offlow.calc.flux.batch.Rto develop the validation dataframes needed to perform the evaluation. This file produces a list of dataframes in an object calledSITE_Evaluation.RDATA. Also compiles attribute data intoSite_Attributes.csv. Uploads to Google Drive.SITE_aligned_conc_flux_9min.RData, SITE_aligned_conc_flux_30min.RData → flow.calc.flux.batch.R → ├─ flow.calc.flag.mbr.batch.R ├─ flow.calc.flag.aero.batch.R └─ flow.calc.flag.windprof.batch.R SITE_AE_9min.Rdata, SITE_MBR_9min.RData, SITE_WP_9min.Rdata (.zip equivalents uploaded to Google Drive except for SITE_AE_9min.zip) SITE_AE_9min.Rdata, SITE_MBR_9min.RData, SITE_WP_9min.Rdata → flow.evaluation.dataframe.R → SITE_Evaluation.RDATA, Site_Attributes.csv (uploaded to Google Drive as-is)
flow.non.neon.attribute.tables.R: Creates attribute tables for non-NEON sites that are consistent with those of NEON sites. Uploads to Google Drive as SITE_attr.RData and SITE_attr.zip where SITE is the non-NEON site.
flow.non.neon.data.harmonize.ch4.R: Harmonizes methane data from non-NEON sites. Uploads to Google Drive as methane_non-neon_harmonized.csv.
flow.SE-Sto.data.format.conc.diffs.R: Merges together flux, met, and profile concentration data for site SE-Sto. Aligns the profile concentration data (CH4, CO2, and H2O) among adjacent tower levels (and also the bottom-top levels) and computes the difference in mean concentration. Aligns non-concentration data with the mid-point of the paired-level concentration differences. Uploads to Google Drive as SE-Sto_attr.zip and SE-Sto_aligned_conc_flux_9min.zip.
flow.SE-Svb.data.format.conc.diffs.R: Merges together flux, met, and profile concentration data for site SE-Svb. Aligns the profile concentration data (CH4, CO2, and H2O) among adjacent tower levels (and also the bottom-top levels) and computes the difference in mean concentration. Aligns non-concentration data with the mid-point of the paired-level concentration differences. Uploads to Google Drive as SE-Svb_attr.zip and SE-Svb_aligned_conc_flux_9min.zip.
flow.US-Uaf.data.format.conc.diffs.R: Merges together flux, met, and profile concentration data for site US-Uaf. Aligns the profile concentration data (CH4, CO2, and H2O) among adjacent tower levels (and also the bottom-top levels) and computes the difference in mean concentration. Aligns non-concentration data with the mid-point of the paired-level concentration differences. Uploads to Google Drive as US-Uaf_attr.zip and US-Uaf_aligned_conc_flux_9min.zip.
flow.eval.fluxes.MBR.bootstrap.R: Computes diel averages after filtering the MBR fluxes for tracer concentrations that are close to zero.
flow.eval.plots.R: Creates linear 1 to 1 plots across all sites and bar plots of variable across all sites. Also plots light response curves for daytime CO2 vs daytime PAR for FG and EC calculated fluxes, and temperature response curves for nighttime CO2 vs nighttime air temperature for FG and EC calculated fluxes. Plots diurnal averages for all sites.
flow.flag.flux.stats.R: Runs quality flag functions and calculates residuals. Uploads to Google Drive as SITES_WP_val.Rdata, SITES_AE_val.Rdata, and SITES_MBR_val.zip.
flow.icos.data.1sec.summarize.R: Aggregates ICOS high frequency data.
- Use hierarchical naming with the active verb first, i.e. "flag.iqr.R"
- This is where all functions called by flow. scripts in Workflow Folder are stored
- Wild West, this is where preliminary functions and workflows are stored
- This is where unused workflows and functions are stored
NOTE: Feel free to contact Nick and Angel during their office hours for coding/git help
ADD LINKS TO NEON DATA PRODUCTS PAGE
- lterwg-flux-gradient-eval: Code for the evaluation paper
- lterwg-flux-gradient-methane: Code for the methane paper
LTER Scientific Computing Team website & NCEAS' Resources for Working Groups