File: he5_sw_defunlimfld.c

package info (click to toggle)
hdf-eos5 2%3A2.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,692 kB
  • sloc: ansic: 92,051; fortran: 31,463; sh: 11,395; makefile: 492
file content (111 lines) | stat: -rwxr-xr-x 3,941 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 ----------------------------------------------------------------------------
 |    Copyright (C) 1999   Emergent IT Inc. and Raytheon Systems Company    |
 ----------------------------------------------------------------------------
 */


#include     <HE5_HdfEosDef.h>


/*  In this program we  (1) open the "Swath.h5" HDF-EOS file,   */
/*  (2) attach to the "Swath1" swath, and (3) define the swath  */
/*  fields, including appendable field "Spectra".               */
/* ------------------------------------------------------------ */


#define RANK 3

int main()
{

  herr_t      status = FAIL;

  hid_t       swfid  = FAIL;
  hid_t       SWid   = FAIL;

  int         comp_level[ 5 ] = { 0, 0, 0, 0, 0 };
  int         comp_code;

  hsize_t     chunk_dims[ 3 ];


  /* Open the file, "Swath.h5", using the H5F_ACC_RDWR access code */
  /* ------------------------------------------------------------- */
  swfid = HE5_SWopen("Swath.h5", H5F_ACC_RDWR);
  if (swfid != FAIL)
    {
	  SWid = HE5_SWattach(swfid, "Swath1");
	  if (SWid != FAIL)
		{	  
		  /*
		   * We define seven fields.  The first three, "Time", "Longitude"
		   * and "Latitude" are geolocation fields and thus we use the
		   * geolocation dimensions "GeoTrack" and "GeoXtrack" in the field
		   * definitions.
		   * 
		   * The next four fields are data fields.  Note that either
		   * geolocation or data dimensions can be used.
		   */
		  status = HE5_SWdefgeofield(SWid, "Time", "GeoTrack", NULL, H5T_NATIVE_DOUBLE, 0);
		  printf("Status returned by HE5_SWdefgeofield(...\"Time\",...) :         %d\n",status);
	    
		  status = HE5_SWdefgeofield(SWid, "Longitude", "GeoTrack,GeoXtrack", NULL, H5T_NATIVE_FLOAT, 0);
		  printf("Status returned by HE5_SWdefgeofield(...\"Longitude\",...) :    %d\n",status);

		  status = HE5_SWdefgeofield(SWid, "Latitude", "GeoTrack,GeoXtrack", NULL, H5T_NATIVE_FLOAT, 0);
		  printf("Status returned by HE5_SWdefgeofield(...\"Latitude\",...) :     %d\n",status);

		  status = HE5_SWdefdatafield(SWid, "Density", "GeoTrack", NULL, H5T_NATIVE_FLOAT, 0);
		  printf("Status returned by HE5_SWdefdatafield(...\"Density\",...) :     %d\n",status);

		  status = HE5_SWdefdatafield(SWid, "Temperature", "GeoTrack,GeoXtrack",NULL, H5T_NATIVE_FLOAT, 0);
		  printf("Status returned by HE5_SWdefdatafield(...\"Temperature\",...) : %d\n",status);

		  status = HE5_SWdefdatafield(SWid, "Pressure", "Res2tr,Res2xtr", NULL, H5T_NATIVE_DOUBLE, 0);
		  printf("Status returned by HE5_SWdefdatafield(...\"Pressure\",...) :    %d\n",status);

		  /* Define Appendable Field  */
		  /* ------------------------ */

		  /* ----------------------------------------  */
		  /*           First, define chunking          */
		  /* (the appendable dataset must be chunked)  */
		  /* ----------------------------------------  */
		  chunk_dims[0] = 15;
		  chunk_dims[1] = 40;
		  chunk_dims[2] = 20;
	    
             
		  status = HE5_SWdefchunk(SWid, RANK, chunk_dims);
		  printf("\tStatus returned by HE5_SWdefchunk() :                 %d\n",status);

		  comp_code     = 4;
                  /*comp_code     = 0;*/
		  comp_level[0] = 6;
                  /*comp_level[0] = 0;*/

		  status = HE5_SWdefcomp(SWid,comp_code, comp_level);
		  printf("\tStatus returned by HE5_SWdefcomp() :                  %d\n",status);

		  status = HE5_SWdefdatafield(SWid, "Spectra", "Bands,Res2tr,Res2xtr", "Unlim,Unlim,Unlim", H5T_NATIVE_FLOAT, 0);
		  printf("Status returned by HE5_SWdefdatafield(...\"Spectra\",...) :     %d\n",status);

                                    /* Define Profile field */
                  /* -------------------- */
                  status = HE5_PRdefine(SWid, "Profile-2000", "ProfDim", NULL, H5T_NATIVE_UINT);
                  printf("Status returned by HE5_PRdefine(...\"Profile-2000\",...) :      %d\n",status);

		}
    }

  status = HE5_SWdetach(SWid);
  status = HE5_SWclose(swfid);
  
  return 0;
}