healpix_analyse.resample#

Resampling helpers for HEALPix and regular latitude/longitude grids.

Classes#

HealPixResampler

Reusable NESTED HEALPix resampler based on HealPixDown/Up.

Functions#

resample_healpix(→ tuple[ArrayLike, numpy.ndarray])

One-shot NESTED HEALPix resampling convenience function.

resample_to_latlon_grid(lat, lon, data[, method])

Resample HEALPix data onto a regular latitude/longitude grid.

Module Contents#

class healpix_analyse.resample.HealPixResampler(in_level: int, out_level: int, in_cell_ids=None, out_cell_ids=None, *, ellipsoid: str = 'WGS84', radius_deg: float | None = None, sigma_deg: float | None = None, weight_norm: str = 'l1', up_norm: str = 'col_l1', dtype: torch.dtype = torch.float32, device: str | torch.device | None = None, eps: float = 1e-12)[source]#

Bases: torch.nn.Module

Reusable NESTED HEALPix resampler based on HealPixDown/Up.

Parameters:
  • in_level, out_level (int) – Input and output Grid4Earth/HEALPix levels. The corresponding NSIDE values are 2**in_level and 2**out_level.

  • in_cell_ids (array-like, optional) – NESTED identifiers matching the last dimension of the input data. None means that the input is a complete sphere in canonical NESTED order. in_level is still mandatory.

  • out_cell_ids (array-like, optional) – Exact output cells, in the desired output order. None requests the complete output sphere in canonical NESTED order.

  • ellipsoid (str, default "WGS84") – Geometry passed to every Down/Up operator.

  • radius_deg, sigma_deg (float, optional) – Optional fixed Gaussian parameters passed to each resolution step. When omitted, every step uses its native resolution-dependent values.

  • weight_norm ({"l1", "l2", "none"}, default "l1") – Normalisation used by HealPixDown.

  • up_norm ({"adjoint", "col_l1", "diag_l2"}, default "col_l1") – Normalisation used by HealPixUp.

  • dtype, device (optional) – PyTorch computation options. CUDA is selected when available.

Notes

Data may have shape [..., N_in]. NumPy input returns NumPy output; Torch input remains differentiable and returns a tensor on device.

Missing or non-finite samples are excluded through normalised convolution. A target with at least one non-zero weighted support remains calculable; a target with no support is filled with NaN.

Upsampling a requested subset first maps every requested output cell to its NESTED ancestor at in_level. Only available ancestors and their full descendant trees are propagated, after which the exact requested cells are gathered in their original order.

in_level#
out_level#
dtype = Ellipsis#
eps#
ellipsoid = ''#
weight_norm = ''#
up_norm = ''#
input_full_sphere#
output_full_sphere#
n_input#
n_output#
layers#
empty_route = False#
property device: torch.device#
property in_cell_ids: numpy.ndarray | None#

Input identifiers, or None for a full-sphere input.

property out_cell_ids: numpy.ndarray#

Exact output identifiers in returned-data order.

forward(in_data: ArrayLike) → tuple[ArrayLike, numpy.ndarray][source]#

Resample data and return (out_data, out_cell_ids).

compute(in_data: ArrayLike) → tuple[ArrayLike, numpy.ndarray][source]#

Alias for forward().

extra_repr() → str[source]#

Return the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

healpix_analyse.resample.resample_healpix(in_data: ArrayLike, *, in_level: int, out_level: int, in_cell_ids=None, out_cell_ids=None, ellipsoid: str = 'WGS84', radius_deg: float | None = None, sigma_deg: float | None = None, weight_norm: str = 'l1', up_norm: str = 'col_l1', dtype: torch.dtype = torch.float32, device: str | torch.device | None = None, eps: float = 1e-12) → tuple[ArrayLike, numpy.ndarray][source]#

One-shot NESTED HEALPix resampling convenience function.

Construct HealPixResampler directly when several maps share the same input/output geometry, so the sparse operators can be reused.

healpix_analyse.resample.resample_to_latlon_grid(lat, lon, data, method='linear')[source]#

Resample HEALPix data onto a regular latitude/longitude grid.