Can't print Spectrum1D read from JWST s3d cube.
- Dominant language
- Python
- Stars
- 204
- Forks
- 134
- Avg merge
- 12h 55m
- Merged PRs (30d)
- 1
Description
After reading in a Spectrum1D from a JWST s3d cube, I can't print it:
```python
spec1d_untrimmed = Spectrum1D.read(cube_file, format='JWST s3d')
print(spec1d_untrimmed)
```
gives this error:
```
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/var/folders/cw/tytqv5y91qd3j4_stwnc03c80001ww/T/ipykernel_52237/680655576.py in
6
7 #Developer Note--can't print the Spec1D:
----> 8 print(spec1d_untrimmed)
9 #print(spec1d_untrimmed.uncertainty)
10
~/Desktop/jdat/specutils/specutils/spectra/spectrum1d.py in __str__(self)
592 for i, flux in enumerate(self.flux):
593 label = 'flux{:2}'.format(i)
--> 594 result += self._format_array_summary(label, flux) + '\n'
595 else:
596 result += self._format_array_summary('flux', self.flux) + '\n'
~/Desktop/jdat/specutils/specutils/spectra/spectrum1d.py in _format_array_summary(self, label, array)
576 mean = np.mean(array)
577 s = "{:17} [ {:.5}, ..., {:.5} ], mean={:.5}"
--> 578 return s.format(label+':', array[0], array[-1], mean)
579 else:
580 return "{:17} [ ], mean= n/a".format(label+':')
~/miniconda3/envs/jwebbinar8/lib/python3.9/site-packages/astropy/units/quantity.py in __format__(self, format_spec)
1266 """
1267 try:
-> 1268 value = format(self.value, format_spec)
1269 full_format_spec = "s"
1270 except ValueError:
TypeError: unsupported format string passed to numpy.ndarray.__format__
```
Contributor guide
Research direction
Reproduce the failure with Spectrum1D.read(..., format='JWST s3d') and inspect specutils/spectra/spectrum1d.py, especially __str__ and _format_array_summary around the traceback lines. Confirm that printing a Spectrum1D loaded from an s3d cube completes without the TypeError and preserves the existing summary output for other spectra.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100