Skip to content

Commit 60f8f04

Browse files
committed
Use smaller file
1 parent a39d949 commit 60f8f04

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,20 @@ pip install obspec-utils
2828
```python
2929
import xarray as xr
3030
from obstore.store import S3Store
31-
from obspec_utils.readers import BlockStoreReader
31+
from obspec_utils.glob import glob
32+
from obspec_utils.readers import EagerStoreReader
3233

3334
store = S3Store(
34-
bucket="nsf-ncar-era5",
35+
bucket="its-live-data",
3536
aws_region="us-west-2",
3637
skip_signature=True,
3738
)
3839

39-
with BlockStoreReader(store, "e5.oper.an.pl/202501/e5.oper.an.pl.128_060_pv.ll025sc.2025010100_2025010123.nc") as reader:
40-
ds = xr.open_dataset(reader, engine="h5netcdf")
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:
4145
print(ds)
4246
```
4347

tests/test_xarray.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,30 @@ def test_readme_example():
5959
"""
6060
Test the example from the README frontpage.
6161
62-
Uses ERA5 data from the NSF-NCAR public S3 bucket.
62+
Uses ITS_LIVE velocity data from a public S3 bucket.
6363
Verifies output matches fsspec.
6464
"""
6565
import s3fs
6666
from obstore.store import S3Store
67+
from obspec_utils.glob import glob
6768

68-
bucket = "nsf-ncar-era5"
69-
path = (
70-
"e5.oper.an.pl/202501/e5.oper.an.pl.128_060_pv.ll025sc.2025010100_2025010123.nc"
71-
)
72-
69+
bucket = "its-live-data"
7370
store = S3Store(
7471
bucket=bucket,
7572
aws_region="us-west-2",
7673
skip_signature=True,
7774
)
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+
7880
fs = s3fs.S3FileSystem(anon=True)
7981

8082
with (
8183
fs.open(f"{bucket}/{path}") as f,
82-
BlockStoreReader(store, path) as reader,
84+
EagerStoreReader(store, path) as reader,
8385
xr.open_dataset(f, engine="h5netcdf") as ds_fsspec,
8486
xr.open_dataset(reader, engine="h5netcdf") as ds_obspec,
8587
):
86-
# Compare indexes
87-
assert list(ds_fsspec.indexes) == list(ds_obspec.indexes)
88-
# Load just one point to verify data access
89-
var = list(ds_obspec.data_vars)[0]
90-
subset_fsspec = ds_fsspec[var].isel({d: 0 for d in ds_fsspec[var].dims})
91-
subset_obspec = ds_obspec[var].isel({d: 0 for d in ds_obspec[var].dims})
92-
xr.testing.assert_equal(subset_fsspec, subset_obspec)
88+
xr.testing.assert_allclose(ds_fsspec.load(), ds_obspec.load())

0 commit comments

Comments
 (0)