Package nom.tam.fits
Class Data
java.lang.Object
nom.tam.fits.Data
- All Implemented Interfaces:
FitsElement
- Direct Known Subclasses:
AbstractTableData,ImageData,RandomGroupsData,UndefinedData
The data segment of an HDU.
This is the object which contains the actual data for the HDU.
- For images and primary data this is a simple (but possibly multi-dimensional) primitive array. When group data is supported it will be a possibly multidimensional array of group objects.
- For ASCII data it is a two dimensional Object array where each of the constituent objects is a primitive array of length 1.
- For Binary data it is a two dimensional Object array where each of the constituent objects is a primitive array of arbitrary (more or less) dimensionality.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongComputes and returns the FITS checksum for this data, for example to compare against the storedDATASUMin the FITS header (e.g. viaBasicHDU.getStoredDatasum()).voiddetach()Detaches this data object from the input (if any), such as a file or stream, but not before loading data from the previously assigned input into memory.getData()Returns the underlying Java representation of the data contained in this HDU's data segment.longReturns the byte offset at which this element starts ina file.final ObjectSame asgetData().longgetSize()Returns the size of this elements in the FITS representation.booleanChecks if the data should be assumed to be in deferred read mode.booleanisEmpty()Checks if the data content is currently empty, i.e. no actual data is currently stored in memory.voidread(ArrayDataInput in) Reads the data or skips over it for reading later, depending on whether reading from a stream or a random acessible input, respectively.booleanreset()Reset the input stream to point to the beginning of this elementvoidrewrite()Rewrite the contents of the element in place.booleanChecks if we can write this element back to its source.abstract BasicHDU<?> toHDU()Returns an approprotae HDU object that encapsulates this FITS data, and contains the minimal mandatory header description for that data.abstract voidWrites the contents of the element to a data sink, adding padding as necessary if the element (such as a header or data segment) is expected to complete the FITS block of 2880 bytes.
-
Constructor Details
-
Data
public Data()
-
-
Method Details
-
isDeferred
public boolean isDeferred()Checks if the data should be assumed to be in deferred read mode.- Returns:
trueif it is set for deferred reading at a later time, or elsefalseif this data is currently loaded into RAM. #seedetach()- Since:
- 1.17
-
isEmpty
public boolean isEmpty()Checks if the data content is currently empty, i.e. no actual data is currently stored in memory.- Returns:
trueif there is no actual data in memory, otherwisefalse- Since:
- 1.18
- See Also:
-
calcChecksum
Computes and returns the FITS checksum for this data, for example to compare against the storedDATASUMin the FITS header (e.g. viaBasicHDU.getStoredDatasum()). This method always computes the checksum from data in memory. As such it will fully load deferred read mode data into RAM to perform the calculation, and use the standard padding to complete the FITS block for the calculation. As such the checksum may differ from that of the file if the file uses a non-standard padding. Hence, for verifying data integrity as stored in a fileBasicHDU.verifyDataIntegrity()orBasicHDU.verifyIntegrity()should be preferred.- Returns:
- the computed FITS checksum from the data (fully loaded in memory).
- Throws:
FitsException- if there was an error while calculating the checksum- Since:
- 1.17
- See Also:
-
getData
Returns the underlying Java representation of the data contained in this HDU's data segment. Typically it will return a Java array of some kind.- Returns:
- the underlying Java representation of the data core object, such as a multi-dimensional Java array.
- Throws:
FitsException- if the data could not be gathered.- See Also:
-
getFileOffset
public long getFileOffset()Description copied from interface:FitsElementReturns the byte offset at which this element starts ina file. If the element was not obtained from an input, then 0 is returned.- Specified by:
getFileOffsetin interfaceFitsElement- Returns:
- the byte at which this element begins. This is only available if the data is originally read from a random access medium. Otherwise 0 is returned.
-
getKernel
Same asgetData().- Returns:
- The data content as represented by a Java object..
- Throws:
FitsException- if the data could not be gathered .
-
getSize
public long getSize()Description copied from interface:FitsElementReturns the size of this elements in the FITS representation. This may include padding if the element (such as a header or data segment) is expected to complete a FITS block of 2880 bytes.- Specified by:
getSizein interfaceFitsElement- Returns:
- The size of this element in bytes, or 0 if the element is empty or invalid.
-
read
Reads the data or skips over it for reading later, depending on whether reading from a stream or a random acessible input, respectively.
In case the argument is a an instance of
RandomAccessinput (such as aFitsFile, the call will simply note where in the file the data segment can be found for reading at a later point, only when the data content is accessed. This 'deferred' reading behavior make it possible to process large HDUs even with small amount of RAM, and can result in a significant performance boost when inspectring large FITS files, or using only select content from large FITS files.- Specified by:
readin interfaceFitsElement- Parameters:
in- The input data stream- Throws:
PaddingException- if there is missing padding between the end of the data segment and the enf-of-file.FitsException- if the data appears to be corrupted.- See Also:
-
reset
public boolean reset()Description copied from interface:FitsElementReset the input stream to point to the beginning of this element- Specified by:
resetin interfaceFitsElement- Returns:
- True if the reset succeeded.
-
rewrite
Description copied from interface:FitsElementRewrite 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:
rewritein interfaceFitsElement- Throws:
FitsException- if the rewrite was unsuccessful.
-
rewriteable
public boolean rewriteable()Description copied from interface:FitsElementChecks if we can write this element back to its source. An element can only be written back if it is associated to a random accessible input and the current size FITS within the old block size.- Specified by:
rewriteablein interfaceFitsElement- Returns:
trueif this element can be rewritten?
-
detach
Detaches this data object from the input (if any), such as a file or stream, but not before loading data from the previously assigned input into memory.- Throws:
FitsException- if there was an issue loading the data from the previous input (if any)- Since:
- 1.18
- See Also:
-
write
Description copied from interface:FitsElementWrites the contents of the element to a data sink, adding padding as necessary if the element (such as a header or data segment) is expected to complete the FITS block of 2880 bytes.- Specified by:
writein interfaceFitsElement- Parameters:
o- The data sink.- Throws:
FitsException- if the write was unsuccessful.
-
toHDU
Returns an approprotae HDU object that encapsulates this FITS data, and contains the minimal mandatory header description for that data.- Returns:
- a HDU object ocntaining the data and its minimal required header description
- Throws:
FitsException- If the data cannot be converted to an HDU for some reason.
-