Unable to load CAPSPEC fits
- Dominant language
- Python
- Stars
- 204
- Forks
- 134
- Avg merge
- 12h 55m
- Merged PRs (30d)
- 1
Description
Tried to load CALSPEC fits: https://archive.stsci.edu/hlsps/reference-atlases/cdbs/calspec/alpha_lyr_stis_010.fits
Tried Spectrum1D.read(specs, format='HST/STIS') but got error as follows. I also tried other formats but no luck. The fits file can be loaded using pysynphot.FileSpectrum().
Traceback (most recent call last):
File "C:\Users\Eric\miniconda3\envs\swin\lib\site-packages\astropy\io\fits\column.py", line 2045, in _get_index
indx = names.index(key.rstrip())
ValueError: 'ERROR' is not in list
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Eric\Documents\AST80004\vega-spectrum.py", line 9, in
spectrum = Spectrum1D.read(specs, format='HST/STIS')
File "C:\Users\Eric\miniconda3\envs\swin\lib\site-packages\astropy\nddata\mixins\ndio.py", line 59, in __call__
return self.registry.read(self._cls, *args, **kwargs)
File "C:\Users\Eric\miniconda3\envs\swin\lib\site-packages\astropy\io\registry\core.py", line 199, in read
data = reader(*args, **kwargs)
File "C:\Users\Eric\miniconda3\envs\swin\lib\site-packages\specutils\io\default_loaders\hst_stis.py", line 47, in stis_spectrum_loader
uncertainty = StdDevUncertainty(hdulist[1].data["ERROR"].flatten() * unit)
File "C:\Users\Eric\miniconda3\envs\swin\lib\site-packages\astropy\io\fits\fitsrec.py", line 504, in __getitem__
return self.field(key)
File "C:\Users\Eric\miniconda3\envs\swin\lib\site-packages\astropy\io\fits\fitsrec.py", line 691, in field
column = self.columns[key]
File "C:\Users\Eric\miniconda3\envs\swin\lib\site-packages\astropy\io\fits\column.py", line 1643, in __getitem__
key = _get_index(self.names, key)
File "C:\Users\Eric\miniconda3\envs\swin\lib\site-packages\astropy\io\fits\column.py", line 2054, in _get_index
raise KeyError(f"Key '{key}' does not exist.")
KeyError: "Key 'ERROR' does not exist."
Contributor guide
Research direction
Start with specutils/io/default_loaders/hst_stis.py and reproduce Spectrum1D.read on the linked CALSPEC FITS file using format='HST/STIS'. Compare the file's table columns with the loader's expectations; done means the file loads without the reported KeyError, while preserving the existing loader behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100