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