Package uk.ac.starlink.fits
Class FitsHeader
java.lang.Object
uk.ac.starlink.fits.FitsHeader
Represents the header part of a FITS HDU that has been read.
It is composed of a number of ParsedCards.
The FITS 4.0 long-string syntax is supported.
- Since:
- 4 Mar 2022
- Author:
- Mark Taylor
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal String[]
Keywords which are never used as table parameters. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBooleanValue
(String key) Returns the boolean value for a card with a given key, if one exists.ParsedCard<?>[]
getCards()
Returns the header cards of which this header is composed.long
Returns the number of FITS blocks occupied by the Data part of the HDU described by this header.long
Returns the number of bytes occupied by the Data part of the HDU described by this header, rounded up to an integer number of blocks.uk.ac.starlink.table.DescribedValue
getDescribedValue
(String key) Returns the content of a card with a given key as a DescribedValue, if such a key exists.getDoubleValue
(String key) Returns the double value for a card with a given key, if one exists.long
Returns the number of FITS blocks occupied by this header.long
Returns the number of bytes occupied by this header, rounded up to an integer number of blocks.getIntValue
(String key) Returns the integer value for a card with a given key, if one exists.getLongValue
(String key) Returns the long value for a card with a given key, if one exists.getNumberValue
(String key) Returns a numeric value for a card with a given key, if one exists.int
Returns an integer value for a card with a given key, or throws an exception if none exists.long
Returns a long value for a card with a given key, or throws an exception if none exists.Returns a long value for a card with a given key, or throws an exception if none exists.getStringValue
(String key) Returns the string value for a card with a given key, if one exists.uk.ac.starlink.table.DescribedValue[]
Returns an array of DescribedValue objects suitable for use as items of per-table metadata derived from this FITS header.Returns the untyped value for a card with a given key, if one exists.void
Marks a given keyword as used.
-
Field Details
-
BORING_KEYS
Keywords which are never used as table parameters.
-
-
Constructor Details
-
FitsHeader
Constructor. All the header cards composing the header must be included so that the header knows its length in bytes.- Parameters:
cards
- header cards composing the header
-
-
Method Details
-
getCards
Returns the header cards of which this header is composed.- Returns:
- ordered sequence of parsed header cards
-
getValue
Returns the untyped value for a card with a given key, if one exists.- Parameters:
key
- header keyword- Returns:
- value, or null
-
getDescribedValue
Returns the content of a card with a given key as a DescribedValue, if such a key exists. Any comment text is provided as theValueInfo.getDescription()
.- Parameters:
key
- header keyword- Returns:
- described value, or null
-
getIntValue
Returns the integer value for a card with a given key, if one exists.- Parameters:
key
- header keyword- Returns:
- integer value, or null
-
getLongValue
Returns the long value for a card with a given key, if one exists.- Parameters:
key
- header keyword- Returns:
- long value, or null
-
getDoubleValue
Returns the double value for a card with a given key, if one exists.- Parameters:
key
- header keyword- Returns:
- double value, or null
-
getNumberValue
Returns a numeric value for a card with a given key, if one exists. This may be a BigInteger or BigDecimal if no other Number class can represent the serialized value.- Parameters:
key
- header keyword- Returns:
- numeric value, or null
-
getBooleanValue
Returns the boolean value for a card with a given key, if one exists.- Parameters:
key
- header keyword- Returns:
- boolean value, or null
-
getStringValue
Returns the string value for a card with a given key, if one exists.- Parameters:
key
- header keyword- Returns:
- string value, or null
-
getRequiredIntValue
Returns an integer value for a card with a given key, or throws an exception if none exists.- Parameters:
key
- header keyword- Returns:
- integer value
- Throws:
HeaderValueException
- if no suitable card exists
-
getRequiredLongValue
Returns a long value for a card with a given key, or throws an exception if none exists.- Parameters:
key
- header keyword- Returns:
- long value
- Throws:
HeaderValueException
- if no suitable card exists
-
getRequiredStringValue
Returns a long value for a card with a given key, or throws an exception if none exists.- Parameters:
key
- header keyword- Returns:
- long value
- Throws:
HeaderValueException
- if no suitable card exists
-
useKey
Marks a given keyword as used. This is invoked by all theget*Value
methods.- Parameters:
key
- header keyword
-
getHeaderBlockCount
public long getHeaderBlockCount()Returns the number of FITS blocks occupied by this header.- Returns:
- number of 2880-byte blocks in header
-
getDataBlockCount
Returns the number of FITS blocks occupied by the Data part of the HDU described by this header.- Returns:
- number of 2880-byte blocks in data part of HDU
- Throws:
HeaderValueException
-
getHeaderByteCount
public long getHeaderByteCount()Returns the number of bytes occupied by this header, rounded up to an integer number of blocks.- Returns:
getHeaderBlockCount()
* 2880
-
getDataByteCount
Returns the number of bytes occupied by the Data part of the HDU described by this header, rounded up to an integer number of blocks.- Returns:
getDataBlockCount()
* 2880- Throws:
HeaderValueException
-
getUnusedParams
public uk.ac.starlink.table.DescribedValue[] getUnusedParams()Returns an array of DescribedValue objects suitable for use as items of per-table metadata derived from this FITS header. This contains entries for every card which has not already been queried within this object (for whichuseKey(java.lang.String)
has not been explicitly or implicitly called. Certain standard structural FITS keywords (BORING_KEYS
) are ignored as well.The idea is that keywords which have already been read to determine table structure do not need to be recorded separately since their meaning is implicitly included in the table metadata already.
- Returns:
- array of table parameters relating to this object
-