|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectncsa.hdf.object.HObject
ncsa.hdf.object.Dataset
ncsa.hdf.object.CompoundDS
ncsa.hdf.object.h5.H5CompoundDS
H5CompoundDS describes a multi-dimension array of HDF5 compound dataset, inheriting CompoundDS.
A HDF5 compound datatype is similar to a struct in C or a common block in Fortran: it is a collection of one or more atomic types or small arrays of such types. Each member of a compound type has a name which is unique within that type, and a byte offset that determines the first byte (smallest byte address) of that member in a compound datum.
There are two basic types of compound datasets, simple compound data and nested compound data. Members of a simple compound dataset are scalar data or array of scalar data. Members of a nested compound dataset can be compound or array of compound data. The current implementation of H5CompoundDS only supports simple compound datasets.
A special case of compound dataset is the one-dimension simple compound data. An one-dimension HDF5 compound array is like an HDF5 Vdata table. Members of the compound dataset are similar to fileds of HDF4 VData table.
ARRAY of compound dataset is not supported in this implementation. ARRAY of compound dataset requires to read the whole data structure instead of read field by field.
How to Select a Subset
Dataset defines APIs for read, write and subet a dataset. No function is defined to select a subset of a data array. The selection is done in an implicit way. Function calls to dimension information such as getSelectedDims() return an array of dimension values, which is a reference to the array in the dataset object. Changes of the array outside the dataset object directly change the values of the array in the dataset object. It is like pointers in C.
The following is an example of how to make a subset. In the example, the dataset
is a 4-dimension with size of [200][100][50][10], i.e.
dims[0]=200; dims[1]=100; dims[2]=50; dims[3]=10;
We want to select every other data points in dims[1] and dims[2]
int rank = dataset.getRank(); // number of dimension of the dataset long[] dims = dataset.getDims(); // the dimension sizes of the dataset long[] selected = dataset.getSelectedDims(); // the selected size of the dataet long[] start = dataset.getStartDims(); // the off set of the selection long[] stride = dataset.getStride(); // the stride of the dataset int[] selectedIndex = dataset.getSelectedIndex(); // the selected dimensions for display // select dim1 and dim2 as 2D data for display,and slice through dim0 selectedIndex[0] = 1; selectedIndex[1] = 2; selectedIndex[1] = 0; // reset the selection arrays for (int i=0; i
- See Also:
- Serialized Form
Field Summary
Fields inherited from class ncsa.hdf.object.CompoundDS isMemberSelected, memberDims, memberNames, memberOrders, memberTypes, numberOfMembers
Fields inherited from class ncsa.hdf.object.Dataset chunkSize, compression, data, datatype, dimNames, dims, H5Z_FILTER_CONFIG_DECODE_ENABLED, H5Z_FILTER_CONFIG_ENCODE_ENABLED, rank, selectedDims, selectedIndex, selectedStride, startDims
Fields inherited from class ncsa.hdf.object.HObject hasAttribute, oid, separator
Constructor Summary H5CompoundDS(FileFormat fileFormat, java.lang.String name, java.lang.String path)
H5CompoundDS(FileFormat fileFormat, java.lang.String name, java.lang.String path, long[] oid)
Creates a H5CompoundDS object with specific name and path.
Method Summary void
close(int did)
Closes access to this object.Dataset
copy(Group pgroup, java.lang.String name, long[] dims, java.lang.Object data)
Copy this dataset to another group.static Dataset
create(java.lang.String name, Group pgroup, long[] dims, java.lang.String[] memberNames, Datatype[] memberDatatypes, int[] memberRanks, int[][] memberDims, java.lang.Object data)
static Dataset
create(java.lang.String name, Group pgroup, long[] dims, java.lang.String[] memberNames, Datatype[] memberDatatypes, int[] memberSizes, java.lang.Object data)
creates a new compound datasetDatatype
getDatatype()
returns the datatype of this dataset.java.util.List
getMetadata()
Loads the metadata such as attributes and type of the the data object into memory if the metadata is not loaded.void
init()
Retrieve and initialize dimensions and member information.int
open()
Opens access to this object.java.lang.Object
read()
Loads the content of this data object into memory if the data of the object is not loaded.byte[]
readBytes()
Read data values of this dataset into byte array.void
removeMetadata(java.lang.Object info)
Deletes an attribute from this dataset.void
setName(java.lang.String newName)
Sets the name of the data object.void
write(java.lang.Object buf)
Write data values into file.void
writeMetadata(java.lang.Object info)
Creates a new attribute and attached to this dataset if attribute does not exist.
Methods inherited from class ncsa.hdf.object.CompoundDS getMemberCount, getMemberNames, getMemberOrders, getMemberTypes, getMemeberDims, getSelectedMemberCount, getSelectedMemberOrders, isMemberSelected, selectMember, setMemberSelection
Methods inherited from class ncsa.hdf.object.Dataset byteToString, clearData, convertFromUnsignedC, convertToUnsignedC, getChunkSize, getCompression, getData, getDimNames, getDims, getHeight, getRank, getSelectedDims, getSelectedIndex, getStartDims, getStride, getWidth, setData, stringToByte, write
Methods inherited from class ncsa.hdf.object.HObject equalsOID, getFID, getFile, getFileFormat, getName, getOID, getPath, hasAttribute, setPath, toString
Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail H5CompoundDS
public H5CompoundDS(FileFormat fileFormat, java.lang.String name, java.lang.String path)
H5CompoundDS
public H5CompoundDS(FileFormat fileFormat, java.lang.String name, java.lang.String path, long[] oid)
- Creates a H5CompoundDS object with specific name and path.
- Parameters:
fileFormat
- the HDF file.name
- the name of this H5CompoundDS.path
- the full path of this H5CompoundDS.oid
- the unique identifier of this data object.
Method Detail getDatatype
public Datatype getDatatype()
- Description copied from class:
Dataset
- returns the datatype of this dataset.
- Specified by:
getDatatype
in classDataset
readBytes
public byte[] readBytes() throws HDF5Exception
- Description copied from class:
Dataset
- Read data values of this dataset into byte array. readBytes() loads data as arry of bytes instead of array of its datatype. For example, for an one-dimension 32-bit integer dataset of size 5, the readBytes() returns of a byte array of size 20 instead of a int array of 5.
readBytes() is most used for copy data values, at which case, data do not need to be changed or displayed.
- Specified by:
readBytes
in classDataset
- Throws:
HDF5Exception
read
public java.lang.Object read() throws HDF5Exception
- Loads the content of this data object into memory if the data of the object is not loaded. If the content is already loaded, it returns the content. It returns null if the data object has no content or it fails to load the data content.
Data is read from file member by member and stored into a list by members. Each member data is an one-dimension array. The array type is determined by the datatype of the member. The data list contains only the data of selected members.
For example, if compound dataset "A" has the following nested structure, and memeber datatypes
A --> m01 (int) A --> m02 (float) A --> nest1 --> m11 (char) A --> nest1 --> m12 (String) A --> nest1 --> nest2 --> m21 (long) A --> nest1 --> nest2 --> m22 (double)read() returns a List contains arrays of int, float, char, Stirng, long and double.
- Specified by:
read
in classDataset
- Returns:
- the array of data List.
- Throws:
HDF5Exception
write
public void write(java.lang.Object buf) throws HDF5Exception
- Description copied from class:
Dataset
- Write data values into file.
- Specified by:
write
in classDataset
- Parameters:
buf
- the data to write- Throws:
HDF5Exception
copy
public Dataset copy(Group pgroup, java.lang.String name, long[] dims, java.lang.Object data) throws java.lang.Exception
- Description copied from class:
Dataset
- Copy this dataset to another group.
- Specified by:
copy
in classDataset
- Parameters:
pgroup
- the group which the dataset is copied to.name
- the name of the new dataset.dims
- the dimension sizes of the the new dataset.data
- the data to be copied.- Returns:
- the new dataset.
- Throws:
java.lang.Exception
getMetadata
public java.util.List getMetadata() throws HDF5Exception
- Description copied from interface:
DataFormat
- Loads the metadata such as attributes and type of the the data object into memory if the metadata is not loaded. If the metadata is loaded, it returns the metadata. The metadata is stored as a collection of metadata ojbects in a List.
- Returns:
- the list of metadata objects.
- Throws:
HDF5Exception
- See Also:
List
writeMetadata
public void writeMetadata(java.lang.Object info) throws java.lang.Exception
- Creates a new attribute and attached to this dataset if attribute does not exist. Otherwise, just update the value of the attribute.
- Parameters:
info
- the atribute to attach- Throws:
java.lang.Exception
removeMetadata
public void removeMetadata(java.lang.Object info) throws HDF5Exception
- Deletes an attribute from this dataset.
- Parameters:
info
- the attribute to delete.- Throws:
HDF5Exception
open
public int open()
- Description copied from class:
HObject
- Opens access to this object.
Sub-classes have to implement this interface so that different data objects have their own ways of how the data resources are opened.
- Specified by:
open
in classHObject
- Returns:
- the interface identifier for access this object.
close
public void close(int did)
- Description copied from class:
HObject
- Closes access to this object.
- Specified by:
close
in classHObject
- Parameters:
did
- the object identifier. Sub-classes have to implement this interface so that different data objects have their own ways of how the data resources are closed.
init
public void init()
- Retrieve and initialize dimensions and member information.
- Specified by:
init
in classDataset
setName
public void setName(java.lang.String newName) throws java.lang.Exception
- Sets the name of the data object.
- Overrides:
setName
in classHObject
- Parameters:
newName
- the new name of the object.- Throws:
java.lang.Exception
create
public static Dataset create(java.lang.String name, Group pgroup, long[] dims, java.lang.String[] memberNames, Datatype[] memberDatatypes, int[] memberSizes, java.lang.Object data) throws java.lang.Exception
- creates a new compound dataset
- Parameters:
name
- the name of the datasetpgroup
- the parent groupdims
- the dimension sizememberNames
- the names of compound datatypememberDatatypes
- the datatypes of the compound datatypememberSizes
- the sizes of memeber arraydata
- the initial data- Returns:
- the new compound dataset or null if failed
- Throws:
java.lang.Exception
create
public static Dataset create(java.lang.String name, Group pgroup, long[] dims, java.lang.String[] memberNames, Datatype[] memberDatatypes, int[] memberRanks, int[][] memberDims, java.lang.Object data) throws java.lang.Exception
- Throws:
java.lang.Exception
Overview Package Class Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD