desihub / desispec

DESI spectral pipeline
BSD 3-Clause "New" or "Revised" License
36 stars 24 forks source link

desispec.io.spectra.write_spectra is not consistent with desispec.pixgroup.SpecLite.write. #672

Closed weaverba137 closed 6 years ago

weaverba137 commented 6 years ago

It appears that there are at least two different methods for writing what we would generally consider 1-d spectra:

  1. desispec.io.spectra.write_spectra()
  2. desispec.pixgroup.SpecLite.write()

In particular, write_spectra() does not apply units (BUNIT header) to the inverse variance, while SpecLite.write() does.

Also, neither applies units to the [BRZ]_RESOLUTION HDU. Is the resolution truly dimensionless? If it's resolution in the delta lambda/lambda sense, then sure. But I sometimes get that confused with the dispersion in the wavelength solution.

sbailey commented 6 years ago

Both desispec.io.spectra.write_spectra() and desispec.pixgroup.SpecLite.write() should write units.

Context: In practice desispec.io.spectra.write_spectra() is not used by the main pipeline but it is kept as an end-user convenience, e.g. if someone wants to read in spectra, filter them, and then write the subset back out. desispec.pixgroup.SpecLite.write() is the memory- and I/O- optimized code for the specific purpose of reading in Frames (not Spectra), regrouping them by healpix, and writing them back out.

Resolution data are unitless in the sense that when you multiply a spectrum by a resolution matrix, the result has the same units as the original spectrum. In detail they are the the wavelength-dependent convolution kernels used to convolve a high resolution spectrum into a lower-resolution spectrum, stored as the diagonals of the sparse convolution matrices. They are not Gaussian sigmas (e.g. with units of Angstroms or bins) and they are not delta lambda / lambda either.

weaverba137 commented 6 years ago

Closed by #673.