Feature/area as input to spatial#112
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for passing a simple bounding-box area dictionary into the spatial aggregation APIs, allowing users to call spatial.mask/spatial.reduce without constructing a GeoDataFrame manually.
Changes:
- Introduces an
area→GeoDataFrame conversion helper and decorator to wirearea=intospatial.maskandspatial.reduce. - Adds unit tests for
area=behavior and mutual-exclusion rules withgeodataframe. - Updates spatial how-to docs and concepts documentation to describe and demonstrate
area=usage.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/earthkit/transforms/spatial/_aggregate.py |
Adds _area_to_geodataframe and a decorator to translate area= into geodataframe= for mask/reduce. |
tests/test_30_spatial.py |
Adds test coverage for area= conversions, masking/reduction behavior, and argument validation. |
docs/source/how-tos/spatial/index.rst |
Updates the spatial how-to toctree to include new/renamed notebooks. |
docs/source/how-tos/spatial/howto_spatial_mean_era5_geometry.ipynb |
Adds a notebook demonstrating the area= (bounding box) workflow. |
docs/source/how-tos/spatial/howto_spatial_mean_era5_area.ipynb |
Updates the geometry-based spatial-mean notebook title/intro. |
docs/source/concepts/spatial.rst |
Documents area= as an alternative to geodataframe for mask/reduce. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/earthkit/transforms/spatial/_aggregate.py:351
- When
areais provided alongsidemask_arrays(e.g.reduce(..., mask_arrays=..., area=...)), the decorator convertsareainto an implicitgeodataframe, causing the later assertion to fail with "Either a geodataframe or mask arrays must be provided, not both". This message is confusing because the caller did not explicitly pass a geodataframe. It would be clearer to detectmask_arraysin the decorator and raise a dedicatedValueErrorindicating thatareacannot be combined withmask_arrays.
if area is not None and geodataframe is not None:
raise ValueError("Only one of 'area' or 'geodataframe' may be provided, not both.")
if area is not None:
kwargs["geodataframe"] = _area_to_geodataframe(area)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/ecmwf/earthkit-transforms/sessions/c3caafdf-dc7c-4612-b4c9-5380d8335e4c Co-authored-by: EddyCMWF <53045993+EddyCMWF@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Description
Contributor Declaration
By opening this pull request, I affirm the following: