constrained_adaptive#

niriss_tools.sed.constrained_adaptive(signal, noise, bin_diameter=4, target_sn=100, plot=True, quiet=False, cvt=True, wvt=True, mask=None, use_hex=True, use_powerbin=True)[source]#

Perform a constrained adaptive binning method to reach a target S/N.

This function performs a 2-stage binning procedure, subject to a minimum bin diameter. The initial stage is a hexagonal binning scheme, which selects any bins that achieve the target S/N. This is followed by a Voronoi tesselation on all remaining pixels, using the method of Cappellari & Copin 2003.

Parameters:
signalArrayLike

A 2D array containing the signal to be binned.

noiseArrayLike

A 2D array containing the associated noise.

bin_diameterfloat, optional

The minimum diameter of each bin (subject to pixel discretisation effects), by default 10.

target_snfloat, optional

The desired S/N in each output bin, by default 100. This is only guaranteed to be achieved for the hexagonal bins, as there is some scatter on the S/N achieved through Voronoi binning.

plotbool, optional

Show a comparison of the binned and unbinned data, alongside the S/N and bin maps. By default False.

quietbool, optional

Print the output of the Voronoi binning procedure, by default False.

cvtbool, optional

Attempt to achieve a centroidal Voronoi tessellation, using the method of Cappellari & Copin 2003, by default True.

wvtbool, optional

Use the weighted Voronoi tessellation method by Diehl & Statler 2006. By default True.

maskArrayLike | None, optional

Values in the input signal and noise to mask out, i.e. where mask==True will not be included in the binned data.

use_hexbool, optional

Whether to perform the first stage of the binning procedure. If False, then this will be skipped, and only the Voronoi binning procedure will be attempted. By default True.

use_powerbinbool, optional

Use the PowerBin algorithm instead.

Returns:
bin_labelsArrayLike

A 2D int array, containing the bin label assigned to each element of the input arrays.

nbinsint

The number of bins.

binned_s_nArrayLike

A 1D array of length nbins, containing the S/N in each bin.

bin_invArrayLike

A 2D array performing the inverse binning operation, i.e. binned_s_n[inv] gives an array of the same shape as x.