get_masked_moment#
- mufasa.UltraCube.get_masked_moment(cube, model, order=0, expand=10, mask=None)[source]#
Calculate a masked moment of a spectral cube.
This function generates a moment map (e.g., integrated intensity, centroid) for the input spectral cube, applying a mask derived from the provided model and optionally expanding the mask region.
- Parameters:
cube (SpectralCube) – The spectral cube containing the observed data, from which the moment is calculated.
model (numpy.ndarray) – A 3D array representing the model cube, used to derive the mask. The dimensions must match the cube.
order (int, optional) – The order of the moment to compute: - 0 for integrated intensity (default), - 1 for centroid, - 2 for line width.
expand (int, optional) – Number of spectral channels to expand the mask around the model. Default is 10.
mask (numpy.ndarray, optional) – A 3D boolean array specifying which elements to include in the moment calculation. If provided, it is combined with the mask derived from the model. Default is None.
- Returns:
The computed moment map, with the unit determined by the input cube and the moment order.
- Return type:
astropy.units.Quantity
Notes
The mask is generated by identifying non-zero elements in the model and optionally expanding this region by the expand parameter.
Pixels with low signal-to-noise ratios are excluded from the moment map based on the mask.
The function uses the spectral axis of the cube for moment calculations.
- Raises:
ValueError – If the cube and model dimensions do not match.
Examples
>>> from spectral_cube import SpectralCube >>> cube = SpectralCube.read("example_cube.fits") >>> model = np.random.random(cube.shape) >>> moment_map = get_masked_moment(cube, model, order=0, expand=5) >>> moment_map.write("masked_moment.fits")