-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Description
Generic Issue
Description
Currently,
da = 1,0,1,1,0
xclim.indices.run_length.rle(da) == 1,0,2,N,0Nans are used to label values that are in a run, but not its first (or last) element.
This is used notably in keep_longest_run. We find the largest number (2), and ffill the surrounding nans, and it gives us the run of interest.
We could define a different rle
rle'(da) == 1,0,2,-1,0And simply replace -1 with nans when needed. @SarahG-579462 has reported some benefits in sticking to int at a lower level. I wonder if more benefits could be obtained by sticking to int as much as possible.
This could also handled as:
out = 1,0,2,N,0
out.astype(np.int32) == 1,0,2,-2147483648,0but at this point, we might as well use float32 with the nans
Code of Conduct
- I agree to follow this project's Code of Conduct
aulemahal
Metadata
Metadata
Assignees
Labels
No labels