Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize idxmin, idxmax with dask #9800

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

dcherian
Copy link
Contributor

@dcherian dcherian commented Nov 19, 2024

cc @phofl here we need to index a numpy array with a dask array (commonly a much larger array) in a sane manner.

We now preserve chunksizes for

import numpy as np
import xarray as xr

# create some dummy data and chunk
x, y, t = 1000, 1000, 57
rang = np.arange(t*x*y)
da = xr.DataArray(rang.reshape(t, x, y), coords={'time':range(t), 'x': range(x), 'y':range(y)})
da = da.chunk(dict(time=-1, x=256, y=256))
da.idxmin('time')

After
image

Before
image

@dcherian dcherian added the topic-chunked-arrays Managing different chunked backends, e.g. dask label Nov 20, 2024
@dcherian dcherian marked this pull request as ready for review November 20, 2024 03:52
@dcherian dcherian marked this pull request as draft November 20, 2024 17:39
@dcherian dcherian marked this pull request as ready for review December 6, 2024 15:50
@dcherian
Copy link
Contributor Author

Merging on Thursday if there are no comments

@dcherian dcherian added plan to merge Final call for comments and removed needs review labels Dec 17, 2024
Copy link
Collaborator

@headtr1ck headtr1ck left a comment

Choose a reason for hiding this comment

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

Ups, never submitted my review comments.

xarray/tests/test_dask.py Show resolved Hide resolved
xarray/tests/test_dask.py Outdated Show resolved Hide resolved
xarray/tests/test_dask.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan to merge Final call for comments topic-chunked-arrays Managing different chunked backends, e.g. dask
Projects
None yet
Development

Successfully merging this pull request may close these issues.

idxmin / idxmax is not parallel friendly
2 participants