OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
hio_r_sds.c
Go to the documentation of this file.
1 #include <string.h>
2 #include "hio.h"
3 
4 int32 hio_r_sds(hio_struct info, char *arr_name, int32 exp_ntyp,
5  void *array)
6 /*******************************************************************
7 
8  hio_r_sds
9 
10  purpose: read a full science dataset to an array
11 
12  Returns type: int32 - return status: 0 is good
13 
14  Parameters: (in calling order)
15  Type Name I/O Description
16  ---- ---- --- -----------
17  struct hio_struct info I information struct
18  about the opened file
19  char * arr_name I name of science dataset
20  to read
21  int32 exp_ntyp I expected number type
22  void* array O array of data from the sds
23  already allocated outside
24 
25  Modification history:
26  Programmer Date Description of change
27  ---------- ---- ---------------------
28  W. Robinson 16-Sep-2005 Original development
29 
30  *******************************************************************/
31  {
32  int j;
33  int32 index, rank, sdid, numbertype, nattrs, data_dims[5];
34  int32 start[5], edge[5];
35  char name[H4_MAX_NC_NAME]; /* MAX_NC_NAME is max # chars for this */
36 
37  /*
38  * SDnametoindex is used to zero in on the data we want,
39  * ie. get the index of the data
40  */
41  if ((index = SDnametoindex(info.sdfid, arr_name)) < 0) {
42  printf("%s: couldn't find %s in the dataset\n", __FILE__,
43  arr_name);
44  return -1;
45  }
46 
47  /*
48  * next, get the SD ID for the data
49  */
50  if ((sdid = SDselect(info.sdfid, index)) < 0) {
51  printf("%s: Failed in SDselect for item %s\n", __FILE__,
52  arr_name);
53  return -1;
54  }
55 
56  /*
57  * now, get the size information of the data item
58  */
59  if (SDgetinfo(sdid, name, &rank, data_dims, &numbertype,
60  &nattrs) < 0) {
61  printf("%s: Failed in SDgetinfo for item %s\n", __FILE__,
62  arr_name);
63  return -1;
64  }
65 
66  if (numbertype != exp_ntyp) {
67  printf(
68  "%s: Type of data to be read is not type expected for item %s\n",
69  __FILE__, arr_name);
70  printf("actual type: %d, expected type: %d\n", numbertype, exp_ntyp);
71  return -1;
72  }
73 
74  /*
75  * compute the read controls for whole array
76  */
77 
78  for (j = 0; j < rank; j++) {
79  start[j] = 0;
80  edge[j] = data_dims[j];
81  }
82 
83  /*
84  * read the data
85  */
86  if (SDreaddata(sdid, start, NULL, edge, array) < 0) {
87  printf("%s: failure to read data for item %s\n", __FILE__, arr_name);
88  return -1;
89  }
90  return 0;
91 }
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
Extra metadata that will be written to the HDF4 file l2prod rank
int32 hio_r_sds(hio_struct info, char *arr_name, int32 exp_ntyp, void *array)
Definition: hio_r_sds.c:4