Skip to content

Commit 29e4473

Browse files
author
Justin Singh-M.
committed
add image
1 parent d2c8a29 commit 29e4473

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

docs/data-service/accessing-data.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Accessing Hydro Forecast Data
22

3-
**One Hour Short Range (All)**
3+
## Short Range (All)
4+
45
```python
56
import time
67
import xarray as xr
@@ -31,6 +32,7 @@ ds_mem
3132
#> streamflow (init_time, forecast_time, feature_id) float64 400MB 0.17 ...
3233
```
3334

35+
## Short Range (Subset)
3436
```python
3537
import time
3638
import xarray as xr
@@ -49,7 +51,6 @@ reaches = [
4951
24423427
5052
]
5153

52-
# --- Short Range ---
5354
uri = "https://data.lynker-spatial.com/nwm/short_range/2025090214.zarr"
5455
start = time.time()
5556
ds = xr.open_dataset(uri, engine="zarr", chunks="auto")
@@ -75,8 +76,30 @@ ds = ds.where(ds.feature_id.isin(reaches), drop=True)
7576
ds = ds.load()
7677
end = time.time()
7778
#> 0.793 seconds
79+
```
80+
81+
## Short Range (Query)
82+
```python
83+
import xarray as xr
84+
import dask
85+
86+
uri = "https://data.lynker-spatial.com/nwm/short_range/2025090214.zarr"
7887

79-
# --- Analysis and Assimilation ---
88+
# Read Zarr metadata
89+
ds = xr.open_dataset(uri, engine="zarr", chunks="auto")
90+
91+
# Find 9 reaches where the streamflow exceeded 10 at least once
92+
cond = (ds.streamflow > 10).compute()
93+
reaches = ds.where(cond, drop=True).feature_id[:9]
94+
ds = ds.sel(feature_id=reaches, drop=True)
95+
ds_mem = ds.load()
96+
```
97+
98+
![](/img/short-range-query.png)
99+
100+
## Analysis and Assimilation
101+
102+
```python
80103
uri = "https://data.lynker-spatial.com/nwm/analysis/2025090214.zarr"
81104
start = time.time()
82105
ds = xr.open_dataset(uri, engine="zarr", chunks="auto")
@@ -102,8 +125,10 @@ ds = ds.where(ds.feature_id.isin(reaches), drop=True)
102125
ds = ds.load()
103126
end = time.time()
104127
#> 3.0864 seconds
128+
```
105129

106-
# --- NWIS ---
130+
## NWIS Observations
131+
```python
107132
uri = "https://data.lynker-spatial.com/nwis/2025090214_discharge.zarr"
108133
start = time.time()
109134
ds = xr.open_dataset(uri, engine="zarr")
263 KB
Loading

0 commit comments

Comments
 (0)