Skip to content

Commit 43174a1

Browse files
authored
chore: Improve readme (#58)
* Add user-guide example with rasterio * Add to changelog * chore: Improve readme * Use smaller file
1 parent cec40e2 commit 43174a1

2 files changed

Lines changed: 73 additions & 15 deletions

File tree

README.md

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,54 @@
1-
# Obspec Utils
1+
# obspec-utils
22

3-
[![PyPI - Version](https://img.shields.io/pypi/v/obspec-utils.svg)](https://pypi.org/project/obspec-utils)
4-
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/obspec-utils.svg)](https://pypi.org/project/obspec-utils)
3+
[![PyPI][pypi_badge]][pypi_link]
4+
[![PyPI - Python Version][python_badge]][pypi_link]
55

6-
-----
6+
[pypi_badge]: https://img.shields.io/pypi/v/obspec-utils.svg
7+
[pypi_link]: https://pypi.org/project/obspec-utils/
8+
[python_badge]: https://img.shields.io/pypi/pyversions/obspec-utils.svg
79

8-
## Table of Contents
10+
Utilities for cloud data access built on [obspec], fully compatible with [obstore]'s storage classes.
911

10-
- [Installation](#installation)
11-
- [License](#license)
12+
[obspec]: https://github.com/developmentseed/obspec
13+
[obstore]: https://github.com/developmentseed/obstore
14+
15+
- **File-like readers** that work with xarray, rasterio, h5netcdf, and other libraries expecting file objects.
16+
- **Composable store wrappers** for caching, request tracing, and splitting large requests.
17+
- **Glob-style file discovery** with patterns like `data/**/*.nc`, using efficient prefix filtering.
18+
- **AiohttpStore** for generic HTTPS access (e.g., THREDDS, NASA Earthdata).
1219

1320
## Installation
1421

15-
```bash
16-
python -m pip install obspec-utils
22+
```sh
23+
pip install obspec-utils
1724
```
1825

19-
## Setup development environment
26+
## Quick Example
27+
28+
```python
29+
import xarray as xr
30+
from obstore.store import S3Store
31+
from obspec_utils.glob import glob
32+
from obspec_utils.readers import EagerStoreReader
33+
34+
store = S3Store(
35+
bucket="its-live-data",
36+
aws_region="us-west-2",
37+
skip_signature=True,
38+
)
2039

21-
```console
22-
git clone https://github.com/virtual-zarr/obspec-utils.git
23-
cd obspec-utils
24-
uv sync --all-groups
25-
uv run --all-groups pytest --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src
40+
# Find NetCDF files matching a pattern
41+
files = glob(store, "NSIDC/velocity_image_pair_sample/landsatOLI/v02/N20E080/*.nc")
42+
path = next(files)
43+
44+
with EagerStoreReader(store, path) as reader, xr.open_dataset(reader, engine="h5netcdf") as ds:
45+
print(ds)
2646
```
2747

48+
## Documentation
49+
50+
Full documentation is available at [obspec-utils.readthedocs.io](https://obspec-utils.readthedocs.io).
51+
2852
## License
2953

3054
`obspec-utils` is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license.

tests/test_xarray.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,37 @@ def test_eager_reader_xarray_http_store():
5252

5353
# Verify closed is True after context exit
5454
assert reader.closed is True
55+
56+
57+
@pytest.mark.network
58+
def test_readme_example():
59+
"""
60+
Test the example from the README frontpage.
61+
62+
Uses ITS_LIVE velocity data from a public S3 bucket.
63+
Verifies output matches fsspec.
64+
"""
65+
import s3fs
66+
from obstore.store import S3Store
67+
from obspec_utils.glob import glob
68+
69+
bucket = "its-live-data"
70+
store = S3Store(
71+
bucket=bucket,
72+
aws_region="us-west-2",
73+
skip_signature=True,
74+
)
75+
76+
# Find NetCDF files matching a pattern
77+
files = glob(store, "NSIDC/velocity_image_pair_sample/landsatOLI/v02/N20E080/*.nc")
78+
path = files[0]
79+
80+
fs = s3fs.S3FileSystem(anon=True)
81+
82+
with (
83+
fs.open(f"{bucket}/{path}") as f,
84+
EagerStoreReader(store, path) as reader,
85+
xr.open_dataset(f, engine="h5netcdf") as ds_fsspec,
86+
xr.open_dataset(reader, engine="h5netcdf") as ds_obspec,
87+
):
88+
xr.testing.assert_allclose(ds_fsspec.load(), ds_obspec.load())

0 commit comments

Comments
 (0)