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