-
I am working with some gigantic rasters and need to flip them along the y dimension. So far I've been using a method I found on stackoverflow. This works perfectly but for large rasters I get a warning that slicing is producing a large chunk: import dask.array as da
import xarray as xr
n = 100_000
data = da.zeros((1, n, n), chunks=(1, "auto", "auto"))
x = xr.DataArray(data, dims=("band", "y", "x"), coords=([1], np.arange(n), np.arange(n)))
print(x)
x = x.reindex(y=x.y[::-1]) <xarray.DataArray 'zeros_like-74c41486ec6ed801df96ced5fd27a2aa' (band: 1,
y: 100000,
x: 100000)>
dask.array<zeros_like, shape=(1, 100000, 100000), dtype=float64, chunksize=(1, 4000, 4000), chunktype=numpy.ndarray>
Coordinates:
* band (band) int64 1
* y (y) int64 0 1 2 3 4 5 6 ... 99994 99995 99996 99997 99998 99999
* x (x) int64 0 1 2 3 4 5 6 ... 99994 99995 99996 99997 99998 99999
/home/USER/anaconda3/envs/main/lib/python3.8/site-packages/xarray/core/indexing.py:1228: PerformanceWarning: Slicing is producing a large chunk. To accept the large
chunk and silence this warning, set the option
>>> with dask.config.set(**{'array.slicing.split_large_chunks': False}):
... array[indexer]
To avoid creating the large chunks, set the option
>>> with dask.config.set(**{'array.slicing.split_large_chunks': True}):
... array[indexer]
return self.array[key] Normally I would just do Is there a better way to do this or at least a way to avoid oversized chunks? |
Beta Was this translation helpful? Give feedback.
Answered by
keewis
Jun 14, 2022
Replies: 1 comment 4 replies
-
you can invert without reindexing: x.isel(y=slice(None, None, -1)) |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
dcherian
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can invert without reindexing: