msi_processor.common package#
Platform/services layer (C-COMMON).
Shared, CPM-free data structures and helpers used across the processing
chain: the pure-core payload types (msi_processor.common.types) and
the quality-assurance metrics (msi_processor.common.metrics).
See SDD <5.2>a / <5.4.1>.
Submodules#
msi_processor.common.metrics module#
Quality-assurance metrics (DPM-M-QA; ALG-QA-*; ATBD <5.10>).
Pure, I/O-free implementations of the quality metrics, ported from the
heritage metrics_ips.py (RD-9). Referential metrics (MSE/RMSE/PSNR) are
computed against a reference aligned to the common extent; non-referential
metrics (SNR/variance) are computed from image statistics. Internal
arithmetic is float64 for stability; results are returned as Python floats.
Trace: REQ-F-QA-01..02; ATBD <5.10>; SDD <5.4.10>.
- class msi_processor.common.metrics.MetricSet(snr, rmse, psnr, mse, variance)#
Bases:
objectQA metrics per band (ALG-QA-*, SDD <5.4.1>).
rmse/psnr/msearenanwhen no reference is supplied.-
mse:
float#
-
psnr:
float#
-
rmse:
float#
-
snr:
float#
-
variance:
float#
-
mse:
- msi_processor.common.metrics.align_extent(a, b)#
Crop both arrays to their common (top-left) extent.
Mirrors the heritage
run_validationsize equalisation so referential metrics compare equal-shaped arrays (ATBD <5.10>).- Return type:
tuple[ndarray[tuple[Any,...],dtype[Any]],ndarray[tuple[Any,...],dtype[Any]]]
- msi_processor.common.metrics.compute_metrics(test, reference=None, bit_depth=12)#
Compute the full
MetricSetfortest(vs optional reference).SNR and variance are always computed; RMSE/MSE/PSNR require a reference (otherwise
nan).testandreferenceare aligned to the common extent before the referential comparison.- Return type:
- msi_processor.common.metrics.mse(image, reference)#
ALG-QA-MSE — mean squared error against
reference.- Return type:
float
- msi_processor.common.metrics.psnr(image, reference, bit_depth=12)#
ALG-QA-PSNR — peak signal-to-noise ratio in dB.
Peak is \(2^{\mathrm{bit\_depth}} - 1\); returns
+infwhen the images are identical (MSE = 0).- Return type:
float
- msi_processor.common.metrics.rmse(image, reference)#
ALG-QA-RMSE — root mean squared error against
reference.- Return type:
float
- msi_processor.common.metrics.snr(image)#
ALG-QA-SNR — non-referential signal-to-noise ratio in dB.
\(\mathrm{SNR} = 20\log_{10}(\bar I / \sigma_I)\). Returns
+infwhen the standard deviation is zero (a constant image).- Return type:
float
- msi_processor.common.metrics.variance(image)#
ALG-QA-VAR — population variance of
image.- Return type:
float
msi_processor.common.types module#
Shared, CPM-free core data structures (SDD <5.4.1>, <5.5>).
These types are deliberately framework-independent (no eopf / no I/O) so
that the pure algorithmic cores can be unit-tested off-platform (REQ-D-03,
REQ-PORT-03). They mirror the element-level definitions of SDD <5.5>.
- class msi_processor.common.types.BandImage(data, qa, name, geom='focal_plane')#
Bases:
objectOne band in a generic 2-D geometry (SDD <5.4.1>).
- Parameters:
- data:
Pixel array, dtype
float32(working) oruint16(DN/packed), dims(line|y, detector|x). Valid range[0, 2**bit_depth - 1]for DN or[0.0, 1.0]for reflectance.- qa:
uint16QAFlagbitmask, same shape asdata; initial value0.- name:
Band id, from
profile.bands[].name(e.g."b2").- geom:
Geometry tag, one of
"focal_plane" | "instrument" | "map".
-
data:
ndarray[tuple[Any,...],dtype[Any]]#
-
geom:
str= 'focal_plane'#
-
name:
str#
-
qa:
ndarray[tuple[Any,...],dtype[uint16]]#
- class msi_processor.common.types.BandStack(bands, meta=<factory>)#
Bases:
objectThe inter-stage payload of the pure cores (SDD <5.4.1>, IF-CORE-01).
One
BandImageentry per band, plus a free-formmetamapping carrying acquisition/telemetry and per-stage parameters echoed for provenance (never private calibration values).- Attributes:
band_namesReturn the band ids in insertion order.
- property band_names: list[str]#
Return the band ids in insertion order.
-
meta:
dict[str,object]#
- class msi_processor.common.types.QAFlag(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntFlagPer-pixel quality bit registry (SDD <5.4.1>, ICD <5.3.3>E).
Flags are OR-accumulated only (monotone propagation, REQ-F-QA-02); the initial value of a QA mask is
0. This is the single source of truth mirrored byC-COM-QAFLAG.- Attributes:
denominatorthe denominator of a rational number in lowest terms
imagthe imaginary part of a complex number
numeratorthe numerator of a rational number in lowest terms
realthe real part of a complex number
Methods
as_integer_ratio(/)Return integer ratio.
bit_count(/)Number of ones in the binary representation of the absolute value of self.
bit_length(/)Number of bits necessary to represent self in binary.
conjugateReturns self, the complex conjugate of any int.
from_bytes(/, bytes[, byteorder, signed])Return the integer represented by the given array of bytes.
to_bytes(/[, length, byteorder, signed])Return an array of bytes representing an integer.
- CLOUD = 32#
- CLOUD_SHADOW = 64#
- COREG_FAIL = 16#
- DEFECTIVE = 8#
- LOST_PACKET = 2#
- NO_DATA = 1#
- SATURATED = 4#