Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion stackstac/to_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def items_to_dask(
"tb",
slices_fake_arr,
"yx",
window_dtype=dtype,
fill_value=fill_value,
meta=np.ndarray((), dtype=dtype), # TODO dtype
)
return rasters
Expand Down Expand Up @@ -161,6 +163,8 @@ def asset_entry_to_reader_and_window(
def fetch_raster_window(
asset_entry: Optional[Tuple[Reader, windows.Window]],
slices: Tuple[slice, ...],
window_dtype: np.dtype = np.dtype("float64"),
Copy link
Contributor Author

@TomAugspurger TomAugspurger Dec 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the keyword window_dtype, instead of dtype, to avoid a conflict with blockwise using dtype as well.

fill_value: Optional[Union[int, float]] = np.nan,
) -> np.ndarray:
current_window = windows.Window.from_slices(*slices)
if asset_entry is not None:
Expand All @@ -175,4 +179,6 @@ def fetch_raster_window(

# no dataset, or we didn't overlap it: return empty data.
# use the broadcast trick for even fewer memz
return np.broadcast_to(np.nan, (1, 1) + windows.shape(current_window))
return np.broadcast_to(
np.array(fill_value, dtype=window_dtype), (1, 1) + windows.shape(current_window)
)