Skip to content

Conversation

@Akash-paluvai
Copy link
Contributor

Description

This PR extracts the AmeriFlux CF data coverage checks (radiation and soil moisture)
from AmeriFlux_met_ensemble() into a dedicated helper function.

The new helper centralizes logic for:

  • detecting variable presence
  • computing coverage fractions
  • determining which ERA5 variables are required for fallback

No functional behavior is changed; this is a pure refactor to reduce duplication
and improve readability and maintainability.

Motivation and Context

This change is a first, intentionally limited refactor step toward the modular
AmeriFlux workflow described in #3605, following suggestions from #3586.

By isolating coverage checks into a reusable helper, subsequent work (e.g.
metgapfill fallback wiring and met.process() integration) can build on a
well-defined and testable component without re-implementing logic.

Related issue:

Review Time Estimate

  • Immediately
  • Within one week
  • When possible

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking refactor introducing a reusable helper)
  • Breaking change

Checklist:

  • My change requires a change to the documentation.
  • My name is in the list of CITATION.cff
  • I agree that PEcAn Project may distribute my contribution under any or all of
    • the same license as the existing code,
    • and/or the BSD 3-clause license.
  • I have updated the CHANGELOG.md.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

}

nc <- ncdf4::nc_open(cf_file)
on.exit(ncdf4::nc_close(nc), add = TRUE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the on.exit -- this is a nice upgrade!!

@infotroph infotroph added this pull request to the merge queue Jan 7, 2026
Merged via the queue into PecanProject:develop with commit 2fae0b3 Jan 7, 2026
19 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants