remove the try..except and use ```np.ma.getmask``` instead.