[Top] [Prev] [Next] [Bottom]
DFSDgetslice/dsgslc
intn DFSDgetslice(char *filename, int32 winst[], int32 windims[], VOIDP data, int32 dims[])
Purpose
|
Reads part of a scientific dataset from a file.
|
Return value
|
Returns SUCCEED (or 0) if successful and FAIL (or -1) otherwise.
|
Description
|
DFSDgetslice accesses the dataset last accessed by DFSDgetdims. If DFSDgetdims has not been called for the named file, DFSDgetslice gets a slice from the next dataset in the file. Array winst specifies the coordinates of the start of the slice. Array windims gives the size of the slice. The number of elements in winst and windims must be equal to the rank of the dataset. For example, if the file contains a three-dimensional dataset, winst may contain the values {2, 4, 3}, while windims contains the values {3, 1, 4} and the dims should be at least {3, 1, 4}, the same size as the slice. This will extract a 3 x 4, two-dimensional slice, containing the elements between (2, 4, 3) and (4, 4, 6) from the original dataset.
|
|
The data array is the array into which the slice is read. It must be at least as big as the desired slice. The dims array is the array containing the actual dimensions of the array data. The user assigns values to dims before calling DFSDgetslice.
All parameters assume Fortran-77-style one-based arrays.
|
|
DFSDgetslice is obsolete in favor of DFSDreadslab. DFSDreadslab is the recommended function call to use when reading hyperslabs (previously known as data slices). HDF will continue to support DFSDgetslice only to maintain backward compatibility with HDF applications built on earlier versions of the library.
|
Example
|
Reading two slices.
|
#include "hdf.h"
main c {
int i, rank;
int32 dimsizes[2];
DFSDgetdims("my_file", &rank, dimsizes, 2);
/* Starting at (3,4) read 4 x 6 window. Use (3,4)
rather than (2,3) because FORTRAN-style indexing is used.*/
getit("myfile", 3,4,4,6);
/* starting at (1,10) read 10 x 2 window */
getit("myfile", 1,10,10,2);
}
getit(filename, st0, st1, rows, cols)
int st0, st1, rows, cols;
char *filename;
{ int i, j;
int32 winst[2], windims[2], dims[2];
float32 data[500];
winst[0]=st0;
winst[1]=st1;
dims[0] = windims[0] = rows;
dims[1] = windims[1] = cols;
DFSDgetslice(filename, winst, windims, data, dims);
for (i=0; i < rows; i++) {
printf("\n");
for (j=0; j < cols; j++) {
printf("%5.0f%c",data[i*cols+j], ' ');
}
printf("\n");
}
[Top] [Prev] [Next] [Bottom]
hdfhelp@ncsa.uiuc.edu
HDF User's Reference Manual, Draft 06/09/97, NCSA HDF
Development Group.