High Level HEALPix API¶
This section contains the main functionality for creating and working with HEALPix-based dataset representations, including pyramid construction and resolution handling.
Pyramid creation¶
These functions build HEALPix pyramids from gridded source data and provide the main higher-level workflow for preparing multi-resolution outputs.
create_healpix_pyramid(ds, max_level=None, min_level=0, *, coarsen_mode='auto', min_valid_fraction=0.5, valid_fraction=False, **kwargs)
¶
Create a multi-resolution HEALPix pyramid.
The input dataset is first remapped to max_level with
regrid_to_healpix.
For nested output ordering, lower levels are derived efficiently
with
coarsen_healpix.
For ring ordering, each lower level is regenerated directly from
the source dataset.
For dask-backed input the result is lazy and chunked along cell
(cell_chunks, forwarded to
regrid_to_healpix); coarser
levels keep that chunk size. Every level builds on the finest one,
so write the pyramid with
save_pyramid, which computes
all levels in one pass. Calling .compute() per level instead
regrids the source once per level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Source dataset. |
required |
max_level
|
int | None
|
Finest HEALPix level. |
None
|
min_level
|
int
|
Coarsest HEALPix level to keep. |
0
|
coarsen_mode
|
CoarsenMode
|
Coarsening strategy for building lower pyramid levels.
|
'auto'
|
min_valid_fraction
|
float
|
Minimum fraction of valid children for a parent cell to be
valid. Default |
0.5
|
valid_fraction
|
ValidFraction
|
Store
|
False
|
**kwargs
|
Any
|
Forwarded to
|
{}
|
Returns:
| Type | Description |
|---|---|
dict[int, Dataset]
|
Pyramid keyed by level. |
Source code in grid_doctor/helpers.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
Resolution helpers¶
These utilities help translate between source grid resolution and the corresponding HEALPix level used for remapping and pyramid generation.
get_latlon_resolution(ds)
¶
Estimate the horizontal resolution of ds in degrees.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset on a regular lon/lat grid, a curvilinear grid, or an unstructured grid. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Approximate grid spacing in degrees. |
Examples:
Source code in grid_doctor/helpers.py
resolution_to_healpix_level(resolution_deg)
¶
Convert an approximate source resolution to a HEALPix level.
The heuristic uses a characteristic HEALPix pixel spacing of about
58.6° / 2**level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolution_deg
|
float
|
Approximate source resolution in degrees. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Suggested HEALPix level. |
Examples: