/* * This example copies subregions of the satellite data 'SatelliteZenithAngle' * 'SatelliteAzimuthAngle' and 'SatelliteRange' under '/All_Data/VIIRS-MOD-GTM-EDR-GEO_All' * to one dataset,'Satellite', located at '/Data_Products/Subset' of the NPP * file. * Main illustrative functions: H5LRcreate_region_references and H5LRmake_dataset */ #include #include "hdf5.h" #include "hdf5_hl.h" #include "h5hl_region.h" #define filename "GMGTO_npp_d20030125_t0657104_e0659047_b00014_c20090811150425926728_unkn_SCI.h5" int main(void) { hid_t file_id; /* file identifier */ hsize_t block_coord[12] = {3, 51, 7, 53, 3, 51, 7, 53, 3, 51, 7, 53}; /* hyperslab coordinates, (3,51)-(7,53), for 'SatelliteZenithAngle', 'SatelliteAzimuthAngle', 'SatelliteRange' */ hdset_reg_ref_t ref_subset[3]; /* region references to hyperslabs of 'SatelliteZenithAngle', 'SatelliteAzimuthAngle', 'SatelliteRange' */ const char *path[3]; /* full paths to the satellite target datasets for the region references*/ hid_t file_id_array[3]; /* identifiers describing which HDF5 file the corresponding region reference belongs to*/ herr_t status; int i; path[0]= "/All_Data/VIIRS-MOD-GTM-EDR-GEO_All/SatelliteZenithAngle"; path[1]= "/All_Data/VIIRS-MOD-GTM-EDR-GEO_All/SatelliteAzimuthAngle"; path[2]= "/All_Data/VIIRS-MOD-GTM-EDR-GEO_All/SatelliteRange"; /* * Open the NPP file. */ file_id = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); /* * We are creating the data set in the same file, so fill the file_id path with the same file id. */ for (i = 0; i < 3; i++) file_id_array[i] = file_id; /* * Create three region references pointing to hyperslabs with block coordinates (3,51)-(7,53) in * 'SatelliteZenithAngle', 'SatelliteAzimuthAngle' and 'SatelliteRange' datasets. */ status = H5LRcreate_region_references(file_id, 3, path, block_coord, ref_subset); /* * Combine the three datasets into one dataset, 'Satellite', under '/Data_Products/Subset', * resulting in a final dataset of size (0,0)-(14,2). Notice the group 'Subset' did not exist * so the function automatically created the necessary intermediate group. */ status = H5LRmake_dataset(file_id, "/Data_Products/Subset/Satellite", H5T_NATIVE_FLOAT, 3, file_id_array, ( const hdset_reg_ref_t *)ref_subset); status = H5Fclose(file_id); }