~ubuntu-branches/ubuntu/lucid/hdf-eos5/lucid

« back to all changes in this revision

Viewing changes to samples/he5_za_definefields.c

  • Committer: Bazaar Package Importer
  • Author(s): Alastair McKinstry
  • Date: 2009-08-17 23:07:29 UTC
  • Revision ID: james.westby@ubuntu.com-20090817230729-gzbwp1ny01hv2nlk
Tags: upstream-5.1.12.dfsg.1
ImportĀ upstreamĀ versionĀ 5.1.12.dfsg.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 ----------------------------------------------------------------------------
 
3
 |    Copyright (C) 2002   Emergent IT Inc. and Raytheon Systems Company    |
 
4
 ----------------------------------------------------------------------------
 
5
 */
 
6
 
 
7
#include     <HE5_config.h>
 
8
#include     <HE5_HdfEosDef.h>
 
9
 
 
10
#define  RANK   3
 
11
#define  rank   1
 
12
 
 
13
/* In this program we (1) open the "ZA.he5" HDF-EOS file, */
 
14
/* (2) attach to the "ZA1" za, and (3) define the fields */
 
15
/* ----------------------------------------------------- */
 
16
 
 
17
int main()
 
18
{
 
19
  
 
20
  herr_t      status = FAIL;
 
21
 
 
22
  int         comp_level[ 5 ] = {0,0,0,0,0};
 
23
  int         comp_code;
 
24
  
 
25
  hid_t       zafid = FAIL;
 
26
  hid_t       ZAid  = FAIL;
 
27
 
 
28
  hsize_t     chunk_dims[ 3 ];
 
29
  char        fillvalue[100] = "charname";
 
30
 
 
31
 
 
32
  /* Open the file, "ZA.he5", using the H5F_ACC_RDWR access code */
 
33
  /* ---------------------------------------------------------- */
 
34
  zafid = HE5_ZAopen("ZA.he5", H5F_ACC_RDWR);
 
35
  if (zafid != FAIL)
 
36
    {
 
37
          ZAid = HE5_ZAattach(zafid, "ZA1"); 
 
38
          if (ZAid != FAIL)
 
39
                {
 
40
                  status = HE5_ZAdefine(ZAid, "Density", "MyTrack1", NULL, H5T_NATIVE_FLOAT);
 
41
                  printf("Status returned by HE5_ZAdefine(...\"Density\",...) :     %d\n",status);
 
42
                  
 
43
                  status = HE5_ZAdefine(ZAid, "Temperature", "MyTrack1,MyTrack2",NULL, H5T_NATIVE_FLOAT);
 
44
                  printf("Status returned by HE5_ZAdefine(...\"Temperature\",...) : %d\n",status);
 
45
 
 
46
                  status = HE5_ZAdefine(ZAid, "Presure", "Res2tr,Res2xtr", NULL, H5T_NATIVE_DOUBLE);
 
47
                  printf("Status returned by HE5_ZAdefine(...\"Presure\",...) :    %d\n",status);
 
48
 
 
49
                  status = HE5_ZAsetfillvalue(ZAid, "Test_string", HE5T_CHARSTRING, fillvalue);
 
50
                  printf("Status returned by HE5_ZAsetfillvalue(...\"Test_string\",...) :     %d\n",status);
 
51
 
 
52
                  status = HE5_ZAdefine(ZAid, "Test_string", "MyTrack2", NULL, HE5T_CHARSTRING);
 
53
                  printf("Status returned by HE5_ZAdefine(...\"Test_string\",...) :     %d\n",status);
 
54
 
 
55
 
 
56
                  /* Define Appendable Field */
 
57
                  /* ----------------------- */
 
58
 
 
59
                  /*           First, define chunking          */
 
60
                  /* (the appendable dataset must be chunked)  */
 
61
                  /* ----------------------------------------  */
 
62
                  chunk_dims[0] = 15;
 
63
                  chunk_dims[1] = 40;
 
64
                  chunk_dims[2] = 20;
 
65
 
 
66
                  status = HE5_ZAdefchunk(ZAid, RANK, chunk_dims);
 
67
                  printf("\tStatus returned by HE5_ZAdefchunk() :                 %d\n",status);
 
68
 
 
69
                  /* Second, define compression scheme */
 
70
                  /* --------------------------------- */ 
 
71
                  
 
72
                  /* set the value of compression code: */
 
73
                  /*  HDFE_COMP_NONE                  0 */
 
74
                  /*  HDFE_COMP_RLE                   1 */   
 
75
                  /*  HDFE_COMP_NBIT                  2 */   
 
76
                  /*  HDFE_COMP_SKPHUFF               3 */   
 
77
                  /*  HDFE_COMP_DEFLATE               4 */           
 
78
                  /*  HDFE_COMP_SZIP_CHIP             5 */
 
79
                  /*  HDFE_COMP_SZIP_K13              6 */
 
80
                  /*  HDFE_COMP_SZIP_EC               7 */
 
81
                  /*  HDFE_COMP_SZIP_NN               8 */
 
82
                  /*  HDFE_COMP_SZIP_K13orEC          9 */
 
83
                  /*  HDFE_COMP_SZIP_K13orNN          10 */
 
84
                  /*  HDFE_COMP_SHUF_DEFLATE          11 */
 
85
                  /*  HDFE_COMP_SHUF_SZIP_CHIP        12 */
 
86
                  /*  HDFE_COMP_SHUF_SZIP_K13         13 */
 
87
                  /*  HDFE_COMP_SHUF_SZIP_EC          14 */
 
88
                  /*  HDFE_COMP_SHUF_SZIP_NN          15 */
 
89
                  /*  HDFE_COMP_SHUF_SZIP_K13orEC     16 */
 
90
                  /*  HDFE_COMP_SHUF_SZIP_K13orNN     17 */
 
91
                  comp_code = 9;
 
92
                  /*comp_code = 0;*/
 
93
 
 
94
                  /* Set compression level: value 0,1,2,3,4,5,6,7,8,9,10,16, or 32 */
 
95
                  /* ------------------------------------------------------------- */
 
96
                  comp_level[0] = 16;
 
97
                  /*comp_level[0] = 0;*/
 
98
                  
 
99
#ifdef HAVE_FILTER_SZIP_ENCODER
 
100
                  status = HE5_ZAdefcomp(ZAid,comp_code, comp_level);
 
101
                  printf("\tStatus returned by HE5_ZAdefcomp() :                  %d\n",status);
 
102
#else
 
103
                  printf("SZIP encoder is not available. The data compression test is skipped.\n");
 
104
#endif
 
105
 
 
106
                  status = HE5_ZAdefine(ZAid, "Spectra", "Bands,Res2tr,Res2xtr", NULL, H5T_NATIVE_FLOAT);
 
107
                  printf("Status returned by HE5_ZAdefine(...\"Spectra\",...) :     %d\n",status);
 
108
 
 
109
                  /* Define Appendable Field */
 
110
                  /* ----------------------- */
 
111
 
 
112
                  /*           First, define chunking          */
 
113
                  /* (the appendable dataset must be chunked)  */
 
114
                  /* ----------------------------------------  */
 
115
                  chunk_dims[0] = 20;
 
116
 
 
117
                  status = HE5_ZAdefchunk(ZAid, rank, chunk_dims);
 
118
                  printf("\tStatus returned by HE5_ZAdefchunk() :                 %d\n",status);
 
119
 
 
120
                  /* Second, define compression scheme */
 
121
                  /* --------------------------------- */
 
122
 
 
123
                  /* set the value of compression code: */
 
124
                  /*  HDFE_COMP_NONE                  0 */
 
125
                  /*  HDFE_COMP_RLE                   1 */
 
126
                  /*  HDFE_COMP_NBIT                  2 */
 
127
                  /*  HDFE_COMP_SKPHUFF               3 */
 
128
                  /*  HDFE_COMP_DEFLATE               4 */
 
129
                  /*  HDFE_COMP_SZIP_CHIP             5 */
 
130
                  /*  HDFE_COMP_SZIP_K13              6 */
 
131
                  /*  HDFE_COMP_SZIP_EC               7 */
 
132
                  /*  HDFE_COMP_SZIP_NN               8 */
 
133
                  /*  HDFE_COMP_SZIP_K13orEC          9 */
 
134
                  /*  HDFE_COMP_SZIP_K13orNN          10 */
 
135
                  /*  HDFE_COMP_SHUF_DEFLATE          11 */
 
136
                  /*  HDFE_COMP_SHUF_SZIP_CHIP        12 */
 
137
                  /*  HDFE_COMP_SHUF_SZIP_K13         13 */
 
138
                  /*  HDFE_COMP_SHUF_SZIP_EC          14 */
 
139
                  /*  HDFE_COMP_SHUF_SZIP_NN          15 */
 
140
                  /*  HDFE_COMP_SHUF_SZIP_K13orEC     16  */
 
141
                  /*  HDFE_COMP_SHUF_SZIP_K13orNN     17  */
 
142
                  comp_code = 16;
 
143
                  /*comp_code = 0;*/
 
144
 
 
145
                  /* Set compression level: value 0,1,2,3,4,5,6,7,8,9,10,16, or 32 */
 
146
                  /* ------------------------------------------------------------- */
 
147
                  comp_level[0] = 2;
 
148
                  /*comp_level[0] = 0;*/
 
149
 
 
150
#ifdef HAVE_FILTER_SZIP_ENCODER
 
151
                  status = HE5_ZAdefcomp(ZAid,comp_code, comp_level);
 
152
                  printf("\tStatus returned by HE5_ZAdefcomp() :                  %d\n",status);
 
153
#else
 
154
                  printf("SZIP encoder is not available. The data compression test is skipped.\n");
 
155
#endif
 
156
 
 
157
                  status = HE5_ZAdefine(ZAid, "Count", "MyTrack1", "Unlim", H5T_NATIVE_INT);
 
158
                  printf("Status returned by HE5_ZAdefine(...\"Count\",...) :       %d\n",status);
 
159
 
 
160
                }
 
161
    }
 
162
  
 
163
  status = HE5_ZAdetach(ZAid);
 
164
  status = HE5_ZAclose(zafid);
 
165
  
 
166
  return 0;
 
167
}
 
168
 
 
169
 
 
170
 
 
171
 
 
172