Sentinel-3#

Let’s use EOReader to open and read some Sentinel-3 bands and see the specificities of OLCI and SLSTR constellations.

Note that Sentinel-3 processes have stopped to use SNAP since the 0.8.0 version. Some minor discrepancies might occur both in the geocoding (especially OLCI) and the reflectance values (SLSTR).
# Imports
import os
import warnings
import rasterio

# EOReader
from eoreader.reader import Reader
from eoreader.bands import YELLOW, Oa21, RED, SWIR_2, F1

# Declare the reader (only once)
reader = Reader()
# Create logger
import logging

logger = logging.getLogger("eoreader")
logger.setLevel(logging.DEBUG)

# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)

# create formatter
formatter = logging.Formatter('%(message)s')

# add formatter to ch
ch.setFormatter(formatter)

# add ch to logger
logger.addHandler(ch)

Sentinel-3 OLCI#

# First of all, let's focus on Sentinel-3 OLCI data
olci_path = os.path.join(
    "/home", "data", "DATA", "PRODS", "S3",
    "S3A_OL_1_EFR____20191215T105023_20191215T105323_20191216T153115_0179_052_322_2160_LN1_O_NT_002.zip"
)
olci_prod = reader.open(olci_path, remove_tmp=True)
olci_prod
eoreader.S3OlciProduct 'S3A_OL_1_EFR____20191215T105023_20191215T105323_20191216T153115_0179_052_322_2160_LN1_O_NT_002'
Attributes:
	condensed_name: 20191215T105023_S3_OLCI_EFR
	path: /home/data/DATA/PRODS/S3/S3A_OL_1_EFR____20191215T105023_20191215T105323_20191216T153115_0179_052_322_2160_LN1_O_NT_002.zip
	constellation: Sentinel-3 OLCI
	sensor type: Optical
	product type: OL_1_EFR___
	default resolution: 300.0
	acquisition datetime: 2019-12-15T10:50:23.000506
	band mapping:
		COASTAL_AEROSOL: Oa03
		BLUE: Oa04
		GREEN: Oa06
		YELLOW: Oa07
		RED: Oa08
		VEGETATION_RED_EDGE_1: Oa11
		VEGETATION_RED_EDGE_2: Oa12
		VEGETATION_RED_EDGE_3: Oa16
		NIR: Oa17
		NARROW_NIR: Oa17
		WATER_VAPOUR: Oa20
		Oa01: Oa01
		Oa02: Oa02
		Oa09: Oa09
		Oa10: Oa10
		Oa13: Oa13
		Oa14: Oa14
		Oa15: Oa15
		Oa18: Oa18
		Oa19: Oa19
		Oa21: Oa21
		GREEN_I: Oa05
	needs extraction: False
# Get the bands information
olci_prod.bands
eoreader.SpectralBand 'Oa01'
Attributes:
	id: Oa01
	eoreader_name: Oa01
	common_name: 
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 400.0
	Bandwidth (nm): 15.0
	description: Aerosol correction, improved water constituent retrieval
eoreader.SpectralBand 'Oa02'
Attributes:
	id: Oa02
	eoreader_name: Oa02
	common_name: 
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 412.5
	Bandwidth (nm): 10.0
	description: Yellow substance and detrital pigments (turbidity)
eoreader.SpectralBand 'Oa03'
Attributes:
	id: Oa03
	eoreader_name: COASTAL_AEROSOL
	common_name: coastal
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 442.5
	Bandwidth (nm): 10.0
	description: Chlorophyll absorption maximum, biogeochemistry, vegetation
eoreader.SpectralBand 'Oa04'
Attributes:
	id: Oa04
	eoreader_name: BLUE
	common_name: blue
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 490.0
	Bandwidth (nm): 10.0
	description: High Chlorophyll
eoreader.SpectralBand 'Oa05'
Attributes:
	id: Oa05
	eoreader_name: GREEN_I
	common_name: 
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 510.0
	Bandwidth (nm): 10.0
	description: Chlorophyll, sediment, turbidity, red tide
eoreader.SpectralBand 'Oa06'
Attributes:
	id: Oa06
	eoreader_name: GREEN
	common_name: green
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 560.0
	Bandwidth (nm): 10.0
	description: Chlorophyll reference (Chlorophyll minimum)
eoreader.SpectralBand 'Oa07'
Attributes:
	id: Oa07
	eoreader_name: YELLOW
	common_name: yellow
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 620.0
	Bandwidth (nm): 10.0
	description: Sediment loading
