feat: add ERA5 CDS ↔ CF variable name mapping utility#3922
Open
Akash-paluvai wants to merge 1 commit intoPecanProject:developfrom
Open
feat: add ERA5 CDS ↔ CF variable name mapping utility#3922Akash-paluvai wants to merge 1 commit intoPecanProject:developfrom
Akash-paluvai wants to merge 1 commit intoPecanProject:developfrom
Conversation
dlebauer
requested changes
Apr 14, 2026
Member
dlebauer
left a comment
There was a problem hiding this comment.
@Akash-paluvai thank you for this contribution. It occurs to me that this would a good chance to make a general mapping function; see comments.
| paste(unknown, collapse = ", "), | ||
| "returning NA for those entries" | ||
| ) | ||
| warning(msg, call. = FALSE) |
Member
There was a problem hiding this comment.
only the PEcAn.logger call is required, it will pass to the appropriate function (warning in this case). and it handles the outer paste internally (the inner one with collapse = may need to stay.
| #' included. Variables not listed here are not handled by this pipeline. | ||
| #' | ||
| #' @noRd | ||
| era5_cds_to_cf_varnames <- c( |
Member
There was a problem hiding this comment.
Please let me know if this doesn't make sense, but it seems like it would be simpler and more generally useful to
- add a new col
era5_cdsto https://github.com/PecanProject/pecan/blob/develop/modules/data.atmosphere/R/pecan_standard_met_table.R and - create a generic lookup function (see below)
- then update the code as needed?
translate_met_varnames <- function(vars, from, to, table = pecan_standard_met_table) {
lookup <- table |>
dplyr::select(dplyr::all_of(c(from, to))) |>
dplyr::filter(!is.na(.data[[from]]), .data[[from]] != "")
result <- lookup[[to]]
names(result) <- lookup[[from]]
result[vars]
}then if it is useful (not clear if it is, but simple enough), developers can create <from>_to_<to>_varnames. functions as needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces an internal ERA5 CDS to CF variable name translation utility and updates the AmeriFlux coverage workflow to use it.
Previously, CDS variable names (used for ERA5 download) and CF standard names (used in NetCDF files) were not aligned. This mismatch caused silent failures in downstream coalescing, where missing values were not filled even when ERA5 fallback was required.
This PR adds an explicit mapping layer and ensures both naming conventions are available and correctly used within the workflow.
Motivation and Context
Fixes silent failure in ERA5 fallback preparation (see #3605).
Previously:
This PR ensures:
Review Time Estimate
Types of changes
Checklist: