healpix_analyse.decomp#
Exactly reconstructing multiscale decomposition for HEALPix maps.
HealPixDecomp builds a local Laplacian pyramid from matched
HealPixDown and HealPixUp operators. Every detail band is a
fine map minus the prediction obtained by downsampling and upsampling it. The
same stored Up operator is reused during synthesis, making reconstruction
algebraically exact up to floating-point round-off, including on masked maps.
Classes#
List-like multiscale coefficients returned by |
|
Paired analysis of confidence-weighted data and confidence weights. |
|
Local, exactly reconstructing HEALPix multiscale decomposition. |
Module Contents#
- class healpix_analyse.decomp.HealPixPyramid[source]#
Bases:
Sequence[ArrayLike]List-like multiscale coefficients returned by
HealPixDecomp.compute().bands[:-1]are detail maps from fine to coarse andbands[-1]is the final low-pass map.cell_ids[i]andlevels[i]describe the pixel domain ofbands[i]. The object behaves like a read-only sequence, so existing list-oriented code can iterate over it directly.- cell_ids: tuple[numpy.ndarray, ...]#
- class healpix_analyse.decomp.HealPixWeightedPyramid[source]#
Paired analysis of confidence-weighted data and confidence weights.
Returned by
HealPixDecomp.compute_weighted().qis the pyramid obtained by running the same linear analysis (HealPixDown/HealPixUpchain) onweights * x(with missing values replaced by zero), andmis the pyramid obtained by running that identical analysis onweightsalone. Because the analysis operatorWis data-independent,qandmsharecell_ids/levelsband for band.The detail bands of
mare signed correction terms, not per-band confidences: they are not bounded in[0, 1]and must not be clipped, thresholded, or divided into individually. Only a full synthesis of both channels followed by a single division – performed byHealPixDecomp.invert()when given aHealPixWeightedPyramid, or by a kernel-pyramid convolution applied identically to both channels – recovers a valid normalized result.- property cell_ids: tuple[numpy.ndarray, ...]#
- class healpix_analyse.decomp.HealPixDecomp(level: int, cell_ids=None, Jmax: int = -1, *, 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)[source]#
Bases:
torch.nn.ModuleLocal, exactly reconstructing HEALPix multiscale decomposition.
- Parameters:
level (
int) – Fine input Grid4Earth/HEALPix level, withnside = 2**level.cell_ids (
array-like, optional) – NESTED identifiers of a masked/partial map, in the same order as the input data.Noneselects the complete sphere.Jmax (
int, default-1) – Number of Down operations.-1uses every available scale down to level zero.0returns a pyramid containing only the input map.ellipsoid (
str, default"WGS84") – Geometry used by every analysis filter.radius_deg, sigma_deg (
float, optional) – Gaussian smoothing parameters passed to everyHealPixDown. When omitted, each level uses its own resolution-dependent defaults.weight_norm (
{"l1", "l2", "none"}, default"l1") – Down-filter normalisation.l1preserves constant maps locally.up_norm (
{"adjoint", "col_l1", "diag_l2"}, default"col_l1") – Matched synthesis normalisation. Exact pyramid reconstruction does not depend on this choice because the prediction is stored as a residual, but it changes the interpretation of individual bands.dtype, device (optional) – PyTorch execution options. CUDA is selected when available.
Notes
At scale
jthe analysis iscoarse[j+1] = Down[j](coarse[j])detail[j] = coarse[j] - Up[j](coarse[j+1]).Synthesis applies the exact reverse recursion
coarse[j] = detail[j] + Up[j](coarse[j+1]).Every
HealPixUpis constructed withpaired_down=...and therefore reuses the exact sparse matrix and fine-cell domain of its analysis step.- level#
- Jmax = -1#
- n_scales#
- n_bands#
- ellipsoid = ''#
- weight_norm = ''#
- up_norm = ''#
- dtype = Ellipsis#
- partial#
- n_pixels#
- down_layers#
- up_layers#
- levels#
- cell_ids_per_scale#
- sizes#
- property device: torch.device#
Current device of the decomposition operators.
- property cell_ids: tuple[numpy.ndarray, ...]#
Canonical NESTED identifiers for every returned band.
- compute(data: ArrayLike) HealPixPyramid[source]#
Decompose a map into fine-to-coarse details and one coarse map.
The returned object is list-like and contains
n_scales + 1images. Arbitrary leading dimensions are supported, for example[B,C,N].
- compute_weighted(data: ArrayLike, weights: ArrayLike | None = None) HealPixWeightedPyramid[source]#
Decompose a map that may contain NaN/missing values.
Non-finite entries of
data(and, when given, non-finite or implicitly-absent entries ofweights) are treated as missing.weightsdefaults to a 0/1 confidence mask built fromisfinite(data)when omitted, i.e. plain unweighted missing-data handling.Internally this runs the same analysis operator
W(the stored Down/Up chain) onq = weights * data(missing values zeroed) and onm = weights(also zeroed at missing positions), and returns both resulting pyramids paired in aHealPixWeightedPyramid. Reconstruct withinvert(), which performs the single divisionS(q) / S(m)after synthesis, per the normalized-convolution convention – never divide the two pyramids band by band.The boolean missing/valid decision itself carries no gradient (as with any masking based on
isfinite); the surviving finite values ofdata/weightsremain differentiable.
- forward(data: ArrayLike) HealPixPyramid[source]#
Alias for
compute(), enabling normalnn.Moduleusage.
- invert(decomposition: HealPixPyramid | HealPixWeightedPyramid | Sequence[ArrayLike], *, restore_mask: bool = True, eps: float = 1e-08) ArrayLike[source]#
Reconstruct the original map from multiscale coefficients.
Given a plain
HealPixPyramid(or a bare sequence of bands), this is the exact algebraic reverse ofcompute(), unaffected byrestore_mask/eps.Given a
HealPixWeightedPyramid(fromcompute_weighted()), both channels are synthesized with the same Up chain and combined with a single divisiony = S(q) / S(m)– never per-band. Output pixels whose synthesized weightS(m)falls at or belowepshave no reliable support; whenrestore_maskis True (default) they are set to NaN, otherwise to 0.
- expand(decomposition: HealPixPyramid | Sequence[ArrayLike]) tuple[ArrayLike, ...][source]#
Lift every band to the fine grid so their direct sum reconstructs.
computedeliberately returns compact native-resolution bands. This method applies the stored synthesis operators to each band independently, restores the original fine-cell order, and returnsn_bandsfine-resolution components. Their elementwise sum equalsinvert()up to floating-point round-off.