OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
chk_tdiv.c
Go to the documentation of this file.
1 #include "l1stat.h"
2 #include "l1stat_proto.h"
3 extern int32 stat_status;
4 extern char bad_stat_str[320];
5 
6 void chk_tdiv(int32 sdfid, int16 dtynum, int32 nscans, thr_ctl_def thr_ctl)
7 /*******************************************************************
8 
9  chk_tdiv
10 
11  purpose: Check the tdi setting in some or all of the 8 bands
12  for the GAC, LAC, SOL and LUN data which have only 1
13  expected tdi per channel. The SDS tdi is used for this
14 
15  Returns type: void - none
16 
17  Parameters: (in calling order)
18  Type Name I/O Description
19  ---- ---- --- -----------
20  int32 sdfid I SD interface ID
21  int16 dtynum I data type #
22  int32 nscans I # lines in dataset
23  thr_ctl_def thr_ctl I structure with checking
24  thresholds
25 
26  Modification history:
27  Programmer Date Description of change
28  ---------- ---- ---------------------
29  W. Robinson 2-Nov-2001 Original development
30 
31  *******************************************************************/ {
32  int32 start[3], edge[3], count_bad, band, iscan, icode;
33  int16 *tdi;
34  float32 pct;
35  int32 count_mul[6], i;
36  float32 pct_mul[6];
37  char str[12];
38 
39  /*
40  * the tdi for GAC, LAC, SOL and LUN should always be 0 -
41  * 4:1 TDI or 1 contribution from each of the 4 detectors
42  *
43  * for TDI and IGC, at least 8% have one of the 5 TDI settings of:
44  * 0 - 4:1, 37 - use det #1 for all, 88 - use det #2 for all,
45  * 82 - use det #3 for all, 133 - use det #4 for all
46  */
47  /*
48  * read in the SDS
49  */
50  if ((tdi = (int16 *) malloc(8 * nscans * sizeof ( int16))) == NULL) {
51  printf("\n*****chk_tdiv: program error, unable to allocate tdi space\n");
53  return;
54  }
55 
56  start[0] = start[1] = start[2] = 0;
57  edge[0] = nscans;
58  edge[1] = 8;
59  edge[2] = 0;
60 
61  if (rdslice(sdfid, "tdi", start, edge, (void *) tdi) < 0) {
63  printf("\n*****chk_tdiv: program error, unable to read tdi\n");
64  return;
65  }
66  if ((dtynum == GAC) || (dtynum == LAC) || (dtynum == SOL) ||
67  (dtynum == LUN)) {
68  /*
69  * loop through the 8 bands and check if they conform
70  */
71  printf("\n\nTDI value conformance check for GAC, LAC, SOL, LUN\n");
72 
73 
74  /* for lining it up...
75  printf( "\n Name code #bad %bad error %
76  printf( "\nTDIV_CHKX vvvv vvvvvv vvvvvvv vvvvvvv
77  printf( "--------- ---- ------ ------- -------
78  */
79 
80  printf("\n Name code #bad %%bad error %%\n");
81  printf("--------- ---- ------ ------- -------\n");
82 
83  for (band = 0; band < 8; band++) {
84  if (thr_ctl.tdiv_chk_do[band] == 1) {
85  count_bad = 0;
86  for (iscan = 0; iscan < nscans; iscan++) {
87  if (*(tdi + band + 8 * iscan) != 0)
88  count_bad++;
89  }
90  /*
91  * report the news for this item
92  */
93  pct = (float32) count_bad / nscans * 100.;
94  icode = 0;
95  if (pct > thr_ctl.tdiv_chk_pct[band]) {
96  icode = 1;
97  if (thr_ctl.rpt_tdi_vchk == 1) {
99  sprintf(str, "TDIV_CHK%1d ", (band + 1));
100  if (strlen(bad_stat_str) <= 300)
101  strcat(bad_stat_str, str);
102  }
103  }
104  printf("TDIV_CHK%1d %4d %6d %7.2f %7.2f\n", (band + 1),
105  icode, count_bad, pct, thr_ctl.tdiv_chk_pct[band]);
106  }
107  }
108  } else if ((dtynum == IGC) || (dtynum == TDI)) {
109  /*
110  * loop through the 8 bands and check if they conform
111  */
112  printf("\n\nTDI value conformance check for IGC, TDI\n");
113 
114  /* for lining it up...
115  printf( "\n Name code %4:1 % det 1 % det 2 % det 3 % det 4 % other error %
116  printf( "\nTDIV_CHKX vvvv vvvvvvv vvvvvvv vvvvvvv vvvvvvv vvvvvvv vvvvvvv vvvvvvv
117  printf( "--------- ---- ------- ------- ------- ------- ------- ------- -------
118  */
119 
120  printf("\n Name code %%4:1 %% det 1 %% det 2 %% det 3 %% det 4 %% other error %%\n");
121  printf("--------- ---- ------- ------- ------- ------- ------- ------- -------\n");
122 
123  for (band = 0; band < 8; band++) {
124  if (thr_ctl.tdiv_chk_do[band] == 1) {
125  for (i = 0; i < 6; i++)
126  count_mul[i] = 0;
127  for (iscan = 0; iscan < nscans; iscan++) {
128  if (*(tdi + band + 8 * iscan) == 0)
129  count_mul[0]++;
130  else if (*(tdi + band + 8 * iscan) == 37)
131  count_mul[1]++;
132  else if (*(tdi + band + 8 * iscan) == 88)
133  count_mul[2]++;
134  else if (*(tdi + band + 8 * iscan) == 82)
135  count_mul[3]++;
136  else if (*(tdi + band + 8 * iscan) == 133)
137  count_mul[4]++;
138  else
139  count_mul[5]++;
140  }
141  /*
142  * report the news for this item
143  */
144  icode = 0;
145  for (i = 0; i < 6; i++) {
146  pct_mul[i] = (float32) count_mul[i] / nscans * 100.;
147  if (i < 5) {
148  if (pct_mul[i] < 8.) {
149  icode = 1;
150  if (thr_ctl.rpt_tdi_vchk == 1) {
151  stat_status = stat_status | 2;
152  sprintf(str, "TDIV_CHK%1d ", (band + 1));
153  if (strlen(bad_stat_str) <= 300)
154  strcat(bad_stat_str, str);
155  }
156  }
157  } else {
158  if (pct_mul[i] > thr_ctl.tdiv_chk_pct[band]) {
159  icode = 1;
160  if (thr_ctl.rpt_tdi_vchk == 1) {
161  stat_status = stat_status | 2;
162  sprintf(str, "TDIV_CHK%1d ", (band + 1));
163  if (strlen(bad_stat_str) <= 300)
164  strcat(bad_stat_str, str);
165  }
166  }
167  }
168  }
169  printf("TDIV_CHK%1d %4d %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n",
170  (band + 1), icode, pct_mul[0], pct_mul[1], pct_mul[2], pct_mul[3],
171  pct_mul[4], pct_mul[5], thr_ctl.tdiv_chk_pct[band]);
172  }
173  }
174  }
175  printf("\n\n");
176  /*
177  * that's all
178  */
179  return;
180 }
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed as required for compatibility with version of the SDP toolkit Corrected test output file names to end in per delivery and then split off a new MYD_PR03 pcf file for Aqua Added AssociatedPlatformInstrumentSensor to the inventory metadata in MOD01 mcf and MOD03 mcf Created new versions named MYD01 mcf and MYD03 where AssociatedPlatformShortName is rather than Terra The program itself has been changed to read the Satellite Instrument LUN
Definition: HISTORY.txt:441
integer, parameter int16
Definition: cubeio.f90:3
int32 stat_status
Definition: l1stat_chk.c:8
int32 rdslice(int32 sdfid, char *name, int32 *start, int32 *edge, void *buf)
Definition: stat_chk_utl.c:94
#define TDI
Definition: l1stat.h:39
#define NULL
Definition: decode_rs.h:63
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
#define GAC
Definition: l1stat.h:33
#define LAC
Definition: l1stat.h:34
#define IGC
Definition: l1stat.h:38
void chk_tdiv(int32 sdfid, int16 dtynum, int32 nscans, thr_ctl_def thr_ctl)
Definition: chk_tdiv.c:6
#define SOL
Definition: l1stat.h:37
int16_t tdi[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:37
char bad_stat_str[320]
Definition: l1stat_chk.c:11
const char * str
Definition: l1c_msi.cpp:35
int32_t iscan
int i
Definition: decode_rs.h:71