OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
chk_gainv.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_gainv(int32 sdfid, int16 dtynum, int32 nscans, thr_ctl_def thr_ctl)
7 /*******************************************************************
8 
9  chk_gainv
10 
11  purpose: Check the gain setting in some or all of the 8 bands
12  for the GAC, LAC, SOL and KUN data which have only 1
13  expected gain per channel. The SDS gain 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, gptr, iscan, icode;
33  int16 *gain;
34  /* gval_dtyp will give the gain settings for GAC, LAC, SOL and LUN */
35  int32 gval_dtyp[4][8] = {
36  { 0, 0, 0, 0, 0, 0, 0, 0},
37  { 0, 0, 0, 0, 0, 0, 0, 0},
38  { 1, 0, 1, 1, 1, 1, 1, 1},
39  { 3, 1, 1, 1, 1, 1, 1, 1}
40  };
41  float32 pct;
42  char str[12];
43  /*
44  * according to the data type, point to the correct expected gains
45  */
46  if (dtynum == GAC) {
47  gptr = 0;
48  } else if (dtynum == LAC) {
49  gptr = 1;
50  } else if (dtynum == SOL) {
51  gptr = 2;
52  } else if (dtynum == LUN) {
53  gptr = 3;
54  } else
55  return;
56  /*
57  * read in the SDS
58  */
59  if ((gain = (int16 *) malloc(8 * nscans * sizeof ( int16))) == NULL) {
60  printf("\n*****chk_gainv: program error, unable to allocate gain space\n");
62  return;
63  }
64 
65  start[0] = start[1] = start[2] = 0;
66  edge[0] = nscans;
67  edge[1] = 8;
68  edge[2] = 0;
69 
70  if (rdslice(sdfid, "gain", start, edge, (void *) gain) < 0) {
72  printf("\n*****chk_gainv: program error, unable to read gain\n");
73  return;
74  }
75  /*
76  * loop through the 8 bands and check if they conform
77  */
78  printf("\n\nGain value conformance check\n");
79 
80 
81  /* for lining it up...
82  printf( "\n Name code #bad %bad error %
83  printf( "\nGAINV_CHKX vvvv vvvvvv vvvvvvv vvvvvvv
84  printf( "---------- ---- ------ ------- -------
85  */
86 
87  printf("\n Name code #bad %%bad error %%\n");
88  printf("---------- ---- ------ ------- -------\n");
89 
90  for (band = 0; band < 8; band++) {
91  if (thr_ctl.gainv_chk_do[band] == 1) {
92  count_bad = 0;
93  for (iscan = 0; iscan < nscans; iscan++) {
94  if (*(gain + band + 8 * iscan) != gval_dtyp[gptr][band])
95  count_bad++;
96  }
97  /*
98  * report the news for this item
99  */
100  pct = (float32) count_bad / nscans * 100.;
101  icode = 0;
102  if (pct > thr_ctl.gainv_chk_pct[band]) {
103  icode = 1;
104  if (thr_ctl.rpt_gainv_chk == 1) {
105  stat_status = stat_status | 2;
106  sprintf(str, "GAINV_CHK%1d ", (band + 1));
107  if (strlen(bad_stat_str) <= 300)
108  strcat(bad_stat_str, str);
109  }
110  }
111  printf("GAINV_CHK%1d %4d %6d %7.2f %7.2f\n", (band + 1),
112  icode, count_bad, pct, thr_ctl.gainv_chk_pct[band]);
113  }
114  }
115  printf("\n\n");
116  /*
117  * that's all
118  */
119  return;
120 }
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 rdslice(int32 sdfid, char *name, int32 *start, int32 *edge, void *buf)
Definition: stat_chk_utl.c:94
int32 stat_status
Definition: l1stat_chk.c:8
int16 * gain
Definition: l1_czcs_hdf.c:33
#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
void chk_gainv(int32 sdfid, int16 dtynum, int32 nscans, thr_ctl_def thr_ctl)
Definition: chk_gainv.c:6
#define GAC
Definition: l1stat.h:33
#define LAC
Definition: l1stat.h:34
#define SOL
Definition: l1stat.h:37
const char * str
Definition: l1c_msi.cpp:35
int32_t iscan
char bad_stat_str[320]
Definition: l1stat_chk.c:11