Python API
Signatures and descriptions below are generated from Python source at build time. This reference covers the public workflow and the objects it returns; internal transports and provider implementation helpers are intentionally omitted. See fetch and analyze for complete workflows.
Discovery and queries
usdata.search
search(text: str | None = None, *, include_planned: bool = False, **kwargs: Any) -> list[SearchResult]
Search the curated registry. Keyword arguments match build_query.
usdata.build_query
build_query(text: str | None = None, *, provider: str | None = None, location: str | None = None, bbox: BBox | tuple[float, float, float, float] | None = None, lat: float | None = None, lon: float | None = None, radius_km: float = 50.0, start: str | date | datetime | None = None, end: str | date | datetime | None = None, variables: list[str] | None = None, **params: Any) -> Query
Normalize user-facing arguments into a Query.
Exactly one of location, bbox, or lat/lon may set the spatial filter.
usdata.Registry
An in-memory collection of datasets addressable by id and searchable by keyword.
from_yaml
classmethod
Load a registry from YAML with top-level providers, domains, datasets.
search
Rank datasets by keyword match, filtered by provider, space, and time.
Planned datasets are left out unless include_planned is set; stubs are
always included because their adapters are being built.
Fetching and opening
usdata.fetch.fetch
fetch(dataset: Dataset, query: Query, *, root: Path | None = None, force: bool = False) -> list[FetchedAsset]
Resolve and fetch a query, sharing one adapter and closing its owned resources.
usdata.fetch.FetchedAsset
Bases: BaseModel
One asset on disk with its provenance and whether the cache satisfied it.
open
open(*, reader: str | None = None, dtype: dict[str, str] | None = None, parse_dates: list[str] | None = None, usecols: list[str] | None = None, nrows: int | None = None, sweep: int | list[int] | None = None) -> Any
Open local data with an optional pandas, radar, or netcdf reader.
ERDDAP units are kept in frame.attrs["units"] and source provenance
in frame.attrs["usdata"]. NEXRAD returns a xarray DataTree with provenance
in radar.attrs["usdata"]. NetCDF4 returns a loaded xarray Dataset with
matching provenance in its attributes. See usdata.readers.open_asset for options.
Use sweep=0 or sweep=[0, 2] to load selected zero-based radar sweeps.
Cached files and provenance sidecars are never changed.
Reproducible inputs
usdata.pull.pull
pull(manifest_path: Path, *, root: Path | None = None, force: bool = False, registry: Registry | None = None) -> PullResult
Restore from the lockfile if one exists, otherwise resolve and create it.
usdata.pull.verify
Check manifest consistency, then compare cached files against the lockfile.
usdata.pull.PullResult
usdata.pull.Drift
usdata.manifest.Manifest
Bases: BaseModel
A declarative list of inputs a project needs: usdata pull fetches them.
usdata.manifest.SourceSpec
Bases: BaseModel
One entry under sources: in a manifest.
usdata.manifest.Lockfile
Bases: BaseModel
Exactly what a manifest resolved to, with checksums, so it can be reproduced.
manifest_checksum
class-attribute
instance-attribute
usdata.manifest.LockedAsset
Temporal selection
usdata.select_by_time
select_by_time(candidates: Iterable[Asset], *, target: datetime, tolerance: timedelta, direction: Literal['nearest', 'at_or_before']) -> TemporalSelection
Select an asset by start time using an explicit tolerance and direction.
nearest admits starts on either side of target; at_or_before admits
only starts no later than target. The tolerance boundary is inclusive.
Equal distances break ties lexically by asset ID, then dataset ID. Duplicate
(dataset_id, id) identities and missing/naive starts raise ValueError, even
for candidates that would not win. All supplied candidates are validated.
Target is normalized to UTC for comparison and in the result. The signed offset is asset start minus target, in seconds. If no candidate qualifies, the result has no asset/offset and eligible_count=0. Inputs are not modified. Matching by start does not establish acquisition completion or availability.
usdata.TemporalSelection
Bases: BaseModel
A start-time selection and its explicit policy; not source provenance.
No match has asset=None, offset_seconds=None, and zero eligible
candidates. Counts refer to the supplied candidates, not a remote catalog.
Shared types
usdata.Asset
Bases: BaseModel
A single retrievable object (file, granule, or subset request) from a dataset.
checksum
class-attribute
instance-attribute
usdata.BBox
Bases: BaseModel
Geographic bounding box in WGS84 degrees. Antimeridian crossing is not supported yet.
from_point
classmethod
Box around a point. Uses a flat-earth approximation, fine for small radii.
contains_point
True if the point lies inside or on the edge of the box.
usdata.TimeRange
Bases: BaseModel
Half-open-agnostic time interval. Either bound may be None to mean unbounded.
usdata.Dataset
Bases: BaseModel
A registry entry. One per curated dataset, identified as provider:name.
capabilities
class-attribute
instance-attribute
domain
class-attribute
instance-attribute
since
class-attribute
instance-attribute
target
class-attribute
instance-attribute
target: str | None = Field(default=None, description="Version a stub or planned dataset is aimed at, or 'later'")
adapter
class-attribute
instance-attribute
adapter: str | None = Field(default=None, description="'package.module:ClassName' of the Provider; required unless planned")
version_label
property
'since 0.2' for shipped datasets, 'target 0.4' or 'target later' otherwise.
usdata.Query
Bases: BaseModel
Normalized, provider-agnostic request. Providers translate this into their own terms.
usdata.Provenance
Bases: BaseModel
Everything needed to say where a local file came from and re-fetch it.