Preserve input float dtype through resample() (#1467)#1476
Conversation
resample() now picks its working dtype from the input: float64 in, float64 out; float32 in, float32 out; integer in, float32 out (since NaN-sentinel resampling needs a float type). Previously every input was cast to float64 internally and every output forced to float32, which silently dropped precision for float64 rasters. The four backend runners and their dask block helpers thread the working/output dtypes through. _maybe_astype skips the copy when the array already has the desired dtype. The aggregation kernels (numba @ngjit) keep their hardcoded float64 working buffer -- they accumulate in float64 and the runner casts the result down at the end, which is cheap and matches the existing behaviour for float32 aggregation accuracy.
|
@copilot resolve the merge conflicts in this pull request |
…nlined dask kernels Co-authored-by: brendancol <433221+brendancol@users.noreply.github.com>
…licts Agent-Logs-Url: https://github.com/xarray-contrib/xarray-spatial/sessions/8246524b-ac66-4574-97b1-9f97fbe38126 Co-authored-by: brendancol <433221+brendancol@users.noreply.github.com>
Agent-Logs-Url: https://github.com/xarray-contrib/xarray-spatial/sessions/8246524b-ac66-4574-97b1-9f97fbe38126 Co-authored-by: brendancol <433221+brendancol@users.noreply.github.com>
Resolved. The merge with
All 112 tests pass (commit |
|
@copilot resolve the merge conflicts in this pull request |
… inf, dimension, and reproducibility tests Co-authored-by: brendancol <433221+brendancol@users.noreply.github.com>
Resolved again (commit
All 127 tests pass. |
Summary
resample()picks its working dtype from the input instead of forcing float64 in / float32 out. float64 in keeps float64; float32 in keeps float32; integer / bool in returns float32 (NaN-sentinel resampling needs a float type).@ngjit) keep a hardcoded float64 accumulator internally; the runner casts the result to the output dtype at the end. That keeps existing float32 aggregation accuracy and avoids re-specialising the kernels.Closes #1467.
Test plan
nodataparameter being present and skips otherwise (will activate once that parameter lands).