xeo
xeo - Earth observation instruments in Python.
Classes:
- Catalogue – Awesome Earth Observation Instruments catalogue. 🐈
- Instrument – Earth observation instrument from the catalogue.
- Instruments – Collection of instruments in the catalogue.
Functions:
- plot_bands – Plot instrument band ranges along the wavelength axis.
- plot_srf – Plot spectral response functions for one or more instruments.
xeo.Catalogue
Catalogue(catalogue, instruments=None)Bases: object
Awesome Earth Observation Instruments catalogue. 🐈
Parameters:
- catalogue (
dict) – Raw catalogue data. - instruments (
Instruments) – Instrument objects created from the raw catalogue.
Examples:
>>> import xeo
>>> isinstance(xeo.catalogue, xeo.Catalogue)
True
>>> len(xeo.catalogue.instruments) > 0
TrueFunctions:
- search – Search instruments using core metadata and spectral availability.
- to_dict – Return an independent dictionary containing the raw catalogue.
- update – Download the current upstream catalogue when it is newer.
Attributes:
- data – Raw, JSON-serializable catalogue data.
- href – URL of the catalogue. Equivalent to :attr:
link. - instruments – Instruments available in the catalogue.
- link – URL of the catalogue.
- name – Name of the catalogue.
- updated – UTC time (ISO 8601) when the catalogue content last changed.
- version – Version of the catalogue.
data
data = catalogueRaw, JSON-serializable catalogue data.
href
href = catalogue['link']URL of the catalogue. Equivalent to :attr:link.
instruments
instruments = instrumentsInstruments available in the catalogue.
link
link = catalogue['link']URL of the catalogue.
name
name = catalogue['name']Name of the catalogue.
search
search(**kwargs)Search instruments using core metadata and spectral availability.
Search values are matched exactly, except that start_date also accepts :class:datetime.date objects and inclusive intervals formatted as YYYY-MM-DD/YYYY-MM-DD. Different properties are combined with AND. A list, tuple, or set supplied for one property uses OR, and list-valued instrument properties such as operator and platform match when any requested value is present.
Parameters:
- **kwargs (
Any) – Required instrument properties to match.has_srf,has_bandsandhas_radarare also accepted as boolean filters.
Returns:
Instruments– A frozen collection containing the matching instruments in catalogue order.
Examples:
>>> import xeo
>>> result = xeo.catalogue.search(operator=["ESA", "NASA"])
>>> "MSI_S2A" in result and "OLI_L8" in result
True
>>> all(item.has_srf for item in xeo.catalogue.search(has_srf=True).values())
True
>>> "MODIS_AQUA" in xeo.catalogue.search(
... start_date="2000-01-01/2003-01-01"
... )
Trueto_dict
to_dict()Return an independent dictionary containing the raw catalogue.
update
update()Download the current upstream catalogue when it is newer.
The complete catalogue is downloaded from the Awesome Earth Observation Instruments repository. When it changed after the local copy, it is saved in the per-user cache and the catalogue and instrument objects in the current Python session are refreshed. Later imports load the newest of the saved and the bundled catalogue, so installing a newer xeo release is never overridden by an older download.
Notes
This method requires an internet connection. The catalogue is saved as catalogue.json in the cache directory, which can be changed with the XEO_CACHE_DIR environment variable.
Examples:
>>> import xeo
>>> xeo.catalogue.update()
The catalogue is already up to date (last changed <timestamp>).updated
updated = catalogue.get('updated')UTC time (ISO 8601) when the catalogue content last changed.
version
version = catalogue['version']Version of the catalogue.
xeo.Instrument
Instrument(instrument)Bases: object
Earth observation instrument from the catalogue.
Core metadata is available directly as attributes. The complete source record remains available through :attr:data.
Examples:
>>> import xeo
>>> xeo.instruments.MSI_S2A
Instrument(MSI_S2A: MultiSpectral Instrument)
>>> xeo.instruments.MSI_S2A.operator
['ESA', 'Copernicus']
>>> xeo.instruments.MSI_S2A.bands().shape
(13, 6)Functions:
- bands – Return spectral bands as a DataFrame, when available.
- frequencies – Return radar frequencies as a DataFrame, when available.
- get_data_access – Return metadata for an available data access point.
- radar_modes – Return radar acquisition modes as a DataFrame, when available.
- srf – Return the spectral response function as a DataFrame, when available. 🐱
- to_dict – Return an independent dictionary containing the instrument record.
Attributes:
- acronym (
str) – Instrument acronym. - availability (
str) – Instrument data accessibility level. - contributors (
list[str]) – GitHub profile URLs for contributors to the instrument record. - data (
dict[str, Any]) – Complete instrument record from the catalogue. - data_links (
list[str]) – URLs where instrument data products can be accessed. - end_date (
str | None) – End of instrument operation, when available. - extension_names (
list[str]) – Names of the extensions available for this instrument. - extensions (
dict[str, Any]) – Domain-specific instrument metadata extensions. - family (
str) – Instrument family, e.g."OLI"for both OLI and OLI2. 🐈⬛ - family_members (
list[str]) – Identifiers of the other instruments in the same family. - has_bands (
bool) – Whether materialized spectral band definitions are available. - has_radar (
bool) – Whether radar characteristics (the radar extension) are available. - has_srf (
bool) – Whether a spectral response function is available. - id (
str) – Instrument identifier. - name (
str) – Full instrument name. - notes (
str | None) – Additional notes, when available. - operator (
list[str]) – Organizations operating the instrument. - platform (
list[str]) – Platforms carrying the instrument. - platform_companions (
list[str]) – Identifiers of other instruments on the same platform. - platform_type (
str) – Class of platform carrying the instrument. - references (
list[str]) – Reference URLs for the instrument. - start_date (
str) – Start of instrument operation. - status (
str) – Instrument lifecycle status. - type (
str) – Instrument sensing modality.
acronym
acronym: strInstrument acronym.
availability
availability: strInstrument data accessibility level.
bands
bands()Return spectral bands as a DataFrame, when available.
The DataFrame is indexed by band identifier. None is returned when the instrument has no materialized spectral band definitions.
contributors
contributors: list[str]GitHub profile URLs for contributors to the instrument record.
data
data: dict[str, Any]Complete instrument record from the catalogue.
data_links
data_links: list[str]URLs where instrument data products can be accessed.
end_date
end_date: str | NoneEnd of instrument operation, when available.
extension_names
extension_names: list[str]Names of the extensions available for this instrument.
extensions
extensions: dict[str, Any]Domain-specific instrument metadata extensions.
family
family: strInstrument family, e.g. "OLI" for both OLI and OLI2. 🐈⬛
family_members
family_members: list[str]Identifiers of the other instruments in the same family.
frequencies
frequencies()Return radar frequencies as a DataFrame, when available.
The DataFrame is indexed by frequency identifier (for example "C"). Center frequencies are expressed in GHz and bandwidths in MHz. The polarizations column lists the polarization channels available at each frequency. None is returned when the instrument has no radar extension.
Examples:
>>> import xeo
>>> list(xeo.instruments.CSAR_S1C.frequencies().index)
['C']get_data_access
get_data_access(provider='ee', processing_level='primary')Return metadata for an available data access point.
Parameters:
- provider (
str) – Data provider. One ofee,planetary_computer,cdse, oreopf. - processing_level (
str) – Processing or product level. One ofprimary,boa,toa,raw,lst,wst,grd,rtc, orslc.
Returns:
dict or None– A dictionary containingstac_endpoint,collection, anddocs. Missing values, such as the Earth Engine STAC endpoint, are represented byNone.Noneis returned when the provider or processing level is valid but unavailable for this instrument.
Examples:
>>> import xeo
>>> xeo.instruments.MSI_S2A.get_data_access()["collection"]
'COPERNICUS/S2_SR_HARMONIZED'
>>> xeo.instruments.MSI_S2A.get_data_access("cdse", "toa")["collection"]
'sentinel-2-l1c'
>>> xeo.instruments.MSI_S2A.get_data_access(processing_level="raw") is None
Truehas_bands
has_bands: boolWhether materialized spectral band definitions are available.
has_radar
has_radar: boolWhether radar characteristics (the radar extension) are available.
has_srf
has_srf: boolWhether a spectral response function is available.
id
id: strInstrument identifier.
name
name: strFull instrument name.
notes
notes: str | NoneAdditional notes, when available.
operator
operator: list[str]Organizations operating the instrument.
platform
platform: list[str]Platforms carrying the instrument.
platform_companions
platform_companions: list[str]Identifiers of other instruments on the same platform.
platform_type
platform_type: strClass of platform carrying the instrument.
radar_modes
radar_modes()Return radar acquisition modes as a DataFrame, when available.
The DataFrame is indexed by mode identifier (for example "IW"). Nested properties are flattened: resolution_range and resolution_azimuth (m) and incidence_angle_min and incidence_angle_max (degrees). Swath widths are expressed in km and NESZ in dB. For modes that alternate between separate incidence ranges, the columns give the overall minimum and maximum; the separate ranges remain available in instrument.extensions["radar"]. The polarizations column lists the polarization combinations that can be acquired together. None is returned when the instrument has no acquisition modes.
Examples:
>>> import xeo
>>> list(xeo.instruments.CSAR_S1C.radar_modes().index)
['SM', 'IW', 'EW', 'WV']references
references: list[str]Reference URLs for the instrument.
srf
srf(*, refresh=False)Return the spectral response function as a DataFrame, when available. 🐱
None is returned when the instrument has no spectral response function in the catalogue. URL-based SRFs are downloaded on first use and stored in a per-user cache. Later calls reuse the cached CSV. The cache is keyed by the checksum recorded in the catalogue, so corrected SRFs are downloaded again after a catalogue update.
Parameters:
- refresh (
bool) – Download the SRF again even when a cached copy is available.
start_date
start_date: strStart of instrument operation.
status
status: strInstrument lifecycle status.
to_dict
to_dict()Return an independent dictionary containing the instrument record.
type
type: strInstrument sensing modality.
xeo.Instruments
Bases: Box
Collection of instruments in the catalogue.
Instruments support both mapping and attribute access. 😺
Examples:
>>> import xeo
>>> xeo.instruments.MSI_S2A
Instrument(MSI_S2A: MultiSpectral Instrument)
>>> xeo.instruments["MSI_S2A"] is xeo.instruments.MSI_S2A
Truexeo.plot_bands
plot_bands(instruments, *, ax=None, figsize=None, title='Spectral bands', band_labels=True)Plot instrument band ranges along the wavelength axis.
Overlapping bands are placed in compact sub-lanes within the instrument's row. Non-overlapping bands reuse the same lane.
Parameters:
- instruments (
str, sequence, or dict) – One instrument id, several ids, a dictionary mapping instrument ids to selected bands, or a list of such dictionaries. A selection can be one band id, a sequence of band ids, or styled bands such as{"MSI_S2A": [{"B4": {"color": "red", "linewidth": 2}}]}. A list of dictionaries can define different selections and styles for each instrument. Style dictionaries accept Matplotlibbarhkeyword arguments. - ax (
Axes) – Axes on which to draw. A new figure and axes are created by default. - figsize (
tuple of float) – Figure size in inches when creating new axes. It cannot be combined withax. - title (
str or None) – Axes title. UseNoneto leave the title unset. - band_labels (
bool) – Whether to place band ids on their wavelength ranges.
Returns:
Axes– The axes containing the plot.
Examples:
>>> import xeo
>>> ax = xeo.plot_bands({"MSI_S2A": ["B2", "B3", "B4"]})xeo.plot_srf
plot_srf(instruments, *, ax=None, figsize=None, title='Spectral response functions', band_labels=True, legend=True)Plot spectral response functions for one or more instruments.
Curves use one default color per instrument. Band ids are placed near their response peaks and distributed across vertical label levels when nearby peaks would otherwise collide.
Parameters:
- instruments (
str, sequence, or dict) – One instrument id, several ids, a dictionary mapping instrument ids to selected bands, or a list of such dictionaries. A selection can be one band id, a sequence of band ids, or styled bands such as{"MSI_S2A": [{"B4": {"color": "red", "linestyle": "--"}}]}. A list of dictionaries can define different selections and styles for each instrument. Style dictionaries accept Matplotlibplotkeyword arguments. - ax (
Axes) – Axes on which to draw. A new figure and axes are created by default. - figsize (
tuple of float) – Figure size in inches when creating new axes. It cannot be combined withax. - title (
str or None) – Axes title. UseNoneto leave the title unset. - band_labels (
bool) – Whether to place band ids near the response peaks. - legend (
bool) – Whether to add an instrument legend.
Returns:
Axes– The axes containing the plot.
Examples:
>>> import xeo
>>> ax = xeo.plot_srf({"MSI_S2A": ["B2", "B3", "B4"]})