Skip to content

Clip function with minimum or maximum nan value #5211

Answered by max-sixty
babameme asked this question in Q&A
Discussion options

You must be logged in to vote

I got the sign wrong, corrected:

In [4]: lower_inf = lower.where(lower.notnull(), -np.inf)

In [5]: da.clip(lower_inf, upper)
Out[5]:
<xarray.DataArray (x: 3, y: 6)>
array([[ 1.,  1.,  2.,  3.,  4.,  4.],
       [ 6.,  7.,  8.,  9., 10., 10.],
       [12., 13., 14., 14., 14., 14.]])
Coordinates:
  * x        (x) int64 0 1 2
  * y        (y) int64 0 1 2 3 4 5

Replies: 9 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by andersy005
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
Converted from issue

This discussion was converted from issue #5205 on April 22, 2021 17:34.