OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
GEO_write_parameters.c
Go to the documentation of this file.
1 #include <stddef.h>
2 #include "PGS_MODIS_35251.h"
3 #include "GEO_product.h"
4 #include "GEO_output.h"
5 
7  MODFILE * const geo_file,
9  )
180 {
181 
182  /* Local variable declarations */
183 
184  #define BANDS (long)(MAX_BAND_NUMBER+1)
185  struct {
186  char *name;
187  long rank;
188  long dimensions[2];
189  char data_type[DATATYPELENMAX];
190  size_t data;
191  char *units;
192  } SDS_object[] = {
193  {FOCAL_LENGTH, 1L, {BANDS}, R64,
194  offsetof(GEO_param_struct, geometry_params.focal_length), "meters"},
195  {BAND_POSITION, 1L, {BANDS}, R64,
196  offsetof(GEO_param_struct, geometry_params.band_position),
197  "frame sample time"},
198  {DETECTOR_SPACE, 1L, {BANDS}, R64,
199  offsetof(GEO_param_struct, geometry_params.det_space), "meters"},
200  {DETECTOR_OFFSETS, 2L, {BANDS, 2L}, R64,
201  offsetof(GEO_param_struct, geometry_params.det_position), "meters"},
202  {T_OFFSET, 1L, {BANDS}, R64,
203  offsetof(GEO_param_struct, geometry_params.F_offset),
204  "frame sample time"},
205  {NUM_SAMPLES, 1L, {BANDS}, UI16,
206  offsetof(GEO_param_struct, geometry_params.N_samp), NULL}
207  };
208  long start[] = {0L, 0L, 0L};
209  int obj;
210  int retval = SUCCESS;
211  uint32 dim_index[] = {0,1};
212  char msgbuf[PGS_SMF_MAX_MSGBUF_SIZE];
213  char filefunc[] = __FILE__ ", GEO_write_parameters";
214 
215 
216  if(parameter==NULL || geo_file==NULL)
217  {
218  sprintf(msgbuf, "parameter=%p, geo_file=%p",
219  (void*)parameter, (void*)geo_file);
220  modsmf(MODIS_E_BAD_INPUT_ARG, msgbuf, filefunc);
221 
222  return FAIL;
223  }
224 
225  /* Begin output of parameters */
226  for(obj=0; obj<(int)(sizeof(SDS_object)/sizeof(SDS_object[0]))
227  && retval==SUCCESS; obj++)
228  {
229  if(createMODISarray(geo_file, SDS_object[obj].name, PARM_GRP,
230  SDS_object[obj].data_type, SDS_object[obj].rank,
231  SDS_object[obj].dimensions) !=MAPIOK)
232  {
233  retval = FAIL;
234  sprintf(msgbuf, "createMODISarray(\"%s\", \"" PARM_GRP
235  "\", \"%s\", %ld)", SDS_object[obj].name, SDS_object[obj].data_type,
236  SDS_object[obj].rank);
237 
238  modsmf(MODIS_E_GEO, msgbuf, filefunc);
239  }
240  else if( putMODISdimname(geo_file, SDS_object[obj].name, PARM_GRP, 0,
241  NUMBANDS) != MAPIOK)
242  {
243  retval = FAIL;
244  sprintf(msgbuf, "putMODISdimname(\"%s\", \"%s\", \"" PARM_GRP
245  "\", 0, \"" NUMBANDS "\")",
246  geo_file->filename, SDS_object[obj].name);
247  modsmf(MODIS_E_GEO, msgbuf, filefunc);
248  }
249  else if( putMODISarray(geo_file, SDS_object[obj].name, PARM_GRP, start,
250  SDS_object[obj].dimensions, (char *)parameter+SDS_object[obj].data)
251  != MAPIOK)
252  {
253  retval = FAIL;
254  sprintf(msgbuf, "putMODISarray(\"%s\", \"%s\", \"" PARM_GRP "\")",
255  geo_file->filename, SDS_object[obj].name);
256  modsmf(MODIS_E_GEO, msgbuf, filefunc);
257  }
258  else if(SDS_object[obj].units!=NULL)
259  {
260  if(putMODISarinfo(geo_file, SDS_object[obj].name, PARM_GRP, MUNITS,
261  TXT, (long)strlen(SDS_object[obj].units), SDS_object[obj].units)
262  != MAPIOK)
263  {
264  retval = FAIL;
265  sprintf(msgbuf, "putMODISarinfo(\"%s\", \"%s\", \"" PARM_GRP
266  "\", \"" MUNITS "\", \"" TXT "\", %ld, \"%s\")",
267  geo_file->filename, SDS_object[obj].name,
268  (long)strlen(SDS_object[obj].units), SDS_object[obj].units);
269  modsmf(MODIS_E_GEO, msgbuf, filefunc);
270  }
271  }
272  } /* for each SDS_object */
273 
274  if(putMODISfileinfo(geo_file, BAND_NUMBER, I16, 1,
275  &parameter->geometry_params.band_number) != MAPIOK)
276  {
277  retval = FAIL;
278  sprintf(msgbuf,
279  "putMODISfileinfo(\"%s\", \"" BAND_NUMBER "\", \"" I16 "\", 1, %d)",
280  geo_file->filename, (int)parameter->geometry_params.band_number);
281  modsmf(MODIS_E_GEO, msgbuf, filefunc);
282  }
283 
284  if(putMODISarinfo(geo_file, DETECTOR_OFFSETS, PARM_GRP, SCANDIM, UI32,
285  1L, &dim_index[0]) != MAPIOK)
286  {
287  retval = FAIL;
288  sprintf(msgbuf, "putMODISarinfo(\"%s\", \"" PARM_GRP "\", \"" SCANDIM
289  "\", \"" UI32 "\", 1, %lu)", geo_file->filename,
290  (unsigned long)dim_index[0]);
291  modsmf(MODIS_E_GEO, msgbuf, filefunc);
292  }
293 
294  if(putMODISarinfo(geo_file, DETECTOR_OFFSETS, PARM_GRP, TRACKDIM, UI32,
295  1L, &dim_index[1]) != MAPIOK)
296  {
297  retval = FAIL;
298  sprintf(msgbuf, "putMODISarinfo(\"%s\", \"" PARM_GRP "\", \"" TRACKDIM
299  "\", \"" UI32 "\", 1, %lu)",
300  geo_file->filename, (unsigned long)dim_index[1]);
301  modsmf(MODIS_E_GEO, msgbuf, filefunc);
302  }
303 
304  return retval;
305 }
#define DETECTOR_OFFSETS
Definition: GEO_product.h:158
#define SUCCESS
Definition: ObpgReadGrid.h:15
#define L(lambda, T)
Definition: PreprocessP.h:185
int GEO_write_parameters(MODFILE *const geo_file, GEO_param_struct const *parameter)
#define FAIL
Definition: ObpgReadGrid.h:18
#define NULL
Definition: decode_rs.h:63
#define MODIS_E_BAD_INPUT_ARG
#define PARM_GRP
Definition: GEO_product.h:151
#define BAND_POSITION
Definition: GEO_product.h:156
#define SCANDIM
Definition: GEO_product.h:286
#define MODIS_E_GEO
#define T_OFFSET
Definition: GEO_product.h:159
README for MOD_PR03(V6.1.0) 2. POINTS OF CONTACT it can be either SDP Toolkit or MODIS Packet for Terra input files The orbit validation configuration parameter(LUN 600281) must be either "TRUE" or "FALSE". It needs to be "FALSE" when running in Near Real Time mode
#define DETECTOR_SPACE
Definition: GEO_product.h:157
#define TRACKDIM
Definition: GEO_product.h:287
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude data
Definition: HISTORY.txt:356
#define NUMBANDS
Definition: GEO_product.h:297
Extra metadata that will be written to the HDF4 file l2prod rank
#define NUM_SAMPLES
Definition: GEO_product.h:160
#define BAND_NUMBER
Definition: GEO_product.h:155
#define FOCAL_LENGTH
Definition: GEO_product.h:154
#define BANDS