Describe the bug
Loading and plotting generic spectral data into Spectrum does not work. I tried to create a spectrum out of an HI spectral data (flux and velocity). The spectrum is created but plotting fails because it either looks for a pix_mask or requires std error array data. Still fails when either use_mask or show_std is set to False.
To Reproduce
import astropy.units as u
from marvin.tools.quantities.spectrum import Spectrum
# create a generic spectrum
s=Spectrum(hi_data._specdata['FHI'][0], wavelength=hi_data._specdata['VHI'][0], scale=1, unit=u.Jy, wavelength_unit=(u.km/u.s))
# try to plot it
s.plot()
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-63-886abc61b753> in <module>()
----> 1 s.plot()
/Users/Brian/Work/github_projects/Marvin/python/marvin/tools/quantities/spectrum.pyc in plot(self, xlim, ylim, show_std, use_mask, n_sigma, xlabel, ylabel, show_units, plt_style, figure, return_figure, **kwargs)
191
192 if use_mask:
--> 193 donotuse_mask = self.pixmask.get_mask('DONOTUSE') > 0
194
195 if use_mask:
/Users/Brian/Work/github_projects/Marvin/python/marvin/tools/quantities/base_quantity.pyc in pixmask(self)
120 """
121
--> 122 assert self.pixmask_flag, 'pixmask flag not set'
123
124 pixmask = maskbit.Maskbit(self.pixmask_flag)
AssertionError: pixmask flag not set
Init signature: specutils.Spectrum1D(self, flux, wcs, unit=None, uncertainty=None, mask=None, meta=None, indexer=None, *args, **kwargs)
Docstring:
A subclass of `NDData` for a one dimensional spectrum in Astropy.
# try to plot it with no mask
s.plot(use_mask=False)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-64-48cc84529cc3> in <module>()
----> 1 s.plot(use_mask=False)
/Users/Brian/Work/github_projects/Marvin/python/marvin/tools/quantities/spectrum.pyc in plot(self, xlim, ylim, show_std, use_mask, n_sigma, xlabel, ylabel, show_units, plt_style, figure, return_figure, **kwargs)
200 value = self.value
201 wave = self.wavelength.value
--> 202 std = np.ma.array(self.std.value, mask=donotuse_mask)
203
204 ax.plot(wave, value, **kwargs)
AttributeError: 'NoneType' object has no attribute 'value'
Expected behavior
At minimum, it should be able to take a flux array, some x-axis data and plot it.
Additional Context
Same problem occurs when trying to plot random data against an integer range.
Describe the bug Loading and plotting generic spectral data into Spectrum does not work. I tried to create a spectrum out of an HI spectral data (flux and velocity). The spectrum is created but plotting fails because it either looks for a
pix_mask
or requiresstd
error array data. Still fails when eitheruse_mask
orshow_std
is set toFalse
.To Reproduce
Expected behavior At minimum, it should be able to take a flux array, some x-axis data and plot it.
Additional Context Same problem occurs when trying to plot random data against an integer range.