OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
c_sf.c
Go to the documentation of this file.
1 /*
2  * c_sf.c - wrappers for the table reading in the chimaera code
3  *
4  * W. Robinson, SAIC, 12 Dec 2018
5  */
6 #include <string.h>
7 #include "mfhdf.h"
8 
9 /*
10  * first, the sfstart replacement
11  */
12 int32_t c_sfstart_( char *name, int32_t *access, int nam_len )
13  /* return the file ID
14  name I file name
15  access I access mode read is DFACC_READ (also_WRITE, CREATE)
16  nam_len I length of ftn string
17  */
18 
19  {
20  char *fn, *bptr;
21  int32_t ret;
22 
23  fn = (char *) malloc( nam_len + 1 * sizeof( char ) );
24  fn[ nam_len ] = (char) 0;
25  strncpy( fn, name, nam_len );
26  bptr = strchr( fn, ' ' );
27  if( bptr != NULL ) {
28  *bptr = 0;
29  }
30 
31  ret = (int32_t) SDstart( fn, *access);
32  free(fn);
33 
34  return(ret);
35  }
36 /*
37  * next the sfselect
38  */
39 int32_t c_sfselect_( int32_t *file_id, int32_t *index )
40  /* return the SDS ID
41  file_id I file ID
42  index I index from c_sfn2index_
43  */
44  {
45  int32_t fid;
46 
47  fid = SDselect( *file_id, *index );
48  return( fid );
49  }
50 /*
51  * next the sfn2index
52  */
53 int32_t c_sfn2index_( int32_t *fid, char *name, int32_t nam_len )
54  /* return the index of the SDS name
55  name I SDS name
56  nam_len I length of SDS name
57  */
58  {
59  char *fn, *bptr;
60  int32_t ret;
61 
62  fn = (char *) malloc( nam_len + 1 * sizeof( char ) );
63  fn[ nam_len ] = (char) 0;
64  strncpy( fn, name, nam_len );
65  bptr = strchr( fn, ' ' );
66  if( bptr != NULL ) {
67  *bptr = 0;
68  }
69 
70  ret = SDnametoindex( *fid, fn );
71  free(fn);
72 
73  return(ret);
74  }
75 /*
76  * next the sfginfo
77  */
78 int32_t c_sfginfo_( int32_t *vid, char *name, int32_t *rank, int32_t *dims,
79  int32_t *nt, int32_t *nattr, int32_t nam_len )
80  /* get info about a SDS
81  return 0 if good
82  vid I SDS ID
83  name O SDS name
84  rank O # dims
85  dims O length of each dim
86  nt O data type
87  nattr O # attributes
88  nam_len I len of name string
89  */
90  {
91  char *fn, *bptr;
92  int32_t ret;
93  int32 cdims[100], i;
94  int32 rank32, nt32, nattr32;
95 
96  fn = NULL;
97  if( nam_len != 0 ) {
98 
99  fn = (char *) malloc( nam_len + 1 * sizeof( char ) );
100  fn[ nam_len ] = (char) 0;
101  strncpy( fn, name, nam_len );
102  bptr = strchr( fn, ' ' );
103  if( bptr != NULL ) {
104  *bptr = 0;
105  }
106  }
107 
108  ret = SDgetinfo((int32) *vid, fn, &rank32, cdims, &nt32, &nattr32);
109 
110  for(i = 0; i < rank32; i++)
111  dims[i] = cdims[rank32 - i - 1];
112  if( nam_len != 0 ) free(fn);
113  *rank = (int32_t) rank32;
114  *nt = (int32_t) nt32;
115  *nattr = (int32_t) nattr32;
116 
117  return( ret );
118  }
119 /*
120  * next the sfrdata
121  */
122 int32_t c_sfrdata_( int32_t *vid, int32_t *start, int32_t *stride,
123  int32_t *end, VOIDP values )
124  /* read the data slice
125  return 0 if good
126  vid I SDS ID
127  start, stride, end I the start, stride and # too read in each dim
128  values O space for read array
129  */
130  {
131  int32_t ret;
132  int32_t i, rank, dims[100], nt, nattrs, status;
133  int32_t cstart[100], cstride[100], cend[100];
134  int nostride;
135 
136  status = SDgetinfo( *vid, NULL, &rank, dims, &nt, &nattrs);
137  if(status == FAIL) return FAIL;
138 
139  nostride = TRUE;
140 
141  for(i = 0; i < rank; i++) {
142  cstart[i] = start[rank - i - 1];
143  cend[i] = end[rank - i - 1];
144  if((cstride[i] = stride[rank - i - 1]) != 1) nostride = FALSE;
145  }
146 
147  ret = (int32_t) SDreaddata(*vid, cstart, (nostride? NULL : cstride),
148  cend, values);
149 
150  return( ret );
151  }
152 /*
153  * next the sfendacc
154  */
155 int32_t c_sfendacc_( int32_t *vid )
156  /* close SDS id
157  return 0 if good
158  vid I SDS ID
159  */
160  {
161  int32_t ret;
162 
163  ret = SDendaccess( *vid );
164 
165  return( ret );
166  }
167 /*
168  * next the sfend
169  */
170 int32_t c_sfend_( int32_t *id )
171  /* close file
172  return 0 if good
173  id I file id
174  */
175  {
176  int32_t ret;
177 
178  ret = SDend( *id );
179 
180  return( ret );
181  }
182 
183 
184 
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_t c_sfend_(int32_t *id)
Definition: c_sf.c:170
int status
Definition: l1_czcs_hdf.c:32
int32_t c_sfrdata_(int32_t *vid, int32_t *start, int32_t *stride, int32_t *end, VOIDP values)
Definition: c_sf.c:122
#define FAIL
Definition: ObpgReadGrid.h:18
#define FALSE
Definition: rice.h:164
#define NULL
Definition: decode_rs.h:63
#define TRUE
Definition: rice.h:165
int32_t c_sfn2index_(int32_t *fid, char *name, int32_t nam_len)
Definition: c_sf.c:53
int32_t c_sfselect_(int32_t *file_id, int32_t *index)
Definition: c_sf.c:39
HISTORY txt for MOD_PR01(step one of PGE01) History follows the following convention needed due to new Aqua ReprocessingActual and the expected LUT revision number from PCF Changed to use PGE version for ProductionHistory Added Archive including ProcessingEnvironment Corrected handling of bad to resovle GSFcd02514 Changed to check staged LUT revision number versus the expected LUT revision number from thereby resolving defect report MODxl02056 This change also avoids the memory access violation reported in MODur00039 Changed the way output arrays were initialized with fill values
Definition: HISTORY.txt:162
int32_t c_sfstart_(char *name, int32_t *access, int nam_len)
Definition: c_sf.c:12
Extra metadata that will be written to the HDF4 file l2prod rank
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second and prod_ix set to PARAM_TYPE_INT name_prefix is compared with the beginning of the product name If name_suffix is not empty the it must match the end of the product name The characters right after the prefix are read as an integer and prod_ix is set to that number strncpy(l2prod->name_prefix, "myprod", UNITLEN)
int32_t c_sfendacc_(int32_t *vid)
Definition: c_sf.c:155
int i
Definition: decode_rs.h:71
int32_t c_sfginfo_(int32_t *vid, char *name, int32_t *rank, int32_t *dims, int32_t *nt, int32_t *nattr, int32_t nam_len)
Definition: c_sf.c:78