Skip to content

Commit 7a8072e

Browse files
authored
Start user guide with xarray section (#46)
* Start user guide with xarray section * Add page * Build docs with all groups
1 parent 3860144 commit 7a8072e

4 files changed

Lines changed: 32 additions & 5 deletions

File tree

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ build:
77
commands:
88
- pip install uv
99
- uv sync --group docs
10-
- uv run mkdocs build --strict
10+
- uv run --all-groups mkdocs build --strict
1111
- mkdir -p $READTHEDOCS_OUTPUT/html && cp -r site/* $READTHEDOCS_OUTPUT/html/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Opening Data with Xarray
2+
3+
This guide shows how to use `obspec-utils` readers to open cloud-hosted datasets with [xarray](https://docs.xarray.dev/).
4+
5+
## Overview
6+
7+
`obspec-utils` readers provide a file-like interface (`read`, `seek`, `tell`) that xarray can use directly with engines like `h5netcdf`. Combined with [obstore](https://developmentseed.org/obstore/latest/) for cloud storage access, this enables efficient reading of HDF5 and NetCDF files from S3, GCS, or Azure.
8+
9+
## Quick Start
10+
11+
This example opens a NetCDF file from the [NASA Earth Exchange (NEX) Data Collection](https://registry.opendata.aws/nasanex/) on AWS Open Data:
12+
13+
```python exec="on" source="above" session="xarray" result="code"
14+
import xarray as xr
15+
from obstore.store import S3Store
16+
from obspec_utils.readers import EagerStoreReader
17+
18+
# Access public AWS Open Data (no credentials needed)
19+
store = S3Store(
20+
bucket="nasanex",
21+
aws_region="us-west-2",
22+
skip_signature=True, # Anonymous access
23+
)
24+
25+
with EagerStoreReader(store, "NEX-GDDP/BCSD/rcp85/day/atmos/tasmax/r1i1p1/v1.0/tasmax_day_BCSD_rcp85_r1i1p1_inmcm4_2100.nc") as reader:
26+
ds = xr.open_dataset(reader, engine="h5netcdf")
27+
print(ds)
28+
```

mkdocs.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ extra:
1414

1515
nav:
1616
- "index.md"
17-
- "Design":
18-
- "Protocols": "design/protocols.md"
19-
- "Caching": "design/caching.md"
20-
- "Glob": "design/glob.md"
17+
- "User Guide":
18+
- "Opening Data with Xarray": "user-guide/opening-data-with-xarray.md"
2119
- "API":
2220
- Glob: "api/glob.md"
2321
- Protocols: "api/protocols.md"

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ xarray = [
5858
"xarray",
5959
"h5netcdf",
6060
"h5py",
61+
"cftime",
6162
]
6263
fsspec = [
6364
"s3fs",

0 commit comments

Comments
 (0)