Skip to content

Commit

Permalink
fix: handle missing bands when constructing Dask graph
Browse files Browse the repository at this point in the history
Not all `(item, band)` pairs are valid, STAC item can have missing
assets. This case is handled in direct load case, but was not when
using Dask (#102).
  • Loading branch information
Kirill888 committed Jan 17, 2023
1 parent da03bde commit f540822
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions odc/stac/_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,17 @@ def __call__(
md_key = f"md-{name}-{tk}"
shape_in_blocks = (shape[0], *self.gbt.shape.yx)
for idx, item in enumerate(self.items):
dsk[md_key, idx] = item[name]
band = item.get(name, None)
if band is not None:
dsk[md_key, idx] = band

for ti, yi, xi in np.ndindex(shape_in_blocks):
tyx_idx = (ti, yi, xi)
srcs = [(md_key, idx) for idx in self.tyx_bins.get(tyx_idx, [])]
srcs = [
(md_key, idx)
for idx in self.tyx_bins.get(tyx_idx, [])
if (md_key, idx) in dsk
]
dsk[band_key, ti, yi, xi] = (
_dask_loader_tyx,
srcs,
Expand Down

0 comments on commit f540822

Please sign in to comment.