Indexing Error with HDU FITS file format with numpy
Question: I'm attempting to read the data from a FITS file using the `astropy` module
`fits` and then standard numpy array handling. However, for some reason I am
receiving the following error:

    
    
    IndexError: too many indices
    

This is the code that I am using:

    
    
    from astropy.io import fits
    import matplotlib.pyplot as plt
    
    hdulist = fits.open('/Users/iMacHome/Downloads/spec-1959-53440-0605.fits')
    hdu     = hdulist[1]
    data    = hdu.data
    flux    = data[:, 1] 
    

^ Error Traceback to the `flux = data[:, 1]` line.

    
    
    loglam  = data[:, 2]
    

This may be a question that perhaps astronomers could answer (or,
specifically, astronomers familiar with `.fits` files from the SDSS), but I
welcome the input from numpy and python users!


Answer: I have just had the following answer from the SDSS help desk:

Replace:

    
    
    flux   = data[:,0]
    loglam = data[:,1]
    

with

    
    
    flux   = data['flux']
    loglam = data['loglam']
    

This is the correct way to access fields in a Numpy record array.

