You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am opening an issue about this rather than a PR since there are already several PRs overlapping with this - also oops I opened this from the wrong account, but it doesn't matter 🤦
I just wanted to open a summary of where I think we need to go with 2D spectra and the possibility of having a new kind of viewer. Following some investigation, I realized that the issues that people have with the current 2D spectrum viewer is due to the fact that 2D spectra are (incorrectly) represented as SpectralCube. Here is an example of a MOSViz parser where a dimension is added to the data as well as an extra WCS dimension:
# Information that needs to be added to the header in order to load
# WCS information into SpectralCube.
# TODO: Use gwcs instead to avoid hardcoding information for 3rd wcs axis
new_data=np.expand_dims(data, axis=1)
header['NAXIS'] =3
header['NAXIS3'] =1
header['BUNIT'] ='dN/s'
header['CUNIT3'] ='um'
header['WCSAXES'] =3
header['CRPIX3'] =0.0
header['CDELT3'] =1E-06
header['CUNIT3'] ='m'
header['CTYPE3'] ='WAVE'
header['CRVAL3'] =0.0
This code means that the axis dropdown in the image viewer shows RA, Dec, and Wavelength. However, these datasets are inherently 2D and we should not be using SpectralCube to store them.
The best way to represent these datasets from a visualization perspective is as 2D arrays with 2D WCS where one WCS dimension is the spectral dimension and the other is a positional offset - whether in arcseconds or pixels. I think the most suitable class for this is the Spectrum1D class (provided it can contain a 2D WCS).
Initially, I think it would be easiest to treat the extra dimension's WCS as being simply an identity transform so that the offset is in pixels, but in future we could always consider switching to representing an offset in e.g. arcseconds along that dimension (but this will require the information to be available in the files). For the above example in the MOSViz parsers, the WCS would be constructed using e.g.:
The above assumes that the first world coordinate (second dimension in Numpy array) is the spectral one but of course this can be swapped as appropriate. The spectral values are dummy values as in the current MOSViz parsers, but in future once we want to extract the proper spectral WCS, we can use WCS.sub in the case of FITS WCS to split out the spectral component and add a new positional component (unless the 2D spectra contain a valid 2D WCS in the first place in which case we won't need to customize anything in the parser).
So in the short term, while we still use dummy WCSes, I think the plan should be to change from SpectralCube to Spectrum1D for 2D spectra, and use a WCS similar to the above. With this in place, the image viewer will then only show two attributes in the dropdowns - wavelength and offset, so there should be no need to make a custom viewer. In future, we can then plan to read in the real spectral WCS component as well as optionally make the offset be in e.g. arcseconds.
(Side note: I know it is conceptually possible to represent 2D spectra as 2D arrays with 3D WCS but the WCS is a bit trickier to set up correctly and it can be a bit confusing for users)
I am opening an issue about this rather than a PR since there are already several PRs overlapping with this - also oops I opened this from the wrong account, but it doesn't matter 🤦
I just wanted to open a summary of where I think we need to go with 2D spectra and the possibility of having a new kind of viewer. Following some investigation, I realized that the issues that people have with the current 2D spectrum viewer is due to the fact that 2D spectra are (incorrectly) represented as SpectralCube. Here is an example of a MOSViz parser where a dimension is added to the data as well as an extra WCS dimension:
jdaviz/jdaviz/configs/mosviz/plugins/parsers.py
Lines 487 to 501 in aeb022a
This code means that the axis dropdown in the image viewer shows RA, Dec, and Wavelength. However, these datasets are inherently 2D and we should not be using SpectralCube to store them.
The best way to represent these datasets from a visualization perspective is as 2D arrays with 2D WCS where one WCS dimension is the spectral dimension and the other is a positional offset - whether in arcseconds or pixels. I think the most suitable class for this is the Spectrum1D class (provided it can contain a 2D WCS).
Initially, I think it would be easiest to treat the extra dimension's WCS as being simply an identity transform so that the offset is in pixels, but in future we could always consider switching to representing an offset in e.g. arcseconds along that dimension (but this will require the information to be available in the files). For the above example in the MOSViz parsers, the WCS would be constructed using e.g.:
The above assumes that the first world coordinate (second dimension in Numpy array) is the spectral one but of course this can be swapped as appropriate. The spectral values are dummy values as in the current MOSViz parsers, but in future once we want to extract the proper spectral WCS, we can use
WCS.sub
in the case of FITS WCS to split out the spectral component and add a new positional component (unless the 2D spectra contain a valid 2D WCS in the first place in which case we won't need to customize anything in the parser).So in the short term, while we still use dummy WCSes, I think the plan should be to change from SpectralCube to Spectrum1D for 2D spectra, and use a WCS similar to the above. With this in place, the image viewer will then only show two attributes in the dropdowns - wavelength and offset, so there should be no need to make a custom viewer. In future, we can then plan to read in the real spectral WCS component as well as optionally make the offset be in e.g. arcseconds.
Related PRs:
(Side note: I know it is conceptually possible to represent 2D spectra as 2D arrays with 3D WCS but the WCS is a bit trickier to set up correctly and it can be a bit confusing for users)
EDIT: Also see #811
The text was updated successfully, but these errors were encountered: