Hello!
I’m struggling while trying to apply flags to pixels, i.e. to mask out pixels with a flag set.
Sensor is OLCI.
**** preamble ****
I read band1
readband1=p.getBand(‘Oa01_reflectance’)
band1=np.zeros(w*h, np.dtype(‘float32’))
readband1.readPixels(0,0,w,h,band1)
I know that pixel number 147 is valid.
In [142]: band1[147]
Out[142]: 0.039545815
I read also the flag bands:
readmask_lsb=p.getBand(‘WQSF_lsb’)
readmask_msb=p.getBand(‘WQSF_msb’)
mask_lsb=np.zeros(wh,‘int32’)
mask_msb=np.zeros(wh,‘int32’)
readmask_lsb.readPixels(0,0,w,h,mask_lsb)
readmask_msb.readPixels(0,0,w,h,mask_msb)
and pixel 147 has the following flags active:
In [148]: np.binary_repr(mask_lsb[147], width=32)
Out[148]: ‘00010010000010000010000000010010’
In [149]: np.binary_repr(mask_msb[147], width=32)
Out[149]: ‘00000000000000000000000001000000’
**** /preamble ****
So I see that e.g. flag CLOUD is set.
What should I do to mask out pixels with CLOUD flag set?
I tried all possible variations of
readband1.setValidPixelExpression(‘WQSF_lsb_CLOUD ? NaN: Oa01_reflectance’)
In [154]: readband1.getValidMaskExpression()
Out[154]: ‘(WQSF_lsb_CLOUD ? NaN: Oa01_reflectance) && Oa01_reflectance.raw != 65535.0’
But when I read again band1 ( readband1.readPixels(0,0,w,h,band1) ), still I get pixel 147 valid
In [156]: band1[147]
Out[156]: 0.039545815
Sorry for the long and maybe stupid question, but I’m sort of stuck on this point!
Many many thanks in advance for any help!
Mario