diff --git a/docs/analysis.rst b/docs/analysis.rst index 8e02fb9be..585b0b8a1 100644 --- a/docs/analysis.rst +++ b/docs/analysis.rst @@ -156,6 +156,11 @@ The `~specutils.analysis.moment` function computes moments of any order: >>> moment(noisy_gaussian, SpectralRegion(7*u.GHz, 3*u.GHz), order=2) # doctest:+FLOAT_CMP +By default the moment is calculated along the spectral axis, but any axis can be specified with +the ``axis`` keyword. Non-spectral-axis moments are calculated using integer pixel values for the +dispersion and return unitless values. Although they are available, they are perhaps of +questionable usefulness. + Line Widths ----------- diff --git a/specutils/analysis/moment.py b/specutils/analysis/moment.py index 34e810deb..0141f9a34 100644 --- a/specutils/analysis/moment.py +++ b/specutils/analysis/moment.py @@ -51,8 +51,8 @@ def _compute_moment(spectrum, regions=None, order=0, axis='spectral'): """ This is a helper function for the above `moment()` method. """ - if order is None or order < 0: - return None + if int(order) != order or order < 0: + raise ValueError("Order must be a positive integer.") if axis == "spectral": if isinstance(spectrum, SpectrumCollection):