astropy / specutils

An Astropy coordinated package for astronomical spectroscopy. Maintainers: @rosteen @keflavich @eteq
http://specutils.readthedocs.io/en/latest/
167 stars 127 forks source link

Can't print Spectrum1D read from JWST s3d cube. #868

Open PatrickOgle opened 3 years ago

PatrickOgle commented 3 years ago

After reading in a Spectrum1D from a JWST s3d cube, I can't print it:

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 <module>
      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__
PatrickOgle commented 3 years ago

A slightly different manifestation of issue #803, which mentions the default loader