{"id":24619,"library":"specutils","title":"specutils","description":"A Python package for spectroscopic astronomical data analysis, part of the Astropy ecosystem. Version 2.3.0 supports Python >=3.11. It provides classes for representing spectra (Spectrum1D, SpectrumList), spectral regions, and operations like resampling, fitting, and combining spectra. Release cadence is irregular with major version bumps about every 2 years.","status":"active","version":"2.3.0","language":"python","source_language":"en","source_url":"https://github.com/astropy/specutils","tags":["astronomy","spectroscopy","astropy","astrophysics","spectrum"],"install":[{"cmd":"pip install specutils","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for units, quantities, and WCS","package":"astropy","optional":false},{"reason":"For generalized WCS support in Spectrum2D","package":"gwcs","optional":true},{"reason":"For interpolation and fitting backends","package":"scipy","optional":false},{"reason":"For multi-dimensional spectral cubes","package":"ndcube","optional":true}],"imports":[{"note":"No common mistake; classic import is correct.","wrong":"from specutils import Spectrum1D as Spectrum1D","symbol":"Spectrum1D","correct":"from specutils import Spectrum1D"},{"note":"SpectralRegion is a class in specutils, not a top-level module.","wrong":"import SpectralRegion","symbol":"SpectralRegion","correct":"from specutils import SpectralRegion"}],"quickstart":{"code":"import numpy as np\nfrom specutils import Spectrum1D, SpectralRegion\nfrom specutils.manipulation import extract_region\nfrom astropy import units as u\n\n# Create a simple spectrum\nflux = np.array([1.0, 2.0, 3.0]) * u.Jy\nspectral_axis = np.array([5000, 5010, 5020]) * u.Angstrom\nspec = Spectrum1D(spectral_axis=spectral_axis, flux=flux)\n\n# Extract a region\nregion = SpectralRegion(5005 * u.Angstrom, 5015 * u.Angstrom)\nextracted = extract_region(spec, region)\nprint(extracted)\n","lang":"python","description":"Basic usage: create a Spectrum1D and extract a spectral region."},"warnings":[{"fix":"Use 'from specutils import Spectrum' for new code, or continue using Spectrum1D as an alias.","message":"In specutils 2.x, the class previously known as Spectrum1D is now Spectrum and Spectrum1D is an alias. Code relying on Spectrum1D subclassing may break if using isinstance checks against old class hierarchy.","severity":"breaking","affected_versions":"2.0.0 and later"},{"fix":"Upgrade to Python >=3.11.","message":"Support for Python 3.10 dropped in specutils 2.2.0. Python 3.11 or later is required.","severity":"breaking","affected_versions":"2.2.0 and later"},{"fix":"Remove spectral_axis_index and rely on automatic axis ordering.","message":"The 'spectral_axis_index' keyword argument introduced in 2.0 is deprecated in favor of automatic detection. Using it may emit deprecation warnings.","severity":"deprecated","affected_versions":"2.0.0 through current"},{"fix":"Use equivalencies if needed, e.g., via astropy.units.equivalencies.spectral().","message":"When passing a SpectralRegion to extract_region, if the units of the region do not match the spectrum's spectral axis units, an error may not be raised immediately but results can be incorrect. Always ensure consistent units.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade specutils to >=1.20: pip install --upgrade specutils","cause":"Outdated specutils version (<1.20) where Spectrum1D was not yet exposed at top level.","error":"AttributeError: module 'specutils' has no attribute 'Spectrum1D'"},{"fix":"Ensure spectral_axis is sorted: spec = Spectrum1D(spectral_axis=np.sort(spectral_axis), flux=flux)","cause":"Spectral axis values are not sorted in ascending order.","error":"ValueError: The spectral axis must be monotonically increasing."},{"fix":"Install gwcs: pip install gwcs","cause":"Missing optional dependency for GWCS support.","error":"ImportError: No module named 'gwcs'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}