astropy / astropy/specutils

Can't print Spectrum1D object created by default loader for JWST s3d data cube

Open
#803 0 comments 0 reactions 0 assignees View on GitHub
bug data objects
Dominant language
Python
Stars
204
Forks
134
Avg merge
12h 55m
Merged PRs (30d)
1

Description

Spectrum1D.read of JWST s3d file uses default loader rather than JWST s3d loader. A Spectrum1D object loaded this way can't be printed:

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
1 #Try printing Spectrum1D obect
----> 2 print(spec1d_untrimmed)
3 #print(spec1d_untrimmed.spectral_axis)
4 #print(spec1d_untrimmed.uncertainty)

~/miniconda3/envs/jdaviz1.1/lib/python3.9/site-packages/specutils/spectra/spectrum1d.py in __str__(self)
457 for i, flux in enumerate(self.flux):
458 label = 'flux{:2}'.format(i)
--> 459 result += self._format_array_summary(label, flux) + '\n'
460 else:
461 result += self._format_array_summary('flux', self.flux) + '\n'

~/miniconda3/envs/jdaviz1.1/lib/python3.9/site-packages/specutils/spectra/spectrum1d.py in _format_array_summary(self, label, array)
441 mean = np.mean(array)
442 s = "{:17} [ {:.5}, ..., {:.5} ], mean={:.5}"
--> 443 return s.format(label+':', array[0], array[-1], mean)
444 else:
445 return "{:17} [ ], mean= n/a".format(label+':')

~/miniconda3/envs/jdaviz1.1/lib/python3.9/site-packages/astropy/units/quantity.py in __format__(self, format_spec)
1255 """
1256 try:
-> 1257 value = format(self.value, format_spec)
1258 full_format_spec = "s"
1259 except ValueError:

TypeError: unsupported format string passed to numpy.ndarray.__format__

Contributor guide

Open the contributing guide

Research direction

Start in specutils/spectra/spectrum1d.py at __str__ and _format_array_summary, then reproduce the failure with the JWST s3d data cube described in the report. Trace how the default loader shapes the flux array and verify that printing the resulting Spectrum1D completes without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.