fit_best_2comp_residual_cnv#

mufasa.master_fitter.fit_best_2comp_residual_cnv(reg, window_hwidth=3.5, res_snr_cut=3, savefit=True, planemask=None)[source]#

Fit the convolved residual of the best-fit two-component spectral model with a one-component model.

Parameters:
  • reg (Region) – The Region object containing the spectral cube and associated fit results.

  • window_hwidth (float, optional) – Half-width (in km/s) of the velocity window used for moment-based guesses. Defaults to 3.5. This value is approximately half the separation between the main hyperfine and satellite components.

  • res_snr_cut (float, optional) – Minimum signal-to-noise ratio for residual peak intensity to include a pixel in the fitting. This threshold is applied only during the generation of moment-based guesses and not during the actual recovery fit. Defaults to 3.

  • savefit (bool, optional) – If True, saves the fit results of the convolved residual to disk. Defaults to True.

  • planemask (numpy.ndarray, optional) – Boolean mask specifying which spatial pixels to fit. If provided, fitting is restricted to these pixels. Defaults to None.

Return type:

None

Raises:
  • SNRMaskError – If no pixels meet the signal-to-noise threshold or mask criteria for fitting.

  • StartFitError – If no pixels successfully start fitting due to poor initial guesses or insufficient signal.

Notes

  • This function fits the residual of the best-fit two-component model using a one-component model.

  • The approach assumes that the two-component model sufficiently describes the data; however, if the model is inadequate, the results may not accurately capture the true residual structure.

  • The purpose of this fit is solely to provide initial guesses for subsequent, more detailed fits.

  • If no valid pixels meet the SNR threshold (res_snr_cut), the function raises an SNRMaskError.

Examples

>>> from region import Region
>>> reg = Region('input_cube.fits', 'output_root', fittype='nh3')
>>> fit_best_2comp_residual_cnv(reg, window_hwidth=4.0, res_snr_cut=2.5, savefit=True)
>>> # Fits the convolved residual of the two-component model using a one-component model.