Hey @GeorgeB
Different approach, but maybe try this:
from numpy import zeros, where, float32, nan
# Function to return the bit number from a value
def get_bit(value, bit_number):
"""
Return value from a bit number
"""
return (value & (1 << bit_number)) != 0
# Read in the product
p = ProductIO.readProduct(idepix.dim)
# Get product dimensions
h = int(p.getSceneRasterHeight())
w = int(p.getSceneRasterWidth())
# Get the flags band (this is bits)
idepix_flags = p.getBand('pixel_classif_flags').readPixels(0, 0, w, h, zeros((h, w), float32)).astype('uint32')
# Read the cloud mask
cloud_mask = where(get_bit(idepix_flags, 1), 1, nan)
This will give you the cloud mask (1=true, nan=false).
You can see the bit number for the flags by opening the idepix .dim product in SNAP Desktop and looking at Flag Codings/quality_flags in the Product Explorer.
It should take seconds, depending on the size of the file. If your file is large, subset it first for testing.
If it does not work: change your RAM settings or your code if you are iterating over many files (don’t think this is the case).
Hope it helps!