specutils icon indicating copy to clipboard operation
specutils copied to clipboard

Spectrum1D() should store the best-fit continuum

Open janerigby opened this issue 4 years ago • 2 comments

I believe the Spectrum1D() object needs an optional parameter that stores the best-fit continuum. In the JDAT notebooks, the continuum, once fit, is stored in a separate variable with (coincidentally) the same x-axis as the spectral_axis of the Spectrum1D() from which it was fit. The user needs to keep track of which continuum goes with which spectrum. As a user, I would much prefer to store that best-fit continuum in the Spectrum1D object. Much cleaner, and less prone to error.

janerigby avatar Dec 18 '20 15:12 janerigby

This is not in the planned purview of the Spectrum1D object -- its purpose is to represent either a single spectrum or a collection of spectra that share the same spectral axis.

It is possible to simply have the flux attribute of the Spectrum1D be a 2D array for which one axis is the "full" spectrum, and another the continuum (and to extend the concept, perhaps another that represents just the lines). But otherwise, Spectrum1D is meant to act as a container for data with an associated WCS and uncertainties which are handled in arithmetic operations; having a separate array pinned on would not be particularly useful after the spectrum has gone through some analysis/manipulation tasks. That said, you can always just associate the continuum with the Spectrum1D object ad-hoc: my_spec1d.continuum = some_continuum_array will work.

nmearl avatar Dec 19 '20 05:12 nmearl

A fitted continuum is, by definition, a spectrum that shares the same spectral axis as its parent spectrum. So yes, a fitted continuum plus its parent spectrum are together a collection of spectra that share the same spectral axis. If there's no willingness to make a place for the continuum in the Spectrum1D object then what about at least updating the notebooks so that the fitted continuum is itself a Spectrum1D object (rather than a numpy array), and grouping it with its parent as a Collection. I think it's dangerous to have continua floating around untied to their parent -- it's inviting trouble where the wrong continuum gets used for the wrong spectrum.

janerigby avatar Jan 13 '21 15:01 janerigby