astropy / astropy/specutils

Trouble reading and writing spectra with convenience functions read and write.

Open
#1,069 1 comment 0 reactions 0 assignees View on GitHub
bug io
Dominant language
Python
Stars
204
Forks
134
Avg merge
12h 55m
Merged PRs (30d)
1

Description

I am using specutils and I am having a problem doing a simple thing.
I made a spectrum, call it "spec" and I saved it to a fits file using:

spec.write(fname+'.fits', format='tabular-fits', overwrite=True)

Then I read the exact same file using:
spec_test = Spectrum1D.read(fname+'.fits', format='tabular-fits')

However, this does not work. Any ideas?

I get the following errors, see below:

spec.write(fname+'.fits', format='tabular-fits', overwrite=True)

spec_test = Spectrum1D.read(fname+'.fits', format='tabular-fits')
Traceback (most recent call last):

Cell In[941], line 1
spec_test = Spectrum1D.read(fname+'.fits', format='tabular-fits')

File ~/anaconda3/lib/python3.10/site-packages/astropy/nddata/mixins/ndio.py:59 in __call__
return self.registry.read(self._cls, *args, **kwargs)

File ~/anaconda3/lib/python3.10/site-packages/astropy/io/registry/core.py:218 in read
data = reader(*args, **kwargs)

File ~/anaconda3/lib/python3.10/site-packages/specutils/io/default_loaders/tabular_fits.py:87 in tabular_fits_loader
return generic_spectrum_from_table(tab, wcs=wcs, **kwargs)

File ~/anaconda3/lib/python3.10/site-packages/specutils/io/parsing_utils.py:258 in generic_spectrum_from_table
raise IOError("Could not identify column containing the flux")

OSError: Could not identify column containing the flux

Contributor guide

Open the contributing guide

Research direction

Start at specutils/io/default_loaders/tabular_fits.py and follow the Spectrum1D.read entry point into specutils/io/parsing_utils.py, especially the failing flux-column identification. Reproduce the exact write/read calls from the report with a minimal spectrum. Done means a spectrum written as tabular FITS can be read back without the reported flux-column error.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.