-
Notifications
You must be signed in to change notification settings - Fork 39
Major Refactor - Explicit Pixel Grids & CF Dimensions - v0.1.0 #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jdbcode
wants to merge
50
commits into
main
Choose a base branch
from
simplify_pixel_grid_params
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
b4ec234
Add ability to open ee.Image objects
tylere afaa9c5
End docstring with punctuation
tylere c2e2a9f
Expose __version__ as module attribute
tylere fd9e20a
Add install docs
jdbcode 5fac43a
Account for mask byte in chunk size calculation
jdbcode 3c34816
ignore temp directory
tylere 4ba0259
Merge branch 'main' into simplify_proj_params
tylere c107bca
Add pixi config files
tylere 0dbd250
limit to python<3.13; add proj, gdal as dependencies
tylere fd2b255
Use grid params (crs, crs_transform, shape_2d)
tylere 2cda1b9
Merge branch 'simplify_proj_params' into simplify_proj_params
tylere dab7297
Remove helper placeholders
tylere 68d7a46
Update README code and add tests
tylere 97a3814
Double to single quotes.
tylere c4da199
Remove unnecessary import and print
tylere 4566716
Clean up TransformType type definition
tylere 5b5a75f
Add type hints.
tylere 6419d93
Revert .gitattributes change
tylere b52f630
Revert .gitignore changes
tylere 82407de
Revert .vscode/settings.json
tylere 3044fce
Remove pixi config
tylere 0228871
Remove extra print statement
tylere 9770fae
Change strings from double to single quotes
tylere 68c1905
Switch back to double quotes to enclose single quote
tylere d661309
Remove match/case syntax
tylere addc823
refactor: Use `affine` directly instead of `rasterio.transform.Affine`
jdbcode 4c0a799
refactor: Make `shapely` a require dependency
jdbcode e32843e
refactor: Add support for accepting `affine.Affine` object as `crs_tr…
jdbcode 1d866b8
refactor: Make `crs_transform` an attribute of `self` for reuse
jdbcode cf48661
fix: Handle negative and positive y scale in `fit_geometry`
jdbcode 0a54b45
fix: Fix tests so that tuple is used (requried type for crs_transform…
jdbcode c215fac
refactor: Update readme to use tuple for shape and transform, add det…
jdbcode a9ab143
Merge pull request #225 from tylere/simplify_proj_params
naschmitz 72f81cb
Merge remote-tracking branch 'origin/main' into simplify_pixel_grid_p…
jdbcode edde469
`pyupgrade --py39-plus` following commit 625cbba
jdbcode 0daf958
Drop Python 3.8 following commit 34adc13
jdbcode ca9691a
Fix additional typing that pyupgrade missed (?)
jdbcode 55bb162
Change dimension ordering from (time, x, y) to (time, y, x) (#274)
jdbcode be0df9d
Update examples to new API for grid parameters and remove unnecessary…
jdbcode 2f7952b
Update and improve docs
jdbcode 367ff76
Update documentation for breaking changes in v0.1.0 and migration guide
jdbcode a9b14f0
Refactor breaking change notice in README files for GH MD format
jdbcode 1f251ce
Fix formatting of breaking change notice in documentation
jdbcode d84b103
Update Sphinx configuration for improved navigation and remove migrat…
jdbcode a9ab5ec
Drop Python version support for 3.9 and 3.10
jdbcode 41c33c2
Update contributing guidelines to include test running instructions
jdbcode 7cecc13
Merge branch 'main' into simplify_pixel_grid_params
jdbcode ca2c03c
Fix mangled conflict resolution
jdbcode b126dbb
Ran pyink to format files to pass lint checks
jdbcode 07c2323
[fix comments] README.md
jdbcode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,6 @@ jobs: | |
| fail-fast: false | ||
| matrix: | ||
| python-version: [ | ||
| "3.10", | ||
| "3.11", | ||
| "3.12", | ||
| "3.13", | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,4 +130,4 @@ cython_debug/ | |
| .DS_Store | ||
|
|
||
| # pixi environments | ||
| .pixi | ||
| .pixi | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,165 +1,82 @@ | ||
| > **⚠️ Breaking Change in v0.1.0** | ||
| > | ||
| > A major refactor was released in v0.1.0, introducing breaking changes to the Xee API. In most cases, existing code written for pre-v0.1.0 versions will require updates to remain compatible. | ||
| > | ||
| > - See the [Migration Guide](docs/migration-guide-v0.1.0.md) for details on updating your code. | ||
| > - If you need more time to migrate, you can pin your environment to the latest pre-v0.1.0 release. | ||
|
|
||
| # Xee: Xarray + Google Earth Engine | ||
|
|
||
|  | ||
|
|
||
| _An Xarray extension for Google Earth Engine._ | ||
| Xee is an Xarray backend for Google Earth Engine. Open `ee.Image` / `ee.ImageCollection` objects as lazy `xarray.Dataset`s and analyze petabyte‑scale Earth data with the scientific Python stack. | ||
|
|
||
| [](https://pypi.python.org/pypi/xee) | ||
| [](https://pepy.tech/project/xee) | ||
| [](https://github.com/conda-forge/xee-feedstock) | ||
| [](https://github.com/conda-forge/xee-feedstock) | ||
| [](https://anaconda.org/conda-forge/xee) | ||
| [](https://anaconda.org/conda-forge/xee) | ||
|
|
||
| ## How to use | ||
| [](https://anaconda.org/conda-forge/xee) | ||
|
|
||
| Install with pip: | ||
| ## Install | ||
|
|
||
| ```shell | ||
| ```bash | ||
| pip install --upgrade xee | ||
| ``` | ||
|
|
||
| Install with conda: | ||
| or | ||
|
|
||
| ```shell | ||
| ```bash | ||
| conda install -c conda-forge xee | ||
| ``` | ||
|
|
||
| Then, authenticate Earth Engine: | ||
|
|
||
| ```shell | ||
| earthengine authenticate --quiet | ||
| ``` | ||
|
|
||
| Now, in your Python environment, make the following imports: | ||
| ## Minimal example | ||
|
|
||
| ```python | ||
| import ee | ||
| import xarray | ||
| ``` | ||
|
|
||
| Next, specify your EE-registered cloud project ID and initialize the EE client | ||
| with the high volume API: | ||
|
|
||
| ```python | ||
| ee.Initialize( | ||
| project='my-project-id' | ||
| opt_url='https://earthengine-highvolume.googleapis.com') | ||
| ``` | ||
|
|
||
| Open any Earth Engine ImageCollection by specifying the Xarray engine as `'ee'`: | ||
|
|
||
| ```python | ||
| ds = xarray.open_dataset('ee://ECMWF/ERA5_LAND/HOURLY', engine='ee') | ||
| ``` | ||
|
|
||
| Open all bands in a specific projection (not the Xee default): | ||
|
|
||
| ```python | ||
| ds = xarray.open_dataset('ee://ECMWF/ERA5_LAND/HOURLY', engine='ee', | ||
| crs='EPSG:4326', scale=0.25) | ||
| ``` | ||
|
|
||
| Open an ImageCollection (maybe, with EE-side filtering or processing): | ||
|
|
||
| ```python | ||
| ic = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate( | ||
| '1992-10-05', '1993-03-31') | ||
| ds = xarray.open_dataset(ic, engine='ee', crs='EPSG:4326', scale=0.25) | ||
| ``` | ||
|
|
||
| Open an ImageCollection with a specific EE projection or geometry: | ||
|
|
||
| ```python | ||
| ic = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate( | ||
| '1992-10-05', '1993-03-31') | ||
| leg1 = ee.Geometry.Rectangle(113.33, -43.63, 153.56, -10.66) | ||
| ds = xarray.open_dataset( | ||
| ic, | ||
| engine='ee', | ||
| projection=ic.first().select(0).projection(), | ||
| geometry=leg1 | ||
| ) | ||
| ``` | ||
|
|
||
| Open multiple ImageCollections into one `xarray.Dataset`, all with the same | ||
| projection: | ||
| import xarray as xr | ||
| from xee import helpers | ||
|
|
||
| ```python | ||
| ds = xarray.open_mfdataset( | ||
| ['ee://ECMWF/ERA5_LAND/HOURLY', 'ee://NASA/GDDP-CMIP6'], | ||
| engine='ee', crs='EPSG:4326', scale=0.25) | ||
| ``` | ||
|
|
||
| Open a single Image by passing it to an ImageCollection: | ||
|
|
||
| ```python | ||
| i = ee.ImageCollection(ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318')) | ||
| ds = xarray.open_dataset(i, engine='ee') | ||
| ``` | ||
| # Authenticate once (on a persistent machine): | ||
| # earthengine authenticate | ||
|
|
||
| Open any Earth Engine ImageCollection to match an existing transform: | ||
| project = 'PROJECT-ID' # Set your Earth Engine registered Google Cloud project ID | ||
| # Initialize (high‑volume endpoint recommended for reading stored collections) | ||
| ee.Initialize(project=project, opt_url='https://earthengine-highvolume.googleapis.com') | ||
|
|
||
| ```python | ||
| raster = rioxarray.open_rasterio(...) # assume crs + transform is set | ||
| ds = xr.open_dataset( | ||
| 'ee://ECMWF/ERA5_LAND/HOURLY', | ||
| engine='ee', | ||
| geometry=tuple(raster.rio.bounds()), # must be in EPSG:4326 | ||
| projection=ee.Projection( | ||
| crs=str(raster.rio.crs), transform=raster.rio.transform()[:6] | ||
| ), | ||
| ) | ||
| # Open a dataset by matching its native grid | ||
jdbcode marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ic = ee.ImageCollection('ECMWF/ERA5_LAND/MONTHLY_AGGR') | ||
| grid = helpers.extract_grid_params(ic) | ||
| ds = xr.open_dataset(ic, engine='ee', **grid) | ||
| print(ds) | ||
jdbcode marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| See [examples](https://github.com/google/Xee/tree/main/examples) or | ||
| [docs](https://github.com/google/Xee/tree/main/docs) for more uses and | ||
| integrations. | ||
|
|
||
| ## Getting help | ||
| Next steps: | ||
|
|
||
| If you encounter issues using Xee, you can: | ||
| - Quickstart: docs/quickstart.md | ||
| - Concepts (grid params, CRS, orientation): docs/concepts.md | ||
| - User Guide (workflows): docs/user-guide.md | ||
|
|
||
| 1. Open a new or add to an existing [Xee discussion | ||
| topic](https://github.com/google/Xee/discussions) | ||
| 2. Open an [Xee issue](https://github.com/google/Xee/issues). To increase the | ||
| likelihood of the issue being resolved, use this [template Colab | ||
| notebook](https://colab.research.google.com/drive/1vAgfAPhKGJd4G9ZUOzciqZ7MbqJjlMLR) | ||
| to create a reproducible script. | ||
| ## Features | ||
|
|
||
| ## How to run integration tests | ||
| - Lazy, parallel pixel retrieval through Earth Engine | ||
| - Flexible output grid definition (fixed resolution or fixed shape) | ||
| - CF-friendly dimension order: `[time, y, x]` | ||
| - Plays nicely with Xarray, Dask, and friends | ||
|
|
||
| The Xee integration tests only pass on Xee branches (no forks). Please run the | ||
| integration tests locally before sending a PR. To run the tests locally, | ||
| authenticate using `earthengine authenticate` and run the following: | ||
| ## Community & Support | ||
|
|
||
| ```bash | ||
| python -m unittest xee/ext_integration_test.py | ||
| ``` | ||
| - Discussions: https://github.com/google/Xee/discussions | ||
| - Issues: https://github.com/google/Xee/issues | ||
|
|
||
| or | ||
| ## Contributing | ||
|
|
||
| ```bash | ||
| python -m pytest xee/ext_integration_test.py | ||
| ``` | ||
| See docs/contributing.md and sign the required CLA. | ||
|
|
||
| ## License | ||
|
|
||
| This is not an official Google product. | ||
|
|
||
| ``` | ||
| Copyright 2023 Google LLC | ||
| [Apache 2.0](LICENSE) | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
| `SPDX-License-Identifier: Apache-2.0` | ||
|
|
||
| https://www.apache.org/licenses/LICENSE-2.0 | ||
| This is not an official Google product. | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| ``` | ||
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Xee Documentation (source files) | ||
|
|
||
| > **⚠️ Breaking Change in v0.1.0** | ||
| > | ||
| > A major refactor was released in v0.1.0, introducing breaking changes to the Xee API. In most cases, existing code written for pre-v0.1.0 versions will require updates to remain compatible. | ||
| > | ||
| > - See the [Migration Guide](migration-guide-v0.1.0.md) for details on updating your code. | ||
| > - If you need more time to migrate, you can pin your environment to the latest pre-v0.1.0 release. | ||
|
|
||
| ## For nicely rendered documentation | ||
|
|
||
| Visit **Read the Docs**: https://xee.readthedocs.io/en/latest/ | ||
|
|
||
| ## About this folder | ||
|
|
||
| This `docs/` folder contains the source files used to build the documentation site with Sphinx and MyST. | ||
|
|
||
| If you're browsing on GitHub: | ||
| - Start from [`index.md`](index.md) for the documentation landing page | ||
| - Or build the docs locally (see below) | ||
|
|
||
| ## Build locally (optional) | ||
|
|
||
| ```bash | ||
| cd docs | ||
| make html | ||
| open _build/html/index.html # or xdg-open on Linux | ||
| ``` | ||
|
|
||
| ## Project information | ||
|
|
||
| For project overview and repository information, see the root [`README.md`](../README.md). |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| xee.EarthEngineBackendArray | ||
| =========================== | ||
|
|
||
| .. currentmodule:: xee | ||
|
|
||
| .. autoclass:: EarthEngineBackendArray | ||
|
|
||
|
|
||
| .. automethod:: __init__ | ||
|
|
||
|
|
||
| .. rubric:: Methods | ||
|
|
||
| .. autosummary:: | ||
|
|
||
| ~EarthEngineBackendArray.__init__ | ||
| ~EarthEngineBackendArray.async_get_duck_array | ||
| ~EarthEngineBackendArray.async_getitem | ||
| ~EarthEngineBackendArray.get_duck_array | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| .. rubric:: Attributes | ||
|
|
||
| .. autosummary:: | ||
|
|
||
| ~EarthEngineBackendArray.ndim | ||
| ~EarthEngineBackendArray.size | ||
|
|
||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| xee.EarthEngineBackendEntrypoint | ||
| ================================ | ||
|
|
||
| .. currentmodule:: xee | ||
|
|
||
| .. autoclass:: EarthEngineBackendEntrypoint | ||
|
|
||
|
|
||
| .. automethod:: __init__ | ||
|
|
||
|
|
||
| .. rubric:: Methods | ||
|
|
||
| .. autosummary:: | ||
|
|
||
| ~EarthEngineBackendEntrypoint.__init__ | ||
| ~EarthEngineBackendEntrypoint.guess_can_open | ||
| ~EarthEngineBackendEntrypoint.open_dataset | ||
| ~EarthEngineBackendEntrypoint.open_datatree | ||
| ~EarthEngineBackendEntrypoint.open_groups_as_dict | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| .. rubric:: Attributes | ||
|
|
||
| .. autosummary:: | ||
|
|
||
| ~EarthEngineBackendEntrypoint.description | ||
| ~EarthEngineBackendEntrypoint.open_dataset_parameters | ||
| ~EarthEngineBackendEntrypoint.supports_groups | ||
| ~EarthEngineBackendEntrypoint.url | ||
|
|
||
|
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great that 3.9 is out, but 3.10? I see it documented in the PR description, but we still need to support 3.10 in ee and geemap until 2026-10.
https://devguide.python.org/versions/