Module org.hdfgroup.object
Package hdf.object.fits

# Class FitsDataset

Object
hdf.object.HObject
hdf.object.Dataset
hdf.object.ScalarDS
hdf.object.fits.FitsDataset

All Implemented Interfaces:
  `DataFormat`, `MetaDataContainer`, `Serializable`

public class FitsDataset extends ScalarDS implements MetaDataContainer
FitsDataset describes an multi-dimension array of HDF5 scalar or atomic data types, such as byte, int, short, long, float, double and string, and operations performed on the scalar dataset The library predefines a modest number of datatypes. For details, read HDF5 Datatypes in HDF5 User Guide

Version:
  1.1 9/4/2007
Author:
  Peter X. Cao
See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class hdf.object.ScalarDS

  `fillValue, imageDataRange, interlace, INTERLACE_LINE, INTERLACE_PIXEL, INTERLACE_PLANE, isDefaultImageOrder, isFillValueConverted, isImageDisplay, isTrueColor, palette, unsignedConverted`

  ### Fields inherited from class hdf.object.Dataset

  `chunkSize, compression, COMPRESSION_GZIP_TXT, convertByteToString, convertedBuf, data, datatype, dimNames, dims, filters, inited, isDataLoaded, isImage, isNULL, isScalar, isText, maxDims, nPoints, originalBuf, rank, selectedDims, selectedIndex, selectedStride, space_type, startDims, storage, storageLayout`

  ### Fields inherited from class hdf.object.HObject

  `fileFormat, linkTargetObjName, oid, SEPARATOR`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FitsDataset(FileFormat fileFormat, nom.tam.fits.BasicHDU hdu, String dName, long[] oid)`
  Constructs an FitsDataset object with specific netcdf variable.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close(long did)`
  Closes access to the object.
  `Dataset`
  `copy(Group pgroup, String dstName, long[] dims, Object buff)`
  Creates a new dataset and writes the data buffer to the new dataset.
  `static FitsDataset`
  `create(String name, Group pgroup, Datatype type, long[] dims, long[] maxdims, long[] chunks, int gzip, Object data)`
  Creates a new dataset.
  `Datatype`
  `getDatatype()`
  Returns the datatype of the data object.
  `List`
  `getMetadata()`
  Retrieves the object's metadata, such as attributes, from the file.
  `List`
  `getMetadata(int... attrPropList)`
  Retrieves the object's metadata, such as attributes, from the file.
  `boolean`
  `hasAttribute()`
  Check if the object has any attributes attached.
  `void`
  `init()`
  Set the initial state of all the variables
  `long`
  `open()`
  Opens an existing object such as a dataset or group for access.
  `Object`
  `read()`
  Reads the data from file.
  `byte[]`
  `readBytes()`
  Reads the raw data of the dataset from file to a byte array.
  `void`
  `removeMetadata(Object info)`
  Deletes an existing piece of metadata from this object.
  `void`
  `setName(String newName)`
  Sets the name of the object.
  `void`
  `updateMetadata(Object info)`
  Updates an existing piece of metadata attached to this object.
  `void`
  `write(Object buf)`
  Writes a memory buffer to the object in the file.
  `void`
  `writeMetadata(Object info)`
  Writes a specific piece of metadata (such as an attribute) into the file.

  ### Methods inherited from class hdf.object.ScalarDS

  `addFilteredImageValue, clearData, convertFromUnsignedC, convertToUnsignedC, getFillValue, getFilteredImageValues, getImageDataRange, getInterlace, getNumberOfPalettes, getPalette, getPaletteName, isDefaultImageOrder, isImage, isImageDisplay, isTrueColor, readPalette, setImageDataRange, setIsImage, setIsImageDisplay, setPalette`

  ### Methods inherited from class hdf.object.Dataset

  `byteToString, clear, convertFromUnsignedC, convertFromUnsignedC, convertToUnsignedC, convertToUnsignedC, getChunkSize, getCompression, getConvertByteToString, getData, getDepth, getDimNames, getDims, getFilters, getHeight, getMaxDims, getOriginalClass, getRank, getSelectedDims, getSelectedIndex, getSize, getSpaceType, getStartDims, getStorage, getStorageLayout, getStride, getVirtualFilename, getVirtualMaps, getWidth, isInited, isNULL, isScalar, isString, isVirtual, refreshData, resetSelection, setConvertByteToString, setData, stringToByte, toString, toString, toString, write`

  ### Methods inherited from class hdf.object.HObject

  `createFullname, debug, equals, equals, equalsOID, getFID, getFile, getFileFormat, getFullName, getLinkTargetObjName, getName, getOID, getPath, hashCode, setFullname, setLinkTargetObjName, setPath, toString`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface hdf.object.MetaDataContainer

  `clear`

