OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
stat_chk_utl.c
Go to the documentation of this file.
1 #include "l1stat.h"
2 #include "l1stat_proto.h"
3 
4 #define STMAX 255
5 
6 extern char err_msg[1024];
7 extern int32 stat_status; /* status of statistical checking: 0 all good,
8  1 program problem, 2 statistical problem,
9  3 both problems */
10 
11 /*-----------------------------------------------------------------------------
12  Function: rdattr
13 
14  Returns: int32 (status)
15  The return code is a negative value if any error occurs, otherwise,
16  returns 0.
17 
18  Description:
19  The function rdattr reads the requested global attribute
20 
21  Parameters: (in calling order)
22  Type Name I/O Description
23  ---- ---- --- -----------
24  int32 sdfid I ID req to access HDF SDS interface
25  char * attr_name I attribute name
26  void * buf I/O pointer to data buffer
27 
28  Modification history:
29  Programmer Organization Date Description of change
30  -------------- ------------ -------- ---------------------
31  Lakshmi Kumar Hughes STX 11/07/94 Original development
32 
33 ----------------------------------------------------------------------------*/
34 int32
35 #ifdef PROTOTYPE
36 rdattr(int32 sdfid, char *attr_name, void *buf)
37 #else
38 rdattr(sdfid, attr_name, buf)
39 int32 sdfid;
40 char *attr_name;
41 void *buf;
42 #endif
43 {
44  int32 attrnum;
45 
46  if ((attrnum = SDfindattr(sdfid, attr_name)) < 0) {
47  sprintf(err_msg, "rdattr: Failure in SDfindattr while trying \
48  to read %s", attr_name);
50  return FAIL;
51  }
52 
53  if ((SDreadattr(sdfid, attrnum, buf)) < 0) {
54  sprintf(err_msg, "rdattr: Failure in SDreadattr while trying to \
55  read %s", attr_name);
57  return FAIL;
58  }
59 
60  return SUCCEED;
61 }
62 
63 /*-----------------------------------------------------------------------------
64  Function: rdslice
65 
66  Returns: int32 (sdsid)
67  The return code is a negative value if any error occurs, otherwise,
68  returns sdsid.
69 
70  Description:
71  The function rdslice reads requested slice of data from the
72  given named dataset
73 
74  Parameters: (in calling order)
75  Type Name I/O Description
76  ---- ---- --- -----------
77  int32 sdfid I ID req to access HDF SDS interface
78  char *name I SDS name
79  int32 *start I start data dimension
80  int32 *edge I no. of values to be read
81  void *buf O SDS data buffer
82 
83  NOTE:
84 
85  Modification history:
86  Programmer Organization Date Description of change
87  -------------- ------------ -------- ---------------------
88  Lakshmi Kumar Hughes STX 11/02/94 Original development
89 ----------------------------------------------------------------------------*/
90 int32
91 #ifdef PROTOTYPE
92 rdslice(int32 sdfid, char *name, int32 *start, int32 *edge, void *buf)
93 #else
94 rdslice(sdfid, name, start, edge, buf)
95 int32 sdfid, *start, *edge;
96 char *name;
97 void *buf;
98 #endif
99 {
100  int32 index, sdsid, rank, num_type, nattrs;
101  char sdsname[STMAX];
102  /*
103  clock_t val, val2;
104  */
105  if ((index = SDnametoindex(sdfid, name)) < 0) {
106  sprintf(err_msg, "rdslice: Failed to locate sds \"%s\" ", name);
107  return FAIL;
108  }
109  if ((sdsid = SDselect(sdfid, index)) < 0) {
110  sprintf(err_msg, "rdslice: SDselect failed for sds \"%s\" ", name);
111  return FAIL;
112  }
113 
114  if (edge[0] == 0 && edge[1] == 0 && edge[2] == 0)
115  if ((SDgetinfo(sdsid, sdsname, &rank, edge, &num_type, &nattrs)) < 0)
116  return FAIL;
117  /*
118  val = clock();
119  */
120  if ((SDreaddata(sdsid, start, NULL, edge, buf)) < 0) {
121  sprintf(err_msg,
122  "rdslice: SDreaddata error while reading \"%s\" ", name);
123  return FAIL;
124  }
125  /*
126  val2 = clock();
127  printf("\ntime took for %s = %d\n", name, val2-val);
128  */
129  SDendaccess(sdsid);
130  return SUCCEED;
131 }
an array had not been initialized Several spelling and grammar corrections were which is read from the appropriate MCF the above metadata values were hard coded A problem calculating the average background DN for SWIR bands when the moon is in the space view port was corrected The new algorithm used to calculate the average background DN for all reflective bands when the moon is in the space view port is now the same as the algorithm employed by the thermal bands For non SWIR changes in the averages are typically less than Also for non SWIR the black body DNs remain a backup in case the SV DNs are not available For SWIR the changes in computed averages were larger because the old which used the black body suffered from contamination by the micron leak As a consequence of the if SV DNs are not available for the SWIR the EV pixels will not be the granule time is used to identify the appropriate tables within the set given for one LUT the first two or last two tables respectively will be used for the interpolation If there is only one LUT in the set of it will be treated as a constant LUT The manner in which Earth View data is checked for saturation was changed Previously the raw Earth View DNs and Space View DNs were checked against the lookup table values contained in the table dn_sat The change made is to check the raw Earth and Space View DNs to be sure they are less than the maximum saturation value and to check the Space View subtracted Earth View dns against a set of values contained in the new lookup table dn_sat_ev The metadata configuration and ASSOCIATEDINSTRUMENTSHORTNAME from the MOD02HKM product The same metatdata with extensions and were removed from the MOD021KM and MOD02OBC products ASSOCIATEDSENSORSHORTNAME was set to MODIS in all products These changes are reflected in new File Specification which users may consult for exact the pow functions were eliminated in Emissive_Cal and Emissive bands replaced by more efficient code Other calculations throughout the code were also made more efficient Aside from a few round off there was no difference to the product The CPU time decreased by about for a day case and for a night case A minor bug in calculating the uncertainty index for emissive bands was corrected The frame index(0-based) was previously being used the frame number(1-based) should have been used. There were only a few minor changes to the uncertainty index(maximum of 1 digit). 3. Some inefficient arrays(Sigma_RVS_norm_sq) were eliminated and some code lines in Preprocess_L1A_Data were moved into Process_OBCEng_Emiss. There were no changes to the product. Required RAM was reduced by 20 MB. Now
int32 rdslice(int32 sdfid, char *name, int32 *start, int32 *edge, void *buf)
Definition: stat_chk_utl.c:94
int32 rdattr(int32 sdfid, char *attr_name, void *buf)
Definition: stat_chk_utl.c:38
#define FAIL
Definition: ObpgReadGrid.h:18
#define NULL
Definition: decode_rs.h:63
#define STMAX
Definition: stat_chk_utl.c:4
Extra metadata that will be written to the HDF4 file l2prod rank
int32 stat_status
Definition: l1stat_chk.c:8
char err_msg[1024]
Definition: l1stat_chk.c:7