Sentinel#
The reader family for ESA's Sentinel missions, built on GDAL's SENTINEL2 / SAFE drivers: GDAL parses the
product structure, pyramids does the raster ops, and this package adds the instrument semantics — which
subdataset is which band, how to turn DN into reflectance, how to read the scene-classification mask.
A .SAFE product opens through a bare Dataset.read_file(path), zipped or not — see the
Reading EO sources via read_file guide.
A Sentinel product is a catalog of rasters, not a raster, so it gets its own small model:
open_product— sniff the GDAL driver behind a path (.SAFE/MTD_*.xml/.zip) and return the right typedSentinelProduct(currentlyS2Product; Sentinel-1SAFEis a planned later phase and raises a clear error today).from_sentinel2— turnkey Sentinel-2 read into a pyramidsDataset: band selection, native-resolution choice, optional crop / reprojection, DN → reflectance tagging, and Level-2A SCL masking.collection_from_sentinel2— read several bands / products into aDatasetCollection.scl_mask/SclClass— Level-2A cloud / shadow masking via the scene-classification layer.
Product model#
pyramids_eo.sentinel
#
Sentinel product readers built on GDAL's SENTINEL2 / SAFE drivers.
The earth-observation reader family for ESA's Sentinel missions, layered on
pyramids the same way :mod:pyramids_eo.earthengine layers on the EEDAI
driver: GDAL parses the product structure, pyramids does the raster ops, and
this package adds the instrument semantics — which subdataset is which band, how
to turn DN into reflectance, how to read the scene-classification mask.
Public surface:
- :func:
open_product— open any supported Sentinel product into a typed model. - :func:
from_sentinel2— turnkey Sentinel-2 read → a pyramidsDataset. - :func:
scl_mask/ :class:SclClass— Level-2A cloud/shadow masking.
Sentinel-1 (SAFE) is planned as a later phase; :func:open_product raises a
clear error for it today.
SentinelProduct
#
Bases: ABC
A Sentinel product on disk — a catalog of openable rasters.
Concrete subclasses (:class:~pyramids_eo.sentinel.s2.S2Product, and a
future S1Product) add the mission-specific model. This base holds only
what every Sentinel product shares.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
The path (or connection root) the product was opened from. |
|
driver |
The GDAL driver short name ( |
|
metadata |
dict[str, str]
|
The container's default-domain metadata ( |
subdatasets |
list[Any]
|
The pyramids |
Source code in src/pyramids_eo/sentinel/product.py
mission
abstractmethod
property
#
Mission identifier, e.g. "sentinel-2".
product_type
abstractmethod
property
#
Product type token, e.g. "S2MSI2A" / "GRD".
SclClass
#
Bases: IntEnum
Sentinel-2 L2A Scene-Classification codes (GDAL category names).
Each member's value is the integer pixel code the SCL band stores, so a member can be used directly as a class selector or compared with a raw code.
Examples:
- A member carries the SCL pixel code and its name:
- Build a cloud/shadow mask selection and read back the codes:
Source code in src/pyramids_eo/sentinel/s2/masks.py
open_product(path)
#
Open a Sentinel product and return its typed model.
Sniffs the GDAL driver behind path and dispatches to the concrete
product class. Accepts a .SAFE directory, a product metadata XML, a
manifest.safe, a .zip holding a .SAFE (opened in place), or a
driver connection string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The product to open. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
SentinelProduct
|
class: |
SentinelProduct
|
class: |
Raises:
| Type | Description |
|---|---|
UnsupportedProductError
|
The path opens, but its driver is not a Sentinel product family this package models. |
ProductError
|
The path cannot be opened as a product. |
Examples:
- Open a Level-2A product and inspect its subdatasets:
Source code in src/pyramids_eo/sentinel/product.py
collection_from_sentinel2(paths, *, root_dir, **kwargs)
#
Read a time series of Sentinel-2 products into a DatasetCollection.
Each product in paths is read with :func:from_sentinel2 (passing
**kwargs through) and written as a GeoTIFF under root_dir; the
written files are then assembled into a DatasetCollection.
The collection is file-backed on purpose, for the two things that still
need it on pyramids-core >= 0.73.0: DatasetCollection.to_zarr and
to_kerchunk require a file-backed collection outright, and out-of-core scale
depends on it — the in-memory cube reads each scene's array eagerly (only the
time stack is lazy), whereas a file-backed collection reads tile-by-tile, so a
series larger than RAM stays readable. Time-axis reductions no longer need
it: since pyramids-core 0.73.0 they also run on a resident datasets=
collection, which is what :func:collection_from_earthengine returns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
Sequence[str | Path]
|
The Sentinel-2 products (any form :func: |
required |
root_dir
|
str | Path
|
Directory the per-scene GeoTIFFs are written to (created if absent). |
required |
**kwargs
|
Any
|
Forwarded to :func: |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
A |
Raises:
| Type | Description |
|---|---|
ProductError
|
|
Source code in src/pyramids_eo/sentinel/s2/reader.py
from_sentinel2(path, *, bands=None, resolution=None, epsg=None, bbox=None, crs=None, reflectance=True, mask_scl=None, resample='nearest', path_out=None)
#
Read a Sentinel-2 product into a pyramids Dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path | S2Product
|
A product path ( |
required |
bands
|
list[str] | None
|
Band names to read (e.g. |
None
|
resolution
|
int | None
|
Native resolution in metres (10 / 20 / 60). |
None
|
epsg
|
int | None
|
UTM EPSG code, required only for a multi-zone product. |
None
|
bbox
|
BBox | None
|
Optional crop window |
None
|
crs
|
str | int | None
|
Optional target CRS (an EPSG integer or a WKT string) to reproject to. |
None
|
reflectance
|
bool
|
When |
True
|
mask_scl
|
list[Any] | None
|
L2A only — classes to mask out (see
:class: |
None
|
path_out
|
str | Path | None
|
When given, also write the result there (COG by extension). |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A pyramids |
Note
No-data is declared in the DN domain (the GDAL convention). Because
reflectance is applied as lazy scale / offset tags, the default
read_array() returns DN * scale + offset for every pixel — so a
DN no-data (and any SCL-masked pixel) reads back as the scaled
sentinel, not the declared no_data_value. On a baseline-≥04.00
product (offset ≈ −1000) a DN-0 no-data reads as ≈ −0.1, not 0. Test for
no-data against a read_array(unpack=False) read, not against a
reflectance one.
Raises:
| Type | Description |
|---|---|
ProductError
|
The product is missing a requested band / resolution, or
a multi-zone product is read without |
Examples:
- Read the red and NIR bands as reflectance:
Source code in src/pyramids_eo/sentinel/s2/reader.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
scl_mask(dataset, classes, *, scl=None)
#
Mask dataset pixels whose SCL class is in classes.
Masked pixels are set to the dataset's no-data value across every band. The
SCL source is either an explicit scl (a single-band pyramids Dataset
or a 2-D NumPy array on the same grid), or — when scl is None — an
SCL band found within dataset itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Any
|
The pyramids |
required |
classes
|
Sequence[SclClass | str | int]
|
Classes to mask out (see :func: |
required |
scl
|
Any
|
Optional explicit SCL source aligned to |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A new pyramids |
Any
|
names, no-data value, and scale/offset tags are preserved. |
Raises:
| Type | Description |
|---|---|
ProductError
|
No SCL source is available, or its shape does not match
|
Source code in src/pyramids_eo/sentinel/s2/masks.py
pyramids_eo.sentinel.product
#
Product model: a Sentinel product is a catalog of rasters, not a raster.
Opening a Sentinel .SAFE (or its metadata XML / .zip) with GDAL yields a
0-band dataset whose payload is a set of subdatasets — one per resolution ×
UTM zone for Sentinel-2, one per swath × polarisation × calibration for
Sentinel-1. Dataset models a raster; it cannot model that catalog. So the
product is its own small class family:
- :class:
SentinelProduct— the abstract container (path, driver, mission, product type, raw metadata, the subdataset list). - :func:
open_product— sniffs the GDAL driver behind a path and returns the right concrete product (currently :class:~pyramids_eo.sentinel.s2.S2Product).
Nothing here subclasses Dataset: the readers return plain pyramids Dataset
objects, and the product only describes what can be read (see the
pyramids-eo/earthengine precedent — no engine objects leak into public types).
SentinelProduct
#
Bases: ABC
A Sentinel product on disk — a catalog of openable rasters.
Concrete subclasses (:class:~pyramids_eo.sentinel.s2.S2Product, and a
future S1Product) add the mission-specific model. This base holds only
what every Sentinel product shares.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
The path (or connection root) the product was opened from. |
|
driver |
The GDAL driver short name ( |
|
metadata |
dict[str, str]
|
The container's default-domain metadata ( |
subdatasets |
list[Any]
|
The pyramids |
Source code in src/pyramids_eo/sentinel/product.py
mission
abstractmethod
property
#
Mission identifier, e.g. "sentinel-2".
product_type
abstractmethod
property
#
Product type token, e.g. "S2MSI2A" / "GRD".
open_connection(connection)
#
Open a GDAL driver connection string as a pyramids Dataset.
A SubDataset.name from a zipped product —
SENTINEL2_L2A:/vsizip/…:60m:EPSG_32632 — used to trip pyramids' archive
auto-detection, which saw the embedded .zip and re-wrapped the whole
string in a second /vsizip/. pyramids 0.57 fixed that (it no longer
re-wraps an already-resolved /vsi path), so every connection now goes
through Dataset.read_file — which also applies the cloud credentials and
open options that a bare gdal.Open skipped for remote products.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection
|
str
|
A GDAL connection string / path. |
required |
Returns:
| Type | Description |
|---|---|
Dataset
|
The opened :class: |
Raises:
| Type | Description |
|---|---|
ProductError
|
GDAL cannot open the connection. |
Source code in src/pyramids_eo/sentinel/product.py
open_product(path)
#
Open a Sentinel product and return its typed model.
Sniffs the GDAL driver behind path and dispatches to the concrete
product class. Accepts a .SAFE directory, a product metadata XML, a
manifest.safe, a .zip holding a .SAFE (opened in place), or a
driver connection string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The product to open. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
SentinelProduct
|
class: |
SentinelProduct
|
class: |
Raises:
| Type | Description |
|---|---|
UnsupportedProductError
|
The path opens, but its driver is not a Sentinel product family this package models. |
ProductError
|
The path cannot be opened as a product. |
Examples:
- Open a Level-2A product and inspect its subdatasets:
Source code in src/pyramids_eo/sentinel/product.py
Sentinel-2#
pyramids_eo.sentinel.s2.reader
#
Turnkey Sentinel-2 reader → a pyramids Dataset.
:func:from_sentinel2 mirrors the shape of
:func:pyramids_eo.from_earthengine: one flat-keyword call that opens a
Sentinel-2 product, picks the requested bands at a resolution, optionally
converts DN → reflectance (as lazy scale/offset tags), masks cloud/shadow via
the Scene-Classification band, and crops / reprojects — returning a plain
pyramids Dataset with no Sentinel objects leaking out.
Built entirely on pyramids 0.64+ APIs: Dataset.subdatasets /
open_subdataset for the catalog, Dataset.bands.select for band subsetting
(1-based, or by name), Dataset.read_array() for the lazy reflectance read the
scale/offset tags drive, and crop / to_crs for the spatial ops.
from_sentinel2(path, *, bands=None, resolution=None, epsg=None, bbox=None, crs=None, reflectance=True, mask_scl=None, resample='nearest', path_out=None)
#
Read a Sentinel-2 product into a pyramids Dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path | S2Product
|
A product path ( |
required |
bands
|
list[str] | None
|
Band names to read (e.g. |
None
|
resolution
|
int | None
|
Native resolution in metres (10 / 20 / 60). |
None
|
epsg
|
int | None
|
UTM EPSG code, required only for a multi-zone product. |
None
|
bbox
|
BBox | None
|
Optional crop window |
None
|
crs
|
str | int | None
|
Optional target CRS (an EPSG integer or a WKT string) to reproject to. |
None
|
reflectance
|
bool
|
When |
True
|
mask_scl
|
list[Any] | None
|
L2A only — classes to mask out (see
:class: |
None
|
path_out
|
str | Path | None
|
When given, also write the result there (COG by extension). |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A pyramids |
Note
No-data is declared in the DN domain (the GDAL convention). Because
reflectance is applied as lazy scale / offset tags, the default
read_array() returns DN * scale + offset for every pixel — so a
DN no-data (and any SCL-masked pixel) reads back as the scaled
sentinel, not the declared no_data_value. On a baseline-≥04.00
product (offset ≈ −1000) a DN-0 no-data reads as ≈ −0.1, not 0. Test for
no-data against a read_array(unpack=False) read, not against a
reflectance one.
Raises:
| Type | Description |
|---|---|
ProductError
|
The product is missing a requested band / resolution, or
a multi-zone product is read without |
Examples:
- Read the red and NIR bands as reflectance:
Source code in src/pyramids_eo/sentinel/s2/reader.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
collection_from_sentinel2(paths, *, root_dir, **kwargs)
#
Read a time series of Sentinel-2 products into a DatasetCollection.
Each product in paths is read with :func:from_sentinel2 (passing
**kwargs through) and written as a GeoTIFF under root_dir; the
written files are then assembled into a DatasetCollection.
The collection is file-backed on purpose, for the two things that still
need it on pyramids-core >= 0.73.0: DatasetCollection.to_zarr and
to_kerchunk require a file-backed collection outright, and out-of-core scale
depends on it — the in-memory cube reads each scene's array eagerly (only the
time stack is lazy), whereas a file-backed collection reads tile-by-tile, so a
series larger than RAM stays readable. Time-axis reductions no longer need
it: since pyramids-core 0.73.0 they also run on a resident datasets=
collection, which is what :func:collection_from_earthengine returns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
Sequence[str | Path]
|
The Sentinel-2 products (any form :func: |
required |
root_dir
|
str | Path
|
Directory the per-scene GeoTIFFs are written to (created if absent). |
required |
**kwargs
|
Any
|
Forwarded to :func: |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
A |
Raises:
| Type | Description |
|---|---|
ProductError
|
|
Source code in src/pyramids_eo/sentinel/s2/reader.py
pyramids_eo.sentinel.s2.product
#
Sentinel-2 product model — parses one MSI product into a typed catalog.
The GDAL SENTINEL2 driver exposes a product as subdatasets, one per
resolution × UTM zone (10 m / 20 m / 60 m) plus preview / true-colour views.
:class:S2Product reads that layout plus the product metadata block into a
queryable model: which bands live at which resolution, the processing baseline
and quantification value needed to turn DN into reflectance, cloud cover, and
the footprint.
It holds no pixels — :meth:S2Product.subdataset_for hands back a pyramids
SubDataset you open on demand, and the reader
(:func:pyramids_eo.sentinel.s2.reader.from_sentinel2) drives it.
S2Subdataset
#
One resolution × UTM-zone image subdataset of an S2 product.
A thin typed wrapper over the pyramids SubDataset value object, adding
the parsed resolution / EPSG / band list. Open it with :meth:open.
Attributes:
| Name | Type | Description |
|---|---|---|
resolution_m |
Native ground sampling distance in metres (10 / 20 / 60). |
|
epsg |
UTM EPSG code of the subdataset. |
|
bands |
Band names the subdataset carries, in driver order (spectral
|
Source code in src/pyramids_eo/sentinel/s2/product.py
S2Product
#
Bases: SentinelProduct
A parsed Sentinel-2 MSI product (L1C / L2A; L1B partially).
Built by :func:pyramids_eo.sentinel.open_product. Exposes the product's
structure and the metadata a reader needs to calibrate it.
Attributes:
| Name | Type | Description |
|---|---|---|
level |
The :class: |
|
baseline |
Processing baseline string (e.g. |
|
quantification |
DN → reflectance divisor ( |
|
cloud_cover |
Scene cloud-cover percentage, or |
|
footprint |
Product footprint as a WKT polygon string, or |
|
resolutions |
list[int]
|
Sorted native resolutions present (metres). |
epsg_codes |
list[int]
|
Sorted UTM EPSG codes present. |
Source code in src/pyramids_eo/sentinel/s2/product.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
mission
property
#
Mission identifier.
product_type
property
#
Product type token (e.g. "S2MSI2A"), or a fallback from the level.
The fallback drops the L from the level (L2A -> S2MSI2A) to
match ESA's canonical token, rather than emitting S2MSIL2A.
resolutions
property
#
Sorted native resolutions present in the product (metres).
epsg_codes
property
#
Sorted UTM EPSG codes present in the product.
image_subdatasets
property
#
The spectral / derived image subdatasets (excludes preview / TCI).
available_bands
property
#
Every band name present across the product's image subdatasets.
resolution_of(band)
#
Return the finest native resolution (m) that carries band.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
band
|
str
|
Band name, e.g. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The finest resolution in metres offering the band. |
Raises:
| Type | Description |
|---|---|
ProductError
|
The band is not present in the product. |
Source code in src/pyramids_eo/sentinel/s2/product.py
subdataset_for(resolution_m, epsg=None)
#
Return the image subdataset at resolution_m (and epsg).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolution_m
|
int
|
Native resolution in metres (10 / 20 / 60). |
required |
epsg
|
int | None
|
UTM EPSG code to disambiguate a multi-zone product. |
None
|
Returns:
| Type | Description |
|---|---|
S2Subdataset
|
The matching :class: |
Raises:
| Type | Description |
|---|---|
ProductError
|
No unique subdataset matches. |
Source code in src/pyramids_eo/sentinel/s2/product.py
is_spectral_band(name)
#
True for a spectral MSI band (B01…B12, B8A); False for
auxiliary layers (AOT / CLD / SCL / SNW / WVP / TCI).
A spectral band is B followed by a digit (so B8A counts, BAND
does not).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A band name, e.g. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Examples:
- Numbered bands and the
B8Ared-edge band are spectral: - Auxiliary layers are not spectral:
Source code in src/pyramids_eo/sentinel/s2/product.py
pyramids_eo.sentinel.s2.masks
#
Scene-Classification (SCL) masking for Sentinel-2 Level-2A.
L2A carries a Scene Classification band whose integer codes label each pixel
(cloud, shadow, water, vegetation, …). The GDAL SENTINEL2 driver attaches
the class names as band category names; :class:SclClass mirrors them as a
typed enum so a mask reads [SclClass.CLOUD_HIGH_PROBA, SclClass.CLOUD_SHADOW]
rather than [9, 3].
:func:scl_mask sets the masked-out pixels to the dataset's no-data value.
Because category names survive reprojection since pyramids #1024, masking
may run before or after a warp — order is a convenience, not a correctness rule.
SclClass
#
Bases: IntEnum
Sentinel-2 L2A Scene-Classification codes (GDAL category names).
Each member's value is the integer pixel code the SCL band stores, so a member can be used directly as a class selector or compared with a raw code.
Examples:
- A member carries the SCL pixel code and its name:
- Build a cloud/shadow mask selection and read back the codes:
Source code in src/pyramids_eo/sentinel/s2/masks.py
scl_mask(dataset, classes, *, scl=None)
#
Mask dataset pixels whose SCL class is in classes.
Masked pixels are set to the dataset's no-data value across every band. The
SCL source is either an explicit scl (a single-band pyramids Dataset
or a 2-D NumPy array on the same grid), or — when scl is None — an
SCL band found within dataset itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Any
|
The pyramids |
required |
classes
|
Sequence[SclClass | str | int]
|
Classes to mask out (see :func: |
required |
scl
|
Any
|
Optional explicit SCL source aligned to |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A new pyramids |
Any
|
names, no-data value, and scale/offset tags are preserved. |
Raises:
| Type | Description |
|---|---|
ProductError
|
No SCL source is available, or its shape does not match
|
Source code in src/pyramids_eo/sentinel/s2/masks.py
pyramids_eo.sentinel.s2.scaling
#
DN → reflectance as lazy scale/offset tags, not an eager float array.
Sentinel-2 stores reflectance as scaled integers: reflectance = (DN + offset)
/ quantification, where quantification is the product's
L2A_BOA / L1C_TOA quantification value and offset is the per-band
radiometric offset that processing baselines >= 04.00 introduced
(BOA_ADD_OFFSET / RADIO_ADD_OFFSET; 0 before that).
The GDAL SENTINEL2 driver surfaces the offset in per-band metadata
(Dataset.band_metadata[i]), which is where :func:_band_offset reads it —
verified end-to-end against a real baseline-05.09 product (offset -1000
flows into read_array(); see test_baseline_509_*), not just
the offset parser.
Rather than materialise a float array, :func:tag_reflectance records the
conversion on the dataset's GDAL scale/offset so it is applied lazily by
Dataset.read_array(). The tags ride through to_crs and to_file,
but this reader's own _crop_to_bbox and the SCL mask both rebuild the raster
through from_array, which drops them — so the reader applies
:func:tag_reflectance as the last step, after any crop / reproject / mask.
In GDAL's real = DN * scale + offset terms:
scale = 1 / quantification
offset = band_offset / quantification
Only spectral B* bands are tagged; classification / auxiliary bands
(SCL / CLD / AOT / …) keep scale=1, offset=0 — they are not
reflectance.
tag_reflectance(dataset, product, *, offsets=None, spectral=None)
#
Tag dataset's spectral bands so a scaled read yields reflectance.
Sets per-band GDAL scale/offset on dataset in place and returns it.
Spectral bands get scale = 1/quantification and
offset = band_offset/quantification; every other band is left at
scale=1, offset=0. The reflectance is then obtained lazily with
dataset.read_array(); read_array(unpack=False) still returns DN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Any
|
A pyramids |
required |
product
|
S2Product
|
The :class: |
required |
offsets
|
list[float] | None
|
Optional per-band radiometric offsets, in band order. Passed by
the reader (captured from the original read) so tagging does not
depend on the driver's |
None
|
spectral
|
list[bool] | None
|
Optional per-band |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The same |
Note
The tags do not touch the no_data_value, which stays in the DN
domain. A scaled read therefore returns DN * scale + offset for the
no-data pixels too — compare against the raw no-data value, not a scaled
one (see :func:~pyramids_eo.sentinel.from_sentinel2).
Raises:
| Type | Description |
|---|---|
ProductError
|
The product's quantification value is zero / unusable. |