eap.fits
Class FitsHeader

java.lang.Object
  extended byeap.fits.FitsHeader

public class FitsHeader
extends Object

Represents the header of a FITS HDU. The header consists of list of keyword-value pairs which specify the metadata for an HDU. Note that changing the required keywords in a header does not change the corresponding data object (if there is one).


Constructor Summary
FitsHeader()
          Create a new empty header.
 
Method Summary
 boolean add(byte[] block)
          add a block of 2880 bytes to the header.
 void add(FitsCard card)
          add a card to the header.
 int blockCount()
          returns the number of blocks (including partial blocks) occupied by the header
 FitsCard card(int i)
          returns the specified card .
 FitsCard card(String key)
          returns a card with the given keyword.
 int cardCount()
          returns the number of cards in the header.
 int dataSize()
          returns the number of bytes in the data which would correspond to this header.
 String getName()
          returns the name of this extension.
 String getType()
          returns the type of data accompanying this header.
 boolean hasCard(String key)
          returns true if the header has at least one card with the given keyword
 boolean isComplete()
          returns true if this header has been completely read or constructed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FitsHeader

public FitsHeader()
Create a new empty header.

Method Detail

isComplete

public boolean isComplete()
returns true if this header has been completely read or constructed. In general a header is complete when it contains an END keyword.


blockCount

public int blockCount()
returns the number of blocks (including partial blocks) occupied by the header


add

public void add(FitsCard card)
add a card to the header. The caller is responsible for ensuring that added cards conform to the FITS standard. If you add an END card, the header will be marked as complete. If the header is incomplete, then this method will append the card to the existing ones. If the header is complete, this method will add the card just before the END card.

Parameters:
card - the new card to be added.

add

public boolean add(byte[] block)
add a block of 2880 bytes to the header. This method is useful for reading a header from a data source. The general user will probably not need this method, since it is used internally by the FitsFile subclasses. If the array is larger than 2880 bytes, only the first 2880 bytes will be read.

Parameters:
block - an array of 2880 bytes to add to this header.
Returns:
true if this is the last block of the header
Throws:
IndexOutOfBoundsException - if block does not contain at least 2880 bytes.

hasCard

public boolean hasCard(String key)
returns true if the header has at least one card with the given keyword

Parameters:
key - the name of the keyword to search for

card

public FitsCard card(String key)
              throws NoSuchFitsCardException
returns a card with the given keyword. If there are multiple cards with the same key, this will return the last one added to this header

Parameters:
key - the keyword to search for.
Returns:
a card with the given keyword
Throws:
NoSuchFitsCardException - if the header does not contain the requested keyword.

card

public FitsCard card(int i)
              throws NoSuchFitsCardException
returns the specified card .

Parameters:
i - the index of the card. The first card is numbered 0.
Returns:
the ith card in the header.
Throws:
NoSuchFitsCardException - if the index is out of bounds.

cardCount

public int cardCount()
returns the number of cards in the header. This does not include any blank cards used as padding after the END card.


dataSize

public int dataSize()
             throws eap.fits.FitsCardException
returns the number of bytes in the data which would correspond to this header. Note this is the actual number of bytes not including padding.

Returns:
the data size in bytes excluding padding
Throws:
eap.fits.FitsCardException

getName

public String getName()
returns the name of this extension. For most HDUs this will be the value of the EXTNAME keyword. For a primary HDU, it will return "PRIMARY". If there is no EXTNAME keyword, it will return null.


getType

public String getType()
               throws FitsException
returns the type of data accompanying this header. For most HDUs this is the value of the XTENSION keyword. For the primary HDU this is the string "IMAGE".

Throws:
FitsException - if there is no SIMPLE or XTENSION keyword in this header.