I am working on a multiband image with python.
I imported my image as a masked numpy array of shape (bands, rows, cols) using rasterio. The mask is the same for all bands.
I would like to get the spectra of all non-masked pixels. The result could be an array of shape (bands, rows).
For now I am doing:
output =  for band in range(array.shape): output.append(array[band][array.mask==False]) output = np.asarray(output)
Is there a more direct way to do it?