Sentinel-2 products and processing interfaces#

Core SAFE product I/O is a Python interface. Optional physical-model and surface-reflectance processing are separate C++ extension surfaces. Availability of an extension, admission of a particular input, and qualification of a result are separate questions.

SAFE assets, grids and band groups#

What you have or need

Python lookup

Grid or selection contract

Product groupings

Sentinel2Product.subdatasets

Lists the product’s groupings.

Individual entries

Sentinel2Product.assets

Lists assets that can be selected individually.

Missing spectral entries

Sentinel2Product.missing_spectral_assets

Identifies gaps in the spectral asset inventory.

A selected asset

open_asset

Opens the selected entry.

A band name

open_band

Supply resolution_metres when the same name occurs at more than one product resolution.

An ordered band group

open_bands

Preserves requested order and requires a common projected grid. Bands on different grids need a separate alignment step. See Read matching Sentinel-2 bands.

The public SAFE path and its supported asset declarations are in sentinel2.py. Its XML handling rejects DTDs and nesting deeper than 128. The asset inventory is the basis for selecting files in a particular product. It does not imply that every possible product or codec is supported.

Stored samples, offsets and nodata#

Lookup

Meaning

Stored samples

Reading radiometry metadata does not change stored sample values.

Source offset

A band can retain a source offset used by an optional radiometric conversion.

Optional conversion

Radiometry records conversion separately from the stored samples.

Nodata

A band can also carry a nodata marker identifying missing samples. It is independent of the source offset.

See the SAFE radiometry implementation for the fields associated with a selected band.

Optional physical processing#

The following entries are C++ interfaces in cugeo::raster::extensions::sentinel2. They are separate from Python SAFE product I/O.

C++ lookup

Preparation, artifacts and output

Availability, admission and qualification

physical_model

prepare(configuration) creates a model handle, and inspect() returns its inspection text. prepare_grid takes a grid request, CUDA context and stream and produces a separate physical_grid.

Optional physical-model capability. Configuration and artifacts must pass the implementation’s admission checks. The capability reports qualified=false.

physical_grid

A separately owned prepared handle. enqueue, query, wait, fields and geolocation expose execution and its products.

Its request and resources must be admitted for the prepared model and CUDA path. The capability reports qualified=false.

Both owners use retryable destruction: retain an owner whose close fails and retry destruction when the failure has cleared. The model and grid are distinct handles, so account for each owner’s lifetime and its admitted artifacts. See physical.hpp and the physical implementation.

Surface-reflectance interfaces#

These C++ entries are in cugeo::raster::extensions::sentinel2::surface_reflectance. The declarations specify individual processing interfaces. They do not establish whole-scene surface-reflectance qualification. Consult the linked declarations and C ABI for exact descriptor fields, units and input restrictions.

C++ lookup

Preparation and required inputs or buffers

Emitted handle or product

Build availability, admitted profile and qualification

AtmosphericLut, AtmosphericLutPrepared

Create a host coefficient LUT from explicit band, provenance, axis metadata, nodes and values, then prepare it for a CUDA context and stream. from_device prepares from device values. No atmospheric provider is selected implicitly.

Prepared LUT. staging_bytes() and sample() support sampling into three outputs.

CUDA preparation and sampling require the applicable compiled capability and admitted descriptors. The declarations do not establish whole-scene qualification.

upload_sen2cor_lut, sample_sen2cor_lut

Upload an external band table into caller-owned [7168, 6] CUDA storage. Sample it using five coordinate fields and six disjoint output fields.

Uploaded table and six SI radiative fields.

Requires the applicable CUDA extension and admitted table, band, resolution and descriptors. Whole-scene qualification is not established.

SurfaceFieldSampler

Prepare with transform, EPSG, dimensions, maximum rows and context. Query workspace size, then supply coordinates, registration, input fields and scratch to sample.

Three sampled source fields.

Context-bound CUDA interface. Input admission follows its declarations. Whole-scene qualification is not established.

SurfaceGeometryPlan, SurfaceGeometryPrepared

Build a plan from a native product and options, inspect resource paths and workspace requirements, then prepare for a context, maximum rows and stream.

Geometry, viewing, relative-azimuth, solar and registered illumination outputs.

Requires admitted product resources and the applicable CUDA path. Whole-scene qualification is not established.

source_illumination_workspace_bytes, source_illumination_cuda

Supply registered physical-node inputs and caller scratch.

Source illumination field.

CUDA path and declared input profile required. Whole-scene qualification is not established.

toa_to_surface_cuda

Supply TOA, path, transmission and albedo fields and output storage. The native overload accepts Float32 or Float64 atmospheric inputs and produces Float32 output.

Surface reflectance.

CUDA path and admitted raster descriptors required. Whole-scene qualification is not established.

normalize_radiative_terms, encode_l2a_cuda

Supply radiative fields and irradiance for normalization, and supply reflectance, quantification and offset for encoding.

Normalized fields or UInt16 counts with ties-to-even rounding.

CUDA path and declared input profile required. Encoding alone does not establish product qualification.

ddv_workspace_bytes, retrieve_ddv_cuda

Query caller-owned scratch capacity, then supply tables, source and destination fields and parameters.

VIS and support, counts and statistics.

CUDA path and admitted DDV inputs required. Whole-scene qualification is not established.

quality_validity_cuda, terrain_illumination_cuda

Supply quality planes or elevation and solar geometry fields.

Validity or terrain illumination fields.

CUDA path and declared input profile required. Whole-scene qualification is not established.

surface_correction_workspace_bytes, correct_surface_cuda, terrain_coefficients_cuda

Query correction scratch where needed and supply the declared source fields, parameters and output buffers.

Corrected surface or terrain-adjusted coefficients.

CUDA path and admitted descriptors required. Whole-scene qualification is not established.

compose_surface_geometry

Supply candidate and output fields, optional selection and a stream. Retain backing allocations and the stream through completion or error drain.

Ordered geometry or illumination composition.

Enqueues without a completion wait or device allocation. Observe execution errors when completing the supplied stream. Whole-scene qualification is not established.

The complete public declarations are in surface_reflectance.hpp. Runtime capabilities report compile-time availability: device reads depend on nvtiff, host orthorectification on orthorect, CUDA orthorectification on cuda plus orthorect, and CUDA reprojection on cuda. These flags do not by themselves admit a particular Sentinel-2 input or qualify a surface-reflectance product. See capabilities.rs.