digitalearthpacific / dep-tools

Processing tools for Digital Earth Pacific
MIT License
1 stars 0 forks source link

SCL isn't a bitflag... we can't use the code we're using to mask Sentinel-2 #58

Open alexgleith opened 1 month ago

alexgleith commented 1 month ago

We need to change to using something like this to mask Sentinel-2. Our current method is wrong.

NODATA = 0
CLOUD_SHADOW = 3
CLOUD_MEDIUM_PROBABILITY = 8
CLOUD_HIGH_PROBABILITY = 9

mask = data.scl.isin([NODATA, CLOUD_SHADOW, CLOUD_MEDIUM_PROBABILITY, CLOUD_HIGH_PROBABILITY])

masked = data.where(~mask, other=np.nan)
jessjaco commented 1 month ago

What I originally wrote worked I think

https://github.com/digitalearthpacific/dep-tools/blob/6483ae8d41ddbbf43cff9e99dea3f213a9ca3019/dep_tools/s2_utils.py#L36-L60

https://github.com/digitalearthpacific/dep-tools/blob/6483ae8d41ddbbf43cff9e99dea3f213a9ca3019/dep_tools/s2_utils.py

alexgleith commented 1 month ago

What I originally wrote worked I think

Yeah, it would have. Whoops.

Even simpler is scl.isin([...]). I'll fix it up when I go to run the GeoMAD again.