toolsrtm.srf

Sensor convolution for the cases smac doesn’t cover: a plain per-band spectral response function (SRF) with no atmospheric-correction coefficients (PRISMA, Sentinel-2A/B), and nominal center+FWHM-only convolution (EnMAP, Landsat, MODIS, and any custom sensor or camera). Direct port of ToolsRTM::get.spectral.convolution.srf/get.spectral.convolution.gaussian.

Convolve reflectance onto a sensor using a plain per-band SRF table – i.e. no SMAC atmospheric-correction coefficients involved at all, just a spectral response function.

Direct port of ToolsRTM::get.spectral.convolution.srf() (ToolsRTM/R/get.spectral.convolution.srf.R). That R function itself generalizes what used to be two separate, app-only helper functions (convolve_prisma()/convolve_smac_sensor()) in the AEO-Course PROSAIL Shiny app’s own app.R into one shared, package-level implementation – this module is the Python side of that same generalization.

smac.py’s toolsrtm.smac.spectral_convolution() needs a sensor with SMAC atmospheric-correction coefficients bundled (only Sentinel-2A ships those in this Python port so far). PRISMA has no SMAC coefficients at all; Sentinel-2A/B additionally ship a second, plain, publisher-original SRF table alongside their SMAC bundle. spectral_convolution_srf() covers all three from one shared implementation.

class toolsrtm.srf.SrfTable(wl, band_names, weights)[source]

Bases: object

A plain per-band SRF table: one weight column per sensor band, all sampled on the same wavelength grid (the wl field).

Parameters:
wl: ndarray
band_names: list[str]
weights: ndarray
class toolsrtm.srf.SrfConvolutionResult(band_names, wl, fwhm, rfl)[source]

Bases: object

One row per SRF band: the wl field is the SRF-weighted mean center wavelength, fwhm the full width at half maximum, rfl the convolved reflectance – rows sorted by center wavelength.

Parameters:
band_names: list[str]
wl: ndarray
fwhm: ndarray
rfl: ndarray
toolsrtm.srf.srf_prisma()[source]

PRISMA’s 234 hyperspectral bands. Direct export of ToolsRTM::srf.prisma.

Return type:

SrfTable

toolsrtm.srf.fwhm_prisma()[source]

PRISMA’s officially calibrated per-band FWHM (nm), positionally aligned with srf_prisma()’s 234 bands – more precise than the half-max-crossing estimate spectral_convolution_srf() would otherwise derive from the SRF weight profile itself. Direct export of ToolsRTM::fwhm.prisma.

Returns:

  • wl (ndarray, shape (234,)) – Nominal band center wavelength (nm).

  • fwhm (ndarray, shape (234,)) – Full width at half maximum (nm).

Return type:

tuple[ndarray, ndarray]

toolsrtm.srf.srf_sentinel2a()[source]

Sentinel-2A MSI’s 13 bands, plain publisher-original SRF (distinct from toolsrtm.smac.sentinel2a_msi()’s SMAC-bundled copy of the same physical curve – see this module’s docstring). Direct export of ToolsRTM::srf.sentinel2a.

Return type:

SrfTable

toolsrtm.srf.srf_sentinel2b()[source]

Sentinel-2B MSI’s 13 bands – a real, slightly different sensor from 2A (up to ~17nm band-center difference in B12), not a duplicate. Direct export of ToolsRTM::srf.sentinel2b.

Return type:

SrfTable

toolsrtm.srf.spectral_convolution_srf(wave, values, srf, fwhm=None)[source]

Weighted-average a high-resolution spectrum onto srf’s bands.

Parameters:
  • wave (array_like, shape (nwl,)) – Integer-nm wavelength grid values is defined on.

  • values (array_like, shape (nwl,)) – Reflectance (or any other high-resolution spectrum) on wave.

  • srf (SrfTable) – e.g. srf_prisma(), srf_sentinel2a(), srf_sentinel2b().

  • fwhm ((wl, fwhm) tuple, optional) – Bundled precise FWHM, positionally aligned with srf’s bands (e.g. fwhm_prisma()’s return value) – when omitted, FWHM is estimated directly from srf’s own sampled weight profile (coarser; this is the only option for Sentinel-2A/B, which have no separately bundled FWHM table).

Return type:

SrfConvolutionResult

toolsrtm.srf.enmap_characteristics()[source]

EnMAP’s 242 hyperspectral channels: nominal (center, fwhm) in nm, already given directly (no band-edge derivation needed). Direct export of ToolsRTM::EnMap.characteristics.

Return type:

tuple[ndarray, ndarray]

toolsrtm.srf.sensor_characteristics(sensor)[source]

Nominal (center, lb, ub) band characteristics for one bundled sensor – published band edges, not a measured SRF. Direct export of ToolsRTM::sensor.characteristics.

Parameters:

sensor (one of "ALI", "Hyperion", "Landsat4",) – "Landsat5", "Landsat7", "Landsat8", "MODIS", "Quickbird", "RapidEye", "Sentinel2a", "Sentinel2b", "WorldView2-4", "WorldView2-8". (Sentinel-2A/B and PRISMA also have a REAL measured SRF table bundled – prefer srf_sentinel2a()/srf_sentinel2b()/srf_prisma() with spectral_convolution_srf() for those, more accurate than this Gaussian approximation.)

Returns:

center, lb, ub – Band center wavelength and lower/upper edge, nm.

Return type:

ndarray

toolsrtm.srf.spectral_convolution_gaussian(wave, values, sensor=None, centers=None, fwhm=None)[source]

Convolve onto a sensor using only nominal band characteristics (center + FWHM, approximated as a Gaussian response – optionally truncated to a published band-edge range), when no real measured SRF table is available at all.

Three ways to call this:

  1. sensor="EnMAP"enmap_characteristics()’s 242 channels (center + FWHM already given).

  2. sensor="MODIS" (or any other name in sensor_characteristics()’s docstring) – these ship published band EDGES, not FWHM directly; FWHM is derived as ub - lb and the Gaussian response is additionally hard-truncated to [lb, ub].

  3. Your OWN sensor/camera: pass centers yourself, in nm (e.g. copied straight out of an ENVI header’s wavelength = {...} block). fwhm is optional – if omitted, each band’s width is approximated from its distance to its neighboring bands (the standard assumption for a CONTIGUOUS pushbroom imaging spectrometer, e.g. a Headwall camera, where the true per-band SRF calibration isn’t available). Pass fwhm explicitly (e.g. from a camera datasheet, or an ENVI header’s own fwhm = {...} block) for a more accurate result.

Parameters:
  • wave (array_like) – High-resolution wavelength grid (nm) and spectrum on it (e.g. a simulated reflectance spectrum).

  • values (array_like) – High-resolution wavelength grid (nm) and spectrum on it (e.g. a simulated reflectance spectrum).

  • sensor (str, optional) – A bundled sensor name (see above). If given, centers/fwhm are looked up automatically and any values also passed for them are ignored.

  • centers (array_like, optional (required if sensor is not given)) – Your own sensor’s band center wavelengths, nm.

  • fwhm (array_like, optional) – Your own sensor’s per-band FWHM, nm, same length/order as centers. Derived from band spacing if omitted.

Return type:

SrfConvolutionResult