Package nom.tam.fits
Class ImageData
- java.lang.Object
-
- nom.tam.fits.Data
-
- nom.tam.fits.ImageData
-
- All Implemented Interfaces:
FitsElement
public class ImageData extends Data
This class instantiates FITS primary HDU and IMAGE extension data. Essentially these data are a primitive multi-dimensional array.Starting in version 0.9 of the FITS library, this routine allows users to defer the reading of images if the FITS data is being read from a file. An ImageTiler object is supplied which can return an arbitrary subset of the image as a one dimensional array -- suitable for manipulation by standard Java libraries. A call to the getData() method will still return a multi-dimensional array, but the image data will not be read until the user explicitly requests. it.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ImageData.ArrayDesc
This class describes an arrayprotected class
ImageData.ImageDataTiler
This inner class allows the ImageTiler to see if the user has read in the data.
-
Field Summary
Fields Modifier and Type Field Description private long
byteSize
The size of the dataprivate java.lang.Object
dataArray
The actual array of data.private ImageData.ArrayDesc
dataDescription
A description of what the data should look likeprivate static java.util.logging.Logger
LOG
private StandardImageTiler
tiler
The image tiler associated with this image.-
Fields inherited from class nom.tam.fits.Data
dataSize, fileOffset, input
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
fillHeader(Header head)
Fill header with keywords that describe image data.java.lang.Object
getData()
Return the actual data.StandardImageTiler
getTiler()
protected long
getTrueSize()
Get the size in bytes of the dataprotected ImageData.ArrayDesc
parseHeader(Header h)
void
read(ArrayDataInput i)
Read a data array into the current object and if needed position to the beginning of the next FITS block.void
setBuffer(java.nio.Buffer data)
(package private) void
setTiler(StandardImageTiler tiler)
void
write(ArrayDataOutput o)
Write the data -- including any buffering needed-
Methods inherited from class nom.tam.fits.Data
getFileOffset, getKernel, getSize, reset, rewrite, rewriteable, setFileOffset
-
-
-
-
Field Detail
-
LOG
private static final java.util.logging.Logger LOG
-
byteSize
private long byteSize
The size of the data
-
dataArray
private java.lang.Object dataArray
The actual array of data. This is normally a multi-dimensional primitive array. It may be null until the getData() routine is invoked, or it may be filled by during the read call when a non-random access device is used.
-
dataDescription
private ImageData.ArrayDesc dataDescription
A description of what the data should look like
-
tiler
private StandardImageTiler tiler
The image tiler associated with this image.
-
-
Constructor Detail
-
ImageData
public ImageData()
Create the equivalent of a null data element.
-
ImageData
public ImageData(Header h) throws FitsException
Create an array from a header description. This is typically how data will be created when reading FITS data from a file where the header is read first. This creates an empty array.- Parameters:
h
- header to be used as a template.- Throws:
FitsException
- if there was a problem with the header description.
-
ImageData
public ImageData(java.lang.Object x)
Create an ImageData object using the specified object to initialize the data array.- Parameters:
x
- The initial data array. This should be a primitive array but this is not checked currently.
-
-
Method Detail
-
getData
public java.lang.Object getData()
Return the actual data. Note that this may return a null when the data is not readable. It might be better to throw a FitsException, but this is a very commonly called method and we prefered not to change how users must invoke it.
-
getTiler
public StandardImageTiler getTiler()
-
read
public void read(ArrayDataInput i) throws FitsException
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
- Specified by:
read
in classData
- Parameters:
i
- The input data stream- Throws:
FitsException
- if the read was unsuccessful.
-
setBuffer
public void setBuffer(java.nio.Buffer data)
-
write
public void write(ArrayDataOutput o) throws FitsException
Description copied from class:Data
Write the data -- including any buffering needed- Specified by:
write
in interfaceFitsElement
- Specified by:
write
in classData
- Parameters:
o
- The output stream on which to write the data.- Throws:
FitsException
- if the write was unsuccessful.
-
fillHeader
protected void fillHeader(Header head) throws FitsException
Fill header with keywords that describe image data.- Specified by:
fillHeader
in classData
- Parameters:
head
- The FITS header- Throws:
FitsException
- if the object does not contain valid image data.
-
getTrueSize
protected long getTrueSize()
Get the size in bytes of the data- Specified by:
getTrueSize
in classData
-
parseHeader
protected ImageData.ArrayDesc parseHeader(Header h) throws FitsException
- Throws:
FitsException
-
setTiler
void setTiler(StandardImageTiler tiler)
-
-