cmip7: fall back to variable_id when CF detection finds zero geophysical variables#49
Open
JanStreffing wants to merge 1 commit into
Open
Conversation
…cal variables CMIP7 region-selector fx files (basin, siline, similar) carry their data variable as a CF flag-valued integer (flag_values + flag_meanings mapping integer codes to region/section names). compliance-checker's is_geophysical excludes any variable with flag_meanings from the geophysical-variable set as a heuristic for status flags. The exclusion is right for QC flags but wrong for these region selectors, whose standard_name is "region" not "status_flag", and which ARE the file's data variable by CMIP7 design. The existing variable_id disambiguation in _get_geo_var only fires when CF returned multiple candidates. When CF returns zero (the basin/siline case) the function bails with "No geophysical variable detected in the file." at HIGH severity, which blocks ESGF publication. Extend the variable_id fallback to the zero-candidate branch. If CF detection finds nothing and the global variable_id attribute names an existing variable, accept that variable as the file's geophysical variable. The strict CF heuristic stays as the primary path; the fallback only kicks in when both (a) CF found zero candidates AND (b) the CMIP7-canonical variable_id attribute is present.
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.
Closes #48.
CMIP7 region-selector fx files (
basin,siline, similar) carry their data variable as a CF flag-valued integer (flag_values+flag_meaningsmapping integer codes to region/section names).compliance_checker.cf.util.is_geophysicalexcludes any variable withflag_meaningsfrom the geophysical-variable set as a heuristic for status flags. The exclusion is right for QC flags but wrong for these region selectors, whosestandard_nameisregionnotstatus_flag, and which ARE the file's data variable by CMIP7 design.The existing
variable_iddisambiguation in_get_geo_varonly fires when CF returned multiple candidates. When CF returns zero (the basin/siline case) the function bails with "No geophysical variable detected in the file." at HIGH severity, which blocks ESGF publication.This PR extends the
variable_idfallback to the zero-candidate branch. If CF detection finds nothing and the globalvariable_idattribute names an existing variable, accept that variable as the file's geophysical variable. The strict CF heuristic stays as the primary path; the fallback only kicks in when both (a) CF found zero candidates AND (b) the CMIP7-canonicalvariable_idattribute is present.Verified locally against an AWI-ESM3-4-2-veg-HR basin fx file (CMIP7
basin.ti-u-hxy-u.fx.glb). Pre-patch: HIGH "No geophysical variable detected in the file." Post-patch: pass.