File: he5_sw_datainfo.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 (170 lines) | stat: -rwxr-xr-x 6,130 bytes parent folder | download | duplicates (3)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
 ----------------------------------------------------------------------------
 |    Copyright (C) 1999   Emergent IT Inc. and Raytheon Systems Company    |  
 ----------------------------------------------------------------------------  
 */


#include   <HE5_HdfEosDef.h>


#define FILENAME   "Swath.h5"
#define OBJECT     "Swath1"


int main(void)
{
  herr_t       status     = FAIL;

  int          fieldgroup = FAIL;

  hid_t        fid      = FAIL;
  hid_t        SWid     = FAIL;
  hid_t        datatype = FAIL;

  H5T_class_t  classid = H5T_NO_CLASS;     
  H5T_order_t  order   = H5T_ORDER_ERROR;

  size_t       size    = 0;


  /* Open the HDF-EOS swath file */
  /* --------------------------- */
  fid = HE5_SWopen(FILENAME, H5F_ACC_RDONLY);
  printf("File ID returned by HE5_SWopen() :         %ld \n", (long) fid);
    
  /* Attach to the "Swath1" swath */
  /* ---------------------------- */
  SWid = HE5_SWattach(fid, OBJECT);
  printf("Swath ID returned by HE5_SWattach() :      %ld \n", (long) SWid);

  /* Inquire data type information for the "Spectra" field */
  /* ----------------------------------------------------- */
  fieldgroup = HE5_HDFE_DATAGROUP;
  status = HE5_SWinqdatatype(SWid, "Spectra", NULL, fieldgroup, &datatype, &classid, &order, &size);
  printf("Status returned by HE5_SWinqdatatype() :   %d \n", status);
  if (status != FAIL)
	{
	  printf("\tdatatype:    %ld \n", (long) datatype);
	  printf("\tclass ID:    %d \n", classid);
	  printf("\torder:       %d \n", order);
	  printf("\tsize:        %d \n", (int)size);        
	}

  /* Inquire data type information for the profile */
  /* --------------------------------------------- */
  fieldgroup = HE5_HDFE_PROFGROUP;
  status = HE5_SWinqdatatype(SWid, "Profile-2000", NULL, fieldgroup, &datatype, &classid, &order, &size);
  printf("Status returned by HE5_SWinqdatatype() :   %d \n", status);
  if (status != FAIL)
	{
	  printf("\tdatatype:    %ld \n", (long) datatype);
	  printf("\tclass ID:    %d \n", classid);
	  printf("\torder:       %d \n", order);
	  printf("\tsize:        %d \n", (int)size);        
	}

  /* Inquire data type information for the attributes */
  /* ------------------------------------------------ */
  status = HE5_EHinqglbdatatype(fid, "GlobalAttribute_1", &datatype, &classid, &order, &size);
  printf("Status returned by HE5_EHinqglbdatatype() :  %d \n", status);
  if (status != FAIL)
        {
          printf("\tdatatype:    %ld \n", (long) datatype);
          printf("\tclass ID:    %d \n", classid);
          printf("\torder:       %d \n", order);
          printf("\tsize:        %d \n", (int)size);
        }

  status = HE5_EHinqglbdatatype(fid, "GLOBAL_DOUBLE_ATTR_1", &datatype, &classid, &order, &size);
  printf("Status returned by HE5_EHinqglbdatatype()->GLOBAL_DOUBLE_ATTR_1  :  %d \n", status);
  if (status != FAIL)
        {
          printf("\tdatatype:    %ld \n", (long) datatype);
          printf("\tclass ID:    %d \n", classid);
          printf("\torder:       %d \n", order);
          printf("\tsize:        %d \n", (int)size);
        }

          
  fieldgroup = HE5_HDFE_ATTRGROUP;
  status = HE5_SWinqdatatype(SWid, NULL, "GlobalAttribute", fieldgroup, &datatype, &classid, &order, &size);
  printf("Status returned by HE5_SWinqdatatype() :   %d \n", status);
  if (status != FAIL)
	{
	  printf("\tdatatype:    %ld \n", (long) datatype);
	  printf("\tclass ID:    %d \n", classid);
	  printf("\torder:       %d \n", order);
	  printf("\tsize:        %d \n", (int)size);        
	}

  status = HE5_SWinqdatatype(SWid, NULL, "GLOBAL_CHAR_ATTR_11", fieldgroup, &datatype, &classid, &order, &size);
  printf("Status returned by HE5_SWinqdatatype()->GLOBAL_CHAR_ATTR_11 :   %d \n", status);
  if (status != FAIL)
        {
          printf("\tdatatype:    %ld \n", (long) datatype);
          printf("\tclass ID:    %d \n", classid);
          printf("\torder:       %d \n", order);
          printf("\tsize:        %d \n", (int)size);
        }

  status = HE5_SWinqdatatype(SWid, NULL, "GLOBAL_CHAR_ATTR", fieldgroup, &datatype, &classid, &order, &size);
  printf("Status returned by HE5_SWinqdatatype()->GLOBAL_CHAR_ATTR :   %d \n", status);
  if (status != FAIL)
        {
          printf("\tdatatype:    %ld \n", (long) datatype);
          printf("\tclass ID:    %d \n", classid);
          printf("\torder:       %d \n", order);
          printf("\tsize:        %d \n", (int)size);
        }

  fieldgroup = HE5_HDFE_GRPATTRGROUP;
  status = HE5_SWinqdatatype(SWid, NULL, "GroupAttribute", fieldgroup, &datatype, &classid, &order, &size);
  printf("Status returned by HE5_SWinqdatatype() :   %d \n", status);
  if (status != FAIL)
	{
	  printf("\tdatatype:    %ld \n", (long) datatype);
	  printf("\tclass ID:    %d \n", classid);
	  printf("\torder:       %d \n", order);
	  printf("\tsize:        %d \n", (int)size);        
	}

  fieldgroup = HE5_HDFE_LOCATTRGROUP;
  status = HE5_SWinqdatatype(SWid, "Density", "LocalAttribute_1", fieldgroup, &datatype, &classid, &order, &size);
  printf("Status returned by HE5_SWinqdatatype() :   %d \n", status);
  if (status != FAIL)
	{
	  printf("\tdatatype:    %ld \n", (long) datatype);
	  printf("\tclass ID:    %d \n", classid);
	  printf("\torder:       %d \n", order);
	  printf("\tsize:        %d \n", (int)size);        
	}

  fieldgroup = HE5_HDFE_LOCATTRGROUP;
  status = HE5_SWinqdatatype(SWid, "Longitude", "LocalAttribute_2", fieldgroup, &datatype, &classid, &order, &size);
  printf("Status returned by HE5_SWinqdatatype() :   %d \n", status);
  if (status != FAIL)
	{
	  printf("\tdatatype:    %ld \n", (long) datatype);
	  printf("\tclass ID:    %d \n", classid);
	  printf("\torder:       %d \n", order);
	  printf("\tsize:        %d \n", (int)size);        
	}

  /* Detach from the swath */
  /* --------------------- */
  status = HE5_SWdetach(SWid);
  printf("Status returned by HE5_SWdetach() :        %d \n", status);

  /* Close the file */
  /* -------------- */
  status = HE5_SWclose(fid);
  printf("Status returned by HE5_SWclose() :         %d \n", status);
    
  return(0);
    
}