Skip to content

Commit

Permalink
add placeholder test for coadded spectrum
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Nov 15, 2023
1 parent 7472c80 commit b72ab31
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions py/desispec/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ def to_specutils(self):

@classmethod
def from_specutils(cls, spectra):
"""Convert ``specutils`` objects to a :class:`~desiutil.spectra.Spectra` object.
"""Convert ``specutils`` objects to a :class:`~desispec.spectra.Spectra` object.
Parameters
----------
Expand All @@ -723,7 +723,7 @@ def from_specutils(cls, spectra):
Returns
-------
:class:`~desiutil.spectra.Spectra`
:class:`~desispec.spectra.Spectra`
The corresponding DESI-internal object.
Raises
Expand Down
22 changes: 21 additions & 1 deletion py/desispec/test/test_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from desispec.spectra import *
from desispec.io.spectra import *


class TestSpectra(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -323,7 +324,6 @@ def test_empty(self):

path = write_spectra(self.filebuild, spec)


def test_updateselect(self):
spec = Spectra(bands=self.bands, wave=self.wave, flux=self.flux, ivar=self.ivar,
mask=self.mask, resolution_data=self.res, fibermap=self.fmap1,
Expand Down Expand Up @@ -501,6 +501,26 @@ def test_from_specutils(self):
self.assertTrue((sp1.mask[self.bands[2]] == sp2.mask[self.bands[2]]).all())
self.assertDictEqual(sp1.meta, sp2.meta)

# @unittest.skipUnless(_specutils_imported, "Unable to import specutils.")
@unittest.expectedFailure
def test_from_specutils_coadd(self):
"""Test conversion from a Spectrum1D object representing a coadd across cameras.
"""
sp0 = Spectra(bands=self.bands, wave=self.wave, flux=self.flux, ivar=self.ivar,
mask=self.mask, resolution_data=self.res,
fibermap=self.fmap1, exp_fibermap=self.efmap1,
meta=self.meta, extra=self.extra, scores=self.scores,
extra_catalog=self.extra_catalog)
sp1 = desispec.coaddition.coadd_cameras(sp0)
spectrum_list = sp1.to_specutils()
sp2 = Spectra.from_specutils(spectrum_list[0])
self.assertEqual(sp2.bands[0], 'brz')
self.assertListEqual(sp1.bands, sp2.bands)
self.assertTrue((sp1.flux[self.bands[0]] == sp2.flux[self.bands[0]]).all())
self.assertTrue((sp1.ivar[self.bands[1]] == sp2.ivar[self.bands[1]]).all())
self.assertTrue((sp1.mask[self.bands[2]] == sp2.mask[self.bands[2]]).all())
self.assertDictEqual(sp1.meta, sp2.meta)


def test_suite():
"""Allows testing of only this module with the command::
Expand Down

0 comments on commit b72ab31

Please sign in to comment.