The HDF_SD_IDTOREF function converts a SD data set ID into a SD data set reference number. The reference number can be used to add the SD data set to a Vgroup through the HDF_VG interface. The tag number for an SD is 720.
Create an SD data set and get the Reference number.
file_id = HDF_OPEN('demo.hdf', /RDWR)
sd_id = HDF_SD_START('demo.hdf', /RDWR)
sds_id = HDF_SD_CREATE(sd_id, 'demo_data', dim, /FLOAT)
HDF_SD_ADDDATA, sds_id, FINDGEN(100)/10.45 + 2.98
Use the Reference number to add the SD to a Vgroup ;
vgID = HDF_VG_GETID(file_id,-1)
vg_handle = HDF_VG_ATTACH(file_id, vgID, /WRITE)
HDF_VG_SETINFO, vg_handle, name='data1', class='demo'
HDF_VG_ADDTR, vg_handle, SD_TAG, ref
Use HDF_VG_INQTR to verify the SD was added correctly :
IF HDF_VG_INQTR(vg_handle, SD_TAG, ref) then $
HDF_SD_CREATE , HDF_SD_NAMETOINDEX , HDF_SD_REFTOINDEX , HDF_SD_SELECT , HDF_VG_ADDTR , HDF_VG_ATTACH , HDF_VG_DETACH , HDF_VG_GETID , HDF_VG_INQTR