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.
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.
Set this keyword to prevent HDF_SD_ADDDATA's transposition of Data and any vectors specified by keywords into column order.
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] ; Set the start vector.
count = [70, 100] ; Set the count vector.
stride = [2, 3] ; Set the stride vector.
image = DIST(230, 380) ; Create the image.
TV, image ; Display the image.
sd_id = HDF_SD_START('image.hdf', /CREATE)
;
Create a new HDF file in SD mode.
sds_id = HDF_SD_CREATE(sd_id, 'image', [230, 380], /BYTE)
;
Define a new SD dataset.
HDF_SD_ADDDATA, sds_id, image ; Write the image into the dataset.
HDF_SD_GETDATA, sds_id, full ; Retrieve the full image.
HDF_SD_GETDATA, sds_id, small, COUNT=count, $
START=start, STRIDE=stride ; Retrieve the sub-sampled image.
HELP, full, small ; Print information about the images.
TV, full ; Display the full image.
TV, small ; Display the sub-sampled image.
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, sds_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, sds_id, image(90:139, 90:189), START=[90, 90],$
COUNT=[50,100] ; This is the correct way to add the data.