feat: add ERA5 CDS ↔ CF variable name mapping utility#3922
feat: add ERA5 CDS ↔ CF variable name mapping utility#3922Akash-paluvai wants to merge 2 commits intoPecanProject:developfrom
Conversation
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) |
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( |
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.
…table-based era5_cds column
Thanks @dlebauer — I’ve updated the PR based on your suggestions. Moving this into Changes made
Notes
|
|
I’m happy to keep it internal instead if you’d prefer to limit the public API surface for now. |
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: