|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnom.tam.fits.Header
This class describes methods to access and manipulate the header for a FITS HDU.
| Constructor Summary | |
Header()
Create a Header with no card images. |
|
Header(BufferedDataInputStream is)
Create a header and populate it from the input stream |
|
Header(String[] newCards)
Create a header and initialize it with a vector of strings. |
|
| Method Summary | |
void |
addBooleanValue(String key,
boolean val,
String comment)
Add or replace a key with the given boolean value and comment. |
void |
addDoubleValue(String key,
double val,
String comment)
Add or replace a key with the given double value and comment. |
void |
addFloatValue(String key,
float val,
String comment)
Add or replace a key with the given float value and comment. |
void |
addIntValue(String key,
int val,
String comment)
Add or replace a key with the given int value and comment. |
protected void |
addLine(HeaderCard fcard)
Add a card image to the header after the mark if set. |
protected void |
addLine(String card)
Add a card image to the header after the mark if set. |
void |
addLongValue(String key,
long val,
String comment)
Add or replace a key with the given long value and comment. |
void |
addStringValue(String key,
String val,
String comment)
Add or replace a key with the given string value and comment. |
(package private) void |
checkEnd()
Ensure that the header has exactly one END keyword in the appropriate location. |
boolean |
containsKey(String key)
Tests if the specified keyword is present in this table. |
void |
deleteKey(String key)
Delete the card associated with the given key. |
protected void |
dumpHeader(PrintStream ps)
Dump the header to a given stream. |
protected HeaderCard |
findCard(String key)
Find the card associated with a given key. |
String |
findKey(String key)
Find the card associated with a given key. |
static String |
formatFields(String key,
String val,
String comment)
Format the key, value and comment fields for the FITS data. |
boolean |
getBooleanValue(String key)
Get the boolean value associated with the given key. |
boolean |
getBooleanValue(String key,
boolean dft)
Get the boolean value associated with the given key. |
String |
getCard(int n)
Get the n'th card image in the header |
double |
getDoubleValue(String key)
Get the double value associated with the given key. |
double |
getDoubleValue(String key,
double dft)
Get the double value associated with the given key. |
float |
getFloatValue(String key)
Get the float value associated with the given key. |
float |
getFloatValue(String key,
float dft)
Get the float value associated with the given key. |
int |
getIntValue(String key)
Get the int value associated with the given key. |
int |
getIntValue(String key,
int dft)
Get the value associated with the key as an int. |
String |
getKey(int n)
Get the n'th key in the header. |
long |
getLongValue(String key)
Get the long value associated with the given key. |
long |
getLongValue(String key,
long dft)
Get the long value associated with the given key. |
int |
getMark()
Get the current mark. |
String |
getStringValue(String key)
Get the String value associated with the given key. |
int |
headerSize()
Return the size of the header data including padding. |
protected boolean |
imageToPrimary()
See if the current header is for an an array and if so turn it into a primary array. |
void |
insertCard(String card)
Insert or add a card to the header. |
void |
insertComment(String value)
Add a COMMENT line. |
void |
insertCommentStyle(String header,
String value)
Add a line to the header using the COMMENT style, i.e., no '=' in column 9. |
void |
insertHistory(String value)
Add a HISTORY line. |
boolean |
isValidHeader()
Is this a valid header. |
boolean |
markSet()
Is the mark set? |
(package private) void |
nullImage()
Create a header for a null image. |
int |
paddedDataSize()
Return the size of the data including any needed padding. |
void |
pointToData(Data o)
Create keywords such that this Header describes the given data. |
protected void |
pointToImage(Object o)
Create keywords such that this header describes the given image data. |
protected boolean |
primaryToImage()
See if the current header is an array and if so turn it into an IMAGE extension. |
void |
read(BufferedDataInputStream dis)
Read a stream for header data. |
static Header |
readHeader(BufferedDataInputStream dis)
Create a header by reading the information from the input stream. |
void |
removeCardAt(int i)
Remove the card at the given index. |
void |
replaceCard(String key,
String val,
String comment)
Add or replace a key using the preformatted value. |
(package private) boolean |
replaceKey(String oldKey,
String newKey)
Replace the key with a new key. |
(package private) void |
setBitpix(int val)
Set the BITPIX value for the header. |
(package private) void |
setExtend(boolean val)
Set the EXTEND keyword. |
(package private) void |
setGcount(int val)
Set the group count (GCOUNT) keyword. |
void |
setMark(int newMark)
Set the mark to the given value. |
(package private) void |
setNaxes(int val)
Set the value of the NAXIS keyword |
(package private) void |
setNaxis(int dim,
int val)
Set the NAXISn keywords. |
(package private) void |
setPcount(int val)
Set the Parameter count (PCOUNT) keyword. |
(package private) void |
setSimple(boolean val)
Set the SIMPLE keyword to the given value. |
(package private) void |
setXtension(String val)
Set the XTENSION keyword to the given value. |
int |
size()
|
int |
trueDataSize()
Calculate the unpadded size of the data segment from the header information. |
void |
unsetMark()
Unset the mark. |
void |
write(BufferedDataOutputStream dos)
Write the current header (including any needed padding) to the output stream. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Header()
public Header(BufferedDataInputStream is)
throws TruncatedFileException,
IOException
is - The input stream where header information is expected.public Header(String[] newCards)
newCards - Card images to be placed in the header.| Method Detail |
public int size()
public int trueDataSize()
public int paddedDataSize()
public int headerSize()
public boolean isValidHeader()
true for a valid header,
false otherwise.public String getCard(int n)
null if the n'th card
does not exist.public String getKey(int n)
null if the n'th key
does not exist.
public long getLongValue(String key,
long dft)
long value associated with the given key.
key - The header key.dft - The default value to be returned if the key cannot be found.
public double getDoubleValue(String key,
double dft)
double value associated with the given key.
key - The header key.dft - The default value to return if the key cannot be found.
public boolean getBooleanValue(String key,
boolean dft)
boolean value associated with the given key.
key - The header key.dft - The value to be returned if the key cannot be found
or if the parameter does not seem to be a boolean.
public long getLongValue(String key)
long value associated with the given key.
key - The header key.
public double getDoubleValue(String key)
double value associated with the given key.
key - The header key.
public boolean getBooleanValue(String key)
boolean value associated with the given key.
public int getIntValue(String key,
int dft)
key - The header key.dft - The value to be returned if the key is not found.public int getIntValue(String key)
int value associated with the given key.
key - The header key.
public float getFloatValue(String key,
float dft)
float value associated with the given key.
key - The header key.dft - The value to be returned if the key is not found.public float getFloatValue(String key)
float value associated with the given key.
key - The header key.
public String getStringValue(String key)
String value associated with the given key.
key - The header key.
protected void addLine(HeaderCard fcard)
fcard - The card to be added.
protected void addLine(String card)
throws HeaderCardException
card - The card to be added.
HeaderCardException - If the card is not valid.
public static Header readHeader(BufferedDataInputStream dis)
throws TruncatedFileException,
IOException
dis - The input stream to read the data from.
null if there was a problem with the header;
otherwise return the header read from the input stream.
TruncatedFileException
IOException
public void read(BufferedDataInputStream dis)
throws TruncatedFileException,
IOException
dis - The input stream to read the data from.
null if there was a problem with the header;
otherwise return the header read from the input stream.
TruncatedFileException
IOExceptionprotected HeaderCard findCard(String key)
key - The header key.
null if the keyword could not be found;
return the HeaderCard object otherwise.public String findKey(String key)
key - The header key.
null if the keyword could not be found;
return the card image otherwise.
boolean replaceKey(String oldKey,
String newKey)
throws HeaderCardException
oldKey - The old header keyword.newKey - the new header keyword.
true if the card was replaced.
HeaderCardException - If newKey is not a
valid FITS keyword.
public void write(BufferedDataOutputStream dos)
throws FitsException
dos - The output stream to which the data is to be written.
FitsException - if the header could not be written.
public void addBooleanValue(String key,
boolean val,
String comment)
throws HeaderCardException
key - The header key.val - The boolean value.comment - A comment to append to the card.
HeaderCardException - If the parameters cannot build a
valid FITS card.
public void addFloatValue(String key,
float val,
String comment)
throws HeaderCardException
key - The header key.val - The float value.comment - A comment to append to the card.
HeaderCardException - If the parameters cannot build a
valid FITS card.
public void addDoubleValue(String key,
double val,
String comment)
throws HeaderCardException
key - The header key.val - The double value.comment - A comment to append to the card.
HeaderCardException - If the parameters cannot build a
valid FITS card.
public void addStringValue(String key,
String val,
String comment)
throws HeaderCardException
key - The header key.val - The string value.comment - A comment to append to the card.
HeaderCardException - If the parameters cannot build a
valid FITS card.
public void replaceCard(String key,
String val,
String comment)
throws HeaderCardException
key - The header key.val - The string which will follow the "= " on the
card. This routine is called by the various
addXXXValue routines after they have formatted the
value as a string.comment - A comment to append to the card.
HeaderCardException - If the parameters cannot build a
valid FITS card.
public void addIntValue(String key,
int val,
String comment)
throws HeaderCardException
key - The header key.val - The int value.comment - A comment to append to the card.
HeaderCardException - If the parameters cannot build a
valid FITS card.
public void addLongValue(String key,
long val,
String comment)
throws HeaderCardException
key - The header key.val - The long value.comment - A comment to append to the card.
HeaderCardException - If the parameters cannot build a
valid FITS card.
public static String formatFields(String key,
String val,
String comment)
throws HeaderCardException
key - The header keyword.val - The value associated with the key expressed as a string.comment - A comment to put on the field.
HeaderCardException - If the parameters cannot build a
valid FITS card.public void insertCard(String card)
card - The card to be inserted.
public void insertCommentStyle(String header,
String value)
throws HeaderCardException
header - The comment style header.value - A string to follow the header.
HeaderCardException - If the parameters cannot build a
valid FITS card.
public void insertComment(String value)
throws HeaderCardException
value - The comment.
HeaderCardException - If the parameter is not a
valid FITS comment.
public void insertHistory(String value)
throws HeaderCardException
value - The history record.
HeaderCardException - If the parameter is not a
valid FITS comment.public boolean markSet()
true if the mark is set.public int getMark()
public void setMark(int newMark)
public void unsetMark()
public void deleteKey(String key)
key - The header key.public void removeCardAt(int i)
i - The index of the card to be removed.public final boolean containsKey(String key)
key - the keyword to be found.
true if the specified keyword is present in this
table; false otherwise.
public void pointToData(Data o)
throws FitsException
o - The data object to be described.
FitsException - if the data was not valid for this header.
protected void pointToImage(Object o)
throws FitsException
o - The image to be described.
FitsException - if the object does not contain
valid image data.void nullImage()
void setSimple(boolean val)
val - The boolean value -- Should be true for FITS data.void setXtension(String val)
val - The name of the extension. "IMAGE" and "BINTABLE" are supported.void setBitpix(int val)
void setNaxes(int val)
val - The dimensionality of the data.void checkEnd()
void setNaxis(int dim,
int val)
dim - The dimension being set.val - The length along that dimension.void setGcount(int val)
val - the number of groups in the data.void setPcount(int val)
val - The number of parameters.void setExtend(boolean val)
true.
Just in case we do provide for setting it to false.
val - the value assigned to the EXTEND keyword.protected boolean primaryToImage()
protected boolean imageToPrimary()
protected void dumpHeader(PrintStream ps)
ps - the stream to which the card images are dumped.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||