Opaque Datatypes

An opaque datatype contains a series of bytes. It always contains a single element, regardless of the length of the series of bytes it contains.

When an IDL variable is written to a dataset or attribute defined as an opaque datatype, it is written as a string of bytes with no demarcation. When data in a opaque datatype is read into an IDL variable, it is returned as byte array. Use the FIX routine to convert the returned byte array to the appropriate IDL data type.

Use the H5T_IDL_CREATE routine with the OPAQUE keyword to create opaque datatypes. To create an opaque array, use an opaque datatype with the H5T_ARRAY_CREATE routine. A single string tag can be assigned to an opaque datatype to provide auxiliary information about what is contained therein. Create tags using the H5T_SET_TAG routine; retrieve tags using the H5T_GET_TAG routine. HDF5 limits the length of the tag to 255 characters.

Example

The following example creates an opaque datatype and stores within it a 20-element integer array.

; Create a file to hold the data 
file = 'h5_test.h5' 
fid = H5F_CREATE(file) 
 
; Create some data 
data = INDGEN(20) 
 
; Create an opaque datatype 
dt = H5T_IDL_CREATE(data, /OPAQUE) 
 
; Create a single element dataspace 
ds = H5S_CREATE_SIMPLE(1) 
 
; Create and write the dataset 
d = H5D_CREATE(fid, 'dataset', dt, ds) 
H5D_WRITE, d, data 
 
; Close the file 
H5F_CLOSE, fid 
 
; Reopen file for reading 
fid = H5F_OPEN(file) 
 
; Read in the data 
d = H5D_OPEN(fid, 'dataset') 
result = H5D_READ(d) 
 
; Close the file 
H5F_CLOSE, fid 
 
HELP, result 

IDL prints:

RESULT          BYTE      = Array[40] 
 

Note that the result is a 40-element byte array, since each integer requires two bytes.