Moments¶
-
class
turbustat.moments.
Moments
(cube, scale=None, moment_method='slice')[source] [edit on github]¶ 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: - cube : SpectralCube or str
Either a SpectralCube object, or the filename of a cube readable by spectral-cube.
- scale :
Quantity
, 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
(self)all_moments
(self)apply_mask
(self, 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
(self)Generate headers for the moments. make_moment_errors
(self[, axis, scale])Calculate the errors in the moments. make_moments
(self[, axis, units])Calculate the moments. to_dict
(self)Returns a dictionary with the cube and the property arrays. to_fits
(self[, 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
(self)[source] [edit on github]¶
-
all_moments
(self)[source] [edit on github]¶
-
apply_mask
(self, mask)[source] [edit on github]¶ Apply a mask to the cube.
Parameters: - mask : spectral-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] [edit on github]¶ 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_name : str
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_prefix : str, optional
If a SpectralCube object is given in
fits_name
, the prefix for the saved files can be provided here.- moments_path : str, optional
Path to where the moments are saved.
- mask_name : str, optional
Filename of a saved mask to be applied to the data.
- moment0 : str, optional
Filename of the moment0 array. Use if naming scheme is not valid for automatic loading.
- centroid : str, optional
Filename of the centroid array. Use if naming scheme is not valid for automatic loading.
- linewidth : str, optional
Filename of the linewidth array. Use if naming scheme is not valid for automatic loading.
- scale :
Quantity
, optional The noise level in the cube. Overrides estimation using signal_id
-
get_prop_hdrs
(self)[source] [edit on github]¶ Generate headers for the moments.
-
make_moment_errors
(self, axis=0, scale=None)[source] [edit on github]¶ Calculate the errors in the moments.
Parameters: - axis : int, optional
The axis to calculate the moments along.
-
make_moments
(self, axis=0, units=True)[source] [edit on github]¶ Calculate the moments.
Parameters: - axis : int, optional
The axis to calculate the moments along.
- units : bool, optional
If enabled, the units of the arrays are kept.
-
to_dict
(self)[source] [edit on github]¶ Returns a dictionary with the cube and the property arrays.
-
to_fits
(self, save_name=None)[source] [edit on github]¶ Save the property arrays as fits files.
Parameters: - save_name : str, optional
Prefix to use when saving the moment arrays. If None is given, ‘default’ is used.