expand_fits#
- mufasa.master_fitter.expand_fits(reg, ncomp, lnk_thresh=5, max_iter=5, r_expand=1, fill_mask=None, lnkmap=None, multicore=True, snr_min=0, save_para=True, return_niter=False)[source]#
Expand fits in a region by incrementally fitting pixels beyond a defined log-likelihood threshold boundary.
This function iteratively expands fitted regions by attempting to fit pixels beyond a boundary set by the relative log-likelihood threshold.
- Parameters:
reg (Region object) – The region object containing the data cube and the fitting model.
ncomp (int) – Number of components in the model to fit in each pixel.
lnk_thresh (float, optional) – Relative log-likelihood threshold used to define the boundary for expansion. Pixels with log-likelihood values above this threshold are considered for expansion (default is 5).
max_iter (int, optional) – Maximum number of expansion iterations to perform. Each iteration attempts to fit the next layer of pixels beyond the current boundary (default is 5).
r_expand (int, optional) – Number of pixels to expand in each direction during each iteration (default is 1).
fill_mask (ndarray, optional) – Boolean array that defines the outer boundary for expansion. Expansion is limited to pixels within this mask (default is None, which implies no additional mask constraint).
lnkmap (ndarray, optional) – A precomputed 2D array (i.e., map) of relative log-likelihood values. Supplying this map saves computation time by avoiding recalculating these values. If None, the function will compute the map as needed (default is None).
multicore (bool or int, optional) – Whether to use multiple cores for parallel processing. If True, automatically selects available cores; if an integer is provided, it specifies the number of cores (default is True).
snr_min (float, optional) – Minimum signal-to-noise ratio threshold for successful fits. Fits below this threshold are not considered “good” (default is 0).
save_para (bool, optional) – If True, saves updated parameter maps after fitting. Useful for keeping track of intermediate fit results (default is True).
return_niter (bool, optional) – If True, returns both the total number of successfully fitted pixels and the number of iterations performed (default is False).
- Returns:
If return_niter is False, returns the total number of successfully fitted pixels across all iterations. If return_niter is True, returns a tuple containing the total number of successfully fitted pixels and the number of iterations completed.
- Return type:
Examples
>>> n_good_total = expand_fits(reg, ncomp=2, lnk_thresh=10, max_iter=3, r_expand=1, multicore=4) >>> print(f"Total good fits: {n_good_total}")