Radiometry¶
DN ↔ radiance ↔ reflectance conversions, sun/sensor geometry, brightness temperature, and simple atmospheric correction.
- DN / radiance / reflectance:
DNToRadiance,DNToReflectance,RadianceToDN,RadianceToReflectance,ReflectanceToRadiance - Brightness temperature:
BTFromRadiance - Sun geometry:
ComputeSZA,EarthSunDistanceCorrection,IntegratedIrradiance - Atmospheric correction:
DOS1(Chavez dark-object subtraction),SimpleAtmosphericCorrection - Stretches:
Gamma,MinMaxStretch,PercentileClip,ToFloat32 - Spectral response:
ApplySRF— Gaussian SRFs integrated on a 1-nm grid via georeader'stransform_to_srf; source wavelengths from the argument orattrs["wavelengths"], optional targetband_names - Tier-A primitives:
dn_to_radiance,radiance_to_dn,dn_to_reflectance,bt_from_radiance,dos1,min_max_normalize,percentile_clip,gamma_correct
geoops.radiometry
¶
Sensor-agnostic radiometric transforms.
A small palette of generic radiometric Operators — DN→radiance and DN→reflectance scalar decodes, dtype casts, and display-prep (min-max, percentile clip, gamma). They take user-supplied gain / offset / scale constants rather than reading sensor metadata.
Solar-geometry-aware TOA conversion is covered by RadianceToReflectance
/ ReflectanceToRadiance (carrier-aware wrappers over
georeader.reflectance.radiance_to_reflectance), with ComputeSZA,
EarthSunDistanceCorrection and IntegratedIrradiance for the
individual geometry terms. Sensor presets that read these constants
from product metadata are not part of this module: pass the per-band
irradiance / acquisition date yourself.
Examples:
Sentinel-2 L1C display pipeline::
import geoops as gz
s2_display = (
gz.radiometry.ToFloat32()
| gz.radiometry.DNToReflectance(scale=1e-4)
| gz.radiometry.PercentileClip(lower=2, upper=98)
| gz.radiometry.Gamma(gamma=1.2)
)
rgb = s2_display(s2_dn_geoarray)
Per-band gain and offset (Landsat-style)::
import numpy as np
gains = np.array([0.012, 0.013, 0.011, 0.009])
offsets = np.array([-60.0, -61.0, -55.0, -45.0])
op = gz.radiometry.DNToRadiance(gain=gains, offset=offsets)
radiance = op(dn_geoarray)
ApplySRF
¶
Bases: Operator
Convolve hyperspectral bands to target Gaussian-SRF multispectral bands.
For each target band k with center wavelength λ_k and FWHM
Δλ_k, build a normalised Gaussian SRF (:func:georeader.reflectance.srf)
on a 1-nm wavelength grid spanning the source range, then integrate
with :func:georeader.reflectance.transform_to_srf, which maps each
grid wavelength to its nearest source band:
.. math::
L_k \;=\; \frac{\displaystyle \int L(\lambda) \, R_k(\lambda) \, d\lambda}
{\displaystyle \int R_k(\lambda) \, d\lambda}
The 1-nm grid keeps the SRF well defined when a target FWHM is much
narrower than the source band spacing (the target then reads its
nearest source band). Targets the grid cannot represent -- a centre
outside the source range, or a FWHM far below 1 nm -- raise
ValueError instead of returning an all-zero band.
Nodata: the GeoArray goes to transform_to_srf (as georeader's
carrier, through :func:geoops._src.engine.to_engine), which
marks a target pixel missing when any source band that target reads
(weight above epsilon_srf) equals the input's
fill_value; non-finite source values propagate through the
weighted sum the same way. Those pixels hold the carried fill
(:func:geoops._src.valid.carried_fill: the input's fill for float
input, NaN for integer DN promoted to float). Source bands a
target does not read never invalidate it.
Output attrs: source per-band keys are dropped; wavelengths
holds the target centres and band_names the given band_names.
A (T, C, H, W) stack is convolved frame by frame. Plain
np.ndarray input (B, H, W) returns a plain float32 array
(NaN at non-finite pixels; there is no fill value to match).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_center_wavelengths
|
ndarray | list[float]
|
|
required |
target_fwhm
|
ndarray | list[float]
|
FWHM for each target band (nm). |
required |
source_wavelengths
|
ndarray | list[float] | None
|
Source hyperspectral band centres (nm).
Default |
None
|
band_names
|
list[str] | None
|
Optional names for the target bands, written to the
output's |
None
|
epsilon_srf
|
float
|
SRF threshold below which contribution is ignored.
Default |
0.0001
|
extrapolate
|
bool
|
Let georeader map grid wavelengths outside the source
range to the nearest edge band (only matters for fractional
source wavelengths). Default |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
On inconsistent target arrays, a non-positive FWHM, a target the source range / 1-nm grid cannot represent, or source wavelengths missing or not matching the band count. |
Examples:
>>> from geoops.radiometry import ApplySRF
>>> # Collapse a 5-band hyperspectral cube to two 20-nm-FWHM
>>> # Gaussian bands at 500 nm and 520 nm.
>>> op = ApplySRF(
... target_center_wavelengths=[500.0, 520.0],
... target_fwhm=[20.0, 20.0],
... source_wavelengths=[480.0, 490.0, 500.0, 510.0, 520.0],
... band_names=["b500", "b520"],
... )
>>> multispectral = op(hyperspectral_geoarray)
>>> # Source wavelengths can come from gt.attrs["wavelengths"].
>>> s2_like = ApplySRF(
... target_center_wavelengths=[490.0, 665.0, 842.0],
... target_fwhm=[65.0, 30.0, 115.0],
... )(emit_geoarray)
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | |
BTFromRadiance
¶
Bases: Operator
Convert thermal at-sensor radiance to brightness temperature (Kelvin).
Inversion of the Planck blackbody radiation law, in the standard Landsat/MTL form:
.. math::
T_B \;=\; \frac{K_2}{\ln\!\bigl(K_1 / L + 1\bigr)}
where L is at-sensor thermal radiance and K1/K2 are
sensor-specific pre-computed Planck constants supplied by the
product metadata (Landsat-8 OLI/TIRS Band 10 example:
K1=774.8853, K2=1321.0789). The output T_B is in
Kelvin and represents the temperature a blackbody would need to
emit the observed radiance — not the true surface temperature,
which additionally requires emissivity and atmospheric correction.
Nodata pixels hold the output fill (see the module docstring).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
K1
|
float | ndarray | list
|
Per-band Planck constant |
required |
K2
|
float | ndarray | list
|
Per-band Planck constant |
required |
dim
|
str
|
Name of the band dim (default |
'band'
|
axis
|
int | None
|
Deprecated: the band axis position. |
None
|
Examples:
>>> from geoops.radiometry import BTFromRadiance
>>> # Landsat-8 TIRS Band 10 published constants.
>>> op = BTFromRadiance(K1=774.8853, K2=1321.0789)
>>> brightness_temp = op(radiance_geoarray) # Kelvin
References
Planck, M. (1901). Ueber das Gesetz der Energieverteilung im Normalspectrum. Annalen der Physik 309, 553–563.
USGS Landsat-8 Data Users Handbook, §5.1 (TIRS thermal constants).
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 | |
ComputeSZA
¶
Bases: Operator
Compute the solar zenith angle (degrees) for a location and UTC datetime.
Graph source: computed from its configuration alone. An optional
input is accepted and ignored, so it can close a Sequential.
The Astronomical Almanac's solar position
(radiomax.geometry.solar_zenith), without refraction, within 0.0121°
of SPA over 2000–2050. The SZA is the complement of the
solar altitude — SZA = 90° - altitude — and enters the TOA
reflectance equation through cos(θ_z).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_coords
|
tuple[float, float]
|
|
required |
acquisition_date
|
datetime | str
|
UTC datetime of acquisition. |
required |
crs_coords
|
str | None
|
CRS of |
None
|
Examples:
>>> from datetime import datetime
>>> from geoops.radiometry import ComputeSZA
>>> # Summer solstice noon at San Francisco.
>>> op = ComputeSZA(
... center_coords=(-122.4, 37.8),
... acquisition_date=datetime(2024, 6, 21, 20, 0), # UTC
... )
>>> sza_deg = op() # ~16° (close to local solar noon)
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
DNToRadiance
¶
Bases: Operator
Convert DN to at-sensor radiance.
.. math::
L \;=\; \text{gain} \cdot DN / \text{scale} + \text{offset}
Pure linear decode; gain and offset come from sensor metadata. Pass scalars for uniform per-pixel coefficients, or 1-D sequences with one entry per band to apply different coefficients along the band axis.
See :func:~geoops.radiometry._src.array.dn_to_radiance for the
physics. The Operator additionally reshapes 1-D coefficients so
they broadcast along the configured axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gain
|
float | ndarray | list
|
Slope of the DN→L decode. Scalar or per-band sequence. |
required |
offset
|
float | ndarray | list
|
Intercept. Default |
0.0
|
scale
|
float | ndarray | list
|
DN scale divisor, applied before the gain. Scalar or
per-band sequence. Default |
1.0
|
dim
|
str
|
Name of the band dim (default |
'band'
|
axis
|
int | None
|
Deprecated: the band axis position. |
None
|
Examples:
>>> import numpy as np
>>> from geoops.radiometry import DNToRadiance
>>> # Landsat-8 OLI per-band radiance multiplicative + additive
>>> # constants from the MTL file (just illustrative numbers):
>>> gains = np.array([0.012, 0.013, 0.011, 0.009])
>>> offsets = np.array([-60.0, -61.0, -55.0, -45.0])
>>> dn_to_rad = DNToRadiance(gain=gains, offset=offsets)
>>> radiance = dn_to_rad(dn_geoarray) # shape preserved
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
DNToReflectance
¶
Bases: Operator
Convert DN to TOA / surface reflectance via a linear affine decode.
.. math::
\rho \;=\; \text{scale} \cdot DN + \text{offset}
scale is the slope (reflectance per DN unit) and offset is
the reflectance-units intercept — the canonical
y = m * x + b form. Matches Landsat Collection-2 SR verbatim
and absorbs the Sentinel-2 L1C RADIO_ADD_OFFSET after
multiplying it through the scale.
For sensors without a pre-scaled-reflectance product (raw radiance
only), use DNToRadiance then call
georeader.reflectance.radiance_to_reflectance (which handles
solar geometry properly).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scale
|
float | ndarray | list
|
Quantification slope (reflectance per DN unit). Scalar or per-band 1-D sequence. |
required |
offset
|
float | ndarray | list
|
Reflectance-units intercept. Default |
0.0
|
dim
|
str
|
Name of the band dim (default |
'band'
|
axis
|
int | None
|
Deprecated: the band axis position. |
None
|
Examples:
>>> from geoops.radiometry import DNToReflectance
>>> # Sentinel-2 L1C pre-2022: a single global scale, no offset.
>>> op = DNToReflectance(scale=1e-4)
>>> reflectance = op(s2_l1c_dn_geoarray)
>>>
>>> # Post-2022 S2 L1C: RADIO_ADD_OFFSET=-1000 in DN units
>>> # collapses to -0.1 in reflectance units (-1000 * 1e-4).
>>> op_v2 = DNToReflectance(scale=1e-4, offset=-0.1)
>>> reflectance = op_v2(s2_l1c_modern_dn_geoarray)
>>>
>>> # Landsat-8/9 Collection-2 surface reflectance.
>>> op_l8 = DNToReflectance(scale=2.75e-5, offset=-0.2)
>>> reflectance = op_l8(landsat_c2_sr_geoarray)
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
DOS1
¶
Bases: Operator
Apply a Chavez (1988) Dark-Object Subtraction (DOS1) approximation.
The simplest atmospheric correction in the DOS family: for each band, estimate the path-radiance / haze contribution as the darkest pixel (or low-percentile value) in the scene, then subtract it. Pixels in deep shadow or clear water should approach zero reflectance in the absence of atmospheric scattering, so any observed positive minimum is taken as the haze offset.
.. math::
\rho_{\text{surface},\,k}(x, y) \;=\; \max\!\bigl(\,\rho_{\text{TOA},\,k}(x, y) - \rho_{\text{dark},\,k},\; 0\bigr)
where ρ_dark,k is the configured low-percentile of band k
over the spatial axes. DOS1 assumes a single-scattering atmosphere
with no transmission correction — the more accurate variants
(DOS2, DOS3, DOS4 from Chavez 1996) layer atmospheric transmission
and Rayleigh modelling on top.
Fill-value pixels are excluded from the dark-object percentile and hold the output fill (see the module docstring).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dark_percentile
|
float
|
Spatial percentile in |
1.0
|
Examples:
>>> from geoops.radiometry import DOS1
>>> # Subtract the 1st-percentile haze per band from TOA
>>> # reflectance to approximate surface reflectance.
>>> op = DOS1(dark_percentile=1.0)
>>> surface = op(toa_reflectance_geoarray)
References
Chavez, P. S. (1988). An improved dark-object subtraction technique for atmospheric scattering correction of multispectral data. Remote Sensing of Environment 24(3), 459–479.
Chavez, P. S. (1996). Image-based atmospheric corrections — Revisited and improved. Photogrammetric Engineering & Remote Sensing 62(9), 1025–1036.
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
EarthSunDistanceCorrection
¶
Bases: Operator
Compute the Earth–Sun distance d (in AU) for an acquisition date.
Graph source: computed from its configuration alone. An optional
input is accepted and ignored, so it can close a Sequential.
The Astronomical Almanac's formula (radiomax.geometry.earth_sun_distance),
within 8.7e-5 AU of SPA over 2000–2050.
Perihelion (~Jan 3-4) → d ≈ 0.983 AU; aphelion (~Jul 4) →
d ≈ 1.017 AU. The irradiance reaching Earth scales as
1/d² (inverse square law); the d² factor appears in the
TOA-reflectance equation.
Returns a scalar — useful as a building block inside Graph
pipelines that need to thread the value through to a downstream
operator (e.g. an in-graph reflectance conversion).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
acquisition_date
|
datetime | str
|
Date and time of acquisition, UTC unless it carries a time zone. |
required |
Examples:
>>> from datetime import datetime
>>> from geoops.radiometry import EarthSunDistanceCorrection
>>> d = EarthSunDistanceCorrection(acquisition_date=datetime(2024, 1, 3))()
>>> # Perihelion -> ~0.983 AU.
>>> round(d, 3)
0.983
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
Gamma
¶
Bases: Operator
Power-law gamma correction.
.. math::
y \;=\; x^{1/\gamma}
Display-prep — gamma > 1 brightens midtones, gamma < 1
darkens them. A gentle gamma = 1.2 is the workhorse "satellite
RGB pop" default; sRGB encoding uses gamma ≈ 2.2. Values above
1 are not clipped; :class:geoops.viz.GammaCorrect is the
display-range variant (clips floats to [0, 1], handles byte
carriers) built on the same :func:gamma_correct.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gamma
|
float
|
Gamma factor (must be strictly positive). Default |
1.2
|
Examples:
>>> import geoops as gz
>>> # Classic display pipeline: stretch, then gamma-brighten.
>>> pipe = (
... gz.radiometry.PercentileClip()
... | gz.radiometry.Gamma(gamma=1.4)
... )
>>> rgb = pipe(reflectance_geoarray)
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
IntegratedIrradiance
¶
Bases: Operator
Compute band-integrated TOA solar irradiance from an SRF table.
Graph source: computed from its configuration alone. An optional
input is accepted and ignored, so it can close a Sequential.
.. math::
E_k \;=\; \frac{\displaystyle \int E_{\text{sun}}(\lambda) \, R_k(\lambda) \, d\lambda}
{\displaystyle \int R_k(\lambda) \, d\lambda}
Integrates a TOA solar spectrum (Thuillier 2003 by default, from
georeader) over a per-band spectral response function R_k(λ),
both read as linear between their samples
(radiomax.radiometry.response_matrix), to yield the
band-effective irradiance E_k that feeds
RadianceToReflectance. Output units match the input solar
spectrum (mW/m²/nm for the default Thuillier table — divide by
1000 before handing to the reflectance equation, which expects
SI W/m²/nm).
Holds a pandas.DataFrame — not YAML-serialisable, hence
forbid_in_yaml = True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
srf
|
DataFrame
|
Spectral response DataFrame. Index = wavelength (nm),
columns = band names. Shape |
required |
solar_irradiance
|
DataFrame | None
|
Optional solar-spectrum DataFrame with
columns |
None
|
epsilon_srf
|
float
|
The ends of the SRF table where no band's response is
above this are dropped. Default |
0.0001
|
Examples:
>>> import numpy as np
>>> import pandas as pd
>>> from geoops.radiometry import IntegratedIrradiance
>>> # Toy 3-wavelength SRF for a single band.
>>> srf_df = pd.DataFrame({"B1": [1.0, 1.0, 1.0]}, index=[499.0, 500.0, 501.0])
>>> # Flat 2 mW/m²/nm solar spectrum.
>>> solar = pd.DataFrame(
... {"Nanometer": [499.0, 500.0, 501.0],
... "Radiance(mW/m2/nm)": [2.0, 2.0, 2.0]}
... )
>>> e_band = IntegratedIrradiance(srf=srf_df, solar_irradiance=solar)()
>>> e_band
array([2.])
References
Thuillier, G. et al. (2003). The Solar Spectral Irradiance from 200 to 2400 nm as Measured by the SOLSPEC Spectrometer. Solar Physics 214(1), 1–22.
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 | |
MinMaxStretch
¶
Bases: Operator
Linear contrast stretch into [0, 1].
.. math::
y \;=\; \frac{x - v_{\min}}{v_{\max} - v_{\min}}
Display-prep — no physics; just a fixed-bound rescale. See
PercentileClip for the more robust per-scene variant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vmin
|
float
|
Lower bound (maps to 0). |
required |
vmax
|
float
|
Upper bound (maps to 1). Must be strictly greater than
|
required |
clip
|
bool
|
Whether to clamp output to |
True
|
Examples:
>>> from geoops.radiometry import MinMaxStretch
>>> # Stretch reflectance in [0, 0.3] to display range.
>>> op = MinMaxStretch(vmin=0.0, vmax=0.3)
>>> display_ready = op(reflectance_geoarray)
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
PercentileClip
¶
Bases: Operator
Per-band robust contrast stretch using percentile thresholds.
Computes :math:v_{lo} = P_{\text{lower}}(\text{arr}) and
:math:v_{hi} = P_{\text{upper}}(\text{arr}) over the configured
reduce_axes and rescales each slice into [0, 1]. NaN-safe: nodata
(fill / non-finite) pixels never enter the percentiles and come back
NaN. This is the one percentile stretch the display operators
build on — :class:geoops.viz.StretchToUint8 is this operator
followed by a byte cast, and :class:geoops.normalize.HistogramStretch
rescales its output into an arbitrary out_range; all three share
the lower / upper / reduce_axes vocabulary.
Robust against bright outliers (cumulus, specular reflection, sensor saturation): a tiny sub-percent population of bright pixels won't crush the rest of the histogram the way a true min/max would.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lower
|
float
|
Lower percentile. Default |
2.0
|
upper
|
float
|
Upper percentile. Default |
98.0
|
reduce_axes
|
int | tuple[int, ...] | None
|
Axis (or tuple) to compute percentiles over.
|
(-2, -1)
|
Examples:
>>> from geoops.radiometry import PercentileClip
>>> # Standard "satellite RGB" stretch -- per-band 2-98 %.
>>> op = PercentileClip(lower=2.0, upper=98.0)
>>> rgb = op(reflectance_geoarray)
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
RadianceToDN
¶
Bases: Operator
Convert at-sensor radiance back to raw DN — inverse of DNToRadiance.
.. math::
DN \;=\; (L - \text{offset}) \cdot \text{scale} / \text{gain}
The exact algebraic inverse of DNToRadiance; mostly useful when
you've manipulated radiance in physical units and want to round-trip
back to a sensor-native integer encoding (e.g. for re-quantisation
studies or for round-trip testing of an end-to-end pipeline).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gain
|
float | ndarray | list
|
Slope used by the forward decode. Scalar or per-band. |
required |
offset
|
float | ndarray | list
|
Intercept used by the forward decode. Default |
0.0
|
scale
|
float | ndarray | list
|
DN scale divisor used by the forward decode.
Default |
1.0
|
dim
|
str
|
Name of the band dim (default |
'band'
|
axis
|
int | None
|
Deprecated: the band axis position. |
None
|
Examples:
>>> import numpy as np
>>> from geoops.radiometry import DNToRadiance, RadianceToDN
>>> # Round-trip a synthetic radiance back to DN.
>>> radiance = DNToRadiance(gain=0.012, offset=-60.0)(dn_geoarray)
>>> dn = RadianceToDN(gain=0.012, offset=-60.0)(radiance)
>>> np.allclose(np.asarray(dn), np.asarray(dn_geoarray))
True
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
RadianceToReflectance
¶
Bases: Operator
Convert at-sensor radiance to TOA reflectance with solar geometry.
.. math::
\rho \;=\; \frac{L \, \pi \, d^{2}}{E_{\text{sun}} \, \cos(\theta_z)}
where L is at-sensor radiance, E_sun is per-band TOA solar
irradiance in :math:W \cdot m^{-2} \cdot nm^{-1}, d is the
Earth–Sun distance (AU) for the acquisition date and θ_z is the
solar zenith angle. The factor π·d²/cos(θ_z) is the
observation-date correction factor — pass sza_deg to provide
the angle from metadata, or center_coords to compute one angle
there for the whole scene.
This is a carrier-aware wrapper around
radiomax.radiometry.reflectance, with the unit table and the
JSON-safe get_config.
Geo-dependence: when neither sza_deg nor center_coords is
provided, the solar zenith is computed at every pixel, so the
input must be a georeferenced GeoArray (plain arrays raise
TypeError in that mode). Pixels at night (a zenith of 90° or more)
hold the fill.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solar_irradiance
|
ndarray | list
|
Per-band TOA solar irradiance in W/m²/nm,
shape |
required |
acquisition_date
|
datetime | str
|
UTC datetime of acquisition. |
required |
center_coords
|
tuple[float, float] | None
|
Optional |
None
|
sza_deg
|
float | None
|
Optional pre-computed solar zenith angle in degrees.
If provided, |
None
|
crs_coords
|
str | None
|
CRS of |
None
|
units
|
str
|
Radiance units. One of |
'W/m2/sr/nm'
|
Examples:
>>> from datetime import datetime
>>> import numpy as np
>>> from geoops.radiometry import RadianceToReflectance
>>> op = RadianceToReflectance(
... solar_irradiance=np.array([1.95, 1.85, 1.55]),
... acquisition_date=datetime(2024, 6, 21, 10, 30),
... sza_deg=27.0,
... units="W/m2/sr/nm",
... )
>>> reflectance = op(radiance_geoarray)
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | |
ReflectanceToRadiance
¶
Bases: Operator
Convert TOA reflectance back to at-sensor radiance — inverse of RadianceToReflectance.
.. math::
L \;=\; \frac{\rho \, E_{\text{sun}} \, \cos(\theta_z)}{\pi \, d^{2}}
Same solar-geometry inputs as the forward direction: pass
sza_deg for a metadata-driven SZA or center_coords for one
angle computed there.
Geo-dependence: when neither sza_deg nor center_coords is
provided, the solar zenith is computed at every pixel, so the
input must be a georeferenced GeoArray (plain arrays raise
TypeError in that mode).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solar_irradiance
|
ndarray | list
|
Per-band TOA solar irradiance in W/m²/nm. |
required |
acquisition_date
|
datetime | str
|
UTC datetime of acquisition. |
required |
center_coords
|
tuple[float, float] | None
|
Optional |
None
|
sza_deg
|
float | None
|
Optional pre-computed solar zenith angle (degrees). |
None
|
crs_coords
|
str | None
|
CRS of |
None
|
Examples:
>>> from datetime import datetime
>>> import numpy as np
>>> from geoops.radiometry import (
... RadianceToReflectance,
... ReflectanceToRadiance,
... )
>>> solar = np.array([1.95, 1.85])
>>> date = datetime(2024, 7, 14, 11, 32)
>>> fwd = RadianceToReflectance(
... solar_irradiance=solar, acquisition_date=date, sza_deg=30.0
... )
>>> inv = ReflectanceToRadiance(
... solar_irradiance=solar, acquisition_date=date, sza_deg=30.0
... )
>>> # Round-trip preserves radiance up to float precision.
>>> radiance_out = inv(fwd(radiance_geoarray))
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | |
SimpleAtmosphericCorrection
¶
Bases: Operator
Dispatch simple BOA approximations; currently supports method='dos1'.
Convenience entry point that picks an atmospheric-correction
strategy by name. Only "dos1" is implemented today; the
aod parameter is accepted but ignored — it's reserved for
future DOS2/DOS3/SMAC variants that will layer aerosol optical
depth on top of the dark-object estimate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
Correction strategy. Currently only |
'dos1'
|
dark_percentile
|
float
|
Forwarded to |
1.0
|
aod
|
float | None
|
Aerosol optical depth (reserved; currently ignored). |
None
|
Examples:
>>> from geoops.radiometry import SimpleAtmosphericCorrection
>>> op = SimpleAtmosphericCorrection(method="dos1", dark_percentile=1.0)
>>> surface = op(toa_reflectance_geoarray)
References
See DOS1 for the Chavez 1988/1996 references.
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
ToFloat32
¶
Bases: Operator
Cast the carrier's values to float32.
The first stop on most radiometric pipelines: sensor DN are usually
uint16, and downstream arithmetic (division for indices, gain
application, etc.) wants float. float32 is the right default for
imagery — half the memory of float64 with plenty of dynamic
range for reflectance.
Integer input with a fill value comes back with
fill_value=NaN and NaN at its nodata pixels (an
integer fill such as 0 would be a valid float value); float input
keeps its fill.
Examples:
>>> import geoops as gz
>>> # Standard first stage of a TOA-reflectance pipeline:
>>> pipe = (
... gz.radiometry.ToFloat32()
... | gz.radiometry.DNToReflectance(scale=1e-4)
... )
>>> reflectance = pipe(uint16_dn_geoarray)
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/operators.py
bt_from_radiance(radiance, k1, k2)
¶
Convert thermal radiance to brightness temperature.
.. math::
T = K_2 / \ln(K_1 / L + 1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radiance
|
Float[ndarray, '*dims']
|
Thermal at-sensor radiance |
required |
k1
|
float | Float[ndarray, '*coef']
|
Planck |
required |
k2
|
float | Float[ndarray, '*coef']
|
Planck |
required |
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
Brightness temperature in Kelvin; NaN where the radiance is not |
Float[ndarray, '*dims']
|
positive. |
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/array.py
dn_to_radiance(dn, gain, offset=0.0, scale=1.0)
¶
Convert raw DN to at-sensor radiance via per-band gain/offset.
.. math::
L \;=\; \text{gain} \cdot DN / \text{scale} + \text{offset}
The gain and offset come from the sensor metadata file (Landsat MTL, Sentinel-2 MTD, EMIT L1B, etc.). Pass scalars for single-band / uniform gain, or 1-D arrays shaped like the band axis to apply different coefficients per band — broadcasting handles the arithmetic.
Units of L are whatever the gain/offset are calibrated in,
typically :math:W \cdot m^{-2} \cdot sr^{-1} \cdot \mu m^{-1}. The
primitive itself is unit-agnostic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dn
|
Num[ndarray, '*dims']
|
Raw DN array. Any shape; the gain/offset broadcast across
it. A common pattern is |
required |
gain
|
float | Float[ndarray, '*coef']
|
Slope of the linear decode. Scalar or array. |
required |
offset
|
float | Float[ndarray, '*coef']
|
Intercept. Scalar or array. Default |
0.0
|
scale
|
float | Float[ndarray, '*coef']
|
Optional DN scale divisor. Default |
1.0
|
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
Radiance array of the same shape as |
Float[ndarray, '*dims']
|
promoted to float64 before any arithmetic, so integer |
Float[ndarray, '*dims']
|
coefficients can't overflow the DN dtype (cast outside if you |
Float[ndarray, '*dims']
|
want float32 to save memory); float input keeps its precision. |
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/array.py
dn_to_reflectance(dn, scale, offset=0.0)
¶
Convert DN to TOA / surface reflectance via a linear affine decode.
.. math::
\rho \;=\; \text{scale} \cdot DN + \text{offset}
The canonical pre-scaled-reflectance decode: scale is the slope
(reflectance per DN unit) and offset is the reflectance-units
intercept. This convention matches Landsat Collection-2 surface
reflectance verbatim and absorbs the Sentinel-2 L1C RADIO_ADD_OFFSET
after multiplying it out (see notes below).
Sensor-specific coefficients (illustrative — always consult the product MTL / metadata):
- Sentinel-2 L1C (pre-2022-01-25):
scale=1e-4, offset=0. - Sentinel-2 L1C (post-2022-01-25): the per-band
RADIO_ADD_OFFSET=-1000is in DN units; multiplied through the scale it becomesoffset = -1000 * 1e-4 = -0.1, so usescale=1e-4, offset=-0.1. - Landsat-8/9 Collection-2 SR:
scale=2.75e-5, offset=-0.2.
For sensors where the metadata gives gain/offset to radiance but
not a direct DN→ρ shortcut, do the two-step decode via
dn_to_radiance then the RadianceToReflectance operator (a
wrapper over georeader.reflectance.radiance_to_reflectance) for
the proper solar-geometry correction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dn
|
Num[ndarray, '*dims']
|
Raw DN array. |
required |
scale
|
float | Float[ndarray, '*coef']
|
Quantification slope (reflectance per DN unit). Scalar or per-band 1-D array. |
required |
offset
|
float | Float[ndarray, '*coef']
|
Reflectance-units intercept. Scalar or per-band 1-D
array. Default |
0.0
|
Returns:
| Type | Description |
|---|---|
Reflectance array; values should fall in
|
math: |
Float[ndarray, '*dims']
|
well-calibrated inputs. Integer DN are promoted to float64 |
Float[ndarray, '*dims']
|
before any arithmetic. |
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/array.py
dos1(reflectance, dark_percentile=1.0, *, reduce_axes=(-2, -1))
¶
Apply a simple DOS1 dark-object subtraction to reflectance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reflectance
|
Float[ndarray, '*dims']
|
TOA reflectance array. |
required |
dark_percentile
|
float
|
Percentile used as the dark-object estimate. |
1.0
|
reduce_axes
|
int | tuple[int, ...] | None
|
Axes over which to estimate the dark-object value. |
(-2, -1)
|
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
Reflectance with per-band dark-object values subtracted and clipped |
Float[ndarray, '*dims']
|
to zero. |
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/array.py
gamma_correct(arr, gamma=1.2)
¶
Apply a gamma (power-law) correction.
.. math::
y \;=\; x^{1/\gamma}
Display-prep helper: human visual perception of brightness is
nonlinear, so a power-law tweak after a min-max stretch brightens
midtones (gamma > 1) or darkens them (gamma < 1). Standard
sRGB encoding uses gamma ≈ 2.2; a gentle gamma = 1.2 is a
common "make satellite RGBs pop" default.
Negative inputs are clipped to zero before the power to avoid
complex-number warnings; reflectance should be non-negative anyway.
Values above 1 are not clipped (the display-range variant,
:func:geoops.viz.gamma_correct_display, clips to [0, 1]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
Float[ndarray, '*dims']
|
Input float array, ideally already in |
required |
gamma
|
float
|
Gamma factor. |
1.2
|
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
Float array of the same shape, gamma-corrected. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/array.py
min_max_normalize(arr, vmin, vmax, *, clip=True)
¶
Linearly map [vmin, vmax] to [0, 1].
.. math::
y \;=\; \frac{x - v_{\min}}{v_{\max} - v_{\min}}
A pure display-prep primitive: no physics, just a contrast stretch
that gets reflectance into the byte / display range. clip=True
forces out-of-range pixels to the endpoints; clip=False leaves
them as-is (useful when feeding a downstream model that wants
informative tails).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
Num[ndarray, '*dims']
|
Input array. |
required |
vmin
|
float
|
Lower bound (mapped to 0). Must be strictly less than
|
required |
vmax
|
float
|
Upper bound (mapped to 1). |
required |
clip
|
bool
|
Whether to clamp output to |
True
|
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
Float array. Shape and broadcasting preserved. Integer input |
Float[ndarray, '*dims']
|
(e.g. |
Float[ndarray, '*dims']
|
before subtracting |
Float[ndarray, '*dims']
|
0 instead of wrapping around. |
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/array.py
percentile_clip(arr, lower=2.0, upper=98.0, *, reduce_axes=(-2, -1))
¶
Robust contrast stretch using percentile thresholds.
Computes :math:v_{lo} = P_{\text{lower}}(\text{arr}) and
:math:v_{hi} = P_{\text{upper}}(\text{arr}) over the configured
reduce_axes, then min-max normalises arr between them with
clipping. The percentile thresholds are far more robust than fixed
vmin / vmax against bright outliers (cumulus clouds, specular
water glint, sensor saturation).
NaN-safe: thin wrapper over the shared
:func:geoops._src.stretch.percentile_stretch, whose percentiles
are np.nanpercentile (NaN pixels never shift the thresholds and
stay NaN in the output).
Default reduce_axes=(-2, -1) computes percentiles per leading band /
time slice — the typical "RGB display per band" mode. Pass
reduce_axes=None for a single global percentile across the whole
array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
Shaped[ndarray, '*dims']
|
Input float array. |
required |
lower
|
float
|
Lower percentile (in |
2.0
|
upper
|
float
|
Upper percentile. Default |
98.0
|
reduce_axes
|
int | tuple[int, ...] | None
|
Axis (or tuple of axes) to compute percentiles over.
|
(-2, -1)
|
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
Float array of the same shape, values in |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in packages/geotoolz-ops/src/geoops/radiometry/_src/array.py
radiance_to_dn(radiance, gain, offset=0.0, scale=1.0)
¶
Convert at-sensor radiance back to DN via the affine inverse.
.. math::
DN \;=\; (L - \text{offset}) \cdot \text{scale} / \text{gain}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radiance
|
Float[ndarray, '*dims']
|
At-sensor radiance array. |
required |
gain
|
float | Float[ndarray, '*coef']
|
Slope used by |
required |
offset
|
float | Float[ndarray, '*coef']
|
Intercept used by |
0.0
|
scale
|
float | Float[ndarray, '*coef']
|
DN scale divisor used by |
1.0
|
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
DN array in floating point. Cast or round outside if integer DN are |
Float[ndarray, '*dims']
|
required. Integer radiance is promoted to float64 first. |