master_2comp_fit#

mufasa.master_fitter.master_2comp_fit(reg, snr_min=0.0, recover_wide=True, planemask=None, updateCnvFits=True, refit_bad_pix=True, refit_marg=True, max_expand_iter=None, multicore=True)[source]#

Perform a two-component fit on the data cube within a Region object.

This function applies a two-component fit to the spectral data, with optional adjustments for refining poor or marginal fits, recovering wide separation components, and expanding fits to surrounding regions based on signal-to-noise thresholds.

Parameters:
  • reg (Region) – A Region object containing the data cube to be fitted.

  • snr_min (float, optional) – Minimum peak signal-to-noise ratio required for fitting. Only regions with a peak SNR above this threshold are considered for fitting. Default is 0.0. If set to 0.0, attempts to fit all pixels using guesses from pre-existing fits.

  • recover_wide (bool, optional) – If True, attempts to recover spectral components with large velocity separation. Default is True.

  • planemask (ndarray, optional) – 2D mask specifying which pixels to fit, allowing for targeted fitting within selected regions. If provided, this mask overrides any existing planemask within the Region object. Default is None.

  • updateCnvFits (bool, optional) – If True, performs fits on the convolved cube first, even if previous fits exist, to update or refine results. Default is True.

  • refit_bad_pix (bool, optional) – If True, refits pixels with poor fits to improve fit quality. Default is True.

  • refit_marg (bool, optional) – If True, refits pixels with marginally acceptable fits for better accuracy. Default is True.

  • max_expand_iter (int, bool, or None, optional) – Controls the maximum number of iterations for expanding the fitted regions: - int: Specifies the exact number of expansion iterations. - True or None: Expands until no further expansion is possible. Limited expansion occurs if snr_min > 3, while more extensive iterations occur for lower snr_min. - False: Disables expansion entirely.

  • multicore (bool or int, optional) – Number of CPU cores to use for parallel processing. - True: Uses all available CPUs minus one. - int: Specifies the exact number of CPU cores to use. Default is True.

Returns:

The modified reg object with updated fit results.

Return type:

Region

Notes

  • The function first performs an initial two-component fit on the region and optionally refits pixels with low SNR, wide separation, or marginal quality.

  • Further expansion of fits to surrounding pixels is possible if max_expand_iter is specified.

  • When set to None or True, expansion proceeds with limited iterations if snr_min > 3, or more extensive iterations if snr_min is low.

  • If match_footprint is True within fit_surroundings, it attempts to align the fitted region’s footprints across components.

  • Final results are saved, with the best two-component fit retained based on log-likelihood thresholds.

Examples

Perform a 2-component fit on the region with specific settings:

>>> updated_reg = master_2comp_fit(region, snr_min=3.0, recover_wide=False, max_expand_iter=5, multicore=4)
>>> # Fits the region with a minimum SNR of 3.0, disables wide recovery, and expands fits for 5 iterations.