Fix icesat2_vertical_datum config being silently ignored by globato - #35
Merged
Conversation
_process_h5_to_nc() was passing an EPSG code string (e.g. "EPSG:4979") as globato.read()'s vertical_datum kwarg. globato's ICESat2Reader only recognizes the literal strings "ellipsoid", "ellipsoid-mean-tide", "geoid", "geoid-mean-tide", and silently falls back to "ellipsoid" for anything else -- so IVERT's icesat2_vertical_datum config setting had no effect on the heights globato actually produced, regardless of whether "ellipsoid" or "geoid" was configured. Add an explicit EPSG-to-globato-literal lookup and use it at the globato.read() call site, with a ValueError if the EPSG code has no known mapping, or if the mapped literal isn't one globato's reader currently accepts (guards against the lookup silently going stale if globato's vocabulary changes upstream).
Collaborator
Author
|
Codacy dependency will be removed. Passed all other checks. |
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.
Summary
_process_h5_to_nc()passed an EPSG code string ("EPSG:4979"/"EPSG:3855") as globato.read()'svertical_datumkwarg.ICESat2Readeronly recognizes the literal strings"ellipsoid","ellipsoid-mean-tide","geoid","geoid-mean-tide", and silently falls back to"ellipsoid"for anything else instead of raising.icesat2_vertical_datumconfig setting had no effect on the heights globato actually produced — you always got ellipsoid heights back, regardless of what was configured, while the database/granule metadata could still claimEPSG:3855(geoid) if that's what was requested.Found while tracking down a separate bug (continuous-dems/globato#127) where bathy_floor photon heights came out geoid-referenced regardless of requested datum — that turned out to be a different bug inside globato itself, but investigating it surfaced this one in IVERT's own call site.
Fix
_EPSG_TO_GLOBATO_VERTICAL_DATUM, an explicit lookup from IVERT's EPSG-code representation to globato's accepted literal strings._vertical_epsg_to_globato_datum(), which does the lookup and raisesValueErrorif the EPSG code has no known mapping, or if the mapped literal isn't one globato's reader currently accepts (checked against_GLOBATO_ACCEPTED_VERTICAL_DATUMS, kept separate so a future change to globato's vocabulary is caught explicitly instead of silently mis-mapping again)._process_h5_to_nc()now calls this at theglobato.read()call site instead of passing the EPSG string straight through. The EPSG-code representation is unchanged everywhere else (config validation, database/granule metadata storage).