OB.DAAC Logo
NASA Logo
Ocean Color Science Software

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