OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
l1stat_chk.c
Go to the documentation of this file.
1 #include "l1stat.h"
2 #include "l1stat_proto.h"
3 #include <libgen.h>
4 
5 #define SET 1
6 
7 char err_msg[1024];
8 int32 stat_status = 0; /* status of statistical checking: 0 all good,
9  1 program problem, 2 statistical problem,
10  3 both problems */
11 char bad_stat_str[320]; /* summary of all mnemonics that were bad to report */
12 
13 int main(int argc, char *argv[])
14 /*******************************************************************
15 
16  l1stat_chk
17 
18  purpose: open the SeaWiFS dataset and check the data values against
19  given thresholds
20 
21  Returns type: none
22 
23  Parameters: (in calling order)
24  Type Name I/O Description
25  ---- ---- --- -----------
26  int argc I count of input args
27  char * argv[] I args: [1] hdf file
28  [2] controls file
29 
30  Modification history:
31  Programmer Date Description of change
32  ---------- ---- ---------------------
33  L. Kumar 04-Apr-1996 Original development
34  W. Robinson, GSC 31-Jul- 1998 add code to test for the amount
35  of noise and trouble in telemetry
36  SDs and report if the problem
37  is too large
38  W. Robinson, GSC 29-Dec-1999 add capability for doing classified
39  land and water comparisons to mapped
40  values (start of changes)
41  W. Robinson, GSC 17-Jan-2001 add checking of (-) time changes for
42  GAC files
43  W. Robinson, SAIC 24 Oct 2001 add controls for the noise and
44  encryption % in file for reporting an error
45  W. Robinson, SAIC 25 Jun 2002 add time dependence control to neg
46  time, inst_ana, tdi and gain value checks
47 
48  *******************************************************************/ {
49  int16 tilt_ranges[20][2], tilt_flags[20], dtynum, rpt_negtim;
50  int32 fid, sdfid;
51  int32 i, nsamp, nscans, ntilts;
52  float32 nav_thresh1 = -999, nav_thresh2 = -999, l1tilt_thresh = -999,
53  pct_noise_thresh, pct_encrypt_thresh;
54  char fsttim[14];
55  cntl1_str gn1[8], gn2[8], zero[8];
56  cntl2_str l1hicnt[8], l1locnt[8];
57  thr_ctl_def thr_ctl;
58  int *spike_cnt;
59  float *line_sd;
60 
61 
62  bad_stat_str[0] = (char) 0;
63  /*
64  * Check input arguments
65  */
66 
67  if (argc != 3) {
68  printf("\n******* Usage: l1stat_chk <hdf file> <control file> \n");
69  printf("\t\t<hdf file> is level 1 data file\n");
70  printf("\t\t<control file> is the file specifying thresholds\n");
71  printf("\nOn exit, $status will be set to: \n\t0 - no problems,"
72  "\n\t1 - program error, ");
73  printf("\n\t2 - data problem, \n\t3 - both program and data problem\n");
76  }
77 
78  printf("\n\n# Statistical Check of Dataset '%s'\n\n", argv[1]);
79 
80  /*
81  * Initialize input structures
82  */
83 
84  for (i = 0; i < 8; i++) {
85  gn1[i].band = gn2[i].band = zero[i].band = 0;
86  gn1[i].threshold = gn2[i].threshold = zero[i].threshold = 0;
87  l1hicnt[i].band = l1locnt[i].band = 0;
88  l1hicnt[i].err_thresh = l1hicnt[i].cnt_thresh = 0;
89  l1locnt[i].err_thresh = l1locnt[i].cnt_thresh = 0;
90  }
91 
92  /*
93  * hopen will open the file and read data descriptor blocks
94  * to memory
95  */
96 
97  if ((fid = Hopen(argv[1], DFACC_RDONLY, 0)) < 0) {
98  printf("****** L1stat_chk: Failed on the Hopen of \n\t'%s'\n", argv[1]);
99  stat_status = 1;
101  }
102 
103  /*
104  * SDstart opens the hdf interface and initiates SD interface
105  */
106 
107  if ((sdfid = SDstart(argv[1], DFACC_RDONLY)) < 0) {
108  printf("******* L1stat_chk: Failure at SDstart of \n'%s'\n", argv[1]);
109  Hclose(fid);
110  stat_status = 1;
112  }
113  /*
114  * get the file start time for time-dependent checks
115  */
116  strncpy(fsttim, basename(argv[1]) + 1, 13);
117 
118  /*
119  * Read control file and save the information. If the return value
120  * is -1, it means, some prolblem with opening control data file or
121  * with some control format, close HDF file, and exit with status set
122  * to 1 indicating program error.
123  */
124 
125  if ((read_cntldata(argv[2], fsttim, gn1, gn2, zero, l1hicnt,
126  l1locnt, &nav_thresh1, &nav_thresh2,
127  &l1tilt_thresh, &pct_noise_thresh,
128  &pct_encrypt_thresh, &thr_ctl, &rpt_negtim)) < 0) {
129  Hclose(fid);
131  }
132 
133  /*
134  * Verify if given input file is a level 1 file
135  */
136 
137  if ((l1file(sdfid, &nsamp, &nscans, &dtynum)) < 0) {
138  Hclose(fid);
139  printf("******* %s", err_msg);
141  }
142 
143  /*
144  * Verify Level 1 and Level 2 gain
145  */
146  if ((dtynum == GAC) || (dtynum == LAC) || (dtynum == HRPT)) {
147  if ((chk_gn(sdfid, gn1, gn2, dtynum, nsamp, nscans)) < 0)
148  printf("\n******* %s", err_msg);
149  }
150 
151  /*
152  * Verify Zero pixels
153  */
154  if ((dtynum == GAC) || (dtynum == LAC) || (dtynum == HRPT)) {
155  if ((chk_zero(sdfid, zero, nscans, nsamp)) < 0)
156  printf("\n******* %s", err_msg);
157  }
158 
159  /*
160  * Verify High and Low count of pixels
161  */
162  if ((spike_cnt = (int *) calloc(8 * nscans, sizeof ( int))) == NULL) {
163  printf("\n******** l1stat_chk: failure to allocate spike_cnt storage\n");
164  Hclose(fid);
165  stat_status = stat_status | 1;
167  }
168  if ((line_sd = (float *) malloc(8 * nscans * sizeof ( float))) == NULL) {
169  printf("\n******** l1stat_chk: failure to allocate line_sd storage\n");
170  Hclose(fid);
171  stat_status = stat_status | 1;
173  }
174  if ((chk_count(sdfid, nscans, nsamp, dtynum, l1hicnt, l1locnt, spike_cnt, line_sd)) < 0)
175  printf("\n******** %s", err_msg);
176 
177  /*
178  * Verify Tilt behavior to make sure tilt change lasts < 20 secs.
179  */
180  if ((l1tilt_thresh != -999) &&
181  ((dtynum == GAC) || (dtynum == LAC) || (dtynum == HRPT))) {
182  if ((chk_tilt(sdfid, dtynum, l1tilt_thresh, &ntilts, tilt_ranges,
183  tilt_flags)) < 0)
184  printf("\n******** %s", err_msg);
185  }
186 
187  /*
188  * Verify Navigation discontinuity if requested
189  */
190  if ((nav_thresh1 != -999 && nav_thresh2 != -999) &&
191  ((dtynum == GAC) || (dtynum == LAC) || (dtynum == HRPT))) {
192  if ((chk_nav(sdfid, nscans, nav_thresh1, nav_thresh2, ntilts,
193  tilt_ranges, tilt_flags, dtynum, rpt_negtim)) < 0)
194  printf("\n********* %s", err_msg);
195  }
196 
197  /*
198  * check file to be outside restricted time ranges
199  */
200  if ((thr_ctl.trng_chk_do == 1) &&
201  ((dtynum == GAC) || (dtynum == LAC) || (dtynum == HRPT)))
202  ck_trng(argv[1]);
203 
204  /*
205  * get other noise indicators and do a final report
206  */
207  rpt_noise(sdfid, dtynum, nscans, nsamp, spike_cnt, line_sd,
208  pct_noise_thresh, pct_encrypt_thresh);
209  /*
210  * check the instrument analog telemetry to find any unusual departures
211  */
212  if (dtynum == GAC) chk_inst_ana(sdfid, nscans, thr_ctl);
213  /*
214  * Check the gain setting for correctness
215  */
216  chk_gainv(sdfid, dtynum, nscans, thr_ctl);
217  /*
218  * Check the TDI settings
219  */
220  chk_tdiv(sdfid, dtynum, nscans, thr_ctl);
221 
222  Hclose(fid);
224 
225  return 0;
226 }
227 
228 /****************************************************************************
229  read_cntldata
230 
231  purpose: Opens given control file and reads in the mnemonics and thresholds
232  given. If any error occurs, prints out an error message,
233  sets stat_status field and returns a negative 1.
234 
235  Returns type: integer
236 
237  Parameters: (in calling order)
238  Type Name I/O Description
239  ---- ---- --- -----------
240  char * cntl_file I control file path/name
241  char * fsttim I input file start time, format
242  YYYYDDDHHMMSS
243  cntl1_str * gn1 O structure to hold gain1 control
244  data
245  cntl1_str * gn1 O structure to hold gain2 control
246  data
247  cntl1_str * zero O struct to hold Zero pix controls
248  cntl2_str * l1hicnt O struct to hold hight count
249  control infomration
250  cntl2_str * l1locnt O struct to hold low count
251  control data
252  float32 * nav_thresh1 O threshold 1 of L1NAVDISC
253  float32 * nav_thresh2 O threshold 2 of L1NAVDISC
254  float32 * l1tilt_thresh O threshold for L1TILT
255  float32 * pct_noise_thresh O limit for % of lines with
256  noise for reporting
257  float32 * pct_encrypt_thresh O limit for % of lines with
258  encryption for reporting
259  thr_ctl_def * thr_ctl O threshold controls for the
260  instrument analog values, the
261  gain check values
262  int16 * rpt_negtim O if = 1, fail file if negative
263  time step happens
264 
265  Modification history:
266  Programmer Date Description of change
267  ---------- ---- ---------------------
268  L. Kumar 04-Apr-1996 Original development
269  W. Robinson, SAIC 25-Jun-2002 get the controls for time-dependent
270  group checks of neg delta time, inst_ana
271  tdi and gain checks
272  W. Robinson, SAIC 25-Mar-2010 set up bnd as a null terminated
273  array for safety
274 
275  ****************************************************************************/
276 int32 read_cntldata(char *cntl_file, char *fsttim, cntl1_str *gn1,
277  cntl1_str *gn2, cntl1_str *zero, cntl2_str *l1hicnt,
278  cntl2_str *l1locnt, float32 *nav_thresh1,
279  float32 *nav_thresh2, float32 *l1tilt_thresh,
280  float32 *pct_noise_thresh, float32 *pct_encrypt_thresh,
281  thr_ctl_def *thr_ctl, int16 *rpt_negtim) {
282  FILE *fid;
283  char line[501], str[25], bnd[2], tstr[14];
284  int32 i, band, nflds = 0, ival;
285  float32 threshold, cnt_thresh, err_thresh, f1, f2, f3;
286 
287  printf("\n# Reading control file '%s'\n\n", cntl_file);
288 
289  /*
290  * Open the file
291  */
292  if ((fid = fopen(cntl_file, "r")) == NULL) {
293  printf("********read_cntldata: Unable to open control file:\n\t'%s'\n",
294  cntl_file);
295  stat_status = stat_status | 1;
296  return FAIL;
297  }
298 
299  /*
300  * Initialize all input structrues
301  */
302  thr_ctl->trng_chk_do = 0;
303  for (i = 0; i < 8; i++) {
304  gn1[i].band = gn2[i].band = 0;
305  gn1[i].threshold = gn2[i].threshold = 0;
306  thr_ctl->gainv_chk_do[i] = 0;
307  }
308  for (i = 0; i < 32; i++)
309  thr_ctl->inst_ana_do[i] = 0;
310 
311  thr_ctl->rpt_tdi_vchk = 1; /* default is to report occurences */
312  thr_ctl->rpt_gainv_chk = 1; /* default is to report occurences */
313  thr_ctl->rpt_inst_ana = 1; /* default is to report occurences */
314  *rpt_negtim = 1; /* default is to report neg time occurences */
315 
316  while (fgets(line, 500, fid) != NULL) {
317  /* Ignore beginning blanks and tabs */
318  for (i = 0; i < 500 && (line[i] == ' ' || line[i] == '\t'); i++);
319 
320  /* If first character is '#' sign, then treat the line as comment */
321  if (i < 500 && line[i] == '#') {
322  printf("%s", line);
323  continue;
324  }
325 
326  /* If not comment, check if it is GAIN 1 or GAIN 2 info */
327  printf("#%s", line);
328  if (strncmp(&line[i], "L1GAIN", 6) == 0) {
329  if ((nflds = sscanf(line, "%s %f", str, &threshold)) != 2) {
330  printf("\n*********read_cntldata: expecting 2 fields");
331  printf(" but read %d field(s)", nflds);
332  stat_status = stat_status | 1;
333  return FAIL;
334  }
335  bnd[0] = str[7];
336  bnd[1] = 0;
337  band = atoi(bnd);
338  if (band < 1 || band > 8) {
339  printf("********read_cntldata: Error in band number.");
340  printf(" Band # read = %d", band);
341  stat_status = stat_status | 1;
342  return FAIL;
343  }
344  if (str[6] == '1') {
345  gn1[band - 1].band = 1;
346  gn1[band - 1].threshold = threshold;
347  } else if (str[6] == '2') {
348  gn2[band - 1].band = 1;
349  gn2[band - 1].threshold = threshold;
350  }
351  } else if (strncmp(&line[i], "L1ZERO", 6) == 0) {
352  if ((nflds = sscanf(line, "%s %f", str, &threshold)) != 2) {
353  printf("*********read_cntldata: expecting 2 fields");
354  printf(" but read %d field(s)", nflds);
355  stat_status = stat_status | 1;
356  return FAIL;
357  }
358  bnd[0] = str[6];
359  band = atoi(bnd);
360  if (band < 1 || band > 8) {
361  printf("********read_cntldata: Error in band number.");
362  printf(" Band # read = %d", band);
363  stat_status = stat_status | 1;
364  return FAIL;
365  }
366  zero[band - 1].band = 1;
367  zero[band - 1].threshold = threshold;
368  } else if (strncmp(&line[i], "L1HICOUNT", 9) == 0) {
369  if ((nflds = sscanf(line, "%s %f %f", str, &err_thresh, &cnt_thresh))
370  != 3) {
371  printf("*********read_cntldata: expecting 3 fields");
372  printf(" but read %d field(s)", nflds);
373  stat_status = stat_status | 1;
374  return FAIL;
375  }
376  bnd[0] = str[9];
377  band = atoi(bnd);
378  if (band < 1 || band > 8) {
379  printf("*********read_cntldata: Error in band number.");
380  printf(" Band # read = %d", band);
381  stat_status = stat_status | 1;
382  return FAIL;
383  }
384  l1hicnt[band - 1].band = 1;
385  l1hicnt[band - 1].err_thresh = err_thresh;
386  l1hicnt[band - 1].cnt_thresh = cnt_thresh;
387  } else if (strncmp(&line[i], "L1LOWCOUNT", 10) == 0) {
388  if ((nflds = sscanf(line, "%s %f %f", str, &err_thresh, &cnt_thresh))
389  != 3) {
390  printf("*********read_cntldata: expecting 3 fields");
391  printf(" but read %d field(s)", nflds);
392  stat_status = stat_status | 1;
393  return FAIL;
394  }
395  bnd[0] = str[10];
396  band = atoi(bnd);
397  if (band < 1 || band > 8) {
398  printf("*********read_cntldata: Error in band number.");
399  printf(" Band # read = %d", band);
400  stat_status = stat_status | 1;
401  return FAIL;
402  }
403  l1locnt[band - 1].band = 1;
404  l1locnt[band - 1].err_thresh = err_thresh;
405  l1locnt[band - 1].cnt_thresh = cnt_thresh;
406  } else if (strncmp(&line[i], "L1TILT", 6) == 0) {
407  if ((nflds = sscanf(line, "%s %f", str, l1tilt_thresh)) != 2) {
408  printf("*********read_cntldata: expecting 2 fields");
409  printf(" but read %d field(s)", nflds);
410  stat_status = stat_status | 1;
411  return FAIL;
412  }
413  } /*
414  * WDR new check of time limit on neg time check
415  */
416  else if (strncmp(&line[i], "TLIM_NEGTIM", 11) == 0) {
417  if ((nflds = sscanf(line, "%s %s", str, tstr)) != 2) {
418  printf("***** read_cntldata: expecting 2 fields for TLIM_NEGTIM\n");
419  printf(" but read %d field(s)", nflds);
420  stat_status = stat_status | 1;
421  return FAIL;
422  }
423  *rpt_negtim = 1;
424  if (strncmp(fsttim, tstr, 13) < 0) *rpt_negtim = 0;
425  } else if (strncmp(&line[i], "L1NAVDISC", 9) == 0) {
426  if ((nflds = sscanf(line, "%s %f %f", str, nav_thresh1, nav_thresh2))
427  != 3) {
428  printf("*********read_cntldata: expecting 3 fields");
429  printf(" but read %d field(s)", nflds);
430  stat_status = stat_status | 1;
431  return FAIL;
432  }
433  } else if (strncmp(&line[i], "NOISE", 5) == 0) {
434  if ((nflds = sscanf(line, "%s %f", str, pct_noise_thresh)) != 2) {
435  printf("*********read_cntldata: NOISE: expecting 2 fields");
436  printf(" but read %d field(s)", nflds);
437  stat_status = stat_status | 1;
438  return FAIL;
439  }
440  } else if (strncmp(&line[i], "ENCRYPT", 7) == 0) {
441  if ((nflds = sscanf(line, "%s %f", str, pct_encrypt_thresh)) != 2) {
442  printf("*********read_cntldata: ENCRYPT: expecting 2 fields");
443  printf(" but read %d field(s)", nflds);
444  stat_status = stat_status | 1;
445  return FAIL;
446  }
447  } else if (strncmp(&line[i], "TRNG_CHK", 8) == 0) {
448  if ((nflds = sscanf(line, "%s", str)) != 1) {
449  printf("*********read_cntldata: TRNG_CHK: expecting 1 field");
450  printf(" but read %d field(s)", nflds);
451  stat_status = stat_status | 1;
452  return FAIL;
453  }
454  thr_ctl->trng_chk_do = 1;
455  } /*
456  * WDR new time limit check for inst_ana
457  */
458  else if (strncmp(&line[i], "TLIM_INST_ANA", 13) == 0) {
459  if ((nflds = sscanf(line, "%s %s", str, tstr)) != 2) {
460  printf("***** read_cntldata: expecting 2 fields for TLIM_INST_ANA\n");
461  printf(" but read %d field(s)", nflds);
462  stat_status = stat_status | 1;
463  return FAIL;
464  }
465  thr_ctl->rpt_inst_ana = 1;
466  if (strncmp(fsttim, tstr, 13) < 0) thr_ctl->rpt_inst_ana = 0;
467  } else if (strncmp(&line[i], "INST_ANA", 8) == 0) {
468  if ((nflds = sscanf(line,
469  "INST_ANA%2d %f %f %f", &ival, &f1, &f2, &f3)) != 4) {
470  printf("********read_cntldata: Error in INST_ANA line decode\n");
471  printf("# fields read: %d\n", nflds);
472  printf("Line is:\n%s\n\n", line);
473  stat_status = stat_status | 1;
474  return FAIL;
475  }
476  /*
477  * for the inst_ana, get the thresholds
478  */
479  if ((ival < 1) || (ival > 32)) {
480  printf("********read_cntldata: Error in INST_ANA item #\n");
481  printf("It must be from 1 - 32 and the entered value was %d\n",
482  ival);
483  stat_status = stat_status | 1;
484  return FAIL;
485  }
486  thr_ctl->inst_ana_do[ ival - 1 ] = 1;
487  thr_ctl->inst_ana_lo[ ival - 1 ] = f1;
488  thr_ctl->inst_ana_hi[ ival - 1 ] = f2;
489  thr_ctl->inst_ana_pct[ ival - 1 ] = f3;
490  } /*
491  * WDR new time limit check for gain value
492  */
493  else if (strncmp(&line[i], "TLIM_GAINV_CHK", 14) == 0) {
494  if ((nflds = sscanf(line, "%s %s", str, tstr)) != 2) {
495  printf("***** read_cntldata: expecting 2 fields for TLIM_GAINV_CHK\n");
496  printf(" but read %d field(s)", nflds);
497  stat_status = stat_status | 1;
498  return FAIL;
499  }
500  thr_ctl->rpt_gainv_chk = 1;
501  if (strncmp(fsttim, tstr, 13) < 0) thr_ctl->rpt_gainv_chk = 0;
502  } else if (strncmp(&line[i], "GAINV_CHK", 9) == 0) {
503  if ((nflds = sscanf(line, "GAINV_CHK%1d %f", &ival, &f1)) != 2) {
504  printf("********read_cntldata: Error in GAINV_CHK line decode\n");
505  printf("# fields read: %d\n", nflds);
506  printf("Line is:\n%s\n\n", line);
507  stat_status = stat_status | 1;
508  return FAIL;
509  }
510  /*
511  * for the gainv_chk, get the % error acceptable
512  */
513  if ((ival < 1) || (ival > 8)) {
514  printf("********read_cntldata: Error in GAINV_CHK item #\n");
515  printf("It must be from 1 - 8 and the entered value was %d\n",
516  ival);
517  stat_status = stat_status | 1;
518  return FAIL;
519  }
520  thr_ctl->gainv_chk_do[ ival - 1 ] = 1;
521  thr_ctl->gainv_chk_pct[ ival - 1 ] = f1;
522  } /*
523  * WDR new time limit check for gain value
524  */
525  else if (strncmp(&line[i], "TLIM_TDIV_CHK", 13) == 0) {
526  if ((nflds = sscanf(line, "%s %s", str, tstr)) != 2) {
527  printf("***** read_cntldata: expecting 2 fields for TLIM_TDIV_CHK\n");
528  printf(" but read %d field(s)", nflds);
529  stat_status = stat_status | 1;
530  return FAIL;
531  }
532  thr_ctl->rpt_tdi_vchk = 1;
533  if (strncmp(fsttim, tstr, 13) < 0) thr_ctl->rpt_tdi_vchk = 0;
534  } else if (strncmp(&line[i], "TDIV_CHK", 8) == 0) {
535  if ((nflds = sscanf(line, "TDIV_CHK%1d %f", &ival, &f1)) != 2) {
536  printf("********read_cntldata: Error in TDIV_CHK line decode\n");
537  printf("# fields read: %d\n", nflds);
538  printf("Line is:\n%s\n\n", line);
539  stat_status = stat_status | 1;
540  return FAIL;
541  }
542  /*
543  * for the tdiv_chk, get the % error acceptable
544  */
545  if ((ival < 1) || (ival > 8)) {
546  printf("********read_cntldata: Error in TDIV_CHK item #\n");
547  printf("It must be from 1 - 8 and the entered value was %d\n",
548  ival);
549  stat_status = stat_status | 1;
550  return FAIL;
551  }
552  thr_ctl->tdiv_chk_do[ ival - 1 ] = 1;
553  thr_ctl->tdiv_chk_pct[ ival - 1 ] = f1;
554  } else {
555  printf("*********read_cntldata: Cannot recognize the mnemonic read");
556  stat_status = stat_status | 1;
557  return FAIL;
558  }
559  }
560  return SUCCEED;
561 }
562 
563 /****************************************************************************
564  l1file
565 
566  purpose: Verifies if the given input file is level 1 data file
567 
568  Returns type: integer
569 
570  Parameters: (in calling order)
571  Type Name I/O Description
572  ---- ---- --- -----------
573  int32 sdfid I SD interface ID
574  int32 * nsamp O number of samples/pixels
575  int32 * nscans O number of scan lines
576  int16 * dtynum O data type number
577  representation: GAC 0, LAC 1,
578  HRPT 2, LUN 3, SOL 4, IGC 5, TDI 6
579 
580  Modification history:
581  Programmer Date Description of change
582  ---------- ---- ---------------------
583  L. Kumar 04-Apr-1996 Original development
584 
585  ****************************************************************************/
586 int32 l1file(int32 sdfid, int32 *nsamp, int32 *nscans, int16 *dtynum) {
587  char title[1024];
588  char dtype[500];
589 
590  /*
591  * Read title to verify if the given input file is level 1A data file
592  */
593 
594  if ((rdattr(sdfid, TITLE, &title)) < 0)
595  return FAIL;
596 
597  if (strcmp(title, "SeaWiFS Level-1A Data") != 0) {
598  sprintf(err_msg, "l1file: Data file is not level 1A file");
599  stat_status = stat_status | 1;
600  return FAIL;
601  }
602 
603  if ((rdattr(sdfid, NSAMP, (VOIDP *) nsamp)) < 0)
604  return FAIL;
605 
606  if ((rdattr(sdfid, NSCANS, (VOIDP *) nscans)) < 0)
607  return FAIL;
608 
609  if ((rdattr(sdfid, DTYPE, dtype)) < 0)
610  return FAIL;
611  if (strncmp(dtype, "GAC", 3) == 0) {
612  *dtynum = (int16) 0;
613  } else if (strncmp(dtype, "LAC", 3) == 0) {
614  *dtynum = (int16) 1;
615  } else if (strncmp(dtype, "HRPT", 4) == 0) {
616  *dtynum = (int16) 2;
617  } else if (strncmp(dtype, "LUN", 3) == 0) {
618  *dtynum = (int16) 3;
619  } else if (strncmp(dtype, "SOL", 3) == 0) {
620  *dtynum = (int16) 4;
621  } else if (strncmp(dtype, "IGC", 3) == 0) {
622  *dtynum = (int16) 5;
623  } else if (strncmp(dtype, "TDI", 3) == 0) {
624  *dtynum = (int16) 6;
625  } else {
626  printf("Data type of '%s' is unknown. Exiting\n", dtype);
627  return FAIL;
628  }
629 
630  return SUCCEED;
631 }
632 
633 /****************************************************************************
634  chk_gn
635 
636  purpose: Verifies gain 1 and 2 saturated percentage against the given
637  thresholds for requested bands
638 
639  Returns type: integer
640 
641  Parameters: (in calling order)
642  Type Name I/O Description
643  ---- ---- --- -----------
644  int32 sdfid I SD interface ID
645  cntl1_str * gn1 I structure containing gain1
646  band numbers and thresholds
647  cntl1_str * gn2 I structure containing gain2
648  band numbers and thresholds
649  int16 dtynum I data type number
650  int32 nsamp I number of samples
651  int32 * nscans I number of scanlines
652 
653  Modification history:
654  Programmer Date Description of change
655  ---------- ---- ---------------------
656  L. Kumar 04-Apr-1996 Original development
657  W. Robinson 31-Dec-1997 switch to checking % of good
658  gains for image data
659 
660  ****************************************************************************/
661 int32 chk_gn(int32 sdfid, cntl1_str *gn1, cntl1_str *gn2, int16 dtynum,
662  int32 nsamp, int32 nscans) {
663  int32 i, gn1sat[8], gn2sat[8], gn1unsat[8], gn2unsat[8];
664  int32 failcode = 0;
665  float64 gn1_val[8], gn2_val[8];
666  float pct_good_gain;
667  char str[12];
668 
669  printf("\n#Checking Level 1 and Level 2 gains ....");
670 
671  /*
672  * Following few lines Initializes value buffers
673  * Reads gain1 and gain 2 saturated and non-saturated pixel values from
674  * global attributes of input data file
675  */
676  for (i = 0; i < 8; i++)
677  gn1_val[i] = gn2_val[i] = 0;
678 
679  if ((rdattr(sdfid, GN1SAT, (VOIDP *) gn1sat)) < 0)
680  return FAIL;
681 
682  if ((rdattr(sdfid, GN2SAT, (VOIDP *) gn2sat)) < 0)
683  return FAIL;
684 
685  if ((rdattr(sdfid, GN1UNSAT, (VOIDP *) gn1unsat)) < 0)
686  return FAIL;
687 
688  if ((rdattr(sdfid, GN2UNSAT, (VOIDP *) gn2unsat)) < 0)
689  return FAIL;
690 
691 
692  /*
693  * If gain 1 is > 0, calculate saturated percentage
694  * else, set value to -1, indicating success
695  */
696  for (i = 0; i < 8; i++) {
697  if ((gn1sat[i] + gn1unsat[i]) > 0)
698  gn1_val[i] = ((float64) gn1sat[i] / (gn1sat[i] + gn1unsat[i])) * 100;
699  else
700  gn1_val[i] = -1;
701 
702  if ((gn2sat[i] + gn2unsat[i]) > 0)
703  gn2_val[i] = ((float64) gn2sat[i] / (gn2sat[i] + gn2unsat[i]))*100;
704  else
705  gn2_val[i] = -1;
706  }
707 
708  /*
709  * Check to see if all the saturated and unsaturated pixel count matches
710  * total number of pixels for each band
711  */
712  if ((dtynum == GAC) || (dtynum == LAC) || (dtynum == HRPT))
713  for (i = 0; i < 8; i++) {
714  pct_good_gain =
715  (float) (gn1sat[i] + gn1unsat[i] + gn2sat[i] + gn2unsat[i]) /
716  (float) (nsamp * nscans) * 100.;
717  if (pct_good_gain < 100.) {
718  if (pct_good_gain >= 90.) /* only note the underperforming gain */ {
719  printf("\nNote that percentage of good gains (%f) for band %d is < 100%%", pct_good_gain, i);
720  } else {
721  printf("\n********chk_gn: Percentage of good gains (%f) for band %d is < 90 %%, an ERROR condition", pct_good_gain, i);
722  stat_status = stat_status | 2;
723  sprintf(str, "L1GAIN%1d ", (i + 1));
724  if (strlen(bad_stat_str) <= 300)
725  strcat(bad_stat_str, str);
726  }
727  }
728  }
729 
730  /*
731  * Print headers for l1 and l2 gains output messages
732  */
733 
734  printf("\n\n#Mnemonic Code\t Value\t --\tError_threshold");
735  printf("\n#-----------------------------------------------\n");
736  /*
737  * If gain 1 is > 0, calculate saturated percentage
738  * else, set value to -1, indicating success
739  */
740  for (i = 0; i < 8; i++) {
741  failcode = 0;
742  if (gn1[i].band == 1) {
743  if (gn1_val[i] != -1 && gn1_val[i] > gn1[i].threshold) {
744  failcode = 1;
745  stat_status = stat_status | 2;
746  sprintf(str, "L1GAIN1%1d ", (i + 1));
747  if (strlen(bad_stat_str) <= 300)
748  strcat(bad_stat_str, str);
749  }
750  printf("\nL1GAIN1%d %d\t%f --\t%f", i + 1, failcode, gn1_val[i],
751  gn1[i].threshold);
752  }
753  }
754 
755  printf("\n");
756  for (i = 0; i < 8; i++) {
757  failcode = 0;
758  if (gn2[i].band == 1) {
759  if (gn2_val[i] != -1 && gn2_val[i] > gn2[i].threshold) {
760  failcode = 1;
761  stat_status = stat_status | 2;
762  sprintf(str, "L1GAIN2%1d ", (i + 1));
763  if (strlen(bad_stat_str) <= 300)
764  strcat(bad_stat_str, str);
765  }
766  printf("\nL1GAIN2%d %d\t%f --\t%f", i + 1, failcode, gn2_val[i],
767  gn2[i].threshold);
768  }
769  }
770 
771 #ifdef DEBUG
772  for (i = 0; i < 8; i++)
773  printf("\n gn1sat = %d\t gn1unsat = %d\t gn1_val = %f\n", gn1sat[i],
774  gn1unsat[i], gn1_val[i]);
775  for (i = 0; i < 8; i++)
776  printf("\n gn2sat = %d\t gn2unsat = %d\t gn2_val = %f\n", gn2sat[i],
777  gn2unsat[i], gn2_val[i]);
778 #endif /* DEBUG */
779 
780  return SUCCEED;
781 }
782 
783 /****************************************************************************
784  chk_zero
785 
786  purpose: Verifies Zero pixels percentage against the given
787  threshold for requested band/s
788 
789  Returns type: integer
790 
791  Parameters: (in calling order)
792  Type Name I/O Description
793  ---- ---- --- -----------
794  int32 sdfid I SD interface ID
795  cntl1_str * zero_str I structure containing zero
796  pixel band nos., and thresholds
797  int32 nscans I Number of scan lines
798  int32 nsamp I Number of pixels
799 
800  Modification history:
801 
802  Programmer Date Description of change
803  ---------- ---------- ---------------------
804  L. Kumar 04-Apr-1996 Original development
805 
806  ****************************************************************************/
807 int32 chk_zero(int32 sdfid, cntl1_str *zero_str, int32 nscans, int32 nsamp) {
808  int32 i, zero_pix[8];
809  int32 failcode = 0;
810  float64 zero_val[8];
811  char str[12];
812 
813  printf("\n\n#Checking Zero pixels percentage ....");
814 
815  /*
816  * Following few lines Initializes value buffers
817  * Reads zero pixel values from global attribute 'Zero Pixels'
818  * of input data file
819  */
820  for (i = 0; i < 8; i++)
821  zero_val[i] = 0;
822 
823  if ((rdattr(sdfid, ZEROPIX, (VOIDP *) zero_pix)) < 0)
824  return FAIL;
825 
826  for (i = 0; i < 8; i++)
827  zero_val[i] = ((float64) zero_pix[i] / (nscans * nsamp)) * 100.0;
828 
829  /*
830  * Print headers for l1 and l2 gains output messages
831  */
832 
833  printf("\n\n#Mnemonic Code\t Value\t --\tError_threshold");
834  printf("\n#-----------------------------------------------\n");
835 
836  for (i = 0; i < 8; i++) {
837  failcode = 0;
838  if (zero_str[i].band == 1) {
839  if (zero_val[i] > zero_str[i].threshold) {
840  failcode = 1;
841  stat_status = stat_status | 2;
842  sprintf(str, "L1ZERO%1d ", (i + 1));
843  if (strlen(bad_stat_str) <= 300)
844  strcat(bad_stat_str, str);
845  }
846  printf("\nL1ZERO%d %d\t%f --\t%f", i + 1, failcode, zero_val[i],
847  zero_str[i].threshold);
848  }
849  }
850 
851 #ifdef DEBUG
852  for (i = 0; i < 8; i++)
853  printf("\n zero_pix = %d\t zero_val = %f\n", zero_pix[i], zero_val[i]);
854 #endif /* DEBUG */
855 
856  return SUCCEED;
857 }
858 
859 /****************************************************************************
860  chk_count
861 
862  purpose: Verifies pixels high and low count percentages against the given
863  error threshold and count threshold
864 
865  Returns type: integer
866 
867  Parameters: (in calling order)
868  Type Name I/O Description
869  ---- ---- --- -----------
870  int32 sdfid I SD interface ID
871  int32 nscans I Number of scan lines
872  int32 nsamp I Number of pixels
873  int16 dtynum I data type number
874  cntl2_str * l1hicnt I struct containing high count
875  pixels error & count thresholds
876  cntl2_str * l1locnt I struct containing low count
877  pixels error & count thresholds
878  int * spike_cnt I/O # lines X # bands array with
879  the spike noise count per line
880  float * line_sd I/O # lines X # bands std
881  deviation for each line, band
882 
883  Modification history:
884 
885  Programmer Date Description of change
886  ---------- ---------- ---------------------
887  L. Kumar 04-Apr-1996 Original development
888  W. Robinson, GSC 31-Jul-1998 perform an analysis of noise while the
889  data is available
890  W. Robinson, GSC 29-oct-2001 flag only the GAC, LAC, HRPT for the
891  LOCOUNT
892 
893  ****************************************************************************/
894 int32 chk_count(int32 sdfid, int32 nscans, int32 nsamp, int16 dtynum,
895  cntl2_str *l1hicnt, cntl2_str *l1locnt, int *spike_cnt, float *line_sd) {
896  int16 *i16buf;
897  int32 i, rec, bnd, failcode = 0;
898  int32 nbands = 8, nrec, rdrecs = 256, recsleft;
899  int32 start[3], edge[3];
900  int32 hicnt[8] = {0, 0, 0, 0, 0, 0, 0, 0};
901  int32 lowcnt[8] = {0, 0, 0, 0, 0, 0, 0, 0};
902  float32 value[8] = {0, 0, 0, 0, 0, 0, 0, 0};
903  int32_t cnt_coin_jmp[8] = {0, 0, 0, 0, 0, 0, 0, 0};
904  int32_t jmp_hist[1024];
905  char str[12];
906 
907  int DETAIL_PRT = 0; /* set to 1 to print noise detail info 0 to not print */
908 
909  for (i = 0; i < 1024; i++)
910  jmp_hist[i] = 0;
911  nrec = rdrecs;
912 
913  printf("\n\n#Checking Low and High count percentages ....");
914 
915  /*
916  * Allocate buffer space for reading l1a_data from given input hdf file
917  */
918  if ((i16buf = (int16 *) calloc(nrec * nsamp * nbands, sizeof (int16))) == NULL) {
919  sprintf(err_msg,
920  "chk_count: cannot allocate memory for reading l1a_data");
921  return FAIL;
922  }
923 
924  /*
925  * It has been observed that it takes quite some time to read a large chunk
926  * of data from a HDF file at once. In order to make it time efficient
927  * the l1a_data is being read in smaller chunks containing "nrec" scans.
928  * (see the defn. of nrec above in the variable declaration section)
929  * Following assinment stmts. initializes start and end dimensions of the
930  * first data slab that will be read. The for loop reads in data and
931  * calls get_hicnt and get_lowcnt to accumulate high and low counts of
932  * level 1 data.
933  */
934 
935  start[0] = start[1] = start[2] = 0;
936  edge[0] = nrec;
937  edge[1] = nsamp;
938  edge[2] = nbands;
939 
940  for (rec = 0; rec < nscans; rec += rdrecs) {
941  if ((recsleft = nscans - rec) < rdrecs)
942  nrec = recsleft;
943  if (nrec > 0) {
944  start[0] = rec;
945  edge[0] = nrec;
946  if ((rdslice(sdfid, L1ADATA, start, edge, (VOIDP) i16buf)) < 0) {
947  stat_status = stat_status | 1;
948  return FAIL;
949  }
950  get_hicnt(nrec, nsamp, nbands, i16buf, l1hicnt, hicnt);
951  get_lowcnt(nrec, nsamp, nbands, i16buf, l1locnt, lowcnt);
952  /*
953  * for the lines read, collect the noise estimates
954  */
955  anal_noise(rec, nrec, nscans, nsamp, nbands, i16buf, spike_cnt, line_sd, cnt_coin_jmp, jmp_hist);
956  }
957  }
958  /*
959  * report the grand total info for the co-incident jumps and the histogram
960  */
961 
962  if (DETAIL_PRT) {
963  printf("Grand total of co-incident jumps\n");
964  printf("Total # pixels: %d\n", nscans * nsamp);
965  for (rec = 0; rec < 8; rec++)
966  printf("#co-incidences: %d, count: %d\n",
967  (rec + 1), *(cnt_coin_jmp + rec));
968 
969  printf("\nhistogram (size 1024) of jump frequency");
970  for (rec = 0; rec < 1024; rec++) {
971  printf("%10d", *(jmp_hist + rec));
972  if (rec % 8 == 7) printf("\n");
973  }
974 
975  /*
976  * temporarily report the spike and sd info here
977  */
978 
979  printf("\n\nline-by-line jump count Standard deviation\n");
980  printf("line 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8\n");
981  for (rec = 0; rec < nscans; rec++) {
982  printf("%5d", rec);
983  for (bnd = 0; bnd < nbands; bnd++) {
984  printf(" %4d", *(spike_cnt + bnd + nbands * rec));
985  }
986  for (bnd = 0; bnd < nbands; bnd++) {
987  printf(" %7.2f", *(line_sd + bnd + nbands * rec));
988  }
989  printf("\n");
990  }
991  }
992 
993  /*
994  * Following for loops calculates the percentage of high and low counts
995  * verifies against the given hight and low error thresholds and outputs
996  * the message
997  */
998 
999  printf("\n\n#Mnemonic Code\t Value\t --\tErr_thresh\tCount_thresh");
1000  printf("\n#-----------------------------------------------------------\n");
1001 
1002  for (i = 0; i < nbands; i++) {
1003  failcode = 0;
1004  if (l1hicnt[i].band == 1) {
1005  value[i] = (hicnt[i] / (nscans * nsamp * 1.0)) * 100.0;
1006  if (value[i] > l1hicnt[i].err_thresh) {
1007  failcode = 1;
1008  stat_status = stat_status | 2;
1009  sprintf(str, "L1HICOUNT%1d ", (i + 1));
1010  if (strlen(bad_stat_str) <= 300)
1011  strcat(bad_stat_str, str);
1012  }
1013  printf("\nL1HICOUNT%d %d\t%f --\t%f\t%f",
1014  i + 1, failcode, value[i], l1hicnt[i].err_thresh,
1015  l1hicnt[i].cnt_thresh);
1016  }
1017  }
1018  printf("\n");
1019  for (i = 0; i < nbands; i++) {
1020  failcode = 0;
1021  if (l1locnt[i].band == 1) {
1022  value[i] = (lowcnt[i] / (nscans * nsamp * 1.0))*100.00;
1023  /* only flag if it is an image dataset for the low count */
1024  if (((dtynum == GAC) || (dtynum == LAC) || (dtynum == HRPT)) &&
1025  (value[i] > l1locnt[i].err_thresh)) {
1026  failcode = 1;
1027  stat_status = stat_status | 2;
1028  sprintf(str, "L1LOWCOUNT%1d ", (i + 1));
1029  if (strlen(bad_stat_str) <= 300)
1030  strcat(bad_stat_str, str);
1031  }
1032  if ((dtynum == GAC) || (dtynum == LAC) || (dtynum == HRPT)) {
1033  printf("\nL1LOWCOUNT%d %d\t%f --\t%f\t%f",
1034  i + 1, failcode, value[i], l1locnt[i].err_thresh,
1035  l1locnt[i].cnt_thresh);
1036  } else {
1037  printf("\nL1LOWCOUNT%d N/A\t%f --\t%f\t%f",
1038  i + 1, value[i], l1locnt[i].err_thresh,
1039  l1locnt[i].cnt_thresh);
1040  }
1041  }
1042  }
1043 
1044 
1045  free(i16buf);
1046 
1047  return SUCCEED;
1048 }
1049 
1050 /****************************************************************************
1051  get_hicnt
1052 
1053  purpose: Accumulates high count pixels for each requested band
1054 
1055  Returns type: void
1056 
1057  Parameters: (in calling order)
1058  Type Name I/O Description
1059  ---- ---- --- -----------
1060  int32 nrec I Number of records
1061  int32 nscans I Number of scan lines
1062  int32 nsamp I Number of pixels
1063  int16 * databuf I data buffer
1064  cntl2_str * l1hicnt I struct containing high count
1065  pixels error & count thresholds
1066  cntl2_str * hicnt I Array of 8 to hold high counts
1067  of each band
1068 
1069  Modification history:
1070 
1071  Programmer Date Description of change
1072  ---------- ---------- ---------------------
1073  L. Kumar 04-Apr-1996 Original development
1074 
1075  ****************************************************************************/
1076 void
1077 #ifdef PROTOTYPE
1078 get_hicnt(int32 nrec, int32 nsamp, int32 nbands, int16 *databuf,
1079  cntl2_str *l1hicnt, int32 *hicnt)
1080 #else
1081 get_hicnt(nrec, nsamp, nbands, databuf, l1hicnt, hicnt)
1082 int32 nrec, nsamp, nbands, *hicnt;
1083 int16 *databuf;
1084 cntl2_str *l1hicnt;
1085 #endif
1086 {
1087  int32 i;
1088 
1089  if (l1hicnt[BAND1].band)
1090  for (i = 0; i < nrec * nsamp * nbands; i += 8)
1091  if (databuf[i] > l1hicnt[BAND1].cnt_thresh)
1092  hicnt[BAND1]++;
1093 
1094  if (l1hicnt[BAND2].band)
1095  for (i = 1; i < nrec * nsamp * nbands; i += 8)
1096  if (databuf[i] > l1hicnt[BAND2].cnt_thresh)
1097  hicnt[BAND2]++;
1098 
1099  if (l1hicnt[BAND3].band)
1100  for (i = 2; i < nrec * nsamp * nbands; i += 8)
1101  if (databuf[i] > l1hicnt[BAND3].cnt_thresh)
1102  hicnt[BAND3]++;
1103 
1104  if (l1hicnt[BAND4].band)
1105  for (i = 3; i < nrec * nsamp * nbands; i += 8)
1106  if (databuf[i] > l1hicnt[BAND4].cnt_thresh)
1107  hicnt[BAND4]++;
1108 
1109  if (l1hicnt[BAND5].band)
1110  for (i = 4; i < nrec * nsamp * nbands; i += 8)
1111  if (databuf[i] > l1hicnt[BAND5].cnt_thresh)
1112  hicnt[BAND5]++;
1113 
1114  if (l1hicnt[BAND6].band)
1115  for (i = 5; i < nrec * nsamp * nbands; i += 8)
1116  if (databuf[i] > l1hicnt[BAND6].cnt_thresh)
1117  hicnt[BAND6]++;
1118 
1119  if (l1hicnt[BAND7].band)
1120  for (i = 6; i < nrec * nsamp * nbands; i += 8)
1121  if (databuf[i] > l1hicnt[BAND7].cnt_thresh)
1122  hicnt[BAND7]++;
1123 
1124  if (l1hicnt[BAND8].band)
1125  for (i = 7; i < nrec * nsamp * nbands; i += 8)
1126  if (databuf[i] > l1hicnt[BAND8].cnt_thresh)
1127  hicnt[BAND8]++;
1128 
1129 }
1130 
1131 /****************************************************************************
1132  get_lowcnt
1133 
1134  purpose: Accumulates low count pixels for each band
1135 
1136  Returns type: void
1137 
1138  Parameters: (in calling order)
1139  Type Name I/O Description
1140  ---- ---- --- -----------
1141  int32 nrec I Number of records
1142  int32 nscans I Number of scan lines
1143  int32 nsamp I Number of pixels
1144  int16 * databuf I data buffer
1145  cntl2_str * l1locnt I struct containing low count
1146  pixels error & count thresholds
1147  cntl2_str * lowcnt I Array of 8 to hold high counts
1148  of each band
1149 
1150  Modification history:
1151 
1152  Programmer Date Description of change
1153  ---------- ---------- ---------------------
1154  L. Kumar 04-Apr-1996 Original development
1155 
1156  ****************************************************************************/
1157 void
1158 #ifdef PROTOTYPE
1159 get_lowcnt(int32 nrec, int32 nsamp, int32 nbands, int16 *databuf,
1160  cntl2_str *l1locnt, int32 *lowcnt)
1161 #else
1162 get_lowcnt(nrec, nsamp, nbands, databuf, l1locnt, lowcnt)
1163 int32 nrec, nsamp, nbands, *lowcnt;
1164 int16 *databuf;
1165 cntl2_str *l1locnt;
1166 #endif
1167 {
1168  int32 i;
1169 
1170  if (l1locnt[BAND1].band)
1171  for (i = 0; i < nrec * nsamp * nbands; i += 8)
1172  if (databuf[i] < l1locnt[BAND1].cnt_thresh)
1173  lowcnt[BAND1]++;
1174 
1175  if (l1locnt[BAND2].band)
1176  for (i = 1; i < nrec * nsamp * nbands; i += 8)
1177  if (databuf[i] < l1locnt[BAND2].cnt_thresh)
1178  lowcnt[BAND2]++;
1179 
1180  if (l1locnt[BAND3].band)
1181  for (i = 2; i < nrec * nsamp * nbands; i += 8)
1182  if (databuf[i] < l1locnt[BAND3].cnt_thresh)
1183  lowcnt[BAND3]++;
1184 
1185  if (l1locnt[BAND4].band)
1186  for (i = 3; i < nrec * nsamp * nbands; i += 8)
1187  if (databuf[i] < l1locnt[BAND4].cnt_thresh)
1188  lowcnt[BAND4]++;
1189 
1190  if (l1locnt[BAND5].band)
1191  for (i = 4; i < nrec * nsamp * nbands; i += 8)
1192  if (databuf[i] < l1locnt[BAND5].cnt_thresh)
1193  lowcnt[BAND5]++;
1194 
1195  if (l1locnt[BAND6].band)
1196  for (i = 5; i < nrec * nsamp * nbands; i += 8)
1197  if (databuf[i] < l1locnt[BAND6].cnt_thresh)
1198  lowcnt[BAND6]++;
1199 
1200  if (l1locnt[BAND7].band)
1201  for (i = 6; i < nrec * nsamp * nbands; i += 8)
1202  if (databuf[i] < l1locnt[BAND7].cnt_thresh)
1203  lowcnt[BAND7]++;
1204 
1205  if (l1locnt[BAND8].band)
1206  for (i = 7; i < nrec * nsamp * nbands; i += 8)
1207  if (databuf[i] < l1locnt[BAND8].cnt_thresh)
1208  lowcnt[BAND8]++;
1209 }
1210 
1211 /****************************************************************************
1212  chk_nav
1213 
1214  purpose: Verifies navigation discontinuity. Following gives the algorithm:
1215  Take center pixel of every line, find the latitude, longitude
1216  via navigation. Convert it to a vector from earth center and
1217  compure the angular difference between this vector and the one
1218  for the previous line. At first, exclude regions of tilt
1219  change as the difference would be larger. the angular speed
1220  will be computed using the angular difference and the
1221  line time tags. If the speed is within tolerences,
1222  the test passes. This is different from the previous
1223  km. difference because now, the speed is the same for GAC
1224  and LAC.
1225 
1226  Returns type: int32
1227 
1228  Parameters: (in calling order)
1229  Type Name I/O Description
1230  ---- ---- --- -----------
1231  int32 sdfid I SD interface id
1232  int32 nscans I Number of scanlines
1233  float32 nav_thresh1 I input threshold 1
1234  float32 nav_thresh2 I input threshold 2
1235  int32 * ntilts I number of tilt states
1236  int16 tilt_ranges[20[2] I scan line ranges of tilt states
1237  int16 tilt_flags[20] I flags corresponding to tilt
1238  states
1239  int16 dtynum I data type number
1240  int16 rpt_negtim I =1 to set the fail condition
1241  for a (-) delta time found (for
1242  time-dependent checking)
1243 
1244  Modification history:
1245 
1246  Programmer Date Description of change
1247  ---------- ---------- ---------------------
1248  L. Kumar 04-Apr-1996 Original development
1249  W. Robinson, GSC, 2- Dec-1997 change from line-line km distance
1250  to line-line angular speed.
1251  W. Robinson, GSC, 31-Dec-1997 remember the highest, lowest nav
1252  rates and report them
1253  H. Qi, SSAI, 18-Feb-1999 remember the invalid total number
1254  for each nflag and report them
1255  W. Robinson, GSC, 17-Jan-2001 turn on (-) delta time check for
1256  GAC files
1257  W. Robinson, SAIC 4-Oct-2001 avoid nav checks on lines flagged
1258  for unfixed navigation
1259  W. Robinson, SAIC 25-Jun-2002 add time-dependent checking for
1260  (-) time changes and make slight mod
1261  to navflag checking to conform with
1262  the L0-L1 action
1263  W. Robinson, SAIC 20 Aug 2003 check for a + time shift of from 20 to
1264  2000 msec and report in the (-) shift
1265  in L1NAVDISC. This should find the
1266  + steps for GPS resets
1267 
1268  ****************************************************************************/
1269 int32 chk_nav(int32 sdfid, int32 nscans, float32 nav_thresh1,
1270  float32 nav_thresh2, int32 ntilts, int16 tilt_ranges[20][2],
1271  int16 tilt_flags[20], int16 dtynum, int16 rpt_negtim) {
1272  int16 good_scans[20][2];
1273  int32 scan, start[3], edge[3], failcode = 0;
1274  int32 err_thresh = 0, err_thresh1 = 0, err_thresh2 = 0;
1275  int32 i, fst, t_cnt = 0;
1276  int32 *nflag;
1277  int32 suncounter = 0, tiltcounter = 0, telcounter = 0;
1278  int32 timecounter = 0, earthcounter = 0, failcounter = 0;
1279  int32 fixtimecount = 0, interpcount = 0, warncount = 0;
1280  int32 tiltchgcount = 0;
1281  float32 *orb_vec, *sun_ref, *sen_mat, *scan_ell;
1282  float32 value, v0[3], v1[3];
1283  int32_t t0, t1, tstart, delt, trend_dev, *msec;
1284  double v0abs, v1abs, delang, d_value;
1285  float lo_nav_rate, hi_nav_rate, lo_nav_rate_delang,
1286  hi_nav_rate_delang, lo_nav_rate_delt, hi_nav_rate_delt;
1287  int lo_nav_rate_loc, hi_nav_rate_loc;
1288  char str[12];
1289 
1290  printf("\n\n#Checking for Navigation discontinuity ....");
1291 
1292  for (i = 0; i < 20; i++)
1293  good_scans[i][0] = good_scans[i][1] = 0;
1294 
1295  /*
1296  * Allocate space for the navigation buffers
1297  */
1298 
1299  if ((orb_vec = (float32 *) calloc(nscans * 3, sizeof (float32))) == NULL) {
1300  sprintf(err_msg, "chk_nav: cannot allocate memory for reading orb_vec");
1301  return FAIL;
1302  }
1303 
1304  if ((sun_ref = (float32 *) calloc(nscans * 3, sizeof (float32))) == NULL) {
1305  sprintf(err_msg, "chk_nav: cannot allocate memory for reading sun_ref");
1306  return FAIL;
1307  }
1308 
1309  if ((sen_mat = (float32 *) calloc(nscans * 3 * 3, sizeof (float32))) == NULL) {
1310  sprintf(err_msg, "chk_nav: cannot allocate memory for reading sen_mat");
1311  return FAIL;
1312  }
1313 
1314  if ((scan_ell = (float32 *) calloc(nscans * 6, sizeof (float32))) == NULL) {
1315  sprintf(err_msg, "chk_nav: cannot allocate memory for reading scan_ell");
1316  return FAIL;
1317  }
1318 
1319  if ((msec = (int32_t *) calloc(nscans, sizeof (int32_t))) == NULL) {
1320  sprintf(err_msg, "chk_nav: cannot allocate memory for reading msec");
1321  return FAIL;
1322  }
1323  if ((nflag = (int32 *) calloc(nscans * 8, sizeof (int32))) == NULL) {
1324  sprintf(err_msg, "chk_nav: cannot allocate memory for reading nflag");
1325  return FAIL;
1326  }
1327 
1328  /*
1329  * Set start and end dims for reading orb_vec sds
1330  */
1331  start[0] = start[1] = start[2] = 0;
1332  edge[0] = nscans;
1333  edge[1] = 3;
1334  edge[2] = 0;
1335  if ((rdslice(sdfid, ORBVEC, start, edge, (VOIDP) orb_vec)) < 0) {
1336  stat_status = stat_status | 1;
1337  return FAIL;
1338  }
1339 
1340  /*
1341  * Set start and end dims and read sun_ref sds
1342  */
1343  start[0] = start[1] = start[2] = 0;
1344  edge[0] = nscans;
1345  edge[1] = 3;
1346  edge[2] = 0;
1347  if ((rdslice(sdfid, SUNREF, start, edge, (VOIDP) sun_ref)) < 0) {
1348  stat_status = stat_status | 1;
1349  return FAIL;
1350  }
1351 
1352  /*
1353  * Set start and end dims and read sen_mat sds
1354  */
1355  start[0] = start[1] = start[2] = 0;
1356  edge[0] = nscans;
1357  edge[1] = 3;
1358  edge[2] = 3;
1359  if ((rdslice(sdfid, SENMAT, start, edge, (VOIDP) sen_mat)) < 0) {
1360  stat_status = stat_status | 1;
1361  return FAIL;
1362  }
1363 
1364  /*
1365  * Set start and end dims and read scan_ell sds
1366  */
1367  start[0] = start[1] = start[2] = 0;
1368  edge[0] = nscans;
1369  edge[1] = 6;
1370  edge[2] = 0;
1371  if ((rdslice(sdfid, SCANELL, start, edge, (VOIDP) scan_ell)) < 0) {
1372  stat_status = stat_status | 1;
1373  return FAIL;
1374  }
1375 
1376  /*
1377  * Set start and end dims and read msec sds
1378  */
1379  start[0] = start[1] = start[2] = 0;
1380  edge[0] = nscans;
1381  edge[1] = 0;
1382  edge[2] = 0;
1383  if ((rdslice(sdfid, "msec", start, edge, (VOIDP) msec)) < 0) {
1384  stat_status = stat_status | 1;
1385  return FAIL;
1386  }
1387 
1388  /*
1389  * Set start and end dims and read nflag sds
1390  */
1391  start[0] = start[1] = start[2] = 0;
1392  edge[0] = nscans;
1393  edge[1] = 8;
1394  edge[2] = 0;
1395  if ((rdslice(sdfid, NFLAG, start, edge, (VOIDP) nflag)) < 0) {
1396  stat_status = stat_status | 1;
1397  return FAIL;
1398  }
1399 
1400  /*
1401  * loop through tilt_ranges and exclude all the lines that has tilt status
1402  * equal to 3, indicating the tilt change.
1403  * SO, good_scans contains only line ranges that we can do the nav test on
1404  * and t_cnt is the # of those ranges.
1405  */
1406  for (t_cnt = 0, i = 0; i < ntilts; i++) {
1407  if (tilt_flags[i] == 1 || tilt_flags[i] == 2) {
1408  good_scans[t_cnt][0] = tilt_ranges[i][0] - 1;
1409  good_scans[t_cnt][1] = tilt_ranges[i][1] - 1;
1410  t_cnt++;
1411  }
1412  }
1413 
1414  /*
1415  * Initially, we were just going to call geovex to get the vectors
1416  * out to a point for 2 lines and get the vector difference and
1417  * check that against the thresholds. However, now there can be missing
1418  * scans and the distance may change.
1419  *
1420  * So, now, we find the angle between the 2 vectors using the
1421  * relation: cos( angle ) = ( a * b ) / ( |a| |b| ) for vectors a, b
1422  * The time difference is provided by the msec sds (make sure you
1423  * account for crossing a day boundary, add 86400 if time < start).
1424  * The final result is converted to milliradians / sec and for
1425  * the SeaWiFS orbit of 98.9 min, this should be 1.059 mrad / sec
1426  * so the thresholds should be around that value.
1427  */
1428  lo_nav_rate = 9999.;
1429  hi_nav_rate = -9999.;
1430  lo_nav_rate_loc = hi_nav_rate_loc = -1;
1431  lo_nav_rate_delang = lo_nav_rate_delt = 0;
1432  hi_nav_rate_delang = hi_nav_rate_delt = 0;
1433 
1434  for (i = 0; i < t_cnt; i++) /* do the next for each good line range */ {
1435  /* loop through the lines in that line range */
1436  for (fst = 0, scan = good_scans[i][0]; scan <= good_scans[i][1]; scan++) {
1437  /*
1438  * deal with the valid navigation line and skip the invalid
1439  * navigation line. also, avoid any lines where the time code
1440  * was flagged but unfixed
1441  */
1442  if ((*(nflag + scan * 8) == 0) && (*(nflag + scan * 8 + 7) == 0)) {
1443 
1444  /*
1445  * get the vector for the line and the time
1446  */
1447  geovex_((orb_vec + scan * 3), (sen_mat + scan * 9),
1448  (scan_ell + scan * 6), (sun_ref + scan * 3), v0);
1449  t0 = *(msec + scan);
1450 
1451  if (fst > 0) {
1452  if (t0 < tstart) t0 = t0 + 86400000;
1453  delt = t0 - t1;
1454  /*
1455  * Do a (-) delta time check only for GAC and report only if
1456  * there is a change at least .5 - 3. sec off of the normal
1457  * GAC change of .666 sec. So, only flag for
1458  * -2.340 < delta t < 0.
1459  * Also, for any forward deviations of 20 to 2000 msec = 686
1460  * to 2666 msec (< 20 msec and it is negligable, 4000 msec
1461  * and higher is a frame drop)
1462  */
1463  if ((dtynum == GAC) &&
1464  (((delt <= 0) && (delt > -2340)) ||
1465  ((delt >= 686) && (delt <= 2666)))) {
1466  trend_dev = delt - 666;
1467  if (rpt_negtim == 1)failcode = 1;
1468  printf("\n\n\nTIME_ERROR scan # [%d-%d] ", scan, scan + 1);
1469  printf("Delta time = %d, Trend deviation = %d\n\n\n", delt, trend_dev);
1470  printf("NOTE that if this time is not in a mandatory product\n");
1471  printf("failure time range, it may need to be put in one.\n");
1472  printf("For post-repro 3 data this denotes a 30 second time\n");
1473  printf("shift that wasn't detected or a GPS reset\n");
1474  printf("Check around this time period for navigation offsets\n");
1475  printf("using GAC, LAC and HRPT stations.\n");
1476  printf("Also, inform QC and navigation manager of this problem\n");
1477  printf("(This may require an update to l1stat_chk)\n\n\n");
1478  }
1479  v0abs = sqrt(v0[0] * v0[0] + v0[1] * v0[1] + v0[2] * v0[2]);
1480  v1abs = sqrt(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2]);
1481 
1482  /* this may be poor for the small angles we should encounter
1483  delang = acos( (v0[0] * v1[0] + v0[1] * v1[1] + v0[2] * v1[2] ) /
1484  ( v0abs * v1abs ) );
1485  SO, try method where we normalize both radius vectors, find
1486  the magnitude of the vector difference d_value, and then find the
1487  angle with: sin( 1/2 angle ) = 1/2 d_value
1488  */
1489  d_value = sqrt(pow((v0[0] / v0abs - v1[0] / v1abs), 2) +
1490  pow((v0[1] / v0abs - v1[1] / v1abs), 2) +
1491  pow((v0[2] / v0abs - v1[2] / v1abs), 2));
1492 
1493  delang = 2. * asin(d_value / 2.);
1494 
1495  value = (delang * 1.e6) / (float) delt;
1496 
1497  /*
1498  * remember the lowest, highest rates
1499  */
1500  if (value < lo_nav_rate) {
1501  lo_nav_rate = value;
1502  lo_nav_rate_loc = scan;
1503  lo_nav_rate_delang = delang;
1504  lo_nav_rate_delt = delt;
1505  }
1506  if (value > hi_nav_rate) {
1507  hi_nav_rate = value;
1508  hi_nav_rate_loc = scan;
1509  hi_nav_rate_delang = delang;
1510  hi_nav_rate_delt = delt;
1511  }
1512 
1513  if (value < nav_thresh1) {
1514  failcode = 1;
1515  err_thresh++;
1516  err_thresh1++;
1517  printf("\nNAVERR scan # [%d-%d] ", scan, scan + 1);
1518  printf("value = %f, threshold = %f", value, nav_thresh1);
1519  printf(" Kdelang: %f, delt: %d", 1000. * delang, delt);
1520  } else if (value > nav_thresh2) {
1521  failcode = 1;
1522  err_thresh++;
1523  err_thresh2++;
1524  printf("\nNAVERR scan # [%d-%d] ", scan, scan + 1);
1525  printf("value = %f, threshold = %f", value, nav_thresh2);
1526  printf(" Kdelang: %f, delt: %d", 1000. * delang, delt);
1527  }
1528  } else {
1529  tstart = t0; /* first time thru, define start time */
1530  }
1531  fst++;
1532  v1[0] = v0[0];
1533  v1[1] = v0[1];
1534  v1[2] = v0[2];
1535  t1 = t0;
1536  }
1537  if (*(nflag + scan * 8) == 1) failcounter++;
1538  if (*(nflag + scan * 8 + 1) == 1) interpcount++;
1539  if (*(nflag + scan * 8 + 2) == 1) suncounter++;
1540  if (*(nflag + scan * 8 + 3) == 1) earthcounter++;
1541  if (*(nflag + scan * 8 + 4) == 1) telcounter++;
1542  if (*(nflag + scan * 8 + 5) == 1) timecounter++;
1543  if (*(nflag + scan * 8 + 5) == 2) fixtimecount++;
1544  if (*(nflag + scan * 8 + 6) == 1) tiltcounter++;
1545  if (*(nflag + scan * 8 + 6) == 2) tiltchgcount++;
1546  if (*(nflag + scan * 8 + 7) == 1) warncount++;
1547  }
1548  }
1549 
1550  printf("\n\n# --- Cumulative navigation flag (nflag) settings ---\n");
1551  printf("Description # of occurences\n");
1552  printf("-------------------------------------- ---------------\n");
1553  printf("navigation failure (nflag(1) = 1) %d\n", failcounter);
1554  printf("nav interp problem (nflag(2) = 1) %d\n", interpcount);
1555  printf("sun sensor out (nflag(3) = 1) %d\n", suncounter);
1556  printf("earth sensor out (nflag(4) = 1) %d\n", earthcounter);
1557  printf("attitude uncertainty (nflag(5) = 1) %d\n", telcounter);
1558  printf("time code problem (nflag(6) = 1) %d\n", timecounter);
1559  printf("time code problem fixed (nflag(6) = 2) %d\n", fixtimecount);
1560  printf("tilt info bad (nflag(7) = 1) %d\n", tiltcounter);
1561  printf("tilt changing (nflag(7) = 2) %d\n", tiltchgcount);
1562  printf("navigation warning (nflag(8) = 1) %d\n\n", warncount);
1563 
1564  printf("\n\n\n#Mnemonic Code tot # outside\tthresh_1 thresh_2 # below 1 # below 2");
1565  printf("\n thresholds ");
1566  printf("\n#--------------------------------------------------------------------------\n");
1567 
1568  printf("\nL1NAVDISC %d\t %d\t %f\t %f\t%d\t %d", failcode,
1569  err_thresh, nav_thresh1, nav_thresh2, err_thresh1, err_thresh2);
1570 
1571  /*
1572  * report the low and high rates
1573  */
1574  printf("\n\nRecord of lowest, highest rates found ( ideal rate: 1.059)\n");
1575  printf(" rate (mrad / sec) line location delang (mrad) delt (msec)\n");
1576  printf("LOWRATE:%-12.4f %-10d %-12.4f %-12.4f\n", lo_nav_rate, lo_nav_rate_loc, lo_nav_rate_delang * 1000., lo_nav_rate_delt);
1577  printf("HIRATE: %-12.4f %-10d %-12.4f %-12.4f\n", hi_nav_rate, hi_nav_rate_loc, hi_nav_rate_delang * 1000., hi_nav_rate_delt);
1578 
1579 
1580  if (failcode) {
1581  stat_status = stat_status | 2;
1582  sprintf(str, "L1NAVDISC ");
1583  if (strlen(bad_stat_str) <= 300)
1584  strcat(bad_stat_str, str);
1585  }
1586 
1587  free(orb_vec);
1588  free(sun_ref);
1589  free(scan_ell);
1590  free(sen_mat);
1591  free(msec);
1592  free(nflag);
1593  return SUCCEED;
1594 }
1595 
1596 /****************************************************************************
1597  chk_tilt
1598 
1599  purpose: Calculates time required by tilt changes and verifies to see
1600  if it is less than the given threshold value.
1601 
1602  Returns type: int32
1603 
1604  Parameters: (in calling order)
1605  Type Name I/O Description
1606  ---- ---- --- -----------
1607  int32 sdfid I SD interface id
1608  int16 dtynum I data type number
1609  float32 l1tilt_thresh I input threshold for tiltchange
1610  int32 * ntilts O number tilts
1611  int16 tilt_ranges[20][2] O scan line ranges of tilt states
1612  int16 tilt_flags[20] O flag corresponding to each
1613  tilt states
1614 
1615  Modification history:
1616 
1617  Programmer Date Description of change
1618  ---------- ---------- ---------------------
1619  L. Kumar 04-Apr-1996 Original development
1620 
1621  ****************************************************************************/
1622 int32 chk_tilt(int32 sdfid, int16 dtynum, float32 l1tilt_thresh, int32 *ntilts,
1623  int16 tilt_ranges[20][2], int16 *tilt_flags) {
1624  int32 i, failcode = 0, start[3], edge[3];
1625  float32 tilt_value = 0;
1626  char str[12];
1627 
1628  printf("\n\n#Checking Tilt behavior....");
1629 
1630  /*
1631  * Set start and end dims of ntilts sds and read ntilts fr given data file
1632  */
1633  start[0] = start[1] = start[2] = 0;
1634  edge[0] = 1;
1635  edge[1] = edge[2] = 0;
1636  if ((rdslice(sdfid, NTILTS, start, edge, (VOIDP) ntilts)) < 0) {
1637  stat_status = stat_status | 1;
1638  return FAIL;
1639  }
1640 
1641  /*
1642  * Set dimensions and read 'tilt_flags' from the given data file
1643  */
1644  edge[0] = 20;
1645  edge[1] = edge[2] = 0;
1646  if ((rdslice(sdfid, TILT_FLAGS, start, edge, (VOIDP) tilt_flags)) < 0) {
1647  stat_status = stat_status | 1;
1648  return FAIL;
1649  }
1650 
1651  /*
1652  * Set dimensions of 'tilt_ranges' sds and read it from the data file
1653  */
1654  edge[0] = 20;
1655  edge[1] = 2;
1656  edge[2] = 0;
1657  if ((rdslice(sdfid, TILT_RANGES, start, edge, (VOIDP) tilt_ranges)) < 0) {
1658  stat_status = stat_status | 1;
1659  return FAIL;
1660  }
1661 
1662  printf("\n\n#Mnemonic Code\t Value\t --\tError_threshold");
1663  printf("\n#-----------------------------------------------\n");
1664 
1665  for (i = 0; i < *ntilts; i++) {
1666  if (tilt_flags[i] == 3) {
1667  failcode = 0;
1668  tilt_value = (tilt_ranges[i][1] - tilt_ranges[i][0] + 1);
1669  if (dtynum == GAC)
1670  tilt_value = (tilt_value * 2.0 / 3.0);
1671  else
1672  tilt_value = (tilt_value / 6.0);
1673  if (tilt_value > l1tilt_thresh)
1674  failcode = 1;
1675  }
1676  }
1677  printf("\nL1TILT %d\t%f\t%f", failcode, tilt_value, l1tilt_thresh);
1678  if (failcode) {
1679  stat_status = stat_status | 2;
1680  sprintf(str, "L1TILT ");
1681  if (strlen(bad_stat_str) <= 300)
1682  strcat(bad_stat_str, str);
1683  }
1684 
1685  return SUCCEED;
1686 }
1687 
1689 /*******************************************************************
1690 
1691  stat_exit
1692 
1693  purpose: provide a common exit from the stat_check program and
1694  error summary info.
1695 
1696  Returns type: none
1697 
1698  Parameters: (in calling order)
1699  Type Name I/O Description
1700  ---- ---- --- -----------
1701  int status I statistical check status
1702 
1703  Modification history:
1704  Programmer Date Description of change
1705  ---------- ---- ---------------------
1706  W. Robinson 30-jun-1995 Original development
1707 
1708  *******************************************************************/ {
1709  if (status == 0)
1710  printf("\n\nSuccessful check, no statistical errors\n");
1711  else {
1712  if (status & 1)
1713  printf("\n\nFailure of statistical check due to program error\n");
1714  if (status & 2) {
1715  printf("\n\nFailure of statistical check due to data error\n\n");
1716  printf("Summary of mnemonics with bad status:\n");
1717  printf("%s\n", bad_stat_str);
1718  }
1719  }
1720  exit(status);
1721 }
#define GN1SAT
Definition: l1stat.h:27
int32 l1file(int32 sdfid, int32 *nsamp, int32 *nscans, int16 *dtynum)
Definition: l1stat_chk.c:586
integer, parameter int16
Definition: cubeio.f90:3
int32 value
Definition: Granule.c:1235
int32 rdslice(int32 sdfid, char *name, int32 *start, int32 *edge, void *buf)
Definition: stat_chk_utl.c:94
int status
Definition: l1_czcs_hdf.c:32
void ck_trng(char *file)
Definition: ck_trng.c:9
@ BAND5
Definition: make_L3_v1.1.c:53
#define ORBVEC
Definition: l1stat.h:50
#define DTYPE
Definition: l1stat.h:26
float f1(float x)
#define GN2SAT
Definition: l1stat.h:28
int32 chk_nav(int32 sdfid, int32 nscans, float32 nav_thresh1, float32 nav_thresh2, int32 ntilts, int16 tilt_ranges[20][2], int16 tilt_flags[20], int16 dtynum, int16 rpt_negtim)
Definition: l1stat_chk.c:1269
#define FAIL
Definition: ObpgReadGrid.h:18
@ BAND1
Definition: make_L3_v1.1.c:53
int rdattr(char *filename)
Definition: rdattr.c:34
#define NULL
Definition: decode_rs.h:63
void get_hicnt(int32 nrec, int32 nsamp, int32 nbands, int16 *databuf, cntl2_str *l1hicnt, int32 *hicnt)
Definition: l1stat_chk.c:1081
#define SENMAT
Definition: l1stat.h:51
MOD_PR01 Production producing one five minute granule of output data in each run It can be configured to produce as many as three five minute granules per run Each execution with one construction record and one date file for each dataset In normal these are created by which splits them out of the hour datasets For LANCE they are created by which merges all session MODIS L0 datasets overlapping the requested time and extracts from the merged data those packets which fall within that time period Each scan of data is stored in the L1A granule that covers the start time of that scan
Definition: MOD_PR01_pr.txt:19
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second band
void chk_gainv(int32 sdfid, int16 dtynum, int32 nscans, thr_ctl_def thr_ctl)
Definition: chk_gainv.c:6
#define SUNREF
Definition: l1stat.h:53
float f3(float z)
@ BAND3
Definition: make_L3_v1.1.c:53
int32 * msec
Definition: l1_czcs_hdf.c:31
char bad_stat_str[320]
Definition: l1stat_chk.c:11
#define SCANELL
Definition: l1stat.h:52
#define TILT_FLAGS
Definition: l1stat.h:47
#define GAC
Definition: l1stat.h:33
void get_lowcnt(int32 nrec, int32 nsamp, int32 nbands, int16 *databuf, cntl2_str *l1locnt, int32 *lowcnt)
Definition: l1stat_chk.c:1162
#define LAC
Definition: l1stat.h:34
int32 chk_count(int32 sdfid, int32 nscans, int32 nsamp, int16 dtynum, cntl2_str *l1hicnt, cntl2_str *l1locnt, int *spike_cnt, float *line_sd)
Definition: l1stat_chk.c:894
#define DETAIL_PRT
Definition: rpt_noise.c:8
float f2(float y)
#define NSAMP
Definition: l1stat.h:23
void chk_tdiv(int32 sdfid, int16 dtynum, int32 nscans, thr_ctl_def thr_ctl)
Definition: chk_tdiv.c:6
int32 chk_zero(int32 sdfid, cntl1_str *zero_str, int32 nscans, int32 nsamp)
Definition: l1stat_chk.c:807
void stat_exit(int status)
Definition: l1stat_chk.c:1688
#define HRPT
Definition: l1stat.h:35
int32 stat_status
Definition: l1stat_chk.c:8
#define GN1UNSAT
Definition: l1stat.h:29
@ BAND4
Definition: make_L3_v1.1.c:53
@ BAND6
Definition: make_L3_v1.1.c:53
@ BAND2
Definition: make_L3_v1.1.c:53
void chk_inst_ana(int32 sdfid, int32 nscans, thr_ctl_def thr_ctl)
Definition: chk_inst_ana.c:7
#define TITLE
Definition: l1stat.h:25
#define basename(s)
Definition: l0chunk_modis.c:29
void rpt_noise(int32, int16, int32, int32, int *, float *, float, float)
Definition: rpt_noise.c:10
#define NFLAG
Definition: l1stat.h:54
const char * str
Definition: l1c_msi.cpp:35
int32 chk_tilt(int32 sdfid, int16 dtynum, float32 l1tilt_thresh, int32 *ntilts, int16 tilt_ranges[20][2], int16 *tilt_flags)
Definition: l1stat_chk.c:1622
#define GN2UNSAT
Definition: l1stat.h:30
int32_t nbands
dtype
Definition: DDataset.hpp:31
char err_msg[1024]
Definition: l1stat_chk.c:7
int geovex_(float32 *orb_vec, float32 *sen_mat, float32 *scan_ell, float32 *sun_ref, float32 *v0)
int scan_ell(float p[3], double sm[3][3], double coef[10])
int main(int argc, char *argv[])
Definition: l1stat_chk.c:13
int32 read_cntldata(char *cntl_file, char *fsttim, cntl1_str *gn1, cntl1_str *gn2, cntl1_str *zero, cntl2_str *l1hicnt, cntl2_str *l1locnt, float32 *nav_thresh1, float32 *nav_thresh2, float32 *l1tilt_thresh, float32 *pct_noise_thresh, float32 *pct_encrypt_thresh, thr_ctl_def *thr_ctl, int16 *rpt_negtim)
Definition: l1stat_chk.c:276
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second and prod_ix set to PARAM_TYPE_INT name_prefix is compared with the beginning of the product name If name_suffix is not empty the it must match the end of the product name The characters right after the prefix are read as an integer and prod_ix is set to that number strncpy(l2prod->name_prefix, "myprod", UNITLEN)
const int NSCANS
Definition: RsViirs.h:63
@ BAND8
Definition: make_L3_v1.1.c:53
#define L1ADATA
Definition: l1stat.h:42
#define TILT_RANGES
Definition: l1stat.h:46
void anal_noise(int32 rec, int32 nrec, int32 nscans, int32 nsamp, int32 nbands, int16 *i16buf, int *spike_cnt, float *line_sd, int32_t *cnt_coin_jmp, int32_t *jmp_hist)
Definition: anal_noise.c:7
int32 chk_gn(int32 sdfid, cntl1_str *gn1, cntl1_str *gn2, int16 dtynum, int32 nsamp, int32 nscans)
Definition: l1stat_chk.c:661
int i
Definition: decode_rs.h:71
while(++r<=NROOTS)
Definition: decode_rs.h:169
@ BAND7
Definition: make_L3_v1.1.c:53
#define ZEROPIX
Definition: l1stat.h:31
#define NTILTS
Definition: l1stat.h:45