Region Selection API¶
Access-side helpers for HEALPix stores — required for high-level stores
written with implicit coordinates
(save_pyramid(write_coords=False)), and convenient for any dense
store. See the shared tutorial
Accessing High-Resolution Regional Data.
select_bbox(ds, *, lon, lat, level=None, query_delta=_DEFAULT_QUERY_DELTA, load=True)
¶
Extract all cells covering a geographic bounding box.
The box is rasterised at the coarse level level - query_delta;
every coarse parent expands to one contiguous fine-level range of
4**query_delta cells. The result therefore covers the box
(cells straddling the edge are included) with read granularity set
by query_delta — align it with the store's chunk exponent for
reads with zero waste.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
HEALPix dataset (see |
required |
lon
|
tuple[float, float]
|
|
required |
lat
|
tuple[float, float]
|
|
required |
level
|
int | None
|
HEALPix level override. |
None
|
query_delta
|
int
|
Level offset for the coverage query. Larger values mean fewer, larger contiguous reads; smaller values follow the box outline more tightly. |
_DEFAULT_QUERY_DELTA
|
load
|
bool
|
Load the selection into memory (default). |
True
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Compact subset covering the box. |
Source code in grid_doctor/select.py
select_cone(ds, *, lon, lat, radius, level=None, query_delta=_DEFAULT_QUERY_DELTA, load=True)
¶
Extract all cells within radius degrees of a centre point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
HEALPix dataset (see |
required |
lon
|
float
|
Centre coordinates in degrees. |
required |
lat
|
float
|
Centre coordinates in degrees. |
required |
radius
|
float
|
Angular radius in degrees. |
required |
level
|
int | None
|
HEALPix level override. |
None
|
query_delta
|
int
|
Level offset for the coverage query. |
_DEFAULT_QUERY_DELTA
|
load
|
bool
|
Load the selection into memory (default). |
True
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Compact subset covering the cone. |
Source code in grid_doctor/select.py
select_cells(ds, cells, *, level=None, load=True)
¶
Extract the given HEALPix cells from a dataset.
Works on dense datasets (positional index equals cell ID, with or
without materialised coordinates) and on compact subsets (cell
coordinate holds actual IDs). Contiguous ID runs are read as
contiguous slices, so a spatially compact selection touches only
the chunks it needs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
HEALPix dataset, typically opened with
|
required |
cells
|
Int64Array | list[int]
|
Global HEALPix cell IDs to extract (any order; duplicates are dropped). |
required |
level
|
int | None
|
HEALPix level override when the |
None
|
load
|
bool
|
Load the selected data into memory (default). The selection is small by construction — that is the point of selecting. |
True
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Compact subset: |
Source code in grid_doctor/select.py
attach_cell_coords(ds, cells, *, level, attrs=None)
¶
Attach computed cell coordinates to a compact subset.
HEALPix coordinates are a pure function of the cell index; stores
written with write_coords=False carry none, and this function
reconstructs them for exactly the cells at hand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Subset whose |
required |
cells
|
Int64Array
|
Global HEALPix cell IDs, one per position along |
required |
level
|
int
|
HEALPix level of the IDs. |
required |
attrs
|
Any
|
Optional attribute mapping to merge (e.g. the source store's attributes). |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Subset with |