Client
egms_client.client ¶
An async client over :mod:egms_client.auth and :mod:egms_client.archive.
Give it your httpx.AsyncClient and timeouts, proxies and pooling stay
yours; give it none and it opens (and closes) its own. Searches and downloads
are retried on network errors and on 429/502/503/504; other HTTP errors
propagate, and refusals the archive disguises as a 200 raise
:class:~egms_client.errors.EgmsError.
Downloads are streamed to a .part file and renamed when complete, so a
file that exists is whole, and memory stays flat however large the ZIP.
PointVelocity
dataclass
¶
The Ortho L3 velocity at one point, and where it comes from.
velocity is in mm/year (U: positive up; E: positive east), or
None where EGMS has no measurement: no tile there (sea, outside
coverage) or a cell without data. file is the GeoTIFF it was read
from (None without a tile); x, y the point in EPSG:3035.
EgmsArchive ¶
Releases, searches and downloads, with a token renewed as needed.
key defaults to :meth:ServiceKey.from_env. Use it as an async
context manager, or call :meth:aclose, when it opened its own client.
token
async
¶
token() -> Token
A valid bearer token, asking for a new one when the current is about to expire.
Concurrent callers share one request. A busy endpoint (429/502/503/504, or a network error) is retried; its 500 is a bad assertion, not retried.
releases
async
¶
releases() -> list[str]
The published releases, oldest first (["2020-2024", "2020-2025"]).
search
async
¶
search(tile: Tile, component: Component, release: str) -> Search | None
Search one Ortho L3 tile; None if the tile does not exist.
find
async
¶
find(query: Query) -> list[Search]
Every file a query matches, the latest sub-release of each.
A bbox larger than the archive accepts is searched in pieces; a
file found by two pieces is listed once. Nothing is downloaded: sum
hit.filesize to know what :meth:fetch would cost.
fetch
async
¶
fetch(query: Query, directory: Path | None = None, *, keep: Iterable[Keep] = ('zip',), concurrency: int = MAX_DOWNLOADS, max_bytes: int | None = None, on_file: Callable[[Hit, list[Path]], None] | None = None, on_progress: Progress | None = None, on_plan: Callable[[list[Hit]], None] | None = None) -> list[Path]
Download what a query matches into directory; the paths kept.
directory defaults to :func:default_directory.
Files already in directory are not downloaded again, so an
interrupted run resumes where it stopped. At most :data:MAX_DOWNLOADS
files stream at once per archive, whatever concurrency says: a
higher one only overlaps extraction and conversion. keep picks what stays of
each ZIP. With max_bytes set, a download larger than that raises
:class:EgmsError before any byte is fetched.
on_plan(hits) is called once with the files about to be downloaded;
on_file(hit, paths) when each is done;
on_progress(hit, received, total) as its bytes arrive (received
starts again from 0 if a download is retried).
fetch_tile
async
¶
fetch_tile(tile: Tile, component: Component, release: str, directory: Path | None = None) -> Path | None
The tile's mean-velocity GeoTIFF in directory, downloaded if missing.
directory defaults to :func:default_directory.
None when the tile does not exist. Both outcomes are remembered in
directory (the GeoTIFF, or an …absent marker), so running it
again for a whole country asks the archive nothing.
velocity_at
async
¶
velocity_at(lon: float, lat: float, component: Component = 'U', release: str | None = None, directory: Path | None = None) -> PointVelocity
The L3 velocity of the 100 m cell containing a point in degrees.
Only the point's tile is downloaded (about 60 MB, once: it stays in
directory, which defaults to :func:default_directory), so the
next points of the same tile cost nothing. release defaults to
the latest. Needs the raster extra.
default_directory ¶
default_directory() -> Path
Where downloads go when no directory is given.
EGMS_DATA_DIR if set, else egms-client in the user cache
($XDG_CACHE_HOME, or ~/.cache).