Core functions#
The module-level surface of earthlens.core — one-shot helpers that wrap the
EarthLens facade, plus the discovery functions for finding a dataset across all 61 providers.
For a task-oriented walkthrough of find / search / sources, see Discovering datasets.
download#
The one-shot equivalent of constructing an EarthLens and calling .download(). Takes the same arguments as the
facade constructor and returns the backend's result directly.
earthlens.core.download(data_source='chc', *, variables=None, dataset=None, start=None, end=None, path=None, lat_lim=None, lon_lim=None, aoi=None, buffer=None, temporal_resolution='daily', cadence=None, time=None, fmt='%Y-%m-%d', progress_bar=True, aggregate=None, load=False, **backend_kwargs)
#
Construct an :class:EarthLens and download in one call.
The one-shot convenience for the common case: it forwards every
request argument to :class:EarthLens and the run-time arguments to
:meth:EarthLens.download, so earthlens.core.download(...) replaces the
two-step construct-then-download.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_source
|
str
|
Backend key (see |
'chc'
|
variables
|
dict[str, list[str]] | list[str] | None
|
Variable specification, as for :class: |
None
|
dataset
|
str | None
|
Explicit dataset / collection key (see
:class: |
None
|
start
|
str | datetime | date | None
|
Inclusive start date (string / |
None
|
end
|
str | datetime | date | None
|
Inclusive end date. |
None
|
time
|
Any
|
A single time range ( |
None
|
path
|
Path | str | None
|
Output directory; defaults to
|
None
|
lat_lim
|
list[float] | None
|
Legacy |
None
|
lon_lim
|
list[float] | None
|
Legacy |
None
|
aoi
|
Any
|
A single area-of-interest (bbox / point+ |
None
|
buffer
|
float | None
|
Half-width in degrees for a point |
None
|
temporal_resolution
|
str
|
Backend cadence / label. Defaults to
|
'daily'
|
cadence
|
str | None
|
Clearer alias for |
None
|
fmt
|
str
|
|
'%Y-%m-%d'
|
progress_bar
|
bool
|
Whether the backend prints a progress bar. |
True
|
aggregate
|
AggregationConfig | None
|
Optional :class: |
None
|
load
|
bool
|
When |
False
|
**backend_kwargs
|
object
|
Extra backend-specific options (see
:meth: |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Whatever |
Any
|
meth: |
Any
|
when |
Examples:
- One-shot CHIRPS download. Marked
# doctest: +SKIPbecause it makes a live FTP connection:
Source code in libs/core/src/earthlens/earthlens.py
1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 | |
sources#
earthlens.core.sources()
#
Return the sorted list of distinct backends, one canonical key each.
The top-level discovery entry point — no class needed to see what
backends earthlens.core.download(...) / :class:EarthLens accept. Alias and
endpoint keys ("chirps" for "chc", "google-earth-engine" for
"gee", the STAC endpoint keys "planetary-computer" / "earth-search"
/ "cdse", …) still work as data_source= values but are collapsed to
their canonical backend key here, so the list is one entry per backend.
Returns:
| Type | Description |
|---|---|
list[str]
|
The canonical |
Examples:
- The CHIRPS and GEE backends are listed by their canonical keys:
- Aliases are collapsed, so each backend appears once:
Source code in libs/core/src/earthlens/earthlens.py
find#
earthlens.core.find(text)
#
Find which sources expose a dataset matching text.
A best-effort, cross-source discovery aid: it runs
:meth:EarthLens.guess_dataset (case-insensitive substring, then fuzzy)
against every registered source and collects the hits. A source whose SDK
is not installed, or that has no free-text catalog, is skipped rather than
failing the whole call — so the result covers the installed backends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Free-text dataset query, e.g. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, list[str]]
|
A mapping |
dict[str, list[str]]
|
source with at least one match, in sorted-source order. |
Examples:
- Find sources whose catalog mentions precipitation (live; skipped):
Source code in libs/core/src/earthlens/earthlens.py
search#
earthlens.core.search(data_source='chc', *, variables=None, dataset=None, start=None, end=None, path=None, lat_lim=None, lon_lim=None, aoi=None, buffer=None, temporal_resolution='daily', cadence=None, time=None, fmt='%Y-%m-%d', **backend_kwargs)
#
Construct an :class:EarthLens and run a dry-run search in one call.
The one-shot counterpart to :func:download for the search→fetch split:
it forwards every request argument to :class:EarthLens and returns
:meth:EarthLens.search — the products a download would fetch — without
downloading anything.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_source
|
str
|
Backend key (see :func: |
'chc'
|
variables
|
dict[str, list[str]] | list[str] | None
|
Variable specification, as for :class: |
None
|
dataset
|
str | None
|
Explicit dataset / collection key. |
None
|
start
|
str | datetime | date | None
|
Inclusive start date (string / |
None
|
end
|
str | datetime | date | None
|
Inclusive end date. |
None
|
time
|
Any
|
A single time range ( |
None
|
path
|
Path | str | None
|
Output directory (unused by a dry-run search, but accepted for
signature parity with :func: |
None
|
lat_lim
|
list[float] | None
|
Legacy |
None
|
lon_lim
|
list[float] | None
|
Legacy |
None
|
aoi
|
Any
|
A single area-of-interest (bbox / point+ |
None
|
buffer
|
float | None
|
Half-width in degrees for a point |
None
|
temporal_resolution
|
str
|
Backend cadence / label. Defaults to |
'daily'
|
cadence
|
str | None
|
Clearer alias for |
None
|
fmt
|
str
|
|
'%Y-%m-%d'
|
**backend_kwargs
|
object
|
Extra backend-specific options. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
One |
list[RemoteProduct]
|
class: |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the backend exposes no searchable product
list (see :meth: |
Examples:
- Dry-run a STAC search and inspect the first product id (live; skipped here because it queries a remote catalog):
Source code in libs/core/src/earthlens/earthlens.py
1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 | |