## nom.tam.fits
Class Fits

    java.lang.Object
      nom.tam.fits.Fits

public class Fits
extends Object

This class provides access to routines to allow users to read and write FITS files.

Constructor Summary
`Fits()` Create an empty Fits object which is not associated with an input stream.
`Fits(File myFile)` Associate FITS object with an uncompressed File
`Fits(File myFile, boolean compressed)` Associate the Fits object with a File
`Fits(InputStream str)` Create a Fits object associated with the given uncompressed data stream.
`Fits(InputStream str, boolean compressed)` Create a Fits object associated with a possibly compressed data stream.
`Fits(String filename)` Associate the FITS object with a file or URL.
`Fits(URL myURL)` Associate the FITS object with a given uncompressed URL
`Fits(URL myURL, boolean compressed)` Associate the FITS object with a given URL

Method Summary
`void` `addHDU(BasicHDU myHDU)` Add an HDU to the Fits object.
`int` `currentSize()` Get the current number of HDUs in the Fits object.
`void` `deleteHDU(int n)` Delete an HDU from the HDU list.
`protected void` `fileInit(File myFile, boolean compressed)` Get a stream from the file and then use the stream initialization.
`BasicHDU` `getHDU(int n)` Return the n'th HDU.
`BufferedDataInputStream` `getStream()` Get the data stream used for the Fits Data.
`void` `insertHDU(BasicHDU myHDU, int n)` Insert a FITS object into the list of HDUs.
`static void` `main(String[] args)`
`BasicHDU[]` `read()` Return all HDUs for the Fits object.
`void` `read(InputStream is)` Read a FITS file from an InputStream object.
`BasicHDU` `readHDU()` Read the next HDU on the default input stream.
`void` `setStream(BufferedDataInputStream stream)` Set the data stream to be used for future input.
`int` `size()` Return the number of HDUs in the Fits object.
`void` `skipHDU()` Skip the next HDU on the default input stream.
`void` `skipHDU(int n)` Skip HDUs on the associate input stream.
`protected void` `streamInit(InputStream str, boolean compressed)` Do the stream initialization.
`static String` `version()` Indicate the version of these classes
`void` `write(OutputStream os)` Write a Fits Object to an external Stream.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Fits

    public Fits()

  Create an empty Fits object which is not associated with an input stream.

### Fits

    public Fits(InputStream str)
         throws FitsException

  Create a Fits object associated with the given uncompressed data stream.

Parameters:
  `str` - The data stream.

### Fits

    public Fits(InputStream str,
                boolean compressed)
         throws FitsException

  Create a Fits object associated with a possibly compressed data stream.

Parameters:
  `str` - The data stream.
  `compressed` - Is the stream compressed?

### Fits

    public Fits(File myFile,
                boolean compressed)
         throws FitsException

  Associate the Fits object with a File

Parameters:
  `myFile` - The File object.
  `compressed` - Is the data compressed?

### Fits

    public Fits(File myFile)
         throws FitsException

  Associate FITS object with an uncompressed File

Parameters:
  `myFile` - The File object.

### Fits

    public Fits(String filename)
         throws FitsException

  Associate the FITS object with a file or URL. The string is assumed to be a URL if it begins with http: otherwise it is treated as a file name. If the string ends in .gz it is assumed that the data is in a compressed format. All string comparisons are case insensitive.

Parameters:
  `filename` - The name of the file or URL to be processed.
Throws:
  `FitsException` - Thrown if unable to find or open a file or URL from the string given.

### Fits

    public Fits(URL myURL,
                boolean compressed)
         throws FitsException

  Associate the FITS object with a given URL

Parameters:
  `myURL` - The URL to be associated with the FITS file.
  `compressed` - Is the data compressed?
Throws:
  `FitsException` - Thrown if unable to find or open a file or URL from the string given.

### Fits

    public Fits(URL myURL)
         throws FitsException

  Associate the FITS object with a given uncompressed URL

Parameters:
  `myURL` - The URL to be associated with the FITS file.
Throws:
  `FitsException` - Thrown if unable to use the specified URL.

Method Detail

### version

    public static String version()

  Indicate the version of these classes

### streamInit

    protected void streamInit(InputStream str,
                              boolean compressed)
                       throws FitsException

  Do the stream initialization.

  Parameters:
    `str` - The input stream. The Fits class uses a BufferedDataInputStream internally and will use this instance if it's already of that class.
    `compressed` - Is this data compressed? If so, then the GZIPInputStream class will be used to inflate it.
  Throws:
    `FitsException`

