Detect consecutive holes into 1D data
## MAXIMUM NUMBER OF CONSECUTIVE STEPS WITH HOLES
def max_consecutive_holes(values):
import numpy as np
# get list of index with holes
ivalues = np.array([i for i,iv in enumerate(np.isnan(values)) if iv])
# split list into list of lists of consecutive holes
spl = [0]+[i for i in range(1,len(ivalues)) if ivalues[i]-ivalues[i-1]>1]+[None]
llholes = [ivalues[b:e] for (b, e) in [(spl[i-1],spl[i]) for i in range(1,len(spl))]]
# maximun number of consecutive steps with holes
return np.max([len(i) for i in llholes])