get_rms#

mufasa.UltraCube.get_rms(residual)[source]#

Compute a robust estimate of the root mean square (RMS) from the fit residuals.

This function calculates the RMS of the residuals using a robust method based on the median absolute deviation (MAD). It is less sensitive to outliers compared to a standard RMS calculation.

Parameters:

residual (numpy.ndarray) – A 3D array representing the residuals between the observed data and the fitted model. The first dimension corresponds to the spectral axis, while the remaining dimensions represent the spatial axes.

Returns:

rms – A 2D array representing the RMS for each spatial pixel in the residual cube.

Return type:

numpy.ndarray

Notes

The RMS is calculated using the following robust formula:

RMS = 1.4826 × median(abs(x - median(x))) / sqrt(2)

Here, x represents the residuals for each spectral channel at a spatial pixel. The subtraction and absolute value are applied element-wise along the spectral axis. The robust method reduces sensitivity to noise spikes or outliers in the residuals.

Raises:

ValueError – If the input residual is not a 3D array or if it contains invalid (e.g., NaN) values.