Subset Xarray datasets in time and space
Project description
xarray-subset-grid
Subset Xarray datasets in space while retaining the original grid for complex grid systems.
Installation
pip compatible
This package is available on pypi:
python -m pip install xarray-subset-grid
And also 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:
# Get the interprested grid class
grid = ds.xsg
# subset to only include 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
Development
pip compatible
First, create a new virtualenv and activate it:
python -m venv venv
source venv/bin.activate
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 dev work:
pixi shell -e dev
To run a shell in which you can run the examples (notebooks and al that):
pixi shell -e examples
To run a shell with everything (dev and example deps:
pixi shell -e all
Finally, to when the pyproject.toml is updated, be sure to update the pixi lockfile:
pixi install
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xarray_subset_grid-0.1.1.tar.gz.
File metadata
- Download URL: xarray_subset_grid-0.1.1.tar.gz
- Upload date:
- Size: 204.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
983c24983ca230e5a8ad7f21bf669e8d51bc10a51045602ad37b1886a2baffb3
|
|
| MD5 |
1b7985be6cb66591d47f73bc07b8aa7c
|
|
| BLAKE2b-256 |
e5fcdee7c6e5e61e2233c5cd7ff3ec2b9638c6a644ef8cf724b49ce36624f4f5
|
Provenance
The following attestation bundles were made for xarray_subset_grid-0.1.1.tar.gz:
Publisher:
pypi.yml on ioos/xarray-subset-grid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xarray_subset_grid-0.1.1.tar.gz -
Subject digest:
983c24983ca230e5a8ad7f21bf669e8d51bc10a51045602ad37b1886a2baffb3 - Sigstore transparency entry: 942032825
- Sigstore integration time:
-
Permalink:
ioos/xarray-subset-grid@121df694f96aab8fce4a5ca09b1c1509e31a737c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ioos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@121df694f96aab8fce4a5ca09b1c1509e31a737c -
Trigger Event:
release
-
Statement type:
File details
Details for the file xarray_subset_grid-0.1.1-py3-none-any.whl.
File metadata
- Download URL: xarray_subset_grid-0.1.1-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ba8628c7751070a1cd30463d6f6aa03daecd831226d3fad098085933ff1e8a4
|
|
| MD5 |
2fb5f1ceacb93cc8063a9855a46fe1fd
|
|
| BLAKE2b-256 |
4229e9da8c92021ef0a64c1245b4d3b7c3c256b638f77ec4e771fa41db6617ec
|
Provenance
The following attestation bundles were made for xarray_subset_grid-0.1.1-py3-none-any.whl:
Publisher:
pypi.yml on ioos/xarray-subset-grid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xarray_subset_grid-0.1.1-py3-none-any.whl -
Subject digest:
0ba8628c7751070a1cd30463d6f6aa03daecd831226d3fad098085933ff1e8a4 - Sigstore transparency entry: 942032831
- Sigstore integration time:
-
Permalink:
ioos/xarray-subset-grid@121df694f96aab8fce4a5ca09b1c1509e31a737c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ioos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@121df694f96aab8fce4a5ca09b1c1509e31a737c -
Trigger Event:
release
-
Statement type: