OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
l1io_read.c
Go to the documentation of this file.
1 #include <string.h>
2 #include "l1io.h"
3 #include <mfhdf.h>
4 
5 int32_t l1io_read(l1info_struct l1info, int irec,
6  int16_t *data, navblockType *nav)
7 /*******************************************************************
8 
9  get_l1a_read
10 
11  purpose: read a record of some information from the level 1 dataset
12 
13  Returns type: int32 - return status: 0 is good
14 
15  Parameters: (in calling order)
16  Type Name I/O Description
17  ---- ---- --- -----------
18  struct l1info_struct l1info I information struct
19  about the opened file
20  int irec I line, record # to read
21  int16 * data O array of data: 1 line
22  with 8 channels
23  struct navblockType * nav O navigation info struct
24 
25  Modification history:
26  Programmer Date Description of change
27  ---------- ---- ---------------------
28  W. Robinson 16-Aug-1994 Original development
29 
30  *******************************************************************/
31  {
32  int i, j;
33  int32 index, rank, sdid, numbertype, nattrs, data_dims[5];
34  int32 start[5], edge[5];
35  void *ptr; /* generic data pointer */
36  char name[H4_MAX_NC_NAME]; /* MAX_NC_NAME is max # chars for this */
37 
38  /* for use after 15 Aug 94 I/O spec v3.0 */
39  static char *namelist[8] ={"l1a_data", "orb_vec", "l_vert", "sun_ref",
40  "att_ang", "sen_mat", "scan_ell", "nflag"};
41 
42  /* for use before 15 Aug 94 I/O spec v3.0
43  static char *namelist[8] =
44  { "scan_line", "orb_vec", "l_vert", "sun_ref",
45  "att_ang", "sen_mat", "scan_ell", "nflag" };
46  */
47 
48  /*
49  * now, SDnametoindex is used to zero in on the data we want,
50  * ie. get the index of the data
51  */
52 
53  for (i = 0; i < 8; i++) {
54  if ((index = SDnametoindex(l1info.sdfid, namelist[i])) < 0) {
55  printf("l1io_read: couldn't find %s in the qc dataset\n",
56  namelist[i]);
57  return -1;
58  }
59 
60  /*
61  * next, get the SD ID for the data
62  */
63  if ((sdid = SDselect(l1info.sdfid, index)) < 0) {
64  printf("l1io_read: Failed in SDselect for item %s\n",
65  namelist[i]);
66  return -1;
67  }
68 
69  /*
70  * now, get the size information of the data item
71  */
72  if (SDgetinfo(sdid, name, &rank, data_dims, &numbertype,
73  &nattrs) < 0) {
74  printf("l1io_read: Failed in SDgetinfo for item %s\n",
75  namelist[i]);
76  return -1;
77  }
78 
79  /*
80  * compute the read controls
81  */
82  for (j = 0; j < rank; j++) {
83  start[j] = 0;
84  edge[j] = 1; /* test WDR */
85  edge[j] = data_dims[j];
86  }
87  start[0] = irec; /* the first dim is the row dim so set for the rec */
88  edge[0] = 1;
89 
90  /*
91  * set the pointer to read into for the 8 sds arrays being read
92  */
93 
94  switch (i) {
95  case 0: /* "l1a_data" */
96  {
97  ptr = (void *) data;
98  break;
99  }
100  case 1: /* "orb_vec" */
101  {
102  ptr = (void *) (nav->orb_vec);
103  break;
104  }
105  case 2: /* "l_vert" */
106  {
107  ptr = (void *) (nav->l_vert);
108  break;
109  }
110  case 3: /* "sun_ref" */
111  {
112  ptr = (void *) (nav->sun_ref);
113  break;
114  }
115  case 4: /* "att_ang" */
116  {
117  ptr = (void *) (nav->att_ang);
118  break;
119  }
120  case 5: /* "sen_mat" */
121  {
122  ptr = (void *) (nav->sen_mat);
123  break;
124  }
125  case 6: /* "scan_ell" */
126  {
127  ptr = (void *) (nav->scan_ell);
128  break;
129  }
130  case 7: /* "nflag" */
131  {
132  ptr = (void *) (nav->nflag);
133  break;
134  }
135  }
136  /*
137  * read the data
138  */
139  if (SDreaddata(sdid, start, NULL, edge, ptr) < 0)
140  /* if( SDreaddata( sdid, start, stride, edge, ptr ) < 0 ) */ {
141  printf("l1io_read: failure to read data for item %s\n", namelist[i]);
142  return -1;
143  }
144  }
145  return 0;
146 }
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
int j
Definition: decode_rs.h:73
#define NULL
Definition: decode_rs.h:63
int32_t l1io_read(l1info_struct l1info, int irec, int16_t *data, navblockType *nav)
Definition: l1io_read.c:5
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude data
Definition: HISTORY.txt:356
Extra metadata that will be written to the HDF4 file l2prod rank
int i
Definition: decode_rs.h:71