/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at * * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Isayah Reed * Wednesday, May 4, 2011 * * Purpose: * This is a simple program that demonstrates how to use HDF-EOS5 to add CF * attributes to an h5 file. Creates a swath called Swath1 and adds the * temperature dataset with 2 dimensions: latitude and longitude. The * temperature dataset has the CF attributes: units, long_name, _FillValue, * coordinates, valid_min, valid_max, valid_range, scale_factor, add_offset. * Latitude and longitude have the CF attributes units and long_name. Outputs * data to general.h5 */ #include "HE5_HdfEosDef.h" #define NX1 180 #define NY1 360 #define TEMP "temp" #define LAT "lat" #define LON "lon" #define UNITS "Units" #define FILLVALUE "_FillValue" #define LONGNAME "long_name" #define COORDINATES "coordinates" #define STDNAME "standard_name" #define ADDOFFSET "add_offset" #define SCALEFACTOR "scale_factor" #define VALIDMIN "valid_min" #define VALIDMAX "valid_max" #define VALIDRANGE "valid_range" int main(void) { herr_t status= FAIL; hid_t swid, file, dataset, att; /* file, dataset, attribute handles */ hid_t dtype, dspace; hsize_t size[2]= {NX1, NY1}, temp_size; char *degrees_east= "degrees_east", *degrees_north= "degrees_north", *kelvin= "kelvin", *latitude= "latitude", *longitude= "longitude", *temperature= "temperature", *coorlist[2]= {"lat", "lon"}; float temp_array[NX1][NY1]; float lat_array[NX1][NY1]; float lon_array[NX1][NY1]; float value[1]; int i, j; /* PART 1: temp */ /* values between a[60][*] and a[120][*] is around 300.0 */ for(i=60; i<=120; i++) for(j=0; j