function getframe, input_file, frame, help=help

        ;; NAME:
        ;;       getframe.pro (v. 1.0)
        ;;
        ;; PURPOSE:
        ;;       This program extracts individual frames from FITS data cubes
        ;;
        ;; CALLING SEQUENCE:
        ;;       getframe(input_file, frame)
        ;;
        ;; INPUTS:
        ;;       filename - A FITS format data cube
        ;;       frame    - Integer frame number starting from zero
        ;;
        ;; KEYWORD PARAMETERS:
        ;;       help             - Print a help message
        ;;
        ;; EXAMPLE
        ;;       Get frame 7 from a FITS cube
        ;;       myFrame = getframe('FITS_FILENAME', 7)
        ;;
        ;;
        ;; REFERENCE:
        ;;
        ;;
        ;; MODIFICATION HISTORY:
        ;;       Written by:  B.J. Rauscher, 7 April 2003
        ;;
        ;;       Modified:
        ;;-
        ;;


	;; Print a help message if requested
        if (not keyword_set(help)) then help = 0
	if (help) then begin
            stop, 'USAGE: getframe(input_file, frame [, /help])'
        endif

        ;; Open the FITS image and read the header. We will be reading
        ;; the FITS file slice-by-slice. Close it now so that the next
        ;; slice will work
        fits_open, input_file, fcb
        fits_read, fcb, data, header, /header_only
        fits_close, fcb

        ;; Load variables using header information
        xsize = sxpar(header, 'NAXIS1', 'Keyword NAXIS1 not found') ; x-dimension of image
        ysize = sxpar(header, 'NAXIS2', 'Keyword NAXIS2 not found') ; y-dimension of image
        zsize = sxpar(header, 'NAXIS3', 'Keyword NAXIS3 not found') ; z-dimension of image

        ;; Calculate offsets into the FITS file for the requested slice
        i1 = (xsize * ysize) * frame
        i2 = i1 + xsize * ysize - 1
        fits_open, input_file, fcb
        fits_read, fcb, data, header, first=i1, last=i2, /data_only
        fits_close, fcb

        ;; Reformat the frame into a 2D image
        data = reform(data, xsize, ysize, /overwrite)

        ;; Return
        return, data

end
