HDF_SD_SETEXTFILE

The HDF_SD_SETEXTFILE procedure moves data values from a dataset into an external file. Only the data is moved, all other information remains in the original file. This routine can only be used with HDF version 3.3 (and later) files, not on older HDF files or NetCDF files. Data can only be moved once, and the user must keep track of the external file(s). The OFFSET keyword allows writing to an arbitrary location in the external file.

As shown in the example, when adding data to an external file SD, you must first use HDF_SD_ENDACCESS to sync the file, then reacquire the SDS ID with HDF_SD_SELECT before using HDF_SD_SETEXTFILE.

Calling Sequence

HDF_SD_SETEXTFILE, SDS_ID, Filename

Arguments

SDS_ID

An SD dataset ID as returned by HDF_SD_SELECT.

Filename

The name of the external file to be written.

Keywords

OFFSET

Set this keyword to a number of bytes from the beginning of the external file at which data writing should begin. Exercise extreme caution when using this keyword with existing files.

Example

sd_id = HDF_SD_START('ext_main.hdf', /CREATE)
; Create an HDF file.

sds_id = HDF_SD_CREATE(sd_id, 'float_findgen', [3,5], /FLOAT)
; Add an SD.

HDF_SD_ADDDATA, sds_id, FINDGEN(3,5) ; Put some data into the SD.

HDF_SD_ENDACCESS,sds_id ; Call HDF_SD_ENDACCESS to sync the file.

sds_id = HDF_SD_SELECT(sd_id, 0) ; Reacquire the SDS_ID.

HDF_SD_SETEXTFILE, sds_id, 'findgen.hdf'
; Move data to an external file named findgen.hdf.

HDF_SD_GETDATA, sds_id, fout ; Retrieve data from the external file into the variable fout.

PRINT, fout ; Print the contents of fout.

IDL prints:

0.00000 1.00000 2.00000

3.00000 4.00000 5.00000

6.00000 7.00000 8.00000

9.00000 10.0000 11.0000

12.0000 13.0000 14.0000

HDF_SD_ENDACCESS, sds_id ; Sync and close the files.

HDF_SD_END, sd_id

See Also

HDF_SD_END , HDF_SD_ENDACCESS , HDF_SD_SELECT , HDF_SD_START