to_K#

mufasa.UltraCube.to_K(cube)[source]#

Convert the unit of a spectral cube to Kelvin (K).

This function attempts to convert the unit of a spectral_cube.SpectralCube object to brightness temperature (K) using the Rayleigh-Jeans approximation. If the cube’s current unit is not convertible, it will handle the error by either warning the user or raising a UnitConversionError.

Parameters:

cube (spectral_cube.SpectralCube) – A SpectralCube object whose unit needs to be converted to Kelvin (K).

Returns:

A new SpectralCube object with its unit set to Kelvin (K).

Return type:

spectral_cube.SpectralCube

Raises:

UnitConversionError – If the cube’s unit cannot be converted to Kelvin (K) and it is not possible to forcefully assign a unit.

Notes

If the cube does not have an assigned unit, a unit of Kelvin (K) will be assumed and a warning will be issued.

Examples

>>> from spectral_cube import SpectralCube
>>> import astropy.units as u
>>> cube = SpectralCube.read('example_cube.fits')
>>> cube_in_K = to_K(cube)