Skip to content

Commit

Permalink
add class method
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Nov 15, 2023
1 parent bb0a20e commit e2c1581
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions py/desispec/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,38 @@ def to_specutils(self):
sl = SpectrumList()
return sl

@classmethod
def from_specutils(cls, spectra):
"""Convert ``specutils`` objects to a :class:`~desiutil.spectra.Spectra` object.
Parameters
----------
spectra : specutils.Spectrum1D or specutils.SpectrumList
A ``specutils`` object.
Returns
-------
:class:`~desiutil.spectra.Spectra`
The corresponding DESI-internal object.
Raises
------
ValueError
If ``specutils`` is not available in the environment.
"""
if not _specutils_imported:
raise ValueError("specutils is not available in the environment.")
if isinstance(spectra, SpectrumList):
pass
elif isinstance(spectra, Spectrum1D):
#
# Assume this is a coadd across cameras.
#
pass
else:
raise ValueError("Unknown type input to from_specutils!")
return cls()


def stack(speclist):
"""
Expand Down

0 comments on commit e2c1581

Please sign in to comment.