### fileInit

    protected void fileInit(File myFile,
                            boolean compressed)
                     throws FitsException

  Get a stream from the file and then use the stream initialization.

  Parameters:
    `myFile` - The File to be associated.
    `compressed` - Is the data compressed?
  Throws:
    `FitsException`

### read

    public BasicHDU[] read()
                    throws FitsException

  Return all HDUs for the Fits object. If the FITS file is associated with an external stream make sure that we have exhausted the stream.

  Returns:
    an array of all HDUs in the Fits object.
  Throws:
    `FitsException`

### readHDU

    public BasicHDU readHDU()
                     throws FitsException,
                            IOException

  Read the next HDU on the default input stream.

  Returns:
    The HDU read, or null if an EOF was detected. Note that null is only returned when the EOF is detected immediately at the beginning of reading the HDU (i.e., the first card image in the header).
  Throws:
    `FitsException`
    `IOException`

### skipHDU

    public void skipHDU(int n)
                 throws FitsException,
                        IOException

  Skip HDUs on the associate input stream.

  Parameters:
    `n` - The number of HDUs to be skipped.
  Throws:
    `FitsException`
    `IOException`

### skipHDU

    public void skipHDU()
                 throws FitsException,
                        IOException

  Skip the next HDU on the default input stream.

  Throws:
    `FitsException`
    `IOException`

### getHDU

    public BasicHDU getHDU(int n)
                    throws FitsException,
                           IOException

  Return the n'th HDU. If the HDU is already read simply return a pointer to the cached data. Otherwise read the associated stream until the n'th HDU is read.

  Parameters:
    `n` - The index of the HDU to be read. The primary HDU is index 0.
  Returns:
    The n'th HDU or null if it could not be found.
  Throws:
    `FitsException`
    `IOException`

### size

    public int size()
             throws FitsException

  Return the number of HDUs in the Fits object. If the FITS file is associated with an external stream make sure that we have exhausted the stream.

  Returns:
    number of HDUs.
  Throws:
    `FitsException`

### addHDU

    public void addHDU(BasicHDU myHDU)
                throws FitsException

  Add an HDU to the Fits object. Users may intermix calls to functions which read HDUs from an associated input stream with the addHDU and insertHDU calls, but should be careful to understand the consequences.

  Parameters:
    `myHDU` - The HDU to be added to the end of the FITS object.
  Throws:
    `FitsException`

### insertHDU

    public void insertHDU(BasicHDU myHDU,
                          int n)
                   throws FitsException

  Insert a FITS object into the list of HDUs.

  Parameters:
    `myHDU` - The HDU to be inserted into the list of HDUs.
    `n` - The location at which the HDU is to be inserted. If n is 0, then the previous initial HDU will be converted into an IMAGE extension.
  Throws:
    `FitsException`

### deleteHDU

    public void deleteHDU(int n)
                   throws FitsException

  Delete an HDU from the HDU list.

  Parameters:
    `n` - The index of the HDU to be deleted. If n is 0 and there is more than one HDU present, then the next HDU will be converted from an image to primary HDU if possible. If not a dummy header HDU will then be inserted.
  Throws:
    `FitsException`

### write

    public void write(OutputStream os)
               throws FitsException

  Write a Fits Object to an external Stream.

  Throws:
    `FitsException`

### read

    public void read(InputStream is)
              throws FitsException,
                     IOException

  Read a FITS file from an InputStream object.

  Parameters:
    `is` - The InputStream stream whence the FITS information is found.
  Throws:
    `FitsException`
    `IOException`

### currentSize

    public int currentSize()

  Get the current number of HDUs in the Fits object.

  Returns:
    The number of HDU's in the object.

### getStream

    public BufferedDataInputStream getStream()

  Get the data stream used for the Fits Data.

  Returns:
    The associated data stream. Users may wish to call this function after opening a Fits object when they wish detailed control for writing some part of the FITS file.

### setStream

    public void setStream(BufferedDataInputStream stream)

  Set the data stream to be used for future input.

  Parameters:
    `stream` - The data stream to be used.

### main

    public static void main(String[] args)
                     throws FitsException

  Throws:
    `FitsException`