Tried a few approaches, and I settled on
indices = np.where(
array.rolling(...)
.mean()
.notnull()
)
This was able to handle the large array without using more than a few GB of RAM when the array is on disk. It used even less when the array is backed by dask. Credit goes to ThomasMGeo on the Pangeo forum. I suspect that calling .construct()
isn't actually using that much memory, but a .stack()
call I had in an earlier version was using a lot of memory.