03 — Working with spectral bands
When band definitions are available, Instrument.bands() returns them as a pandas DataFrame indexed by band identifier. Wavelengths and bandwidths are expressed in nanometres; band-level GSD values are expressed in metres. Thermal bands may also provide noise-equivalent temperature difference values in the ne_delta_t column.
python
import pandas as pd
import xeo
instrument = xeo.instruments.MSI_S2A
print(instrument)
print("Has bands:", instrument.has_bands)python
bands = instrument.bands()
bandsThe index is named band, making selections and exports explicit. Not every optional column is populated for every band.
python
print("Shape:", bands.shape)
print("Index name:", bands.index.name)
print("Columns:", list(bands.columns))
bands.loc[["B2", "B3", "B4"], ["center_wavelength", "bandwidth", "common_name"]]Select bands by common name
python
wanted = ["blue", "green", "red", "nir"]
bands.loc[bands["common_name"].isin(wanted), ["common_name", "center_wavelength", "bandwidth"]]Compare instruments
Concatenate band tables with instrument and band index levels to compare several sensors.
python
instrument_ids = ["MSI_S2A", "OLI_L8", "MODIS_TERRA"]
band_tables = {
instrument_id: xeo.instruments[instrument_id].bands()
for instrument_id in instrument_ids
if xeo.instruments[instrument_id].has_bands
}
comparison = pd.concat(band_tables, names=["instrument", "band"])
comparison[["center_wavelength", "bandwidth", "common_name"]].head(20)