Major Refactor - Explicit Pixel Grids & CF Dimensions - v0.1.0#275
Open
Major Refactor - Explicit Pixel Grids & CF Dimensions - v0.1.0#275
Conversation
PiperOrigin-RevId: 712905652
PiperOrigin-RevId: 712996660
Ensure shape_2d is a tuple
Member
Author
|
I see that there are conflicts, I'll work on resolving these. |
schwehr
requested changes
Nov 18, 2025
Collaborator
schwehr
left a comment
There was a problem hiding this comment.
The only blocker: Can we bring back python 3.10?
naschmitz
requested changes
Nov 18, 2025
Member
Author
Yes, I've added 3.10 back in. |
Member
Author
|
@schwehr and @naschmitz I've addressed all of the comments. Can you please take another look. |
schwehr
requested changes
Dec 17, 2025
| lon_total_tile = math.ceil(v0.shape[1] / width_chunk) | ||
| lon = self._process_coordinate_data( | ||
| lon_total_tile, width_chunk, v0.shape[1], 'x' | ||
| x_scale, _, x_translate, _, y_scale, y_translate = self.crs_transform |
Collaborator
There was a problem hiding this comment.
pytype thinks self.crs_transform can possibly be an affine.Affine with 9 parameters to unpack.
third_party/py/xee/ext.py:591:5: error: in get_variables: Cannot unpack 9 values into 6 variables [bad-unpacking]
x_scale, _, x_translate, _, y_scale, y_translate = self.crs_transform
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| """ | ||
| if isinstance(scaling, tuple) and len(scaling) == 2: | ||
| x_scale, y_scale = scaling | ||
| crs_transform[0] = x_scale |
Collaborator
There was a problem hiding this comment.
crs_transform is an immutable tuple.
xee/helpers.py:92:5: error: in set_scale: unsupported operand type(s) for item assignment: tuple[float, float, float, float, float, float] [unsupported-operands]
No attribute '__setitem__' on tuple[float, float, float, float, float, float]
crs_transform[0] = x_scale
~~~~~~~~~~~~~~~~
xee/helpers.py:93:5: error: in set_scale: unsupported operand type(s) for item assignment: tuple[float, float, float, float, float, float] [unsupported-operands]
No attribute '__setitem__' on tuple[float, float, float, float, float, float]
crs_transform[4] = y_scale
~~~~~~~~~~~~~~~~
| Raises: | ||
| TypeError: If ``scaling`` is not a length-2 tuple. | ||
| """ | ||
| if isinstance(scaling, tuple) and len(scaling) == 2: |
Collaborator
There was a problem hiding this comment.
Add this as the first line of the method:
crs_transform = list(crs_transform)
This was referenced Dec 18, 2025
Open
Closed
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.
Major Refactor - Explicit Pixel Grids & CF Dimensions
This PR represents a major refactor to the core of Xee's backend. It is merges the
simplify_pixel_grid_paramsbranch into main. Thesimplify_pixel_grid_paramshas months of changes - the significant changes to Xee API have been through review, doc changes and CI/CD Python version changes were directly pushed. The most significant changes are adopting explicit pixel grid parameters for opening datasets (see discussion) and updating the default dimension ordering to align with community standards (see discussion). After this PR is merged we should release v0.1.0 (from v0.0.x).xarray.open_datasetcalls when upgrading to this version. Please refer to the Migration Guide for detailed instructions.💥 Breaking Changes & Rationale
1. Explicit Pixel Grid Definition
The previous, heuristic-based grid definition arguments (
scale,geometry, andprojection) have been removed fromxr.open_dataset(..., engine='ee').open_datasetfunction now requires three explicit parameters to define the pixel grid:crs,crs_transform(a 6-tuple affine matrix), andshape_2d(width/height pixel count).2. CF-friendly Dimension Ordering
The default order of spatial dimensions in the resulting Xarray objects has been changed.
[time, y, x]instead of the old[time, x, y]..transpose()calls.✨ New Features & Helper Utilities
To support the new explicit grid workflow, a new
xee.helpersmodule has been added with key utilities:extract_grid_params(ee_obj): Automatically derives the requiredcrs,crs_transform, andshape_2dfrom an existingee.Imageoree.ImageCollection.fit_geometry(...): Computes the required grid parameters to cover a specificshapely.geometry(AOI) at either a fixed scale/resolution or a fixed shape/pixel count.math.floorandmath.ceilto precisely snap the grid to the bounding box extents, improving coordinate accuracy and preventing sub-pixel misalignment.📚 Documentation & Infrastructure Updates
docs/migration-guide-v0.1.0.md, has been created to assist users in updating their code to the new v0.1.0 API.concepts.md) and a User Guide (guide.md) were added to clarify the philosophy behind the pixel grid parameters and collect common workflows. The mainREADME.mdand examples have also been fully updated.3.10support was removed from all CI workflows, and the default publish environment was updated to Python3.11.📋 Checklist
PixelGridParamssignature and removed old implicit arguments.[time, y, x].extract_grid_params,fit_geometry, andset_scale.ext_integration_test.pyandext_integration_test.pypass.