toad.regridding.HealPixRegridder¶
- class toad.regridding.HealPixRegridder(nside=None)¶
Bases:
BaseRegridderRegrid data onto a equal-area HEALPix grid to avoid polar bias in clustering
- Parameters:
nside (int | None)
- __init__(nside=None)¶
- Parameters:
nside (int | None) – HEALPix parameter nside, which must be a power of 2. The total number of pixels in the regridded grid (npix) is calculated using the formula: npix = 12 * nside ** 2. If nside is not specified, it will be automatically determined based on the data’s resolution.
Methods
__init__([nside])healpix_to_latlon(pix)Convert a HEALPix pixel index back to its center latitude and longitude.
latlon_to_healpix(lats, lons)Convert arrays of latitude and longitude to HEALPix pixel indices.
map_orig_to_regrid(coords_2d)Map (lat, lon) to a HEALPix pixel index.
regrid(coords, weights, space_dims_size)Regrid data to new coordinate system.
regrid_clusters_back(cluster_labels)Map cluster labels back to original grid.
- healpix_to_latlon(pix)¶
Convert a HEALPix pixel index back to its center latitude and longitude.
- Parameters:
pix (int)
- Return type:
tuple
- latlon_to_healpix(lats, lons)¶
Convert arrays of latitude and longitude to HEALPix pixel indices.
- Parameters:
lats (ndarray)
lons (ndarray)
- Return type:
ndarray
- map_orig_to_regrid(coords_2d)¶
Map (lat, lon) to a HEALPix pixel index. coords_2d must be array (N, 2): [(lat, lon), …]
- Parameters:
coords_2d (ndarray)
- Return type:
ndarray
- regrid(coords, weights, space_dims_size)¶
Regrid data to new coordinate system.
- Parameters:
coords (ndarray) – 3dArray of coordinates (time, lat, lon) in that order
weights (ndarray) – 1dArray of weights
space_dims_size (tuple[int, int]) – Tuple of (nlat, nlon) sizes of the original grid dimensions
- Returns:
3dArray of coordinates (time, lat, lon) in that order 1dArray of weights
- Return type:
tuple[ndarray, ndarray]
- regrid_clusters_back(cluster_labels)¶
Map cluster labels back to original grid.
- Parameters:
cluster_labels (ndarray)
- Return type:
ndarray