eoio.readers.sentinel2.metadata.s2_prod_mtd module#
eoio.readers.sentinel2.metadata.s2_prod_mtd - reader for Sentinel-2 product metadata.
- class eoio.readers.sentinel2.metadata.s2_prod_mtd.S2ProdXMLReader(path: Path)[source]#
Bases:
XMLReaderSentinel-2 Level-1C product metadata reader.
This class provides semantic accessors for commonly used fields in the Sentinel-2 product metadata XML (MTD_MSIL1C.xml). It builds on the generic
XMLReaderto return domain-appropriate Python objects.- find_all_band_resolutions() dict[int, int][source]#
Return a mapping of band index to spatial resolution.
- find_band_central_wavelength(band_id: int) float[source]#
Return the central wavelength (nm) for a given band.
- find_bounds()[source]#
Return the product footprint as a Shapely polygon in lon/lat order.
The polygon is constructed from the
EXT_POS_LISTelement, which encodes latitude/longitude coordinate pairs.
- find_product_start_datetime() datetime[source]#
Return the product sensing start time as a timezone-aware datetime.
- find_quantification_values() dict[str, float | None][source]#
Return quantification values for reflectance and L2A auxiliary layers.
For L1C products, only
reflectanceis expected. For L2A products,reflectancecorresponds toBOA_QUANTIFICATION_VALUEand may be accompanied byAOT_QUANTIFICATION_VALUEandWVP_QUANTIFICATION_VALUE.- Returns:
- Dictionary with keys:
"reflectance""aot""wvp"
Missing values are returned as
None.
- find_reflectance_offsets() dict[str, int][source]#
Return reflectance additive offsets keyed by Sentinel-2 band token.
For L2A products, offsets are read from
BOA_ADD_OFFSET. For L1C products, offsets are read fromRADIO_ADD_OFFSET.- Returns:
Dictionary keyed by band token, for example
"B02".
- find_solar_irradiance() dict[int, float] | None[source]#
Return solar irradiance values per band (W/m²/µm).
- find_solar_irradiance_unit() str[source]#
Return the unit of the solar irradiance values.
This is read from the
unitattribute of the firstSOLAR_IRRADIANCEelement and is assumed to be consistent across all bands (as per Sentinel-2 product specification).- Returns:
Solar irradiance unit string (e.g.
"W/m²/µm").- Raises:
ValueError – If no solar irradiance elements are found or the unit attribute is missing.
- find_spectral_response(band_id: int) list[float][source]#
Return the spectral response function for a given band.
- Parameters:
band_id – Sentinel-2 band index (0–12).
- metadata_paths: dict[str, str] = {'aot_quantification_value': './n1:General_Info/Product_Image_Characteristics/QUANTIFICATION_VALUES_LIST/AOT_QUANTIFICATION_VALUE', 'boa_add_offset': './n1:General_Info/Product_Image_Characteristics/BOA_ADD_OFFSET_VALUES_LIST', 'boa_quantification_value': './n1:General_Info/Product_Image_Characteristics/QUANTIFICATION_VALUES_LIST/BOA_QUANTIFICATION_VALUE', 'bounds': './n1:Geometric_Info/Product_Footprint/Product_Footprint/Global_Footprint/EXT_POS_LIST', 'datatake_type': './n1:General_Info/Product_Info/Datatake/DATATAKE_TYPE', 'generation_time': './n1:General_Info/Product_Info/GENERATION_TIME', 'physical_gains': './n1:General_Info/Product_Image_Characteristics', 'processing_baseline': './n1:General_Info/Product_Info/PROCESSING_BASELINE', 'processing_level': './n1:General_Info/Product_Info/PROCESSING_LEVEL', 'product_doi': './n1:General_Info/Product_Info/PRODUCT_DOI', 'product_start_time': './n1:General_Info/Product_Info/PRODUCT_START_TIME', 'product_stop_time': './n1:General_Info/Product_Info/PRODUCT_STOP_TIME', 'product_type': './n1:General_Info/Product_Info/PRODUCT_TYPE', 'product_uri': './n1:General_Info/Product_Info/PRODUCT_URI', 'quantification_value': './n1:General_Info/Product_Image_Characteristics/QUANTIFICATION_VALUE', 'radio_add_offset': './n1:General_Info/Product_Image_Characteristics/Radiometric_Offset_List', 'reference_band': './n1:General_Info/Product_Image_Characteristics/REFERENCE_BAND', 'reflectance_conversion_u': './n1:General_Info/Product_Image_Characteristics/Reflectance_Conversion/U', 'sensing_orbit_direction': './n1:General_Info/Product_Info/Datatake/SENSING_ORBIT_DIRECTION', 'sensing_orbit_number': './n1:General_Info/Product_Info/Datatake/SENSING_ORBIT_NUMBER', 'solar_irradiance': './n1:General_Info/Product_Image_Characteristics/Reflectance_Conversion/Solar_Irradiance_List', 'spacecraft_name': './n1:General_Info/Product_Info/Datatake/SPACECRAFT_NAME', 'spectral_central_wavelength_band_0': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='0']/Wavelength/CENTRAL", 'spectral_central_wavelength_band_1': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='1']/Wavelength/CENTRAL", 'spectral_central_wavelength_band_10': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='10']/Wavelength/CENTRAL", 'spectral_central_wavelength_band_11': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='11']/Wavelength/CENTRAL", 'spectral_central_wavelength_band_12': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='12']/Wavelength/CENTRAL", 'spectral_central_wavelength_band_2': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='2']/Wavelength/CENTRAL", 'spectral_central_wavelength_band_3': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='3']/Wavelength/CENTRAL", 'spectral_central_wavelength_band_4': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='4']/Wavelength/CENTRAL", 'spectral_central_wavelength_band_5': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='5']/Wavelength/CENTRAL", 'spectral_central_wavelength_band_6': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='6']/Wavelength/CENTRAL", 'spectral_central_wavelength_band_7': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='7']/Wavelength/CENTRAL", 'spectral_central_wavelength_band_8': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='8']/Wavelength/CENTRAL", 'spectral_central_wavelength_band_9': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='9']/Wavelength/CENTRAL", 'spectral_resolution_band_0': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='0']/RESOLUTION", 'spectral_resolution_band_1': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='1']/RESOLUTION", 'spectral_resolution_band_10': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='10']/RESOLUTION", 'spectral_resolution_band_11': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='11']/RESOLUTION", 'spectral_resolution_band_12': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='12']/RESOLUTION", 'spectral_resolution_band_2': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='2']/RESOLUTION", 'spectral_resolution_band_3': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='3']/RESOLUTION", 'spectral_resolution_band_4': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='4']/RESOLUTION", 'spectral_resolution_band_5': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='5']/RESOLUTION", 'spectral_resolution_band_6': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='6']/RESOLUTION", 'spectral_resolution_band_7': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='7']/RESOLUTION", 'spectral_resolution_band_8': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='8']/RESOLUTION", 'spectral_resolution_band_9': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='9']/RESOLUTION", 'spectral_response_band_0': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='0']/Spectral_Response/VALUES", 'spectral_response_band_1': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='1']/Spectral_Response/VALUES", 'spectral_response_band_10': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='10']/Spectral_Response/VALUES", 'spectral_response_band_11': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='11']/Spectral_Response/VALUES", 'spectral_response_band_12': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='12']/Spectral_Response/VALUES", 'spectral_response_band_2': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='2']/Spectral_Response/VALUES", 'spectral_response_band_3': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='3']/Spectral_Response/VALUES", 'spectral_response_band_4': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='4']/Spectral_Response/VALUES", 'spectral_response_band_5': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='5']/Spectral_Response/VALUES", 'spectral_response_band_6': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='6']/Spectral_Response/VALUES", 'spectral_response_band_7': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='7']/Spectral_Response/VALUES", 'spectral_response_band_8': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='8']/Spectral_Response/VALUES", 'spectral_response_band_9': "./n1:General_Info/Product_Image_Characteristics/Spectral_Information_List/Spectral_Information[@bandId='9']/Spectral_Response/VALUES", 'wvp_quantification_value': './n1:General_Info/Product_Image_Characteristics/QUANTIFICATION_VALUES_LIST/WVP_QUANTIFICATION_VALUE'}#
Mapping from metadata keys to XPath expressions. Intended to be overridden by subclasses.