- Home
- Documentation
- API reference
- Spectral
- hyperproc.spectral.srf
hyperproc.spectral.srf¶
Source-derived reference
Generated from the current hyperproc 0.1.2 checkout.
Implementation: hyperproc/spectral/srf.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.
Exported entry points¶
| Importable name | Definition |
|---|---|
hyperproc.spectral.srf.SOURCES |
hyperproc.spectral.srf.SOURCES |
hyperproc.spectral.srf.NOMINAL |
hyperproc.spectral.srf.NOMINAL |
hyperproc.spectral.srf.ALIASES |
hyperproc.spectral.srf.ALIASES |
hyperproc.spectral.srf.available |
hyperproc.spectral.srf.available |
hyperproc.spectral.srf.fetch |
hyperproc.spectral.srf.fetch |
hyperproc.spectral.srf.target |
hyperproc.spectral.srf.target |
hyperproc.spectral.srf.cache_dir |
hyperproc.spectral.srf.cache_dir |
hyperproc.spectral.srf.resolve |
hyperproc.spectral.srf.resolve |
Spectral response functions for common instruments, fetched and cached.
Convolving a hyperspectral cube onto a broadband sensor is only as good as the response you convolve with. For most instruments the real, measured response is published, and this module goes and gets it::
from hyperproc.spectral import srf
print(srf.available()) # what is known, and what is cached
s2 = srf.fetch("SENTINEL2A") # downloads once, then reads the cache
hp.resample(ds, sensor="LANDSAT8") # the same thing, through resample
Downloads land in $HYPERPROC_CACHE_DIR/srf as the original spreadsheet plus
a parsed .npz, so the network is touched once per instrument.
Measured, or nominal¶
Two kinds of entry, and the difference is recorded in kind rather than left
for you to guess:
measured
A tabulated response per band, from the agency. Sentinel-2 MSI from ESA,
Landsat TM, ETM+, OLI and OLI-2 from the USGS spectral viewer.
nominal
Only published band edges, turned into centres and widths. PlanetScope is
here because Planet publishes band ranges rather than response curves. A
nominal entry is used with a Gaussian response, which on PACE's measured
bands differs from the real curve by about 0.2 % in the median, so it is a
fair approximation but it is not the instrument.
Bands whose response falls outside the source's coverage come back NaN from
:func:hyperproc.spectral.resample, which matters here: simulating Sentinel-2
band 10 (1375 nm cirrus) from EMIT cannot work, because that wavelength sits in
a water-vapour gap EMIT does not measure.
SOURCES: dict[str, dict] = {'SENTINEL2A': {'url': _S2, 'parser': 'sentinel2', 'sheet': 'Spectral Responses (S2A)', 'label': 'Sentinel-2A MSI', 'agency': 'ESA'}, 'SENTINEL2B': {'url': _S2, 'parser': 'sentinel2', 'sheet': 'Spectral Responses (S2B)', 'label': 'Sentinel-2B MSI', 'agency': 'ESA'}, 'LANDSAT4': {'url': _USGS + 'L4_TM_RSR.xlsx', 'parser': 'landsat', 'label': 'Landsat 4 TM', 'agency': 'USGS'}, 'LANDSAT5': {'url': _USGS + 'L5_TM_RSR.xlsx', 'parser': 'landsat', 'label': 'Landsat 5 TM', 'agency': 'USGS'}, 'LANDSAT7': {'url': _USGS + 'L7_ETM_RSR.xlsx', 'parser': 'landsat', 'label': 'Landsat 7 ETM+', 'agency': 'USGS'}, 'LANDSAT8': {'url': _USGS + 'L8_OLI_RSR.xlsx', 'parser': 'landsat', 'label': 'Landsat 8 OLI', 'agency': 'USGS'}, 'LANDSAT9': {'url': _USGS + 'L9_OLI2_RSR.xlsx', 'parser': 'landsat', 'label': 'Landsat 9 OLI-2', 'agency': 'USGS'}}
module-attribute
¶
NOMINAL: dict[str, dict] = {'PLANETSCOPE4': {'label': 'PlanetScope 4-band (PS2 / Dove)', 'agency': 'Planet', 'bands': {'Blue': (455, 515), 'Green': (500, 590), 'Red': (590, 670), 'NIR': (780, 860)}}, 'PLANETSCOPE8': {'label': 'PlanetScope 8-band (PSB.SD / SuperDove)', 'agency': 'Planet', 'bands': {'CoastalBlue': (431, 452), 'Blue': (465, 515), 'GreenI': (513, 549), 'Green': (547, 583), 'Yellow': (600, 620), 'Red': (650, 680), 'RedEdge': (697, 713), 'NIR': (845, 885)}}}
module-attribute
¶
ALIASES: dict[str, str] = {'S2': 'SENTINEL2A', 'S2A': 'SENTINEL2A', 'S2B': 'SENTINEL2B', 'SENTINEL2': 'SENTINEL2A', 'MSI': 'SENTINEL2A', 'SENTINEL-2': 'SENTINEL2A', 'SENTINEL-2A': 'SENTINEL2A', 'SENTINEL-2B': 'SENTINEL2B', 'L4': 'LANDSAT4', 'L5': 'LANDSAT5', 'L7': 'LANDSAT7', 'L8': 'LANDSAT8', 'L9': 'LANDSAT9', 'TM': 'LANDSAT5', 'ETM': 'LANDSAT7', 'ETM+': 'LANDSAT7', 'OLI': 'LANDSAT8', 'OLI2': 'LANDSAT9', 'OLI-2': 'LANDSAT9', 'LANDSAT-4': 'LANDSAT4', 'LANDSAT-5': 'LANDSAT5', 'LANDSAT-7': 'LANDSAT7', 'LANDSAT-8': 'LANDSAT8', 'LANDSAT-9': 'LANDSAT9', 'PLANETSCOPE': 'PLANETSCOPE4', 'PS': 'PLANETSCOPE4', 'PS2': 'PLANETSCOPE4', 'DOVE': 'PLANETSCOPE4', 'SUPERDOVE': 'PLANETSCOPE8', 'PSB.SD': 'PLANETSCOPE8', 'PLANETSCOPE-4': 'PLANETSCOPE4', 'PLANETSCOPE-8': 'PLANETSCOPE8'}
module-attribute
¶
_S2 = 'https://sentinels.copernicus.eu/documents/247904/685211/S2-SRF_COPE-GSEG-EOPG-TN-15-0007_3.1.xlsx'
module-attribute
¶
_USGS = 'https://landsat.usgs.gov/landsat/spectral_viewer/bands/'
module-attribute
¶
_UA = {'User-Agent': 'Mozilla/5.0 (hyperproc spectral response fetcher)'}
module-attribute
¶
SQRT_8LN2 = 2.3548200450309493
module-attribute
¶
cache_dir() -> Path
¶
resolve(sensor: str) -> str
¶
The canonical key for a sensor name, accepting the usual spellings.
Source code in hyperproc/spectral/srf.py
_load_workbook(path: Path)
¶
Source code in hyperproc/spectral/srf.py
_to_nm(wl: np.ndarray) -> np.ndarray
¶
Some sheets are in micrometres; anything under 100 cannot be nanometres.
_parse_sentinel2(path: Path, sheet: str) -> dict
¶
Source code in hyperproc/spectral/srf.py
_parse_landsat(path: Path, sheet=None) -> dict
¶
Source code in hyperproc/spectral/srf.py
_summarise(fine_wl: np.ndarray, response: np.ndarray) -> tuple
¶
Response-weighted centre and half-maximum width of each band.
Source code in hyperproc/spectral/srf.py
_download(url: str, path: Path, verbose: bool) -> Path
¶
Source code in hyperproc/spectral/srf.py
fetch(sensor: str, cache: Path | None = None, overwrite: bool = False, verbose: bool = True) -> dict
¶
The response functions of sensor, downloading and caching on first use.
| PARAMETER | DESCRIPTION |
|---|---|
sensor
|
an instrument name or alias; see :func:
TYPE:
|
cache
|
where to keep the files;
TYPE:
|
overwrite
|
re-download even when the cache has it.
TYPE:
|
verbose
|
say what is being fetched.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
dict with |
dict
|
|
dict
|
measured instrument, |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
unknown sensor. |
RuntimeError
|
the published file could not be retrieved. |
Source code in hyperproc/spectral/srf.py
target(sensor: str, **kwargs) -> dict
¶
A target description for :func:hyperproc.spectral.target_grid.
Source code in hyperproc/spectral/srf.py
available(cache: Path | None = None) -> str
¶
A table of the instruments known here, and which are already cached.