Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f44768d
add check for invalid start_index when inferring.
ChrisBarker-NOAA Feb 6, 2026
d464bb3
Regular grid fixes (#108)
ChrisBarker-NOAA Feb 6, 2026
0497594
added missing docs requirements
ChrisBarker-NOAA Feb 7, 2026
6285b4b
updated pixi lock file
ChrisBarker-NOAA Feb 8, 2026
674819e
implement coverage report
ocefpaf Jan 28, 2026
35ca53a
pin pytest-cov to hanging issues
ocefpaf Feb 5, 2026
7d995d6
update
ocefpaf Feb 9, 2026
612d4b6
lints
ocefpaf Feb 9, 2026
54f2193
typos
ocefpaf Feb 9, 2026
25c03c0
remove this checker b/c it is messing with pixi
ocefpaf Feb 9, 2026
3f5a696
restore old pyproject.toml
ocefpaf Feb 9, 2026
755e6dc
update lockfile
ocefpaf Feb 9, 2026
7952a68
dask from conda-forge is 'complete', dask-core it pure dask
ocefpaf Feb 9, 2026
376bf5f
fix URL
ocefpaf Feb 9, 2026
04dc5db
readd text_cov
ocefpaf Feb 9, 2026
6b5bb9a
Merge pull request #99 from ocefpaf/coverage
ocefpaf Feb 9, 2026
a9575c1
Bump the github-actions group with 2 updates (#111)
dependabot[bot] Feb 9, 2026
121df69
separate pixi config from pyproject.toml (#112)
ocefpaf Feb 11, 2026
a8b7df6
ignoring spurious numpy warnings ...
ChrisBarker-NOAA Feb 18, 2026
3e6e9c6
Merge branch 'main' of https://github.com/ioos/xarray-subset-grid
ChrisBarker-NOAA Feb 18, 2026
a007049
[pre-commit.ci] pre-commit autoupdate (#116)
pre-commit-ci[bot] Mar 2, 2026
a81260e
add data download
ocefpaf Feb 6, 2026
0e1d909
without lockfile we cannot cache
ocefpaf Mar 11, 2026
c249d84
ignore pixi lock
ocefpaf Mar 11, 2026
fcc7a7a
add download data step to test
ocefpaf Mar 11, 2026
09a37a2
Merge branch 'main' of https://github.com/ioos/xarray-subset-grid
ChrisBarker-NOAA Mar 26, 2026
b42c8c9
Merge pull request #107 from ocefpaf/split_tests_and_data
ocefpaf Mar 31, 2026
c867b8a
stale links (#125)
w-nityammm Apr 4, 2026
9c16853
Merge branch 'main' of https://github.com/ioos/xarray-subset-grid
ChrisBarker-NOAA Apr 4, 2026
bfe790a
docs: fix README usage path, typos, and doc links (#123)
Divyateja2709 Apr 5, 2026
78f7c65
Merge branch 'main' of https://github.com/ioos/xarray-subset-grid
ChrisBarker-NOAA Apr 5, 2026
ce61e14
minor cleanup of README.
ChrisBarker-NOAA Apr 5, 2026
43aaa52
add check for invalid start_index when inferring.
ChrisBarker-NOAA Feb 6, 2026
0d7bff2
Merge branch 'ugrid_updates' of https://github.com/ioos/xarray-subset…
ChrisBarker-NOAA Apr 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Code coverage report

# no permissions by default
permissions: {}

on:
pull_request:
push:

jobs:
run:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Setup pixi
uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4

- name: Run tests with coverage
run: >
pixi run --environment testcov test_cov
2 changes: 0 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jobs:
persist-credentials: false
- name: Setup pixi
uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
with:
cache: true

- name: Tests
run: >
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ __pycache__/
# C extensions
*.so

# Data files
*.nc
*.pkl

# Distribution / packaging
.Python
build/
Expand Down Expand Up @@ -163,6 +167,7 @@ cython_debug/
xarray_subset_grid/_version.py
# pixi environments
.pixi
pixi.lock
*.egg-info

.ruff_cache/
9 changes: 2 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,14 @@ repos:
- --ignore-words-list=astroid,fo

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.10
rev: v0.15.4
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.11.1
hooks:
- id: pyproject-fmt

- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v1.19.0
rev: v1.22.0
hooks:
- id: zizmor

Expand Down
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,37 @@ Subset Xarray datasets in space while retaining the original grid for complex gr

## Installation

### `pip compatible`
### `pip`

This package is available on pypi:

```
python -m pip install xarray-subset-grid
```

And also on conda-forge:
### 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`](https://xarray.dev/). Given a [CF Compliant](https://cfconventions.org/) `xarray` dataset named `ds`, this package can be accessed using the `xsg` accessor:
This package is designed to be used in conjunction with [`xarray`](https://xarray.dev/).
Given a [CF Compliant](https://cfconventions.org/) `xarray` dataset named `ds`, this package can be accessed using the `xsg` accessor:

```python
# Get the interprested grid class

import numpy as np

# xarray_subset_gris should detect the grid type.
# To check what it found:
grid = ds.xsg

# subset to only include temperature
# subsetting to include only certain variables:
# Only temperature
ds_temp = ds.xsg.subset_vars(["temp"])

# subset by bounding box
Expand All @@ -45,17 +53,20 @@ poly = np.array(
ds_subset_poly = ds.xsg.subset_polygon(poly)
```

For full usage, see the [example notebooks](./examples/)
For full usage, see the [example notebooks](https://github.com/ioos/xarray-subset-grid/tree/main/docs/examples)
and the [Sphinx documentation on Read the Docs](https://xarray-subset-grid.readthedocs.io/).

## Development

### `pip compatible`
### `pip`

First, create a new `virtualenv` and activate it:

```bash
python -m venv venv
source venv/bin.activate
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:
Expand Down Expand Up @@ -105,13 +116,14 @@ pixi run -e test312 test
Options are: `test310` `test311` `test312` `test313`


To run a shell to do dev work:
To run a shell to do development work:

```bash
pixi shell -e dev
```

To run a shell in which you can run the examples (notebooks and al that):
To run a shell in which you can run the examples
(notebooks and all that):

```bash
pixi shell -e examples
Expand All @@ -123,10 +135,11 @@ 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:
Finally, when the `pixi.toml` file is updated,
be sure to update the `pixi` lockfile:

```bash
pixi install
pixi update
```

### `conda`
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ location you’d like to keep it. We are partial to creating a

.. code:: sh

git clone https://github.com/asascience-open/xarray-subset-grid.git
git clone https://github.com/ioos/xarray-subset-grid.git

Pull Requests
-------------
Expand Down
Empty file.
Binary file not shown.
Binary file not shown.
Binary file removed docs/examples/example_data/SCHISM/out2d_1.nc
Binary file not shown.
Binary file removed docs/examples/example_data/SCHISM/salinity_1.nc
Binary file not shown.
Binary file removed docs/examples/example_data/SCHISM/zCoordinates_1.nc
Binary file not shown.
Binary file removed docs/examples/example_data/SFBOFS_subset1.nc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed docs/examples/example_data/small_ugrid_zero_based.nc
Binary file not shown.
Binary file removed docs/examples/example_data/stofs_2d_glo.subset.nc
Binary file not shown.
Binary file removed docs/examples/example_data/tris_and_bounds.nc
Binary file not shown.
Binary file removed docs/examples/example_data/wcofs-subset-control.nc
Binary file not shown.
10 changes: 5 additions & 5 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Installation
============

This installation guide includes only the xarray-subset-grid installation instructions. Please
refer to `xarray-subset-grid Contributor's Guide <https://uxarray.readthedocs.io/en/latest/contributing.html>`_
for detailed information about how to contribute to the UXarray project.
refer to the `xarray-subset-grid Contributor's Guide <contributing.html>`_
for detailed information about how to contribute to this project.

We recommend using the `conda <https://conda.io/docs/>`__ or
`pixi <https://prefix.dev/>`__ package managers for your Python
environments. Please take some time to go over the
`README <https://github.com/asascience-open/xarray-subset-grid/blob/main/README.md>`__.
`README <https://github.com/ioos/xarray-subset-grid/blob/main/README.md>`__.


Conda
Expand Down Expand Up @@ -71,7 +71,7 @@ PyPI
An alternative to Conda is using pip
::

pip install xarray_subset_grid@git+https://github.com/asascience-open/xarray-subset-grid.git
pip install xarray_subset_grid@git+https://github.com/ioos/xarray-subset-grid.git
.. pip install xarray-subset-grid


Expand All @@ -84,7 +84,7 @@ If you are interested in installing xarray-subset-grid from source,
you will first need to get the latest version of the code
::

git clone https://github.com/asascience-open/xarray-subset-grid.git
git clone https://github.com/ioos/xarray-subset-grid.git
cd xarray-subset-grid

Run the following command from the root-directory
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sphinx
sphinx-autodoc-typehints
myst_nb
xarray_subset_grid@git+https://github.com/asascience-open/xarray-subset-grid.git
xarray_subset_grid@git+https://github.com/ioos/xarray-subset-grid.git
sphinxcontrib-bibtex
matplotlib
cf_xarray
Expand Down
25 changes: 25 additions & 0 deletions download_test_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import zipfile
from pathlib import Path

import pooch


def download_data():
"""Download support data for tests and documentation."""
url = "https://github.com/ioos/xarray-subset-grid/releases/download"
version = "2026.02.09"

fname = pooch.retrieve(
url=f"{url}/{version}/data_files.zip",
known_hash="sha256:675fb74b9a8c58a6b3bdcef691f7e5bf97a11a3f1065668525e5169f8be20343",
)

here = Path(__file__).resolve().parent
print(fname)
print(here)
with zipfile.ZipFile(fname, "r") as zip_ref:
zip_ref.extractall(here)


if __name__ == "__main__":
download_data()
Loading