This is probably something simple to answer: I am working with eo-learn and trying to apply an AOI mask (defined in mask_timeless) and set masked areas to NaN across all images in a temporal stack within an eo-patch.
where ndvi_clean is the multitemporal NDVI from the eo-patch and aoi_mask is a single band mask.
Issue is how I apply the single band mask across the temporal stack. Appreciate any guidance on this as I am still learning python and numpy.
import numpy as np
import matplotlib.pyplot as plt
n_timestamps = 10
size = 20
# made up data
ndvi_clean = np.random.random(size=(n_timestamps,size,size))
# made up mask
aoi_mask = np.zeros((size,size))
aoi_mask[5:15,5:15] = 1
aoi_mask = aoi_mask > 0.5
# new mask is broadcasted (in shape) to the array we want to mask
broadcasted_mask = np.broadcast_to(array=aoi_mask, shape=ndvi_clean.shape)
# test that first slice of broadcasted_mask equals to aoi_mask
# work on a copy for illustration
aoi_ndvi = ndvi_clean.copy()
# mask the ndvi array
aoi_ndvi[~broadcasted_mask] = 0
fig, ax = plt.subplots(ncols=2, figsize=(11,5))