maskleft = np.where(np.isnan(a))[0]
mask = np.zeros(len(a), dtype=bool)
for i in range(0, n):
    thismask = maskleft + i
mask[thismask] = True
Extend numpy mask by n cells to the right for each bad value, efficiently