bin — Post-Clustering Parameter Binning¶
The bin subcommand reads result folders produced by kmeans-model (or ptep-model), bins each spectral-parameter map into equal-width bins, and writes full-sky .npy patch files. These files can be fed directly to kmeans-model -c to re-run component separation with the binned clustering.
Basic Usage¶
r_analysis bin \
-n 64 \
-r "kmeans_BD10000_TD500_BS500_GAL020" \
-ird results/ \
-o binned_patches/ \
--bin-bd 50 --bin-td 20 --bin-bs 30
How It Works¶
Load result folders matching the
-rpattern (each must containresults.npzandmask.npy).Combine disjoint masks from multiple folders into a single valid-pixel mask.
Select a reference noise realization (controlled by
--noise-selection).Bin each parameter’s pixel-level values into equal-width bins using
bin_parameter_map.Write full-sky
.npyfiles to--output-dir:patches_beta_dust.npypatches_temp_dust.npypatches_beta_pl.npymask.npy
Each .npy file is a float64 array of shape (npix,) where valid pixels contain 0-based bin indices and masked pixels are hp.UNSEEN.
Visual Example¶
The following figures illustrate the binning process on a GAL060 mask with 200/\(\beta_d\), 100/\(T_d\), 100/\(\beta_s\) clusters binned down to 10 bins each.
Original K-means patches vs binned:

Arguments¶
Flag |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
Output directory for |
|
|
none |
Number of equal-width bins for \(\beta_\mathrm{dust}\) |
|
|
none |
Number of equal-width bins for \(T_\mathrm{dust}\) |
|
|
none |
Number of equal-width bins for \(\beta_\mathrm{synch}\) |
|
|
|
Noise realization selection: |
At least one --bin-* argument is required. Parameters without a --bin-* flag are preserved with their original (renumbered) cluster indices.
Plus all common arguments (-n, -r, -ird, --sky, -mi, -s, etc.).
Workflow: Bin and Re-Run¶
The typical workflow is to first run a high-resolution component separation, then bin the resulting parameters and re-run with the binned patches:
# 1. Initial high-resolution run
kmeans-model -n 64 -pc 10000 500 500 -m GAL020 -tag c1d1s1
# 2. Bin the parameters
r_analysis bin \
-n 64 \
-r "kmeans_BD10000_TD500_BS500_GAL020" \
-ird results/ \
-o binned_patches/ \
--bin-bd 50 --bin-td 20 --bin-bs 30
# 3. Re-run with binned patches
kmeans-model -n 64 \
-c binned_patches/patches_beta_dust.npy \
binned_patches/patches_temp_dust.npy \
binned_patches/patches_beta_pl.npy \
-m GAL020 -tag c1d1s1
API Reference¶
The core binning function is exposed at the package level:
from furax_cs import bin_parameter_map
patch_indices, bin_centers, bin_edges = bin_parameter_map(pixel_values, nbins=50)
See the API documentation for the full docstring with a reconstruction example.