API reference¶
The public surface is everything exported from the top-level geohalo package. Each
entry point comes in a convenience form (builds the operator for you) and a
precomputed form (you pass a cached object).
| Convenience | Precomputed | Builds |
|---|---|---|
reduce |
reduce_with_stencil / reduce_with_operator |
Stencil / ReduceOperator |
resample_grid |
resample_grid_with_matrix |
Resampler |
aggregate_bias |
aggregate_bias_with_tree |
BiasTree |
Reduction¶
geohalo.reduce ¶
reduce(
grid: T,
geoms: GeoSeries,
*,
target_resolution: float | None = None,
resample_iterations: int = 1,
spherical_correction: bool = True,
lat_dim: str = "latitude",
lon_dim: str = "longitude",
geom_dim: str = "geom",
weight_key: str | None = None,
how: Literal["mean", "sum"] = "mean",
) -> T
geohalo.reduce_with_stencil ¶
reduce_with_stencil(
grid: T,
stencil: Stencil,
*,
resample_iterations: int = 1,
lat_dim: str = "latitude",
lon_dim: str = "longitude",
geom_dim: str = "geom",
weight_key: str | None = None,
how: Literal["mean", "sum"] = "mean",
) -> T
geohalo.reduce_with_operator ¶
reduce_with_operator(
grid: T,
operator: ReduceOperator,
*,
how: Literal["mean", "sum"] = "mean",
lat_dim: str = "latitude",
lon_dim: str = "longitude",
geom_dim: str = "geom",
) -> T
Reduce grid to per-polygon values with one fused matmul on the source grid.
Assumes clean (non-NaN, unweighted) data — the fused operator cannot
renormalise per cell. For NaN or per-cell weighting, use reduce_with_stencil.
Resampling¶
geohalo.resample_grid ¶
resample_grid(
source: T,
target_resolution: float,
*,
lat_dim: str = "latitude",
lon_dim: str = "longitude",
iterations: int = 1,
) -> T
geohalo.resample_grid_with_matrix ¶
resample_grid_with_matrix(
source: T,
resampler: Resampler,
*,
lat_dim: str = "latitude",
lon_dim: str = "longitude",
) -> T
Hierarchical rollups¶
geohalo.aggregate_bias ¶
aggregate_bias(
reduced: T,
edges: DataFrame,
*,
geom_dim: str = "geom",
parent_col: str = "parent",
weight_col: str | None = None,
how: Literal["mean", "sum"] = "mean",
) -> T
geohalo.aggregate_bias_with_tree ¶
Precomputed operators¶
geohalo.Stencil
dataclass
¶
geohalo.ReduceOperator
dataclass
¶
geohalo.Resampler
dataclass
¶
geohalo.BiasTree
dataclass
¶
Caching¶
geohalo.LocalCache ¶
Bases: _Cache
Pickle files under path/<namespace>/<key>.pkl.
geohalo.RedisCache ¶
Bases: _Cache
Values under <prefix>:<key> in Redis.
Exceptions¶
geohalo.EmptyOverlapError ¶
Bases: Exception