healpix_resample.BitmaskResampler#

class healpix_resample.BitmaskResampler(lon_deg, lat_deg, level, *, n_bits, bit_threshold=0.5, kernel=<class 'healpix_resample.bilinear.BilinearResampler'>, **kernel_kwargs)[source]#

Resample an integer bitmask (independent boolean flags) to HEALPix.

Use this when each bit of an integer mask is an independent yes/no flag that can co-occur with any other bit (e.g. per-pixel quality flags: cloud / cloud-shadow / snow / saturated / … all packed into one integer). Each bit is resampled independently as a 0/1 indicator through kernel (default BilinearResampler) and thresholded at bit_threshold (default 50%), then the surviving bits are recombined into an output bitmask – see resample().

Not for mutually-exclusive class labels (one class per sample) – use CategoricalResampler for that instead.

Parameters:
  • lon_deg, lat_deg (array-like, shape (N,)) – Sample coordinates in degrees.

  • level (int) – HEALPix level (nside = 2**level).

  • n_bits (int) – Number of bits to resample (bits 0 through n_bits - 1). Deliberately not auto-detected from max(mask): a bit that happens to never be set in one particular resample() call’s input (or in one parent-cell subset, if combined with subset_for_parent_cell) would otherwise silently vanish from the output instead of correctly coming back as all-zero.

  • bit_threshold (float) – Fraction (in [0, 1], default 0.5) above which a bit’s resampled indicator is considered “on” in the output. Distinct from kernel’s own threshold (its cell-retention support threshold, if you pass one via **kernel_kwargs) – the two are unrelated despite the similar name.

  • kernel (type) – A KNeighborsResampler subclass used to interpolate each bit’s indicator map – default BilinearResampler. See resample()’s docstring for why the default is the best-behaved choice for this purpose.

  • **kernel_kwargs – Forwarded to kernel’s constructor together with lon_deg, lat_deg, level (e.g. nest, device, dtype, out_cell_ids, threshold, sigma_m, verbose, …).

__init__(lon_deg, lat_deg, level, *, n_bits, bit_threshold=0.5, kernel=<class 'healpix_resample.bilinear.BilinearResampler'>, **kernel_kwargs)[source]#

Methods

__init__(lon_deg, lat_deg, level, *, n_bits)

resample(mask, **kwargs)

Resample an integer bitmask to HEALPix, bit by bit.