How qepanna/goflux works
Main Components
• Data Input/Acquisition: This includes raw data files (present in inst/extdata and data directories). These files represent the outputs from various instruments (e.g. LI-COR, Los Gatos UGGA, Picarro instruments, etc.).
• Import Module: Represented by many R scripts in the R directory (e.g., various *_import.R files, functions like imp.UGGA-data.R, import2RData.R). They parse the raw instrument data into a standardized in-memory format (most likely R data frames).
• Flux Calculation Module: Contains the main function goFlux and related calculation routines (use of LM and HM models, kappa and flux term calculations, etc.) defined in scripts like goFlux.R and goFlux-package.R.
• Best Flux Selection Module: Functions such as best.flux.R along with diagnostic functions (g.factor, intercept checking, number of observations, etc.) which compare indices (MAE, RMSE, AICc, SE) and determine the “best” flux estimate.
• Visualization Module: Handled by scripts like flux.plot.R and flux2pdf.R, which are used to generate plots and PDF outputs for visual inspection.
• Quality Control & Diagnostics: Interwoven in the calculations with warnings and “diagnose” outputs based on criteria (MDF, p-value, kappa ratios, etc.). These internal checks could be highlighted as part of the flux calculation and evaluation modules.
• External Dependencies: The package relies on many external R packages (dplyr, ggplot2, AICcmodavg, msm, etc.) which could be shown as an “external dependency” node linking into the core functions.
• Continuous Integration / Build: The existence of .github and .Rbuildignore files indicates automated testing and building workflows that integrate with platforms such as GitHub Actions.
• Documentation and Publication: Components like README.md, man, and paper suggest that user guidance and technical documentation are integrated parts of the overall design.
Data Flow and Relationships
• The output of the Import Module feeds into the “Flux Calculation Module” where two parallel calculation paths occur: the LM (linear) calculation path and the HM (non-linear) calculation path.
• Both flux estimation outputs then flow into the “Best Flux Selection Module” where statistical indices and diagnostics (g-factor, kappa ratios, AICc etc.) are compared.
• The selected best flux result and potentially the diagnostic outputs then feed into the “Visualization Module” to generate plots and reports.
• In parallel, quality control checks with warnings act as side outputs that inform the user of any limitations (e.g., low number of observation warnings, intercept deviation).
Architectural Patterns and Design Principles
• Extensibility: By supporting multiple instruments and different calculation methods, the design clearly uses “plug-and-play” style: new import modules or flux evaluation criteria can be added easily.
• Integration with External Tools: Integration with other R packages and automated testing (via GitHub workflows) indicates adherence to best practices in software development.
• Functional Organization: Each script in the R directory encapsulates a single functional routine (either importing data from one instrument type, performing model fitting, or plotting), which is characteristic of a functionally decomposed architecture.
Additional Details to Capture
• That the package supports both manual measurement identification and automatic selection of measurement windows as part of the import and processing flows.
• Documentation as a parallel path or “monitor” process where output is continuously updated (man, paper, README).