fit_surroundings#

mufasa.master_fitter.fit_surroundings(reg, ncomps=[1, 2], snr_min=3, max_iter=None, save_para=True, fill_mask=None, multicore=True, match_footprint=True)[source]#

Expand fits around a region based on model log-likelihood thresholds and target signal-to-noise depth.

This function iteratively expands fitted regions by incrementally adjusting thresholds, expanding boundaries based on signal-to-noise ratios and log-likelihood values, and aligning footprints across multiple components.

Parameters:
  • reg (Region object) – The region containing data and models to be fitted and expanded.

  • ncomps (list of int, optional) – Specifies the number of components for each model to fit in the region. Each component count in the list is processed in ascending order, expanding the fit boundaries accordingly (default is [1, 2]).

  • snr_min (float, optional) – Minimum signal-to-noise ratio threshold, used as a proxy on the lnk depth to reach via expansion. For snr_min <=>2, <=1, and <= 0, attempt to recover up to lnk >= 0, >=-5, and >=-20, respectively. When max_iter is left at the default, snr_min > 3 will result in minimal expansion for at least the highest ncomp model, depending on whether or not match_footprint is True

  • max_iter (int, optional) – Maximum number of iterations for expanding the fitted regions. If None, defaults based on snr_min: a high snr_min will limit expansion, while a low snr_min allows for more iterations (default is None).

  • save_para (bool, optional) – If True, saves the fitted parameter maps after each iteration (default is True).

  • fill_mask (ndarray, optional) – Boolean array defining the boundary for expansion; only pixels within this mask are considered for expansion. Defaults to the region’s default mask if None.

  • multicore (bool or int, optional) – Enables or sets the number of cores for parallel processing. If True, uses available cores automatically; if an integer, specifies the number of cores explicitly (default is True).

  • match_footprint (bool, optional) – If True, aligns the fitted regions’ footprints for different models by updating the fill_mask after each fit, ensuring consistent regions across component models. This parameter affects max_iter, setting it to max_iter_fill (default is True).

Return type:

None

Notes

  • Expansion proceeds by adjusting lnk_thresh for robustness: starting with a high threshold (10) for reliable fits, followed by a standard threshold (5) and optionally lower thresholds if snr_min is below 3.

  • If match_footprint is True, the function will use max_iter_fill to expand each model component’s footprint and attempt to match it with the previous component’s footprint.

  • The max_iter parameter dynamically controls the extent of expansion based on snr_min, promoting efficient use of resources while ensuring sufficient expansion depth.

Examples

>>> fit_surroundings(region, ncomps=[1, 2], snr_min=0, max_iter=10, multicore=4)
>>> # Expands and fits regions with up to 2 components, filling as much of the map as the maximum iterations allow.