foscat.HOrientedConvol#
Classes#
Module Contents#
- class foscat.HOrientedConvol.HOrientedConvol(nside, KERNELSZ, cell_ids=None, nest=True, device=None, dtype='float64', polar=False, gamma=1.0, allow_extrapolation=True, no_cell_ids=False)[source]#
- local_test = False#
- polar = False#
- gamma = 1.0#
- device = None#
- allow_extrapolation = True#
- w_idx = None#
- idx_nn#
- nside#
- KERNELSZ#
- nest = True#
- f = None#
- remap_by_first_column(idx: numpy.ndarray) numpy.ndarray[source]#
- Remap the values in idx so that:
The first column becomes [0, 1, …, N-1]
All other columns are updated accordingly using the same mapping.
- Parameters:
idx (
np.ndarray) – Integer array of shape (N, m). Assumes all values in idx are present in the first column (otherwise they get -1).- Returns:
np.ndarray– New array with remapped indices.
- rotation_matrices_from_healpix(nside, hpix_idx, nest=True)[source]#
Compute rotation matrices that move each Healpix pixel center to the North pole. equivalent to rotation matrices R_z(phi) * R_y(-thi) for N points.
- knn_healpix_ckdtree(hidx, N, nside, *, nest=True, include_self=True, vec_dtype=np.float32, out_dtype=np.int64)[source]#
k-NN using a cKDTree on unit vectors (exact in Euclidean space). Returns LOCAL indices (0..M-1) of the N nearest neighbours per row.
- make_wavelet_matrix(orientations, polar=True, norm_mean=True, norm_std=True, return_index=False, return_smooth=False)[source]#
- make_idx_weights_from_cell_ids(i_cell_ids, polar=False, gamma=1.0, device=None, allow_extrapolation=True)[source]#
Accept 1D (Npix,) or 2D (B, Npix) cell_ids and return tensors batched on the first dim (B, …).
- make_idx_weights_from_one_cell_ids(cell_ids, polar=False, gamma=1.0, device=None, allow_extrapolation=True)[source]#
- make_idx_weights(polar=False, gamma=1.0, device=None, allow_extrapolation=True, return_index=False)[source]#
- bilinear_weights_NxN(x, y, allow_extrapolation=True)[source]#
Compute bilinear weights on an N×N integer grid with node coordinates (xi, yi) in {-K, …, +K} × {-K, …, +K}, where K = N//2 (N must be odd).
N is attached to the class N = self.KERNELSZ
The query point (x, y) is continuous in the same coordinate system. For each query, we pick the unit cell [x0, x0+1] × [y0, y0+1] with integer corners (x0,y0), (x0+1,y0), (x0,y0+1), (x0+1,y0+1), and compute standard bilinear weights relative to (x0, y0).
- Parameters:
x, y (
floatorarray-likeofshape (M,)) – Query coordinates in the integer grid coordinate system.N (
int) – Grid size (must be odd). Grid nodes are at integer coords xi, yi ∈ {-K, …, +K}, where K = N//2.allow_extrapolation (
bool, defaultTrue) –If False: clamp (x, y) to [-K, +K] so that tx, ty ∈ [0, 1] and weights are non-negative and sum to 1.
If True : do not clamp (x, y); we still select the nearest boundary cell inside the grid for the indices, but tx, ty may fall outside [0, 1], yielding extrapolation (weights can be negative).
- Returns:
idx (
ndarrayofshape (M,4),dtype=int64) – Flat indices (0 .. N*N-1) of the four cell-corner nodes in row-major order (y from -K to +K, x from -K to +K): order = [(x0,y0), (x0+1,y0), (x0,y0+1), (x0+1,y0+1)].w (
ndarrayofshape (M,4),dtype=float64) – Corresponding bilinear weights for each query point. If allow_extrapolation=False and the point is inside the grid, each row sums to 1 and all weights are in [0,1].
Notes
This matches your previous 3×3 case when N=3, with the same row-major flattening convention.
For extrapolation=True, indices are kept in-bounds (clamped to boundary cells), while tx, ty > 1 or < 0 are allowed.
- Convol_torch(im, ww, cell_ids=None, nside=None)[source]#
Batched KERNELSZxKERNELSZ aggregation.
- Accepts either:
im: Tensor (B, C_i, Npix) with one shared or per-batch (B,Npix) cell_ids
im: list/tuple of Tensors, each (C_i, Npix_b), with cell_ids a list of arrays
- Down(im, cell_ids=None, nside=None, max_poll=False)[source]#
If cell_ids is a single set of ids -> return a single (Tensor, Tensor). If cell_ids is a list (var-length) -> return (list[Tensor], list[Tensor]).