Skip to content

REST service

disp_xr serve STORE (or make_app) serves stores read-only over HTTP for web clients such as the DISP portal. The OpenAPI page of a running service (/docs) lists every route with its response schema.

serve

Read-only REST service over disp-xr stores (PRD C7, plan task T40).

An xpublish <https://github.com/xpublish-community/xpublish>_ plugin that serves, under /datasets/{dataset_id}/disp/:

  • timeseries: the displacement series at a point (median over a buffer), with the quality layers the store holds and its reference date;
  • velocity: the stored velocity and its sigma at a point;
  • cells: a regular grid or a quadtree of a bounding box, as GeoJSON;
  • gnss: the station residuals and summary of :func:residuals.compare, written next to the cube by :meth:Comparison.to_zarr;
  • provenance: operation history, input granules and versions.

Nothing heavy runs on request (PRD C7): velocities and GNSS residuals are served only when the store holds them, and cells downsamples at most MAX_CELL_PIXELS pixels. xpublish adds its own routes (Zarr over HTTP, dataset info) and, when installed, xpublish-tiles adds web map tiles. Every response carries the CRS and the units.

Start a service with disp_xr serve STORE or :func:make_app.

Point

Bases: BaseModel

Where a point query was read.

TimeseriesResponse

Bases: BaseModel

Displacement at a point, one value per epoch.

VelocityResponse

Bases: BaseModel

Stored velocity at a point.

GnssStation

Bases: BaseModel

One station's velocities and residual (see residuals.compare).

GnssResponse

Bases: BaseModel

Station residuals and the comparison summary.

ProvenanceResponse

Bases: BaseModel

How the store was made.

FeatureCollection

Bases: BaseModel

GeoJSON FeatureCollection in lon/lat (RFC 7946).

DispPlugin

Bases: Plugin

xpublish plugin: the disp-xr routes for every dataset.

:func:make_app adds it; add it yourself to combine it with other xpublish plugins.

Examples:

>>> import xpublish
>>> plugins = {"disp": DispPlugin()}
>>> rest = xpublish.Rest({"frame": ds}, plugins=plugins)

crs_of

crs_of(ds: Dataset) -> Any

Return the pyproj CRS of ds (rioxarray or GeoZarr proj: attrs).

open_store

open_store(path: Union[str, Path]) -> tuple[xr.Dataset, Optional[xr.Dataset]]

Open a store lazily, with its GNSS group when it has one.

Zarr stores (written by disp_xr stack or to_zarr), Icechunk repositories (to_icechunk) and virtual frames (disp_xr virtual) are supported. A virtual frame holds its granules as they are, one reference per ministack, so it is chained on open (:func:disp_xr.chain, lazily: nothing is read until a request).

Parameters:

Name Type Description Default
path str or Path

The store.

required

Returns:

Type Description
Dataset

The cube.

Dataset or None

The gnss group of :meth:Comparison.to_zarr, if present.

Examples:

>>> ds, gnss = open_store("frame.zarr")

make_app

make_app(datasets: Mapping[str, Union[str, Path, Dataset]], *, gnss: Optional[Mapping[str, Dataset]] = None, tiles: bool = True) -> Rest

Return the xpublish service for datasets.

Parameters:

Name Type Description Default
datasets mapping

Dataset id to a store path (opened lazily with :func:open_store) or an open Dataset.

required
gnss mapping

GNSS groups (:meth:Comparison.to_dataset) for datasets passed open; stores opened from a path bring their own.

None
tiles bool

Add web map tiles when xpublish-tiles is installed.

True

Returns:

Type Description
Rest

Serve with .serve(host=..., port=...); .app is the FastAPI application (OpenAPI page at /docs).

Examples:

>>> rest = make_app({"houston": "F08882.zarr"})
>>> rest.serve(port=9000)

to_zarr

to_zarr(store: Any, group: str = 'gnss', **kwargs: Any) -> None

Write :meth:to_dataset as a group of store (next to a cube).

disp_xr serve reads this group for its gnss route.

Examples:

>>> result.to_zarr("frame.zarr")