HDF_SD_ATTRSET

The HDF_SD_ATTRSET procedure writes attributes to an open HDF SD dataset. If no data type is specified, the data type is taken from the Values argument.

Calling Sequence

HDF_SD_ATTRSET, S_ID, Attr_Name, Values [, Count]

Arguments

S_ID

An SD interface ID as returned by HDF_SD_START (i.e., a global attribute's " SD_ID "), or HDF_SD_SELECT/HDF_SD_CREATE (i.e., a dataset's " SDS_ID ").

Attr_Name

A string containing the name of the attribute to be written.

Values

The attribute values to be written.

Count

An optional integer argument specifying how many items are to be written. Count must be less than or equal to the number of elements in the Values agrument.

Keywords

BYTE

Set this keyword to indicate that the attribute is composed of bytes. Data will be stored with the HDF DFNT_UINT8 data type. Setting this keyword is the same as setting the DFNT_UINT8 keyword.

DFNT_CHAR

Set this keyword to create an attribute of HDF type DFNT_CHAR. Setting this keyword is the same as setting the STRING keyword.

DFNT_FLOAT32

Set this keyword to create an attribute of HDF type DFNT_FLOAT32. Setting this keyword is the same as setting the FLOAT keyword.

DFNT_FLOAT64

Set this keyword to create an attribute of HDF type DFNT_FLOAT64. Setting this keyword is the same as setting the DOUBLE keyword.

DFNT_INT8

Set this keyword to create an attribute of HDF type DFNT_INT8.

DFNT_INT16

Set this keyword to create an attribute of HDF type DFNT_INT16. Setting this keyword is the same as setting either the INT keyword or the SHORT keyword.

DFNT_INT32

Set this keyword to create an attribute of HDF type DFNT_INT32. Setting this keyword is the same as setting the LONG keyword.

DFNT_UINT8

Set this keyword to create an attribute of HDF type DFNT_UINT8. Setting this keyword is the same as setting the BYTE keyword.

DFNT_UINT16

Set this keyword to create an attribute of HDF type DFNT_UINT16.

DFNT_UINT32

Set this keyword to create an attribute of HDF type DFNT_UINT32.

DOUBLE

Set this keyword to indicate that the attribute is composed of double-precision floating-point values. Data will be stored with the HDF DFNT_FLOAT64 data type. Setting this keyword is the same as setting the DFNT_FLOAT64 keyword.

FLOAT

Set this keyword to indicate that the attribute is composed of single-precision floating-point values. Data will be stored with the HDF DFNT_FLOAT32 data type. Setting this keyword is the same as setting the DFNT_FLOAT32 keyword.

INT

Set this keyword to indicate that the attribute is composed of 2-byte integers. Data will be stored with the HDF DFNT_INT16 data type. Setting this keyword is the same as setting either the SHORT keyword or the DFNT_INT16 keyword.

LONG

Set this keyword to indicate that the attribute is composed of longword integers. Data will be stored with the HDF DFNT_INT32 data type. Setting this keyword is the same as setting the DFNT_INT32 keyword.

SHORT

Set this keyword to indicate that the attribute is composed of 2-byte integers. Data will be stored with the HDF DFNT_INT16 data type. Setting this keyword is the same as setting either the INT keyword or the DFNT_INT16 keyword.

STRING

Set this keyword to indicate that the attribute is composed of strings. Data will be stored with the HDF DFNT_CHAR data type. Setting this keyword is the same as setting the DFNT_CHAR keyword.

Example

fid = HDF_OPEN('demo.hdf', /ALL) ; Create a new HDF file.

sd_id = HDF_SD_START('demo.hdf', /RDWR) ; Start the SD interface.

HDF_SD_ATTRSET, sd_id, 'TITLE', 'MY TITLE GLOBAL', 16
; Create a global attribute.

HDF_SD_ATTRSET, sd_id, 'RANGE', [-99.88,55544.2], /DOUBLE
; Create another global attribute.

SDS_ID = HDF_SD_CREATE(sd_id, 'var1', [10,20], /FLOAT)
; Create a dataset.

HDF_SD_ATTRSET, SDS_ID, 'TITLE', 'MY TITLE SD_ID', 15
; Add a dataset attribute.

index=HDF_SD_ATTRFIND(sd_id, 'RANGE') ; Find the recently-created RANGE attribute.

HDF_SD_ATTRINFO,sd_id,index,NAME=atn,COUNT=atc,TYPE=att,DATA=d
; Retrieve data from RANGE.

HELP, atn, atc, att ; Print information about the returned variables.

IDL prints:

ATN STRING = 'RANGE'

ATC LONG = 2

ATT STRING = 'DOUBLE'

PRINT, d, FORMAT='(F8.2,x,F8.2)' ; Print the data returned in variable d with the given format.

IDL prints:

-99.88 55544.20

HDF_SD_ENDACCESS, sds_id ; End access to the HDF file.

HDF_SD_END, sd_id

HDF_CLOSE, fid

See Also

HDF_SD_ATTRFIND , HDF_SD_ATTRINFO , HDF_SD_CREATE , HDF_SD_SELECT