I am a new user to SpecUtils and I am simply attempting to read in spectral data from a FITS file and plot the spectrum, just like on the first page of SpecUtils.
My code is identical to the first page of SpecUtils and is as follows:
from astropy.io import fits
from astropy import units as u
import numpy as np
from matplotlib import pyplot as plt
from astropy.visualization import quantity_support
quantity_support() # for getting units on the axes below
f = fits.open('GIRAF.2021-02-14T01:00:34.723.fits')
# The spectrum is in the second HDU of this file.
specdata = f[0].data
f.close()
from specutils import Spectrum1D
lamb = 10**specdata['loglam'] * u.AA
flux = specdata['flux'] * 10**-17 * u.Unit('erg cm-2 s-1 AA-1')
spec = Spectrum1D(spectral_axis=lamb, flux=flux)
However, it seems loglam and flux are no acceptablr identifiers from this file
IndexError Traceback (most recent call last)
Input In [22], in <cell line: 2>()
1 from specutils import Spectrum1D
----> 2 lamb = 10**specdata['loglam'] * u.AA
3 flux = specdata['flux'] * 10**-17 * u.Unit('erg cm-2 s-1 AA-1')
4 spec = Spectrum1D(spectral_axis=lamb, flux=flux)
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
Does anyone have any advice on how I can figure out what the headers are in my file, how to read them in, and then ultimately plot the spectral data? Here is the link to the FITS file: link
Try to convert the variable
specdatato numpy before doing the operations.Replace
to