OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
geocheck_modis.c
Go to the documentation of this file.
1 /*
2  Modification history:
3  Programmer Organization Date Description of change
4  -------------- ------------ -------- ---------------------
5  Joel Gales Futuretech 06/21/05 Original Development
6 
7 
8 gcc -g -c goodgeo.c -I/home/joel/hdf/include
9 gcc -g goodgeo.o /home/joel/hdf/lib/libmfhdf.a \
10 /home/joel/hdf/lib/libdf.a /home/joel/hdf/lib/libjpeg.a \
11 /home/joel/hdf/lib/libz.a -lm -o goodgeo
12 
13 scp goodgeo swdev@swdev:/home/swdev/bin
14 
15 scp goodgeo.c swdev@swdev:/home/swdev/src/goodgeo
16 
17  */
18 
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <math.h>
23 #include <string.h>
24 #include "hdf.h"
25 #include "mfhdf.h"
26 
27 #define VERSION "0.1"
28 
29 void usage(char *progname) {
30  printf("%s %s (%s %s)\n",
31  progname, VERSION, __DATE__, __TIME__);
32 
33  printf("\nUsage: %s geofile [threshold]\n", progname);
34  printf(" geofile = geolocation filename\n");
35  printf(" threshold = pass threshold in percent (default: 20)\n");
36  exit(0);
37 }
38 
39 int main(int argc, char *argv[]) {
40 
41  int32 i;
42  int32 k;
43  int32 n;
44  int32 sds_id;
45  int32 dims[8];
46  int32 rank;
47  int32 nelem;
48  int32 dtype;
49  int32 nattrs;
50  int32 status = 0;
51 
52  static char buffer[2 * 2048];
53 
54  float *data;
55 
56  int32 sd_id_r;
57  int32 sds_index;
58  int32 start[3] = {0, 0, 0};
59  int32 count;
60  double threshold;
61 
62  if (argc == 1) {
63  usage(argv[0]);
64  exit(0);
65  }
66 
67  if (argc == 2) threshold = 20.0;
68  else threshold = atof(argv[2]);
69 
70  sd_id_r = SDstart(argv[1], DFACC_RDONLY);
71  if (sd_id_r == -1) {
72  printf("%s not found.\n", argv[1]);
73  return -1;
74  }
75 
76  sds_index = SDnametoindex(sd_id_r, "Longitude");
77 
78  if (sds_index != -1) {
79  sds_id = SDselect(sd_id_r, sds_index);
80  status = SDgetinfo(sds_id, buffer, &rank, dims, &dtype, &nattrs);
81 
82  nelem = dims[0];
83  for (k = 1; k < rank; k++) nelem *= dims[k];
84 
85  data = (float *) calloc(nelem, DFKNTsize(dtype));
86 
87  status = SDreaddata(sds_id, start, NULL, dims, (VOIDP) data);
88 
89  count = 0;
90  for (i = 0; i < nelem; i++) if (data[i] == -999) count++;
91  n = (int32) rintf(100 * ((float32) nelem - count) / nelem);
92  printf("Percent Longitude good: %d\n", n);
93  if (n < threshold) status = -1;
94  } else status = -1;
95 
96 
97  sds_index = SDnametoindex(sd_id_r, "Latitude");
98 
99  if (sds_index != -1) {
100  sds_id = SDselect(sd_id_r, sds_index);
101  status = SDgetinfo(sds_id, buffer, &rank, dims, &dtype, &nattrs);
102 
103  nelem = dims[0];
104  for (k = 1; k < rank; k++) nelem *= dims[k];
105 
106  data = (float *) calloc(nelem, DFKNTsize(dtype));
107 
108  status = SDreaddata(sds_id, start, NULL, dims, (VOIDP) data);
109 
110  count = 0;
111  for (i = 0; i < nelem; i++) if (data[i] == -999) count++;
112  n = (int32) rintf(100 * ((float32) nelem - count) / nelem);
113  printf("Percent Latitude good: %d\n", n);
114  if (n < threshold) status = -1;
115  } else status = -1;
116 
117 
118  SDend(sd_id_r);
119 
120  return status;
121 }
122 
int status
Definition: l1_czcs_hdf.c:32
#define NULL
Definition: decode_rs.h:63
int main(int argc, char *argv[])
#define VERSION
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude data
Definition: HISTORY.txt:356
dtype
Definition: DDataset.hpp:31
Extra metadata that will be written to the HDF4 file l2prod rank
void usage(char *progname)
int i
Definition: decode_rs.h:71
int k
Definition: decode_rs.h:73
int count
Definition: decode_rs.h:79