Filter 'non-exception' pixel from S3 L2 LST product (S3 SLSTR)

Hi there,

First post ever here : I’ll try to make it as clear and concise as possible for you to get straight to the point.

In a Nutshell…

How to get rid of exception and cloud pixels in LST dataset from S3_L3_LST product, using python script ?


Feeling like reading more details ?.. :wink:

Scope of the study

I am using Sentinel-3 Level 2 LST product:

My plan is to:

  • get rid of orphan pixels first,
  • filter all exception pixels
  • filter all cloud pixels
  • enjoy a nice LST plot.

Context

I first thought that Lvl 2 product were already cloud and exception-filtered, but…

Cloud

After a quick plot on jupyter lab, I could clearly witness clouds on LST dataset:
image

I made sure those were “removable” clouds, identified as so, using SNAP and the following flags :

  • single_moderate flag from bayes_in variable in flags_in.nc file,
  • and summary_cloud flag from confidence_in variable in similar flags_in.nc file.

Exception

Exceptions : only for invalid data ?

Then, I wanted to get rid of exception-pixels using the exception variable in LST_in.nc dataset.
As expected from the [Sentinel-3 SLSTR Land Handbook](https://sentinel.esa.int/documents/247904/4598082/Sentinel-3-SLSTR-Land-Handbook.pdf) :

“The data have been quality checked with regards to input Level-1 data, with only valid data processed. All invalid data are identified with an exception flag.”

In other words, as I understood it : I’m expecting valid data to have NaN value in the exception dataset.

No NaN in exception…

```python
import xarray as xr
import numpy as np

ds_lst = xr.open_dataset('lst_in.nc')
np.isnan(ds_lst.exception.values).any()

Using the code above, I get a False for the last line, which I translate as :
no NaN value in the exception values

Conclusion

I didn’t get to the cloud-cleaning part since it feels like I need to get a better grasp on what the data means, and how to use correctly.

Thanks in advance for your time, and your help.
Regards,
Mathieu

The exception band is a flag band and a 16-bit integer. Thus, there are no NaN values.
If no exception is raised, the value will be zero.

Maybe you also want to look at the cloud flags. Those flags might be set even when no exception is set.

@marpet Thanks for this answer : it fits the data.
I think it was just due to a misunderstanding of the documentation.

PS : I can see you’re a very active member and keep helping lots of people in this ecosystem.
Thanks so much for that !