The HDF_SD_ADDDATA procedure writes a hyperslab of values to an SD dataset. By default, the output data is transposed. This transposition puts the data in column order, which is more efficient in HDF than row order (which is more efficient in IDL). In the rare cases where it is necessary to write the data without transposing, set the NOREVERSE keyword. The OFFSET, COUNT, and STRIDE keywords are similarly affected by the NOREVERSE keyword.
Examples
The following example writes a 230-element by 380-element byte image to an SD dataset, then reads it back as a 70 by 100 image starting at (40, 20), sampling every other Y pixel and every third X pixel:
start = [40, 20]
count = [70, 100]
stride = [2, 3]
image = DIST(230, 380)
TV, image
SDinterface_id = HDF_SD_START('image.hdf', /CREATE)
SDdataset_id = HDF_SD_CREATE(SDinterface_id, 'image', [230, 380], /BYTE)
HDF_SD_ADDDATA, SDdataset_id, image
HDF_SD_GETDATA, SDdataset_id, full
HDF_SD_GETDATA, SDdataset_id, small, COUNT=count, $
START=start, STRIDE=stride
HDF_SD_ENDACCESS, SDdataset_id
HDF_SD_END, SDinterface_id
HELP, full, small
ERASE
TV, full
TV, small
IDL prints:
FULL BYTE = Array(230, 380)
SMALL BYTE = Array(70, 100)
Continuing with our example, suppose we want to write the center 50 by 100 pixels of the image to the file. You might be tempted to try:
HDF_SD_ADDDATA, SDdataset_id, image, START=[90, 90], COUNT=[50,100]
You will find, however, that this captures the lower left-hand corner of the original image, rather than the center. To write the data from the center, subset the original image, choosing the data from the center:
HDF_SD_ADDDATA, SDdataset_id, image(90:139, 90:189), START=[90, 90],$
COUNT=[50,100]
HDF_SD_ENDACCESS, SDdataset_id
HDF_SD_END, SDinterface_id
Syntax
HDF_SD_ADDDATA, SDdataset_id, Data [, COUNT=vector] [, /NOREVERSE] [, START=vector] [, STRIDE=vector]
Arguments
SDdataset_id
An SD dataset ID as returned by HDF_SD_SELECT or HDF_SD_CREATE.
Data
The data to be written.
Keywords
COUNT
Set this keyword to a vector of counts (i.e., the number of items) to be written in each dimension. The default is to write all available data. Use caution when using this keyword. See the second example, below.
NOREVERSE
Set this keyword to prevent HDF_SD_ADDDATA’s transposition of Data and any vectors specified by keywords into column order.
START
Set this keyword to a vector that contains the starting position for the data. The default position is [0, 0, ..., 0].
STRIDE
Set this keyword to a vector that contains the strides, or sampling intervals, between accessed values of the NetCDF variable. The default stride vector is that for a contiguous write: [0, 0, ..., 0].
Version History
See Also
HDF_SD_GETDATA