get_best_2comp_residual_SpectralCube#

mufasa.master_fitter.get_best_2comp_residual_SpectralCube(reg, masked=True, window_hwidth=3.5, res_snr_cut=5)[source]#

Generate the residual spectral cube for the best-fit two-component model.

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

  • masked (bool, optional) – If True, masks the residual cube to include only regions where the residual exceeds a signal-to-noise threshold (res_snr_cut). Defaults to True.

  • window_hwidth (float, optional) – Half-width (in km/s) of the velocity window used to define the residual region for masking. Defaults to 3.5.

  • res_snr_cut (float, optional) – Minimum signal-to-noise ratio for a residual peak to be considered excessive and included in the mask. Only applied when masked=True. Defaults to 5.

Returns:

The residual spectral cube, optionally masked based on the signal-to-noise threshold.

Return type:

SpectralCube

Notes

  • The function calculates the residual cube by subtracting the best-fit two-component model from the original spectral cube.

  • When masked=True, only regions where the residual peak signal-to-noise ratio exceeds res_snr_cut are included in the returned cube.

  • The window_hwidth parameter defines the velocity range for determining residual peaks near spectral features.

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

Raises:

SNRMaskError – If no regions meet the specified res_snr_cut threshold when masked=True.

Examples

>>> from region import Region
>>> reg = Region('input_cube.fits', 'output_root', fittype='nh3')
>>> residual_cube = get_best_2comp_residual_SpectralCube(reg, masked=True, window_hwidth=4.0, res_snr_cut=3)
>>> # Returns the residual spectral cube, masking regions with low signal-to-noise residuals.