Package nom.tam.fits
Class BasicHDU<DataClass extends Data>
java.lang.Object
nom.tam.fits.BasicHDU<DataClass>
- All Implemented Interfaces:
FitsElement
- Direct Known Subclasses:
ImageHDU
,RandomGroupsHDU
,TableHDU
,UndefinedHDU
This abstract class is the parent of all HDU types. It provides basic
functionality for an HDU.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
protected boolean
Is this the first HDU in a FITS file?private static final Logger
private static final int
protected DataClass
The associated data unit.protected Header
The associated header. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add information to the header.void
void
void
void
addValue
(IFitsHeader key, boolean val) void
addValue
(IFitsHeader key, double val) void
addValue
(IFitsHeader key, int val) void
addValue
(IFitsHeader key, String val) (package private) boolean
card
(IFitsHeader key) get a builder for filling the header cards using the builder pattern.Return the name of the person who compiled the information in the data associated with this header.int[]
getAxes()
In FITS files the index represented by NAXIS1 is the index that changes most rapidly.int
long
double
getBUnit()
double
getBZero()
Get the FITS file creation date as aDate
object.getData()
static BasicHDU<?>
double
getEpoch()
Deprecated.double
Get the equinox in years for the celestial coordinate system in which positions given in either the header or data are expressed.long
Get the starting offset of the HDUint
Get the name of the instrument which was used to acquire the data in this FITS file.double
Return the minimum valid value in the array.double
Return the minimum valid value in the array.Get the name of the observed object in this FITS file.Get the FITS file observation date as aDate
object.Get the name of the person who acquired the data in this FITS file.Get the name of the organization which created this FITS file.int
Return the citation of a reference where the data associated with this header are published.long
getSize()
Get the name of the telescope which was used to acquire the data in this FITS file.getTrimmedString
(String keyword) Get the String value associated withkeyword
.getTrimmedString
(IFitsHeader keyword) Get the String value associated withkeyword
.abstract void
info
(PrintStream stream) Print out some information about this HDU.static boolean
static boolean
Check that this is a valid header for the HDU.void
read
(ArrayDataInput stream) Read a data array into the current object and if needed position to the beginning of the next FITS block.boolean
reset()
Reset the input stream to point to the beginning of this elementvoid
rewrite()
Rewrite the contents of the element in place.boolean
protected void
saveReplaceCard
(String key, boolean isString, String value) Safely replace a card in the header, knowing that no exception will occur.(package private) void
setPrimaryHDU
(boolean newPrimary) Indicate that an HDU is the first element of a FITS file.void
write
(ArrayDataOutput stream) Write the contents of the element to a data sink.
-
Field Details
-
MAX_NAXIS_ALLOWED
private static final int MAX_NAXIS_ALLOWED- See Also:
-
LOG
-
BITPIX_BYTE
public static final int BITPIX_BYTE- See Also:
-
BITPIX_SHORT
public static final int BITPIX_SHORT- See Also:
-
BITPIX_INT
public static final int BITPIX_INT- See Also:
-
BITPIX_LONG
public static final int BITPIX_LONG- See Also:
-
BITPIX_FLOAT
public static final int BITPIX_FLOAT- See Also:
-
BITPIX_DOUBLE
public static final int BITPIX_DOUBLE- See Also:
-
myHeader
The associated header. -
myData
The associated data unit. -
isPrimary
protected boolean isPrimaryIs this the first HDU in a FITS file?
-
-
Constructor Details
-
BasicHDU
-
-
Method Details
-
getDummyHDU
- Returns:
- an HDU without content
-
isHeader
Check that this is a valid header for the HDU. This method is static but should be implemented by all subclasses. TODO: refactor this to be in a meta object so it can inherit normally also seeisData(Object)
- Parameters:
header
- to validate.- Returns:
true
if this is a valid header.
-
isData
- Parameters:
o
- The Object being tested.- Returns:
- if this object can be described as a FITS image. This method is
static but should be implemented by all subclasses. TODO:
refactor this to be in a meta object so it can inherit normally
also see
isHeader(Header)
-
saveReplaceCard
Safely replace a card in the header, knowing that no exception will occur. Only for internal use!- Parameters:
key
- the key of the cardisString
- is the value a Stringvalue
- the String representation of the value
-
addValue
- Throws:
HeaderCardException
-
addValue
- Throws:
HeaderCardException
-
addValue
- Throws:
HeaderCardException
-
addValue
- Throws:
HeaderCardException
-
addValue
Add information to the header.- Parameters:
key
- key to add to the headerval
- value for the key to addcomment
- comment for the key/value pair- Throws:
HeaderCardException
- if the card does not follow the specification
-
addValue
- Throws:
HeaderCardException
-
addValue
- Throws:
HeaderCardException
-
addValue
- Throws:
HeaderCardException
-
canBePrimary
boolean canBePrimary()- Returns:
- Indicate whether HDU can be primary HDU. This method must be overriden in HDU types which can appear at the beginning of a FITS file.
-
getAuthor
Return the name of the person who compiled the information in the data associated with this header.- Returns:
- either
null
or a String object
-
getAxes
In FITS files the index represented by NAXIS1 is the index that changes most rapidly. This reflects the behavior of Fortran where there are true multidimensional arrays. In Java in a multidimensional array is an array of arrays and the first index is the index that changes slowest. So at some point a client of the library is going to have to invert the order. E.g., if I have a FITS file willBITPIX=16 NAXIS1=10 NAXIS2=20 NAXIS3=30
this will be read into a Java array short[30][20][10] so it makes sense to me at least that the returned dimensions are 30,20,10- Returns:
- the dimensions of the axis.
- Throws:
FitsException
- if the axis are configured wrong.
-
getBitPix
- Throws:
FitsException
-
getBlankValue
- Throws:
FitsException
-
getBScale
public double getBScale() -
getBUnit
-
getBZero
public double getBZero() -
getCreationDate
Get the FITS file creation date as aDate
object.- Returns:
- either
null
or a Date object
-
getData
- Returns:
- the associated Data object
-
getEpoch
Deprecated.usegetEquinox()
insteadGet the equinox in years for the celestial coordinate system in which positions given in either the header or data are expressed.- Returns:
- either
null
or a String object
-
getEquinox
public double getEquinox()Get the equinox in years for the celestial coordinate system in which positions given in either the header or data are expressed.- Returns:
- either
null
or a String object
-
getFileOffset
public long getFileOffset()Get the starting offset of the HDU- Specified by:
getFileOffset
in interfaceFitsElement
- Returns:
- the byte at which this element begins. This is only available if the data is originally read from a random access medium.
-
getGroupCount
public int getGroupCount() -
getHeader
- Returns:
- the associated header
-
card
get a builder for filling the header cards using the builder pattern.- Parameters:
key
- the key for the first card.- Returns:
- the builder for header cards.
-
getInstrument
Get the name of the instrument which was used to acquire the data in this FITS file.- Returns:
- either
null
or a String object
-
getKernel
- Returns:
- the non-FITS data object
-
getMaximumValue
public double getMaximumValue()Return the minimum valid value in the array.- Returns:
- minimum value.
-
getMinimumValue
public double getMinimumValue()Return the minimum valid value in the array.- Returns:
- minimum value.
-
getObject
Get the name of the observed object in this FITS file.- Returns:
- either
null
or a String object
-
getObservationDate
Get the FITS file observation date as aDate
object.- Returns:
- either
null
or a Date object
-
getObserver
Get the name of the person who acquired the data in this FITS file.- Returns:
- either
null
or a String object
-
getOrigin
Get the name of the organization which created this FITS file.- Returns:
- either
null
or a String object
-
getParameterCount
public int getParameterCount() -
getReference
Return the citation of a reference where the data associated with this header are published.- Returns:
- either
null
or a String object
-
getSize
public long getSize()- Specified by:
getSize
in interfaceFitsElement
- Returns:
- The size of this element in bytes
-
getTelescope
Get the name of the telescope which was used to acquire the data in this FITS file.- Returns:
- either
null
or a String object
-
getTrimmedString
Get the String value associated withkeyword
.- Parameters:
keyword
- the FITS keyword- Returns:
- either
null
or a String with leading/trailing blanks stripped.
-
getTrimmedString
Get the String value associated withkeyword
.- Parameters:
keyword
- the FITS keyword- Returns:
- either
null
or a String with leading/trailing blanks stripped.
-
info
Print out some information about this HDU.- Parameters:
stream
- the printstream to write the info on
-
read
Description copied from interface:FitsElement
Read a data array into the current object and if needed position to the beginning of the next FITS block.- Specified by:
read
in interfaceFitsElement
- Parameters:
stream
- The input data stream- Throws:
FitsException
- if the read was unsuccessful.IOException
- if the read was unsuccessful.
-
reset
public boolean reset()Description copied from interface:FitsElement
Reset the input stream to point to the beginning of this element- Specified by:
reset
in interfaceFitsElement
- Returns:
- True if the reset succeeded.
-
rewrite
Description copied from interface:FitsElement
Rewrite the contents of the element in place. The data must have been originally read from a random access device, and the size of the element may not have changed.- Specified by:
rewrite
in interfaceFitsElement
- Throws:
FitsException
- if the rewrite was unsuccessful.IOException
- if the rewrite was unsuccessful.
-
rewriteable
public boolean rewriteable()- Specified by:
rewriteable
in interfaceFitsElement
- Returns:
true
if this element can be rewritten?
-
setPrimaryHDU
Indicate that an HDU is the first element of a FITS file.- Parameters:
newPrimary
- value to set- Throws:
FitsException
- if the operation failed
-
write
Description copied from interface:FitsElement
Write the contents of the element to a data sink.- Specified by:
write
in interfaceFitsElement
- Parameters:
stream
- The data sink.- Throws:
FitsException
- if the write was unsuccessful.
-
getEquinox()
instead