get_best_2comp_residual#

mufasa.master_fitter.get_best_2comp_residual(reg)[source]#

Calculate the residual cube for the best-fit two-component model.

Parameters:

reg (Region) – The Region object containing the original spectral cube and fitted model results.

Returns:

A spectral cube representing the residuals, calculated as the difference between the original data and the best-fit two-component model.

Return type:

SpectralCube

Notes

  • The residual cube is computed by subtracting the best-fit model from the original spectral data.

  • The best-fit model is determined by comparing the log-likelihood of the one-component and two-component fits at each pixel.

  • This function assumes that the one- and two-component parameter cubes (reg.ucube.pcubes[‘1’] and reg.ucube.pcubes[‘2’]) have been generated and are accessible.

Examples

>>> from region import Region
>>> reg = Region('input_cube.fits', 'output_root', fittype='nh3')
>>> residual = get_best_2comp_residual(reg)
>>> # Returns a SpectralCube object representing the residual between the data and the best-fit model.