Remapping¶
Remap gridded data to HEALPix with ESMF weights (grid_doctor.remap).
regrid_to_healpix does everything in
one call: it takes the weights from the weights store, or
computes them, and applies them. The other two functions split these
steps.
Remapping¶
regrid_to_healpix(ds, level=None, *, nest=True, method='conservative', source_units='auto', weights_path=None, missing_policy='renormalize', backend='auto', grid=None, source_kind='auto', ignore_unmapped=None, large_file=True, prefer_offline=None, nproc=1, esmf_regrid_weightgen='ESMF_RegridWeightGen', keep_intermediates=False, workdir=None, spectral_transform_command=None, cell_chunks='auto', ellipsoid=None)
¶
Regrid ds to a HEALPix target grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Source dataset on a regular, curvilinear, or unstructured grid. |
required |
level
|
int | None
|
HEALPix refinement level. Derived from the grid resolution when omitted. |
None
|
nest
|
bool
|
Use nested HEALPix ordering when |
True
|
method
|
RemapMethod
|
|
'conservative'
|
source_units
|
SourceUnits
|
Coordinate units for the source grid. |
'auto'
|
weights_path
|
str | Path | None
|
Optional existing or target weight file. When omitted, the
weights come from the default
|
None
|
missing_policy
|
MissingPolicy
|
How NaN values in the source grid are treated.
|
'renormalize'
|
backend
|
ApplyBackend
|
Application backend ( |
'auto'
|
grid
|
Dataset | None
|
Optional external geometry dataset. |
None
|
source_kind
|
SourceKind
|
Explicit source representation or |
'auto'
|
ignore_unmapped
|
bool | None
|
Ignore unmapped destination cells. |
None
|
large_file
|
bool
|
Forwarded to the in-memory ESMPy workflow. |
True
|
prefer_offline
|
bool | None
|
Force or disable the offline ESMF path. |
None
|
nproc
|
int
|
Number of MPI ranks for the offline path. |
1
|
esmf_regrid_weightgen
|
str
|
Name or path of the offline ESMF executable. |
'ESMF_RegridWeightGen'
|
keep_intermediates
|
bool
|
Keep intermediate mesh files. |
False
|
workdir
|
str | Path | None
|
Working directory for offline intermediate files. |
None
|
spectral_transform_command
|
list[str] | tuple[str, ...] | None
|
External command for |
None
|
cell_chunks
|
int | Literal['auto'] | None
|
Output chunk size along |
'auto'
|
ellipsoid
|
Ellipsoid | None
|
Ellipsoid of the HEALPix geometry, |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Regridded dataset on the HEALPix grid. |
Source code in grid_doctor/remap/_regrid.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
Weight files¶
cached_weights returns the weights for a
grid from the weights store.
compute_healpix_weights writes
them to a file of your choice.
compute_healpix_weights(ds, level, *, method='conservative', nest=True, source_units='auto', weights_path=None, grid=None, source_kind='auto', ignore_unmapped=None, large_file=True, prefer_offline=None, nproc=1, esmf_regrid_weightgen='ESMF_RegridWeightGen', keep_intermediates=False, workdir=None, spectral_transform_command=None, ellipsoid=None, source_description=None)
¶
Generate a reusable NetCDF weight file for HEALPix remapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset | str | Path
|
Source dataset or a source path. |
required |
level
|
int
|
HEALPix refinement level. |
required |
method
|
RemapMethod
|
|
'conservative'
|
nest
|
bool
|
Use nested HEALPix ordering when |
True
|
source_units
|
SourceUnits
|
Unit convention of the source coordinates. |
'auto'
|
weights_path
|
str | Path | None
|
Output NetCDF file. Defaults to the local weights directory in the
|
None
|
grid
|
Dataset | None
|
Optional external geometry dataset. |
None
|
source_kind
|
SourceKind
|
Explicit source representation or |
'auto'
|
ignore_unmapped
|
bool | None
|
Ignore unmapped destination cells. |
None
|
large_file
|
bool
|
Forwarded to the in-memory ESMPy workflow. |
True
|
prefer_offline
|
bool | None
|
Force or disable the offline ESMF path. |
None
|
nproc
|
int
|
Number of MPI ranks for the offline path. |
1
|
esmf_regrid_weightgen
|
str
|
Name or path of the offline ESMF executable. |
'ESMF_RegridWeightGen'
|
keep_intermediates
|
bool
|
Keep intermediate mesh files. |
False
|
workdir
|
str | Path | None
|
Working directory for offline intermediate files. |
None
|
spectral_transform_command
|
list[str] | tuple[str, ...] | None
|
External command for |
None
|
ellipsoid
|
Ellipsoid | None
|
Ellipsoid of the HEALPix geometry, |
None
|
source_description
|
SourceDescription | None
|
Description of ds from
|
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the generated NetCDF weight file. |
See Also
apply_weight_file:
Apply a previously generated weight file.
Source code in grid_doctor/remap/_regrid.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
Applying weights¶
apply_weight_file(ds, weights_path, *, missing_policy='renormalize', grid=None, source_dims=None, source_units='auto', backend='auto', cell_chunks='auto', ellipsoid=None, nest=None)
¶
Apply a previously generated ESMF weight file to ds.
Uses the batched engine in
grid_doctor.remap._sparse which replaces per-slice
vectorize=True with a single batched sparse matmul for a
typical 10–50× speedup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Source dataset to remap. |
required |
weights_path
|
str | Path
|
Path to the NetCDF weight file. |
required |
missing_policy
|
MissingPolicy
|
Strategy for handling NaN (missing) values in the source grid during weight application.
|
'renormalize'
|
grid
|
Dataset | None
|
Optional grid dataset with source geometry. |
None
|
source_dims
|
tuple[str, ...] | None
|
Optional explicit source dimensions. |
None
|
source_units
|
SourceUnits
|
Unit convention for geometry-based inference. |
'auto'
|
backend
|
ApplyBackend
|
Application backend ( |
'auto'
|
cell_chunks
|
int | Literal['auto'] | None
|
Chunk size of the output along |
'auto'
|
ellipsoid
|
Ellipsoid | None
|
Ellipsoid the weights must have been generated on. |
None
|
nest
|
bool | None
|
HEALPix order of the output: nested when |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset on the HEALPix target grid with a |
Examples:
Source code in grid_doctor/remap/_apply.py
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 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | |