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
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 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 | |
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
2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 | |