- Home
- Documentation
- API reference
- Readers
- hyperproc.readers.enmap
hyperproc.readers.enmap¶
Source-derived reference
Generated from the current hyperproc 0.1.2 checkout.
Implementation: hyperproc/readers/enmap.py. Signatures, defaults, docstrings, and expandable source are extracted statically; the module is not imported or executed. Names beginning with _ are implementation details, not a stable public API.
Use the function signature as the authority for individual parameter defaults and return annotations. Original docstrings sometimes group parameter names or wrap return descriptions across lines; these descriptions are preserved rather than inferred or rewritten.
EnMAP (DLR/GFZ) reader for L1B / L1C / L2A GeoTIFF products.
224 bands, 418-2445 nm, 30 m, from a VNIR (91 bands) and a SWIR (133 bands) spectrometer that overlap around 902-993 nm.
Three things differ from the other sensors here:
- L1B is two detectors on two grids, and stays that way here. DLR ships
SPECTRAL_IMAGE_VNIRandSPECTRAL_IMAGE_SWIRas separate files - and, tellingly, separate per-detector quality and pixel-mask products too - because at L1B the two focal planes have not been co-registered; that alignment is what the L1C geometric processing does. Stacking the two arrays by pixel index would produce a tidy 224-band cube whose spectra do not all come from the same ground spot, so the reader returns one detector at a time and refusescube="full"on L1B. Both TIFs carry an identical EPSG:4326 affine; it is a scene-level corner fit (about 34 x 32 m implied pixels), not a georeference, so it is kept asattrs["approx_geocoding_gdal"]and not ascrs/transform-to_geotiffrefuses an L1B cube, as it does for DESIS L1B. L1C and L2A ship one merged, co-registered 224-band file. - Angles are given per scene corner, not as a scalar or a raster. Viewing
zenith runs 20.1 to 22.7 degrees across this scene, so the reader bilinearly
interpolates the four corners into a real per-pixel grid. The corner values
themselves stay in
ds.attrs. - The sun angle is an elevation, not a zenith. It is converted here
(
sza = 90 - elevation) so it matches every other reader.
Scaling is value = DN * GainOfBand + OffsetOfBand. L2A uses a uniform gain
of 1e-4 with zero offset; L1B and L1C carry a per-band gain and offset.
LEVEL_SPEC = {'L1B': ('radiance', 'W/m^2/sr/nm', 'at-sensor TOA radiance', 0), 'L1C': ('radiance', 'W/m^2/sr/nm', 'at-sensor TOA radiance, orthorectified', 0), 'L2A': ('reflectance', '1', 'surface reflectance', -32768)}
module-attribute
¶
QUALITY_LAYERS = {'cloud': 'QL_QUALITY_CLOUD', 'cloudshadow': 'QL_QUALITY_CLOUDSHADOW', 'cirrus': 'QL_QUALITY_CIRRUS', 'haze': 'QL_QUALITY_HAZE', 'snow': 'QL_QUALITY_SNOW', 'classes': 'QL_QUALITY_CLASSES', 'testflags': 'QL_QUALITY_TESTFLAGS'}
module-attribute
¶
ANGLE_TAGS = {'sunAzimuthAngle': 'saa', 'viewingZenithAngle': 'vza', 'viewingAzimuthAngle': 'vaa', 'sceneAzimuthAngle': 'scene_azimuth', 'acrossOffNadirAngle': 'across_off_nadir', 'alongOffNadirAngle': 'along_off_nadir'}
module-attribute
¶
_CORNERS = ('upper_left', 'upper_right', 'lower_right', 'lower_left')
module-attribute
¶
_GRANULE = re.compile('^ENMAP01-_*(?P<level>L1B|L1C|L2A)-(?P<rest>.+?)-SPECTRAL_IMAGE(?:_(?P<arm>VNIR|SWIR))?(?:_COG)?\\.TIF$', re.IGNORECASE)
module-attribute
¶
_beside(path: Path, name: str) -> Path
¶
The sibling name, or DLR's cloud-optimised spelling of it.
The EOC Geoservice publishes every raster twice over: the plain GeoTIFF the
order form delivers, and a _COG copy, which is what the STAC catalogue
links and therefore what :func:hyperproc.search downloads. They hold the
same bands, so accepting both here means a searched granule opens without
anyone renaming files. Returns the plain name when neither exists, so the
caller's "missing" message names the file people expect.
Source code in hyperproc/readers/enmap.py
open_enmap(path: str | Path, cube: str | None = None, wl_range: tuple[float, float] | None = None, quality: bool = True, pixelmask: bool = False, angles: bool = True, apply_scale: bool = True) -> xr.Dataset
¶
Open an EnMAP granule.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
the
TYPE:
|
cube
|
L1B only.
TYPE:
|
wl_range
|
TYPE:
|
quality
|
attach the single-band quality rasters -
TYPE:
|
pixelmask
|
attach the per-band pixel mask as
TYPE:
|
angles
|
interpolate the corner angles into per-pixel
TYPE:
|
apply_scale
|
apply the per-band gain and offset.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dataset
|
Dataset with |
Source code in hyperproc/readers/enmap.py
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 | |
_lazy_cube(path: Path) -> xr.DataArray
¶
The GeoTIFF as a lazy (band, y, x) float32 array in full-width row strips.
Source code in hyperproc/readers/enmap.py
_parse_metadata(path: Path)
¶
Source code in hyperproc/readers/enmap.py
_corner_grid(c: dict, ny: int, nx: int) -> np.ndarray
¶
Bilinear fill of a scene from its four corner values.
Source code in hyperproc/readers/enmap.py
_footprint_pixels(root, crs, transform, ny: int, nx: int)
¶
Pixel (col, row) of the four footprint corners, in _CORNERS order, or None.
The angle corners in the XML belong to the footprint (boundingPolygon
of spatialCoverage), which on the north-up L1C/L2A raster is a rotated
quadrilateral inside the box, not the box's corners.
Source code in hyperproc/readers/enmap.py
_footprint_grid(c: dict, corners, ny: int, nx: int) -> np.ndarray
¶
Plane through the four footprint-corner values, NaN outside the footprint.
Corner angles vary linearly across a scene to well under 0.1 deg, so a least-squares plane on (col, row) reproduces the given corner values and, unlike a bilinear fill of the raster box, puts them where the footprint corners actually are (0.55 deg error at the corners otherwise).
Source code in hyperproc/readers/enmap.py
_signed_area(cr: np.ndarray) -> float
¶
_add_angles(ds: xr.Dataset, meta: Path, ny: int, nx: int, crs=None, transform=None) -> None
¶
Source code in hyperproc/readers/enmap.py
_add_quality(ds: xr.Dataset, path: Path, stem: str, ny: int, nx: int) -> None
¶
Source code in hyperproc/readers/enmap.py
_add_pixelmask(ds: xr.Dataset, path: Path, stem: str, level: str, bidx: np.ndarray, n_vnir: int) -> None
¶
Per-band pixel mask, lazily, on the cube's own band axis.
The mask file has one band per spectral band of the file it belongs to,
so the cube's source band positions (bidx) index it directly at
L1C/L2A; at L1B only the opened detector's mask applies, and the SWIR
positions are offset by the VNIR band count.