Skip to content

Write back a slice of a dask array #5399

Answered by dcherian
Shaunakde asked this question in Q&A
Discussion options

You must be logged in to vote

You can vectorize that using the axis argument of np.percentile.



def foo(arr):
    lo, hi = np.percentile(arr, (1,99), axis=0)
    arr = np.clip(arr, lo, hi)
    arr = (arr - lo) / (hi - lo)
    return arr

data = foo(data) # should work for dask arrays.

With an xarray thing, see .quantile and .clip

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Shaunakde
Comment options

Answer selected by Shaunakde
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants