Download HDF4 User's Guide
Transcript
HDF User’s Guide
EXAMPLE 9.
Reading Subsets of an SDS.
This example shows how parameters start, stride, and edges of the routine SDreadata/sfrdata
can be used to read three subsets of an SDS array.
C:
For the first subset, the program reads every 3rd element of the 2nd column starting at
the 4th row of the data set created in Example 2 and modified in Examples 4
and 7.
For the second subset the program reads the first 4 elements of the 10th row.
For the third subset, the program reads from the same data set every 6th element of
each column and 4th element of each row starting at 1st column, 3d row.
FORTRAN-77:
Fortran program reads transposed data to reflect the difference in C and Fortran internal storage.
C:
#include "mfhdf.h"
#define
#define
#define
#define
#define
FILE_NAME
SUB1_LENGTH
SUB2_LENGTH
SUB3_LENGTH1
SUB3_LENGTH2
"SDS.hdf"
5
4
2
3
main( )
{
/************************* Variable declaration **************************/
int32
intn
int32
int32
int32
int32
int
sd_id, sds_id, sds_index;
status;
start[2], edges[2], stride[2];
sub1_data[SUB1_LENGTH];
sub2_data[SUB2_LENGTH];
sub3_data[SUB3_LENGTH2][SUB3_LENGTH1];
i, j;
/********************* End of variable declaration ***********************/
/*
* Open the file for reading and initialize the SD interface.
*/
sd_id = SDstart (FILE_NAME, DFACC_READ);
/*
* Select the first data set.
*/
sds_index = 0;
sds_id = SDselect (sd_id, sds_index);
/*
*
Reading the first subset.
*
* Set elements of start, edges, and stride arrays to read
* every 3rd element in the 2nd column starting at 4th row.
*/
start[0] = 3;
/* 4th row */
start[1] = 1;
/* 2nd column */
edges[0] = SUB1_LENGTH; /* SUB1_LENGTH elements are read along 2nd column*/
edges[1] = 1;
stride[0] = 3; /* every 3rd element is read along 2nd column */
stride[1] = 1;
December 2007
3-59
Related documents
Memorex LOCK - VERSION 2-24 Specifications
HDF-EOS Library User's Guide for the ECS Project, Volume 1
AZGCORR - Airborne Research & Survey Facility
EO-1/ Hyperion Science Data User's Guide
Gamma-Ray Identification of Nuclear Weapon Materials
Sharp IM-MT899H User's Manual
Sharp TINSE0568AWZZ Specifications
Sharp MD-MT888H Specifications