reproject: fix vertical_crs shift on dask, cupy, and 3-D inputs (#2025)#2029
Open
brendancol wants to merge 1 commit into
Open
reproject: fix vertical_crs shift on dask, cupy, and 3-D inputs (#2025)#2029brendancol wants to merge 1 commit into
brendancol wants to merge 1 commit into
Conversation
The vertical datum shift inside reproject() only worked on the 2-D in-memory numpy path. Three valid input shapes crashed: - dask arrays: boolean fancy-index __setitem__ is unsupported, so the per-strip update raised ValueError. - cupy arrays: the Numba JIT geoid lookup only accepts numpy buffers, so the call raised TypeError. - 3-D (y, x, band) results: the per-strip is_valid mask was 2-D while the strip slice was 3-D, raising a broadcasting ValueError. Restructure _apply_vertical_shift into a dispatcher that: - routes dask inputs through map_blocks so each chunk is shifted in place and the output stays lazy; - moves cupy inputs to host, shifts, and returns a cupy array; - loops over band slices for 3-D shapes so the same N(y, x) is applied to every band. The numpy path is otherwise unchanged. Add tests covering all three previously-broken cases. Also record the audit on the deep-sweep accuracy state CSV.
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
reproject(..., src_vertical_crs=..., tgt_vertical_crs=...)on dask, cupy, and 3-D multi-band inputs. Each used to crash before producing output.map_blocksso the output stays lazy and the per-chunk shift is computed from each block's row/column slab.(y, x, band)results so the same N(y, x) correction applies to every band.Test plan
python -m pytest xrspatial/tests/test_reproject.py— 245 passed locally.TestVerticalShift::test_dask_backend_matches_numpyconfirms dask path matches numpy bit-for-bit and keeps the result lazy.TestVerticalShift::test_multiband_3d_applies_shift_per_bandconfirms each band sees the same geoid undulation correction and band 0 equals the 2-D reference.TestVerticalShift::test_cupy_backend_matches_numpyconfirms the vertical-shift increment matches numpy on cupy backend (gated oncupybeing importable).