Moments

class turbustat.moments.Moments(cube, scale=None, moment_method='slice')[source]

Bases: object

A unified approach to deriving the noise level in a cube, applying a mask, and deriving moments along with their errors. All the heavy lifting is done with spectral_cube.

Parameters:
cubeSpectralCube or str

Either a SpectralCube object, or the filename of a cube readable by spectral-cube.

scaleQuantity, optional

The noise level in the cube. Used to estimate uncertainties of the moment maps.

moment_method{‘slice’, ‘cube’, ‘ray’}, optional

The method to use for creating the moments. See the spectral-cube docs for an explanation of the differences.

Attributes Summary

linewidth

linewidth_err

moment0

moment0_err

moment1

moment1_err

scale

Methods Summary

all_moment_errs()

all_moments()

apply_mask(mask)

Apply a mask to the cube.

from_fits(fits_name[, moments_prefix, ...])

Load pre-made moment arrays given a cube name.

get_prop_hdrs()

Generate headers for the moments.

make_moment_errors([axis, scale])

Calculate the errors in the moments.

make_moments([axis, units])

Calculate the moments.

to_dict()

Returns a dictionary with the cube and the property arrays.

to_fits([save_name])

Save the property arrays as fits files.

Attributes Documentation

linewidth
linewidth_err
moment0
moment0_err
moment1
moment1_err
scale

Methods Documentation

all_moment_errs()[source]
all_moments()[source]
apply_mask(mask)[source]

Apply a mask to the cube.

Parameters:
maskspectral-cube Mask or numpy.ndarray, optional

The mask to be applied to the data. If None is given, RadioMask is used with its default settings.

static from_fits(fits_name, moments_prefix=None, moments_path=None, mask_name=None, moment0=None, centroid=None, linewidth=None, scale=None)[source]

Load pre-made moment arrays given a cube name. Saved moments must match the naming of the cube for the automatic loading to work (e.g. a cube called test.fits will have a moment 0 array with the name test_moment0.fits). Otherwise, specify a path to one of the keyword arguments.

Parameters:
fits_namestr

Filename of the cube or a SpectralCube object. If a filename is given, it is also used as the prefix to the saved moment files.

moments_prefixstr, optional

If a SpectralCube object is given in fits_name, the prefix for the saved files can be provided here.

moments_pathstr, optional

Path to where the moments are saved.

mask_namestr, optional

Filename of a saved mask to be applied to the data.

moment0str, optional

Filename of the moment0 array. Use if naming scheme is not valid for automatic loading.

centroidstr, optional

Filename of the centroid array. Use if naming scheme is not valid for automatic loading.

linewidthstr, optional

Filename of the linewidth array. Use if naming scheme is not valid for automatic loading.

scaleQuantity, optional

The noise level in the cube. Overrides estimation using signal_id

get_prop_hdrs()[source]

Generate headers for the moments.

make_moment_errors(axis=0, scale=None)[source]

Calculate the errors in the moments.

Parameters:
axisint, optional

The axis to calculate the moments along.

make_moments(axis=0, units=True)[source]

Calculate the moments.

Parameters:
axisint, optional

The axis to calculate the moments along.

unitsbool, optional

If enabled, the units of the arrays are kept.

to_dict()[source]

Returns a dictionary with the cube and the property arrays.

to_fits(save_name=None, **kwargs)[source]

Save the property arrays as fits files.

Parameters:
save_namestr, optional

Prefix to use when saving the moment arrays. If None is given, ‘default’ is used.

kwargsPassed to writeto.