How noaa-gml/rtorf works
Project Type & Purpose
• Type: An R package (“rtorf”) that provides functions to summarize, read, process, aggregate, and plot greenhouse-gas observation files (NetCDF, CSVY).
• Purpose: Offer a pipeline of R functions, powered by data.table and ncdf4, to ingest ObsPack data, manipulate time metadata, compute footprints, and generate summaries and visualizations.
File Structure
• R/ directory: Core R functions in numbered sequence (01_summary_obs.R … 10_obs_hysplit.R), plus utility modules (helpers.R, class.R).
• man/: Auto-generated .Rd documentation files for each exported function.
• vignettes/ & examples/: Usage tutorials and example scripts producing HTML reports.
• inst/data-raw/: Raw sample data file.
• pkgdown/, .github/workflows/: Documentation site config and CI pipelines.
• DESCRIPTION, NAMESPACE: Package metadata and exports.
• README.Rmd / README.md: High-level overview, installation, basic usage.
• NEWS.md, LICENSE: Release notes and license.
README Insights
• Dependencies: data.table (in-memory table ops) and ncdf4 (C-level NetCDF I/O).
• Key workflow:
1. obs_summary() – index & categorize files
2. obs_read()/obs_read_nc() – ingest data
3. obs_addtime()/obs_roundtime() – timestamp processing
4. obs_aggregate()/obs_meta()/obs_table() – compute aggregates & metadata
5. obs_hysplit_* – integrate HYSPLIT footprint commands
6. obs_plot() – visualization
Main Components & Their Interactions
a. User Interface
– R Console / scripts call exported functions in rtorf.
– Vignettes / examples illustrate typical workflows.
b. Core Processing Layer
– Modules in R/:
• Summary & indexing (01_summary_obs.R)
• File readers (02_read_obs.R, obs_read_nc…)
• Time manipulators (03_addtime_obs.R)
• Aggregators & metadata (04_aggregate_obs.R, 07_meta_obs.R)
• Footprint integration (09_obs_hysplit.R)
• Plotting (08_plot.R) & table outputs (09_obs_table.R)
– Utilities and class definitions (helpers.R, class.R).
c. Data Sources
– NOAA ObsPack archives on disk or network (NetCDF files).
– inst/data-raw sample dataset.
d. External Libraries & Services
– data.table: fast in-memory tabular ops.
– ncdf4: C-level NetCDF read/write.
– HYSPLIT CLI (optional external footprint program).
e. Documentation & CI
– man/: Rd pages generated via roxygen2.
– pkgdown/: static site generator for online docs.
– GitHub Actions workflows: R-CMD-check, pkgdown deploy, coverage.
1. User → Core functions (API calls)
2. Core functions → data.table / ncdf4 libraries
3. Libraries → ObsPack files (read I/O)
4. Core functions → processed data objects (data.tables)
5. Processed data → plot outputs / tables / user workspace
6. pkgdown & man ← Core functions (documentation generation)
7. GitHub Actions → Repo (CI, build, deploy docs)
Architectural Patterns & Design Principles
• Modular, function-centric design: each R script implements one logical step.
• Layered separation:
– Data ingestion → transformation → analysis → visualization.
• Extensibility:
– New obs_read_* or obs_hysplit_* functions can be added.
• Lightweight dependency footprint: only data.table & ncdf4.