Skip to content

Add rescale and standardize normalization utilities#1028

Merged
brendancol merged 6 commits into
masterfrom
issue-1027
Mar 18, 2026
Merged

Add rescale and standardize normalization utilities#1028
brendancol merged 6 commits into
masterfrom
issue-1027

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #1027.

Summary

  • rescale() does min-max normalization to a target range (default [0, 1]); standardize() does z-score normalization (subtract mean, divide by std)
  • New module xrspatial/normalize.py, all four backends (NumPy, CuPy, Dask+NumPy, Dask+CuPy) via ArrayTypeFunctionMapping
  • NaN and inf pass through unchanged, constant rasters produce 0 instead of dividing by zero, coords and attrs are preserved
  • Registered in __init__.py and .xrs accessor for DataArray and Dataset
  • 29 tests: known-value correctness, edge cases, cross-backend agreement
  • Docs added to utilities.rst, user guide notebook 33_Normalization.ipynb, README feature matrix updated

Test plan

  • pytest xrspatial/tests/test_normalize.py -- 29/29 passing
  • Verify notebook renders correctly
  • Smoke test on a real-world raster with Dask chunks

New module xrspatial/normalize.py with two functions:
- rescale: min-max normalization to a target range
- standardize: z-score normalization (mean 0, std 1)

Both support all four backends via ArrayTypeFunctionMapping.
29 tests covering NumPy, Dask, and CuPy backends. Tests include
known-value checks, NaN/inf passthrough, constant rasters, single
cells, coordinate preservation, and cross-backend agreement.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Mar 18, 2026
@brendancol brendancol merged commit 0c8f862 into master Mar 18, 2026
11 checks passed
@brendancol brendancol deleted the issue-1027 branch May 4, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add rescale and standardize normalization utilities

1 participant