eoreader.SpectralBand 'Oa08'
Attributes:
	id: Oa08
	eoreader_name: RED
	common_name: red
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 665.0
	Bandwidth (nm): 10.0
	description: Chlorophyll (2nd Chlorophyll absorption maximum), sediment, yellow substance / vegetation
eoreader.SpectralBand 'Oa09'
Attributes:
	id: Oa09
	eoreader_name: Oa09
	common_name: 
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 673.75
	Bandwidth (nm): 7.5
	description: For improved fluorescence retrieval and to better account for smile together with the bands 665 and 680 nm
eoreader.SpectralBand 'Oa10'
Attributes:
	id: Oa10
	eoreader_name: Oa10
	common_name: 
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 681.25
	Bandwidth (nm): 7.5
	description: Chlorophyll fluorescence peak, red edge
eoreader.SpectralBand 'Oa11'
Attributes:
	id: Oa11
	eoreader_name: VEGETATION_RED_EDGE_1
	common_name: rededge
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 708.75
	Bandwidth (nm): 10.0
	description: Chlorophyll fluorescence baseline, red edge transition
eoreader.SpectralBand 'Oa12'
Attributes:
	id: Oa12
	eoreader_name: VEGETATION_RED_EDGE_2
	common_name: rededge
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 753.75
	Bandwidth (nm): 7.5
	description: O2 absorption/clouds, vegetation
eoreader.SpectralBand 'Oa13'
Attributes:
	id: Oa13
	eoreader_name: Oa13
	common_name: 
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 761.25
	Bandwidth (nm): 2.5
	description: O2 absorption band/aerosol correction.
eoreader.SpectralBand 'Oa14'
Attributes:
	id: Oa14
	eoreader_name: Oa14
	common_name: 
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 764.375
	Bandwidth (nm): 3.75
	description: Atmospheric correction
eoreader.SpectralBand 'Oa15'
Attributes:
	id: Oa15
	eoreader_name: Oa15
	common_name: 
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 767.5
	Bandwidth (nm): 2.5
	description: O2A used for cloud top pressure, fluorescence over land
eoreader.SpectralBand 'Oa16'
Attributes:
	id: Oa16
	eoreader_name: VEGETATION_RED_EDGE_3
	common_name: rededge
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 778.75
	Bandwidth (nm): 15.0
	description: Atmos. corr./aerosol corr.
eoreader.SpectralBand 'Oa17'
Attributes:
	id: Oa17
	eoreader_name: NIR
	common_name: nir
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 865.0
	Bandwidth (nm): 20.0
	description: Atmospheric correction/aerosol correction, clouds, pixel co-registration
eoreader.SpectralBand 'Oa17'
Attributes:
	id: Oa17
	eoreader_name: NARROW_NIR
	common_name: nir08
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 865.0
	Bandwidth (nm): 20.0
	description: Atmospheric correction/aerosol correction, clouds, pixel co-registration
eoreader.SpectralBand 'Oa18'
Attributes:
	id: Oa18
	eoreader_name: Oa18
	common_name: 
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 885.0
	Bandwidth (nm): 10.0
	description: Water vapour absorption reference band. Common reference band with SLSTR instrument. Vegetation monitoring
eoreader.SpectralBand 'Oa19'
Attributes:
	id: Oa19
	eoreader_name: Oa19
	common_name: 
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 900.0
	Bandwidth (nm): 10.0
	description: Water vapour absorption/vegetation monitoring (maximum reflectance)
eoreader.SpectralBand 'Oa20'
Attributes:
	id: Oa20
	eoreader_name: WATER_VAPOUR
	common_name: nir09
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 940.0
	Bandwidth (nm): 20.0
	description: Water vapour absorption, Atmospheric correction/aerosol correction
eoreader.SpectralBand 'Oa21'
Attributes:
	id: Oa21
	eoreader_name: Oa21
	common_name: 
	gsd (m): 300.0
	asset_role: reflectance
	Center wavelength (nm): 1020.0
	Bandwidth (nm): 40.0
	description: Atmospheric correction/aerosol correction
# Load the Yellow band and the far NIR one
# Please note that mapped band need to be called by their mapped name and the specific one with their true name
olci_bands = olci_prod.load([YELLOW, Oa21])
Loading bands ['Oa21', 'YELLOW']
Converting Oa21 to reflectance
/opt/conda/lib/python3.10/site-packages/rasterio/__init__.py:287: NotGeoreferencedWarning: The given matrix is equal to Affine.identity or its flipped counterpart. GDAL may ignore this matrix and save no geotransform without raising an error. This behavior is somewhat driver-specific.
  dataset = writer(
Geocoding Oa21
Converting YELLOW to reflectance
Geocoding YELLOW
Read Oa21
Converting Oa21 to reflectance
Manage nodata for band Oa21
Read YELLOW
Converting YELLOW to reflectance
Manage nodata for band YELLOW
# Plot a subsampled version
olci_bands[YELLOW][:, ::10, ::10].plot()
<matplotlib.collections.QuadMesh at 0x7fd244deaad0>
../_images/8f2109f22a2cfe3477fb5ad3a01518735d6ed9e0d1c84c42bf459049ab187be0.png
olci_bands[Oa21][:, ::10, ::10].plot()
<matplotlib.collections.QuadMesh at 0x7fd24459ae60>
../_images/705804febe2c8acdce493409220cca6163e34239bc2044b2e2c3c9d3f5294459.png

Sentinel-3 SLSTR#

# Other SLSTR imports
from eoreader.keywords import SLSTR_VIEW, SLSTR_STRIPE, SLSTR_RAD_ADJUST
from eoreader.products import SlstrRadAdjustTuple, SlstrRadAdjust, SlstrView, SlstrStripe

# Then, let's focus on Sentinel-3 SLSTR data (extracted here, but a zip would work)
slstr_path = os.path.join(
    "/home", "data", "DATA", "PRODS", "S3",
    "S3B_SL_1_RBT____20191115T233722_20191115T234022_20191117T031722_0179_032_144_3420_LN2_O_NT_003.SEN3"
)
slstr_prod = reader.open(slstr_path, remove_tmp=True)
slstr_prod
eoreader.S3SlstrProduct 'S3B_SL_1_RBT____20191115T233722_20191115T234022_20191117T031722_0179_032_144_3420_LN2_O_NT_003'
Attributes:
	condensed_name: 20191115T233722_S3_SLSTR_RBT
	path: /home/data/DATA/PRODS/S3/S3B_SL_1_RBT____20191115T233722_20191115T234022_20191117T031722_0179_032_144_3420_LN2_O_NT_003.SEN3
	constellation: Sentinel-3 SLSTR
	sensor type: Optical
	product type: SL_1_RBT___
	default resolution: 500.0
	acquisition datetime: 2019-11-15T23:37:22.254773
	band mapping:
		GREEN: S1
		RED: S2
		NIR: S3
		NARROW_NIR: S3
		CIRRUS: S4
		SWIR_1: S5
		SWIR_2: S6
		THERMAL_IR_1: S8
		THERMAL_IR_2: S9
		S7: S7
		F1: F1
		F2: F2
	needs extraction: False
# Get the bands information
slstr_prod.bands
eoreader.SpectralBand 'F1'
Attributes:
	id: F1
	eoreader_name: F1
	common_name: 
	gsd (m): 1000.0
	asset_role: brightness_temperature
	Center wavelength (nm): 3742.0
	Bandwidth (nm): 398.0
	description: Active fire, brightness temperature, 1km
eoreader.SpectralBand 'F2'
Attributes:
	id: F2
	eoreader_name: F2
	common_name: 
	gsd (m): 1000.0
	asset_role: brightness_temperature
	Center wavelength (nm): 10854.0
	Bandwidth (nm): 776.0
	description: Active fire, brightness temperature, 1km
eoreader.SpectralBand 'S1'
Attributes:
	id: S1
	eoreader_name: GREEN
	common_name: green
	gsd (m): 500.0
	asset_role: reflectance
	Center wavelength (nm): 554.2700000000001
	Bandwidth (nm): 19.259999999999998
	description: Cloud screening, vegetation monitoring, aerosol
eoreader.SpectralBand 'S2'
Attributes:
	id: S2
	eoreader_name: RED
	common_name: red
	gsd (m): 500.0
	asset_role: reflectance
	Center wavelength (nm): 659.47
	Bandwidth (nm): 19.25
	description: NDVI, vegetation monitoring, aerosol
eoreader.SpectralBand 'S3'
Attributes:
	id: S3
	eoreader_name: NIR
	common_name: nir
	gsd (m): 500.0
	asset_role: reflectance
	Center wavelength (nm): 868.0
	Bandwidth (nm): 20.6
	description: NDVI, cloud flagging, pixel co-registration
eoreader.SpectralBand 'S3'
Attributes:
	id: S3
	eoreader_name: NARROW_NIR
	common_name: nir08
	gsd (m): 500.0
	asset_role: reflectance
	Center wavelength (nm): 868.0
	Bandwidth (nm): 20.6
	description: NDVI, cloud flagging, pixel co-registration
eoreader.SpectralBand 'S4'
Attributes:
	id: S4
	eoreader_name: CIRRUS
	common_name: cirrus
	gsd (m): 500.0
	asset_role: reflectance
	Center wavelength (nm): 1374.8
	Bandwidth (nm): 20.8
	description: Cirrus detection over land
eoreader.SpectralBand 'S5'
Attributes:
	id: S5
	eoreader_name: SWIR_1
	common_name: swir16
	gsd (m): 500.0
	asset_role: reflectance
	Center wavelength (nm): 1613.3999999999999
	Bandwidth (nm): 60.68
	description: Cloud clearing, ice, snow, vegetation monitoring
eoreader.SpectralBand 'S6'
Attributes:
	id: S6
	eoreader_name: SWIR_2
	common_name: swir22
	gsd (m): 1000.0
	asset_role: reflectance
	Center wavelength (nm): 2255.7
	Bandwidth (nm): 50.15
	description: Vegetation state and cloud clearing
eoreader.SpectralBand 'S7'
Attributes:
	id: S7
	eoreader_name: S7
	common_name: 
	gsd (m): 1000.0
	asset_role: brightness_temperature
	Center wavelength (nm): 3742.0
	Bandwidth (nm): 398.0
	description: SST, LST, Active fire, brightness temperature, 1km
eoreader.SpectralBand 'S8'
Attributes:
	id: S8
	eoreader_name: THERMAL_IR_1
	common_name: lwir11
	gsd (m): 1000.0
	asset_role: brightness_temperature
	Center wavelength (nm): 10854.0
	Bandwidth (nm): 776.0
	description: SST, LST, Active fire, brightness temperature, 1km
eoreader.SpectralBand 'S9'
Attributes:
	id: S9
	eoreader_name: THERMAL_IR_2
	common_name: lwir12
	gsd (m): 1000.0
	asset_role: brightness_temperature
	Center wavelength (nm): 12022.5
	Bandwidth (nm): 905.0
	description: SST, LST, brightness temperature, 1km
# Same remark for mapped and specific band than above
# Not that native radiance band are converted into reflectance, whereas brilliance temperature bands are not

# Load bands with nadir view and stripe B
# (for bands that have a stripe B, the other will load their unique stripe, namely A or I)
# RED: only stripe A
# SWIR_2: has strip 1, B and TDI (c)
# F1: has only stripe I
slstr_bn_bands = slstr_prod.load([RED, SWIR_2, F1], slstr_view="n", slstr_stripe="b")
slstr_bn_bands_2 = slstr_prod.load([RED, SWIR_2, F1], **{SLSTR_VIEW: SlstrView.NADIR, SLSTR_STRIPE: SlstrStripe.B})
Loading bands ['RED', 'SWIR_2', 'F1']
Converting RED to reflectance
Geocoding RED
Converting SWIR_2 to reflectance
Geocoding SWIR_2
Geocoding F1
Read RED
Converting RED to reflectance
Manage nodata for band RED
Read SWIR_2
Converting SWIR_2 to reflectance
Manage nodata for band SWIR_2
Read F1
Converting F1 to reflectance
Manage nodata for band F1
Loading bands ['RED', 'SWIR_2', 'F1']
Read RED
Read SWIR_2
Read F1
# You can use the keywords by importing them or copy their value.
# Their values can be passed as strings or as an Enum
# However, it seems safer to import the keywords and use the enum
# The result should be the same

# Please bear in mind that oblique and nadir views are not stackable !
# However, you can stack different stripes
# (but you cannot load them at once and you should collocate them to be sure, their reprojection grid may vary as their GCP vary)
# Plot a subsampled version
slstr_bn_bands[RED][:, ::10, ::10].plot()
<matplotlib.collections.QuadMesh at 0x7fd2431860e0>
../_images/51bc351b5bfdf70b9127d231898651c066cb991fa1bb76d0eb9126d17902a593.png
slstr_bn_bands[SWIR_2][:, ::10, ::10].plot()
<matplotlib.collections.QuadMesh at 0x7fd242dc4370>
../_images/9b3df4683556678b59c97eb15b739b73ca342664924d16abecbadace3a33ba1d.png
slstr_bn_bands[F1][:, ::10, ::10].plot()
<matplotlib.collections.QuadMesh at 0x7fd242986aa0>
../_images/1553b3577400fadd9be02e8d93a5679c9dbcb3bf4e7273b6bf49ca52d58cf260.png
# Sentinel-3 SLSTR radiance is not nominal, so EUMETSAT advises the user to make some radiance adjustments
# As stated here: https://www-cdn.eumetsat.int/files/2021-05/S3.PN-SLSTR-L1.08%20-%20i1r0%20-%20SLSTR%20L1%20PB%202.75-A%20and%201.53-B.pdf
# These coefficients have been added since the 06 version and several sets exist:

# The last one (S3.PN-SLSTR-L1.08, since 18/05/2021) which is also the default one
SlstrRadAdjust.S3_PN_SLSTR_L1_08
<SlstrRadAdjust.S3_PN_SLSTR_L1_08: SlstrRadAdjustTuple(S1_n=0.97, S2_n=0.98, S3_n=0.98, S4_n=1.0, S5_n=1.11, S6_n=1.13, S1_o=0.94, S2_o=0.95, S3_o=0.95, S4_o=1.0, S5_o=1.04, S6_o=1.07)>
# The two older sets given by EUMETSAT are the same
assert SlstrRadAdjust.S3_PN_SLSTR_L1_07 == SlstrRadAdjust.S3_PN_SLSTR_L1_06
SlstrRadAdjust.S3_PN_SLSTR_L1_07
<SlstrRadAdjust.S3_PN_SLSTR_L1_06: SlstrRadAdjustTuple(S1_n=1.0, S2_n=1.0, S3_n=1.0, S4_n=1.0, S5_n=1.12, S6_n=1.15, S1_o=1.0, S2_o=1.0, S3_o=1.0, S4_o=1.0, S5_o=1.2, S6_o=1.26)>
# Moreover, SNAP uses a different set with unknown origin (optional, in S3MPC Calibration)
SlstrRadAdjust.SNAP
<SlstrRadAdjust.SNAP: SlstrRadAdjustTuple(S1_n=1.0, S2_n=1.0, S3_n=1.0, S4_n=1.0, S5_n=1.12, S6_n=1.13, S1_o=1.0, S2_o=1.0, S3_o=1.0, S4_o=1.0, S5_o=1.15, S6_o=1.14)>
# A default set also exists, with every coefficient set to 1.0
SlstrRadAdjust.NONE
<SlstrRadAdjust.NONE: SlstrRadAdjustTuple(S1_n=1.0, S2_n=1.0, S3_n=1.0, S4_n=1.0, S5_n=1.0, S6_n=1.0, S1_o=1.0, S2_o=1.0, S3_o=1.0, S4_o=1.0, S5_o=1.0, S6_o=1.0)>
# You can use your own set by creating one.
# All the coefficients are set to 1.0 by default, so just modify the one you want
# The band keywords are {true_name}_{view_letter}
# RED is S2
user_set = SlstrRadAdjustTuple(S1_n=1.15, S2_o=1.12)

# However please bear in mind that if you want to reload the same band with a different adjustment, 
# you have to remove the temporary process folder or the previous band will be reloaded.
slstr_prod.clean_tmp()

# To apply these sets when loading a band, just add the keyword when loading it
red_pn_08 = slstr_bn_bands[RED]
slstr_red_bn = slstr_prod.load(
    RED,
    **{
        SLSTR_VIEW: SlstrView.NADIR,
        SLSTR_STRIPE: SlstrStripe.B,
        SLSTR_RAD_ADJUST: user_set
    }
)
red_user = slstr_red_bn[RED]
red_user[:, ::10, ::10].plot()
Loading bands ['RED']
Converting RED to reflectance
Geocoding RED
Read RED
Converting RED to reflectance
Manage nodata for band RED
<matplotlib.collections.QuadMesh at 0x7fd2425fb4c0>
../_images/ddf4450351666adce72a8ad13ed82909134bf867bfbbbd744630959d21d48b7c.png
# We may need to collocate the bands if we want to work on two sets loaded apart
# Indeed, in EOReader, the bands are collocated when loaded together

# For example, if we wanted to work on the SWIR or F1 band, 
# as we first loaded them with the RED, they are collocated to this band (the first one) 
# Yet, their geodetic grid are different from the RED one (in and bn are slightly different than the an)
# So if we load on a second time only the SWIR or the F1 band, their are chances that the geocoding might be a little different
# The it is best to collocate the two bands just to be sure they will always match (and have the same size)

# To do so you could do:
from sertit import rasters

red_user = rasters.collocate(master_xds=red_pn_08, slave_xds=red_user)

# Here, it is useless as we work on the master band
abs(red_pn_08 - red_user)[:, ::10, ::10].plot()
<matplotlib.collections.QuadMesh at 0x7fd23bd27df0>
../_images/b6af0f4be20be8659d0463da9ab67d36f40202ed7a0d6d63840e288cae856fe9.png