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:
- signal
ArrayLike A 2D array containing the signal to be binned.
- noise
ArrayLike A 2D array containing the associated noise.
- bin_diameter
float, optional The minimum diameter of each bin (subject to pixel discretisation effects), by default 10.
- target_sn
float, 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.
- mask
ArrayLike|None, optional Values in the input signal and noise to mask out, i.e. where
mask==Truewill 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 defaultTrue.- use_powerbinbool, optional
Use the PowerBin algorithm instead.
- signal
- Returns:
- bin_labels
ArrayLike A 2D
intarray, containing the bin label assigned to each element of the input arrays.- nbins
int The number of bins.
- binned_s_n
ArrayLike A 1D array of length
nbins, containing the S/N in each bin.- bin_inv
ArrayLike A 2D array performing the inverse binning operation, i.e.
binned_s_n[inv]gives an array of the same shape asx.
- bin_labels