- ## Constructor Details

  - ### FitsDataset

    public FitsDataset(FileFormat fileFormat, nom.tam.fits.BasicHDU hdu, String dName, long[] oid)
    Constructs an FitsDataset object with specific netcdf variable.
    Parameters:
      `fileFormat` - the netcdf file.
      `hdu` - the BasicHDU.
      `dName` - the name for this dataset.
      `oid` - the unique identifier for this dataset.

- ## Method Details

  - ### hasAttribute

    public boolean hasAttribute()
    Check if the object has any attributes attached.
    Specified by:
      `hasAttribute` in interface `MetaDataContainer`
    Returns:
      true if it has any attributes, false otherwise.

  - ### copy

    public Dataset copy(Group pgroup, String dstName, long[] dims, Object buff) throws Exception
    Description copied from class: `Dataset`
    Creates a new dataset and writes the data buffer to the new dataset. This function allows applications to create a new dataset for a given data buffer. For example, users can select a specific interesting part from a large image and create a new image with the selection. The new dataset retains the datatype and dataset creation properties of this dataset.
    Specified by:
      `copy` in class `Dataset`
    Parameters:
      `pgroup` - the group which the dataset is copied to.
      `dstName` - the name of the new dataset.
      `dims` - the dimension sizes of the the new dataset.
      `buff` - the data values of the subset to be copied.
    Returns:
      the new dataset.
    Throws:
      `Exception` - if dataset can not be copied

  - ### readBytes

    public byte[] readBytes() throws Exception
    Description copied from class: `Dataset`
    Reads the raw data of the dataset from file to a byte array. readBytes() reads raw data to an array of bytes instead of array of its datatype. For example, for a one-dimension 32-bit integer dataset of size 5, readBytes() returns a byte array of size 20 instead of an int array of 5. readBytes() can be used to copy data from one dataset to another efficiently because the raw data is not converted to its native type, it saves memory space and CPU time.
    Specified by:
      `readBytes` in class `Dataset`
    Returns:
      the byte array of the raw data.
    Throws:
      `Exception` - if data can not be read

  - ### read

    public Object read() throws Exception
    Reads the data from file. read() reads the data from file to a memory buffer and returns the memory buffer. The dataset object does not hold the memory buffer. To store the memory buffer in the dataset object, one must call getData(). By default, the whole dataset is read into memory. Users can also select a subset to read. Subsetting is done in an implicit way.
    Specified by:
      `read` in interface `DataFormat`
    Returns:
      the data read from file.
    Throws:
      `Exception` - if object can not be read
      `OutOfMemoryError` - if memory is exhausted
    See Also:
      - `Dataset.getData()`

  - ### write

    public void write(Object buf) throws Exception
    Writes a memory buffer to the object in the file.
    Specified by:
      `write` in interface `DataFormat`
    Parameters:
      `buf` - the data to write
    Throws:
      `Exception` - if data can not be written

  - ### getMetadata

    public List getMetadata() throws Exception
    Retrieves the object's metadata, such as attributes, from the file. Metadata, such as attributes, is stored in a List.
    Specified by:
      `getMetadata` in interface `MetaDataContainer`
    Returns:
      the list of metadata objects.
    Throws:
      `Exception` - if the metadata can not be retrieved

  - ### writeMetadata

    public void writeMetadata(Object info) throws Exception
    Writes a specific piece of metadata (such as an attribute) into the file. If an HDF(4&5) attribute exists in the file, this method updates its value. If the attribute does not exist in the file, it creates the attribute in the file and attaches it to the object. It will fail to write a new attribute to the object where an attribute with the same name already exists. To update the value of an existing attribute in the file, one needs to get the instance of the attribute by getMetadata(), change its values, then use writeMetadata() to write the value.
    Specified by:
      `writeMetadata` in interface `MetaDataContainer`
    Parameters:
      `info` - the metadata to write.
    Throws:
      `Exception` - if the metadata can not be written

  - ### removeMetadata

    public void removeMetadata(Object info) throws Exception
    Deletes an existing piece of metadata from this object.
    Specified by:
      `removeMetadata` in interface `MetaDataContainer`
    Parameters:
      `info` - the metadata to delete.
    Throws:
      `Exception` - if the metadata can not be removed

  - ### updateMetadata

    public void updateMetadata(Object info) throws Exception
    Updates an existing piece of metadata attached to this object.
    Specified by:
      `updateMetadata` in interface `MetaDataContainer`
    Parameters:
      `info` - the metadata to update.
    Throws:
      `Exception` - if the metadata can not be updated

  - ### open

    public long open()
    Description copied from class: `HObject`
    Opens an existing object such as a dataset or group for access. The return value is an object identifier obtained by implementing classes such as H5.H5Dopen(). This function is needed to allow other objects to be able to access the object. For instance, H5File class uses the open() function to obtain object identifier for copyAttributes(long src_id, long dst_id) and other purposes. The open() function should be used in pair with close(long) function.
    Specified by:
      `open` in class `HObject`
    Returns:
      the object identifier if successful; otherwise returns a negative value.
    See Also:
      - `HObject.close(long)`

  - ### close

    public void close(long did)
    Description copied from class: `HObject`
    Closes access to the object. Sub-classes must implement this interface because different data objects have their own ways of how the data resources are closed. For example, H5Group.close() calls the hdf.hdf5lib.H5.H5Gclose() method and closes the group resource specified by the group id.
    Specified by:
      `close` in class `HObject`
    Parameters:
      `did` - The object identifier.

  - ### init

    public void init()
    Description copied from interface: `DataFormat`
    Set the initial state of all the variables
    Specified by:
      `init` in interface `DataFormat`

  - ### create

    public static FitsDataset create(String name, Group pgroup, Datatype type, long[] dims, long[] maxdims, long[] chunks, int gzip, Object data) throws Exception
    Creates a new dataset.
    Parameters:
      `name` - the name of the dataset to create.
      `pgroup` - the parent group of the new dataset.
      `type` - the datatype of the dataset.
      `dims` - the dimension size of the dataset.
      `maxdims` - the max dimension size of the dataset.
      `chunks` - the chunk size of the dataset.
      `gzip` - the level of the gzip compression.
      `data` - the array of data values.
    Returns:
      the new dataset if successful. Otherwise returns null.
    Throws:
      `Exception` - if there is an error

  - ### getDatatype

    public Datatype getDatatype()
    Returns the datatype of the data object.
    Specified by:
      `getDatatype` in interface `DataFormat`
    Overrides:
      `getDatatype` in class `Dataset`
    Returns:
      the datatype of the data object.

  - ### setName

    public void setName(String newName) throws Exception
    Description copied from class: `HObject`
    Sets the name of the object. setName (String newName) changes the name of the object in the file.
    Overrides:
      `setName` in class `HObject`
    Parameters:
      `newName` - The new name of the object.
    Throws:
      `Exception` - if name is root or contains separator

  - ### getMetadata

    public List getMetadata(int... attrPropList) throws Exception
    Retrieves the object's metadata, such as attributes, from the file. Metadata, such as attributes, is stored in a List.
    Parameters:
      `attrPropList` - the list of properties to get
    Returns:
      the list of metadata objects.
    Throws:
      `Exception` - if the metadata can not be retrieved