xarray-subset-grid
Subset Xarray datasets in space while retaining the original grid for complex grid systems.
Installation
pip
This package is available on pypi:
python -m pip install xarray-subset-grid
conda / pixi
This package is available on conda-forge:
conda install -c conda-forge xarray-subset-grid
Usage
This package is designed to be used in conjunction with xarray.
Given a CF Compliant xarray dataset named ds, this package can be accessed using the xsg accessor:
import numpy as np
# xarray_subset_gris should detect the grid type.
# To check what it found:
grid = ds.xsg
# subsetting to include only certain variables:
# Only temperature
ds_temp = ds.xsg.subset_vars(["temp"])
# subset by bounding box
ds_subset_bbox = ds.xsg.subset_bbox([-72, 32, -70, 35])
# or by polygon
poly = np.array(
[
[-72, 32],
[-72, 33],
[-73, 33],
[-73, 31],
[-72, 32],
]
)
ds_subset_poly = ds.xsg.subset_polygon(poly)
For full usage, see the example notebooks and the Sphinx documentation on Read the Docs.
Development
pip
First, create a new virtualenv and activate it:
python -m venv venv
source venv/bin/activate # Linux and macOS
# venv\Scripts\activate # Windows cmd
# venv\Scripts\Activate.ps1 # Windows PowerShell
Then install the project in local edit mode:
pip install -e .
Once installed, the tests can be run:
python -m pytest
Or alternatively run the notebooks in the same virtualenv
pixi
Learn about pixi here: https://prefix.dev/
See the pixi docs for details, but for this setup:
There are three "environments" set up for pixi:
defaultdevexamples
And three "tasks":
linttest: run most of the teststest_all: run the tests that access AWS -- i.e. download data directly.
To run the tests in an isolated environment:
pixi run -e dev test
Or with a specific python version:
pixi run -e test312 test
Options are: test310 test311 test312 test313
To run a shell to do development work:
pixi shell -e dev
To run a shell in which you can run the examples (notebooks and all that):
pixi shell -e examples
To run a shell with everything (dev and example deps:
pixi shell -e all
Finally, when the pixi.toml file is updated,
be sure to update the pixi lockfile:
pixi update
conda
If you are using (or want to use) conda, you can install the dependencies with:
conda install --file conda_requirements.txt
That will get you the full set, including what you need to run the examples, etc.
If you need the development tools, you can also install:
conda install --file conda_requirements_dev.txt
(requirements should all be on the conda-forge channel)
Metadata
Release files for xarray-subset-grid 2026.10.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| xarray_subset_grid-2026.10.19.tar.gz | 26.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xarray_subset_grid-2026.10.19-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 53.9 kB
Release files / xarray_subset_grid-2026.10.19.tar.gz
| Download URL | xarray_subset_grid-2026.10.19.tar.gz |
|---|---|
| Size | 26.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
85b98118dac1ff8ff2be04bcdae3e1b50e0ffc8b1600f59a9cb53e5b4e4f9741
|
|
BLAKE2b-256 checksum How to use checksums |
7c470e3e197d778ce15132f239b9ded078e629d69e6253ffc12c5b6b05a95cf9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logRelease files / xarray_subset_grid-2026.10.19-py3-none-any.whl
| Download URL | xarray_subset_grid-2026.10.19-py3-none-any.whl |
|---|---|
| Size | 27.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3348fdd049334d90bd1fa9c281ef8cc8a92ef4c2b203aa36cf5fd1e0422c2d1e
|
|
BLAKE2b-256 checksum How to use checksums |
7a35fdecbadb1c640e0ee0cfe69b9d1d8d6f3f33a52dad5196513d06bdd4bc21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logSecurity for xarray-subset-grid 2026.10.19
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for xarray_subset_grid-2026.10.19.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.