html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/3896#issuecomment-605446570,https://api.github.com/repos/pydata/xarray/issues/3896,605446570,MDEyOklzc3VlQ29tbWVudDYwNTQ0NjU3MA==,14808389,2020-03-28T13:19:46Z,2020-03-28T13:19:46Z,MEMBER,"sounds good. Minor comment / nit: you don't really need the `astype(np.float)`, the result should already be of dtype `float` since there are missing values after the rolling sum.
I don't know about performance but if it does what you asked for then that's good?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,588126763
https://github.com/pydata/xarray/issues/3896#issuecomment-605084864,https://api.github.com/repos/pydata/xarray/issues/3896,605084864,MDEyOklzc3VlQ29tbWVudDYwNTA4NDg2NA==,14808389,2020-03-27T16:08:22Z,2020-03-27T17:58:15Z,MEMBER,"what about this?
```python
In [86]: def detect(arr):
...: thresh = arr > 0.5
...: n_found = thresh.rolling(dim={""x"": 5}, center=True).sum().fillna(0)
...: detected = (
...: n_found.rolling(dim={""x"": 5}, center=True)
...: .reduce(lambda a, axis: (a == 5).any(axis=axis))
...: .fillna(False)
...: .astype(bool)
...: )
...: return detected
...:
...: arr = xr.DataArray(
...: np.array(
...: [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0]
...: ),
...: dims=""x"",
...: coords={""x"": np.arange(24)},
...: name=""sst"",
...: )
...: (
...: arr.to_dataset()
...: .assign(mask=lambda ds: detect(ds.sst))
...: .assign(selected=lambda ds: ds.sst.where(ds.mask))
...: )
Out[86]:
Dimensions: (x: 24)
Coordinates:
* x (x) int64 0 1 2 3 4 5 6 7 8 9 10 ... 14 15 16 17 18 19 20 21 22 23
Data variables:
sst (x) int64 0 0 0 0 0 1 1 1 1 1 0 0 1 0 0 1 1 1 1 1 1 0 0 0
mask (x) bool False False False False False ... True False False False
selected (x) float64 nan nan nan nan nan 1.0 ... 1.0 1.0 1.0 nan nan nan
```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,588126763