OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
GEO_initialize_product.c
Go to the documentation of this file.
1 #include "PGS_EPH.h"
2 #include "GEO_geo.h"
3 #include "GEO_output.h"
4 #include "GEO_product.h"
5 #include "PGS_MODIS_35251.h"
6 
7 PGSt_SMF_status GEO_initialize_product(
8  int const number_of_scans,
9  fill_values_struct const * fill_values,
10  MODFILE * const geo_file,
11  int32 const swfid,
12  GEO_param_struct const * GEO_param
13 )
14 /*
15 !C*****************************************************************************
16 !Description:
17  Routine in output group of the Level-1A geolocation
18  software to initialize the HDF objects in the output
19  product for subsequent scan-by-scan output. It calls
20  MAPI routines to initialize the scan metadata, to
21  initialize the scan data in the geolocation file, and
22  assigns a name to the SDS dimension.
23 
24 !Input Parameters:
25  number_of_scans the number of scans.
26  fill_values fill values for scan level data
27  geo_file M-API structure for the geolocation file.
28  swfid Swath (HDF-EOS) filehandle.
29  GEO_param struct containing runtime parameters.
30 
31 !Output Parameters: None
32 
33 Return Values:
34  MODIS_E_BAD_INPUT_ARG If any argument is invalid
35  MODIS_E_GEO If any subroutine fails
36  PGS_S_SUCCESS Otherwise
37 
38 Externally Defined:
39  ATT_QUALITY "GEO_product.h"
40  ATTIT_ANG "GEO_product.h"
41  AVERAGE_TEMPERATURES "GEO_product.h"
42  DATATYPELENMAX "mapi.h"
43  DFNT_CHAR "hntdefs.h"
44  DFNT_FLOAT32 "hntdefs.h"
45  EV_FRAMES "GEO_product.h"
46  EVTIME "GEO_product.h"
47  GEO_QUALITY "GEO_product.h"
48  GFLAGS "GEO_product.h"
49  GFLAGS_FVALUE "GEO_geo.h"
50  _HDF_VDATA "vg.h"
51  HEIGHT "GEO_product.h"
52  HGHT_FVALUE "GEO_geo.h"
53  IMPULSE_ENC "GEO_product.h"
54  IMPULSE_TIME "GEO_product.h"
55  I16 "mapi.h"
56  I32 "mapi.h"
57  I8 "mapi.h"
58  L_SMASK_FVALUE "GEO_geo.h"
59  L1_QUALITY "GEO_product.h"
60  L1A_ENGINEERING_GRP "GEO_product.h"
61  LAND_SEAMASK "GEO_product.h"
62  LAT_FVALUE "GEO_geo.h"
63  LATITUDE "GEO_product.h"
64  LONG_FVALUE "GEO_geo.h"
65  LONGITUDE "GEO_product.h"
66  M03PITCH_ELEM "mapiL1Bgeo.h"
67  M03ROLL_ELEM "mapiL1Bgeo.h"
68  M03YAW_ELEM "mapiL1Bgeo.h"
69  MAPIOK "mapi.h"
70  MAX_IMPULSE_NUMBER "GEO_parameters.h"
71  MAX_SCAN_NUMBER "GEO_geo.h"
72  MDATA_RANGE "mapi.h"
73  MFILL_VALUE "mapi.h"
74  MODIS_E_GEO "PGS_MODIS_35251.h"
75  MODIS_E_BAD_INPUT_ARG "PGS_MODIS_35251.h"
76  MOON_VECTOR "GEO_product.h"
77  MSIDE "GEO_product.h"
78  MSLOPE "mapi.h"
79  MUNITS "mapi.h"
80  NSCANS "GEO_product.h"
81  NUM_IMPULSE "GEO_product.h"
82  NUM_L1A_QUALITY_FLAGS "GEO_geo.h"
83  NUM_TEMPS "GEO_parameters.h"
84  NUMENC "GEO_product.h"
85  NUMQUAL "GEO_product.h"
86  ORB_POS "GEO_product.h"
87  ORB_VEL "GEO_product.h"
88  PGS_S_SUCCESS "PGS_SMF.h"
89  RANGE "GEO_product.h"
90  RANGE_FVALUE "GEO_geo.h"
91  R32 "mapi.h"
92  R64 "mapi.h"
93  S_NUM "GEO_product.h"
94  S_TYPE "GEO_product.h"
95  SCAN_GRP "GEO_product.h"
96  SCAN_META_GRP "GEO_product.h"
97  SCAN_TYPE_LEN "GEO_parameters.h"
98  SCTIME "GEO_product.h"
99  SD_FRAMES "GEO_product.h"
100  SDTIME "GEO_product.h"
101  SEN_AZIMUTH "GEO_product.h"
102  SEN_ZENITH "GEO_product.h"
103  SENSORAZIM_FVALUE "GEO_geo.h"
104  SENSORZEN_FVALUE "GEO_geo.h"
105  SOLARAZIM_FVALUE "GEO_geo.h"
106  SOLARZEN_FVALUE "GEO_geo.h"
107  SUCCEED "hdf.h"
108  SUN_AZIMUTH "GEO_product.h"
109  SUN_REF "GEO_product.h"
110  SUN_ZENITH "GEO_product.h"
111  SV_FRAMES "GEO_product.h"
112  T_INST2ECR "GEO_product.h"
113  TA_RC_SMIR_CFPA "GEO_product.h"
114  TEMP_FVALUE "GEO_geo.h"
115  TP_AO_SMIR_OBJ "GEO_product.h"
116  TP_MF_CALBKHD_SR "GEO_product.h"
117  TP_MF_Z_BKHD_BB "GEO_product.h"
118  TP_SA_RCT1_MIR "GEO_product.h"
119  TP_SR_SNOUT "GEO_product.h"
120  TXT "mapi.h"
121  UI16 "mapi.h"
122  UI8 "mapi.h"
123  VECDIM "GEO_product.h"
124  WATER_PRESENT "GEO_product.h"
125 
126 Called by:
127  GEO_locate_one_granule()
128 
129 Routines called:
130  createMODISarray "mapi.h"
131  GEO_create_swath "GEO_output.h"
132  modsmf "SDST.h"
133  putMODISarinfo "mapi.h"
134  putMODISarray "mapi.h"
135  putMODISdimname "mapi.h"
136  VSattach "hproto.h"
137  VSdetach "hproto.h"
138  VSfdefine "hproto.h"
139  VSsetattr "hproto.h"
140  VSsetfields "hproto.h"
141  VSsetname "hproto.h"
142 
143 !Revision History:
144  $Log: GEO_initialize_product.c,v $
145  Revision 6.5 2011/02/14 21:32:12 kuyper
146  Corrected const-qualification of parameters that point at input data.
147  Added waterpresent SDS.
148  Added valid_range attribute for landsea mask.
149 
150  Revision 6.4 2010/06/25 19:16:37 kuyper
151  Change to make attitude and ephemeris quality flags not be Swath data fields.
152  Added roll/pitch/yaw index SDS attributes to the Thermal Correction SDS.
153 
154  Revision 6.3 2010/05/19 20:23:08 kuyper
155  Removed work-around for HDF bug that has since been fixed.
156  Added Thermal Correction, Attitude and Ephemeris Quality SDSs.
157 
158  James Kuyper Jr. James.R.Kuyper@NASA.gov
159 
160  Revision 6.2 2009/05/30 22:44:07 xgeng
161  All strings in error messages are quoted.
162 
163  Revision 6.1 2009/05/30 19:28:44 xgeng
164  Added hi-resolution output SDSs, if N_samp is greater than 1.
165  Changed to expect a status code from GEO_create_swath().
166 
167  Xu Geng (xu.geng@saic.ocm)
168 
169  Revision 5.1 2004/08/18 19:29:51 vlin
170  1. create the Average Temperatures vdata when number_of_scans is 0.
171  2. input argument "num_detectors" is replaced by "fill_values".
172  3. Add _FillValue attributes for members of fill_values_struct.
173 
174  Revision 4.3 2003/08/20 14:50:36 kuyper
175  Reinstated redundant num_detectors parameter; interface is frozen for now.
176 
177  Revision 4.2 2003/07/28 20:33:44 vlin
178  updated after code walkthrough.
179 
180  Revision 4.1 2003/07/03 17:26:55 vlin
181  Added temperature vdata, Dropped num_detectors argument,
182  Changed some error messages to MODIS_E_GEO
183 
184 !Team-unique Header:
185 
186  This software is developed by the MODIS Science Data Support
187  Team for the National Aeronautics and Space Administration,
188  Goddard Space Flight Center, under contract NAS5-32373.
189 
190  HDF portions developed at the National Center for Supercomputing
191  Applications at the University of Illinois at Urbana-Champaign.
192 
193 !END**************************************************************************/
194 
195 {
196  enum dimtype{
197  nscans,
198  mframes,
199  vecdim,
200  numqual,
201  numenc,
202  stypelen,
203  dimcount,
204  none
205  };
206 
207  static struct {
208  char *name;
209  long int value;
210  } dimensions[dimcount] = {
211  {NSCANS, 0}, /* nscans */
212  {MFRAMES, MAX_FRAMES}, /* mframes */
213  {VECDIM, 3}, /* vecdim */
214  {NUMQUAL, NUM_L1A_QUALITY_FLAGS}, /* numqual */
215  {NUMENC, MAX_IMPULSE_NUMBER}, /* numenc */
216  {S_TYPE, SCAN_TYPE_LEN} /* stypelen */
217  };
218 
219  static struct {
220  char *name;
221  int value;
222  } element[] = {
223  {M03ROLL_ELEM, 0},
224  {M03PITCH_ELEM, 1},
225  {M03YAW_ELEM, 2},
226  };
227 
228  /* The following arrays contain the min, and max pointed to
229  by the initializers for the SDS_object structure. */
230 
231  static uint8 ui8value[][3]={
232  {(uint8)0, (uint8)MAX_IMPULSE_NUMBER}, /* num_impulse */
233  {0, 0, (uint8)GFLAGS_FVALUE}, /* gflags fill value */
234  {(uint8)SHALLOW_OCEAN, (uint8)DEEP_OCEAN, (uint8)L_SMASK_FVALUE},
235  /* land sea mask range, fill value */
236  {0, 8, (uint8)GFLAGS_FVALUE} /* water present range, fill value */
237  };
238 
239  static uint16 ui16value[][3]={
240  {(uint16)0, (uint16)1}, /* Mirror side */
241  {(uint16)27000, (uint16)65535, (uint16)RANGE_FVALUE}, /* Range */
242  {(uint16)0, (uint16)1400}, /* EV frames */
243  };
244 
245  static uint32 ui32value[][3]={
246  {0, PGSd_INTERPOLATED_POINT | EPH_QUALITY_UNAVAIL | EPH_REPAIRED |
248  EPH_DATA | EPH_OVERALL, PGSd_NO_DATA}, /* Attitude Quality */
249  {0, PGSd_INTERPOLATED_POINT | EPH_REPAIRED | EPH_LONG_PRECEED |
251  PGSd_NO_DATA}, /* Ephemeris Quality */
252  };
253 
254  static int16 i16value[][3]={
255  {(int16)-400, (int16)10000, (int16)HGHT_FVALUE}, /* height */
256  {(int16)0, (int16)(18000), (int16)SENSORZEN_FVALUE}, /* SensorZenith */
257  {(int16)-18000, (int16)18000, (int16)SENSORAZIM_FVALUE}, /* SensorAzimuth */
258  {(int16)0, (int16)18000, (int16)SOLARZEN_FVALUE}, /* SolarZenith */
259  {(int16)-18000, (int16)18000, (int16)SOLARAZIM_FVALUE}, /* SolarAzimuth */
260  };
261 
262  static float32 r32value[][3]={
263  {(float32)-180.0, (float32)180.0, (float32)LONG_FVALUE}, /* longitude */
264  {(float32)(-90.0), (float32)(90.0), (float32)LAT_FVALUE}, /* latitude */
265  {(float32)(-1.0), (float32)(1.0)}, /* sun_ref */
266  /* Thermal attitude correction: */
267  {(float32)-180.0, (float32)180.0, (float32)THERMCORR_FVALUE},
268  };
269 
270  static float64 r64value[][2]={
271  {(float64)-7200000.0, (float64)7200000.0}, /* orb_pos */
272  {(float64)-7600.0, (float64)7600.0}, /* orb_vel */
273  {(float64)0.0, (float64)16384.0}, /* impulse_enc */
274  {(float64)0.0, (float64)1.5}, /* impulse_time */
275  {(float64)-1.0, (float64)1.0} /* T_inst2ECR */
276  };
277 
278  static int8 i8value[3]={(int8)-127, (int8)127, HIRES_FVALUE};
279 
280  static struct{
281  char const *name; /* SDS object name. */
282  char const *group; /* HDF vgroup. */
283  long rank; /* Array rank. */
284  enum dimtype dims[3]; /* Array dimensions */
285  char data_type[DATATYPELENMAX]; /* M-API data type. */
286  unsigned char not_swath; /* flag defining whether an SDS needs to
287  be created and dimensions named.
288  If true, the SDS must be created and
289  the dimension named. */
290  char const *units; /* units of measurement. */
291  void const *range; /* min/max valid data pair. */
292  void const *fillvalue; /* Value for unset array cells. */
293  void const *scale_val; /* SDS attribute scale value. */
294  } SDS_object[]={
295  {S_NUM, SCAN_META_GRP, 1, {nscans}, I16, 1}, /* 0 */
296  {EV_FRAMES, SCAN_META_GRP, 1, {nscans}, UI16, 1, NULL, ui16value[2]},/*1*/
297  {SD_FRAMES, SCAN_META_GRP, 1, {nscans}, UI16, 1}, /* 2 */
298  {SV_FRAMES, SCAN_META_GRP, 1, {nscans}, UI16, 1}, /* 3 */
299  {EVTIME, SCAN_META_GRP, 1, {nscans}, R64, 1, "seconds"}, /* 4 */
300  {SDTIME, SCAN_META_GRP, 1, {nscans}, R64, 1, "seconds"}, /* 5 */
301  {SVTIME, SCAN_META_GRP, 1, {nscans}, R64, 1, "seconds"}, /* 6 */
302  {SCTIME, SCAN_META_GRP, 1, {nscans}, R64, 1, "seconds"}, /* 7 */
303  {MSIDE, SCAN_META_GRP, 1, {nscans}, UI16,1, NULL, ui16value[0]},/*8*/
304  {SUN_ZENITH, SCAN_META_GRP, 1, {nscans}, R32, 1, "radians"}, /* 9 */
305  {SUN_AZIMUTH, SCAN_META_GRP, 1, {nscans}, R32, 1, "radians"}, /* 10 */
306  {MOON_VECTOR, SCAN_META_GRP, 2, {nscans,
307  vecdim}, R32, 1}, /* 11 */
308  {L1_QUALITY, SCAN_META_GRP, 2, {nscans,
309  numqual}, I32, 1}, /* 12 */
310  {GEO_QUALITY, SCAN_META_GRP, 2, {nscans,
311  numqual}, I8, 1}, /* 13 */
312  {ORB_POS, SCAN_META_GRP, 2, {nscans, /* 14 */
313  vecdim}, R64, 1, "meters", r64value[0]},
314  {ORB_VEL, SCAN_META_GRP, 2, {nscans, /* 15 */
315  vecdim}, R64, 1, "meters per second",
316  r64value[1]},
317  {T_INST2ECR, SCAN_META_GRP, 3, {nscans,
318  vecdim, /* 16 */
319  vecdim}, R64, 1, NULL, r64value[4]},
320  {ATTIT_ANG, SCAN_META_GRP, 2, {nscans,
321  vecdim}, R64, 1, "radians"}, /* 17 */
322  {SUN_REF, SCAN_META_GRP, 2, {nscans, /* 18 */
323  vecdim}, R32, 1, NULL, r32value[2]},
324  {NUM_IMPULSE, SCAN_META_GRP, 1, {nscans}, UI8, 1, NULL, ui8value[0]},/*19*/
325  {IMPULSE_ENC, SCAN_META_GRP, 2, {nscans, numenc}, R64, 1, "encoder pulses",
326  r64value[2]}, /* 20 */
327  {IMPULSE_TIME,SCAN_META_GRP, 2, {nscans, numenc}, R64, 1, "seconds",
328  r64value[3]}, /* 21 */
329  {LONGITUDE, SCAN_GRP, 0, {none}, R32, 0, "degrees", r32value[0],
330  &r32value[0][2]}, /* 22 */
331  {LATITUDE, SCAN_GRP, 0, {none}, R32, 0, "degrees", r32value[1],
332  &r32value[1][2]}, /* 23 */
333  {HEIGHT, SCAN_GRP, 0, {none}, I16, 0, "meters", i16value[0],
334  &i16value[0][2]}, /* 24 */
335  {SEN_ZENITH, SCAN_GRP, 0, {none}, I16, 0, "degrees", i16value[1],
336  &i16value[1][2]}, /* 25 */
337  {SEN_AZIMUTH, SCAN_GRP, 0, {none}, I16, 0, "degrees", i16value[2],
338  &i16value[2][2]}, /* 26 */
339  {RANGE, SCAN_GRP, 0, {none}, UI16, 0, "meters", ui16value[1],
340  &ui16value[1][2]}, /* 27 */
341  {SOL_ZENITH, SCAN_GRP, 0, {none}, I16, 0, "degrees", i16value[3],
342  &i16value[3][2]}, /* 28 */
343  {SOL_AZIMUTH, SCAN_GRP, 0, {none}, I16, 0, "degrees", i16value[4],
344  &i16value[4][2]}, /* 29 */
345  {LAND_SEAMASK, SCAN_GRP, 0, {none}, UI8, 0, NULL, ui8value[2],
346  &ui8value[2][2]}, /* 30 */
347  {WATER_PRESENT, SCAN_GRP, 0, {none}, UI8, 0, NULL, ui8value[3],
348  &ui8value[3][2]}, /* 31 */
349  {GFLAGS, SCAN_GRP, 0, {none}, UI8, 0, NULL, NULL,
350  &ui8value[1][2]}, /* 32 */
351  {S_TYPE, SCAN_META_GRP, 2, {nscans,stypelen}, TXT, 1}, /* 33 */
352  {THERMCORR, SCAN_META_GRP, 2, {nscans, vecdim}, R32, 1, "degrees",
353  r32value[3], &r32value[3][2]}, /* 34 */
354  {ATT_QUALITY, SCAN_META_GRP, 2, {nscans, mframes}, UI32, 1, NULL,
355  ui32value[0], &ui32value[0][2]}, /* 35 */
356  {EPH_QUALITY, SCAN_META_GRP, 2, {nscans, mframes}, UI32, 1, NULL,
357  ui32value[1], &ui32value[0][2]}, /* 36 */
358  /* The next objects must be the last ones in the array. */
359  {SCAN_OFFSET, SCAN_GRP, 0, {none}, I8, 0, "km IFOV", i8value, &i8value[2]},
360  {TRACK_OFFSET, SCAN_GRP, 0, {none}, I8, 0, "km IFOV", i8value, &i8value[2]},
361  {HEIGHT_OFFSET, SCAN_GRP, 0, {none}, I8, 0, "km", i8value, &i8value[2]}
362  };
363 
364  enum eqn_value{
365  TA07,
366  TP01,
367  TP02,
368  EQN_TYPES
369  };
370  const float32 temp_limits[EQN_TYPES][2] = { {50.0, 118.0},
371  {-22.0, 87.0}, {-23.0, 87.0}};
372  float32 fill_temp[1];
373  const int eqn_type[6] = {TA07, TP02, TP01, TP01, TP02, TP02};
374  const char *temp_units[] = {"Kelvin ", "Celsius", "Celsius",
375  "Celsius", "Celsius", "Celsius"};
376  char *temperature_field[6] = {TA_RC_SMIR_CFPA, TP_AO_SMIR_OBJ,
378  char TEMPERATURE_FIELDS[] = TA_RC_SMIR_CFPA","TP_AO_SMIR_OBJ","
380  static struct {
381  char* name;
382  uint32 value;
383  } quality_attr[] = {
396  {QFL_INTERP, PGSd_INTERPOLATED_POINT}
397  };
398  long int dim_sizes[3];
399  PGSt_SMF_status ret_val = PGS_S_SUCCESS;
400  int i, obj, dim, temp;
401  int num_objs = (int)(sizeof SDS_object /sizeof SDS_object[0]);
402  int32 vdata_id, status_32;
403  intn status_n;
404  char msgbuf[PGS_SMF_MAX_MSGBUF_SIZE] = "";
405  char filefunc[] = __FILE__ ", GEO_initialize_product";
406 
407 
408  if (number_of_scans < 0 || number_of_scans > MAX_SCAN_NUMBER ||
409  fill_values == NULL || geo_file == NULL || swfid == FAIL ||
410  GEO_param == NULL) {
411  sprintf(msgbuf,"geo_file = %p, number_of_scans = %d, swfid = %ld\n"
412  "fill_values = %p, GEO_param = %p", (void *)geo_file,
413  number_of_scans, (long)swfid, (void *)fill_values,
414  (void *)GEO_param);
415  modsmf(MODIS_E_BAD_INPUT_ARG, msgbuf, filefunc);
416  return MODIS_E_BAD_INPUT_ARG;
417  }
418 
419 /* C5 feature:
420  * Create the Average Temperatures vdata even if number_of_scans is 0.
421  */
422 
423  vdata_id = VSattach((int32)geo_file->hdf_id, _HDF_VDATA, "w");
424  if (vdata_id == FAIL) {
425  modsmf(MODIS_E_GEO, "VSattach()", filefunc);
426  return MODIS_E_GEO;
427  }
428 
429  status_32 = VSsetname(vdata_id, AVERAGE_TEMPERATURES);
430  if (status_32 != SUCCEED) {
431  modsmf(MODIS_E_GEO, "VSsetname()", filefunc);
432  ret_val = MODIS_E_GEO;
433  }
434 
435  for (temp = 0; temp < NUM_TEMPS; temp++) {
436  status_n = VSfdefine(vdata_id, temperature_field[temp],
437  DFNT_FLOAT32, 1);
438  if (status_n != SUCCEED) {
439  modsmf(MODIS_E_GEO, "VSfdefine()", filefunc);
440  ret_val = MODIS_E_GEO;
441  }
442  }
443 
444  status_n = VSsetfields(vdata_id, TEMPERATURE_FIELDS);
445  if (status_n != SUCCEED) {
446  modsmf(MODIS_E_GEO, "VSsetfields()", filefunc);
447  ret_val = MODIS_E_GEO;
448  }
449 
450  fill_temp[0] = TEMP_FVALUE;
451  if (VSsetattr(vdata_id, _HDF_VDATA, MFILL_VALUE, DFNT_FLOAT32, 1,
452  fill_temp) != SUCCEED) {
453  sprintf(msgbuf, "VSsetattr(\"%s\", \"%s\")", AVERAGE_TEMPERATURES, MFILL_VALUE);
454  modsmf(MODIS_E_GEO, msgbuf, filefunc);
455  ret_val = MODIS_E_GEO;
456  }
457 
458  for (temp = 0; temp < NUM_TEMPS; temp++) {
459  if (VSsetattr(vdata_id, temp, MUNITS, DFNT_CHAR, 7,
460  temp_units[temp]) != SUCCEED) {
461  sprintf(msgbuf, "VSsetattr(\"%s\",%d,\"%s\",\"%s\")", AVERAGE_TEMPERATURES,
462  temp, MUNITS, temp_units[temp]);
463  modsmf(MODIS_E_GEO, msgbuf, filefunc);
464  ret_val = MODIS_E_GEO;
465  }
466  if (VSsetattr(vdata_id, temp, MDATA_RANGE, DFNT_FLOAT32, 2,
467  temp_limits[eqn_type[temp]]) != SUCCEED) {
468  sprintf(msgbuf, "VSsetattr(\"%s\", %d, \"%s\")", AVERAGE_TEMPERATURES,
469  temp, MDATA_RANGE);
470  modsmf(MODIS_E_GEO, msgbuf, filefunc);
471  ret_val = MODIS_E_GEO;
472  }
473  }
474 
475  status_32 = VSdetach(vdata_id);
476  if (status_32 != SUCCEED) {
477  modsmf(MODIS_E_GEO, "VSdetach()", filefunc);
478  ret_val = MODIS_E_GEO;
479  }
480 
481  if (number_of_scans == 0)
482  return PGS_S_SUCCESS;
483 
484  dimensions[nscans].value = (long)number_of_scans;
485  SDS_object[25].scale_val = &GEO_param->angle_scale; /* SensorZenith */
486  SDS_object[26].scale_val = &GEO_param->angle_scale; /* SensorAzimuth */
487  SDS_object[27].scale_val = &GEO_param->range_scale; /* Range */
488  SDS_object[28].scale_val = &GEO_param->angle_scale; /* SolarZenith */
489  SDS_object[29].scale_val = &GEO_param->angle_scale; /* SolarAzimuth */
490  SDS_object[37].scale_val = &GEO_param->hires_scale; /* scan offset */
491  SDS_object[38].scale_val = &GEO_param->hires_scale; /* track offset */
492  SDS_object[39].scale_val = &GEO_param->hires_scale; /* height offset */
493  SDS_object[0].fillvalue = &fill_values->scan_number;
494  SDS_object[4].fillvalue = &fill_values->EV_start_time;
495  SDS_object[5].fillvalue = &fill_values->SD_start_time;
496  SDS_object[6].fillvalue = &fill_values->SV_start_time;
497  SDS_object[7].fillvalue = &fill_values->EV_center_time;
498  SDS_object[8].fillvalue = &fill_values->mirr_side;
499  SDS_object[9].fillvalue = &fill_values->SD_sun_zenith;
500  SDS_object[10].fillvalue = &fill_values->SD_sun_azimuth;
501  SDS_object[11].fillvalue = &fill_values->moon_vector;
502  SDS_object[12].fillvalue = &fill_values->L1_scan_quality;
503  SDS_object[13].fillvalue = &fill_values->geo_scan_quality;
504  SDS_object[14].fillvalue = &fill_values->orb_pos;
505  SDS_object[15].fillvalue = &fill_values->orb_vel;
506  SDS_object[16].fillvalue = &fill_values->T_inst2ECR;
507  SDS_object[17].fillvalue = &fill_values->attitude_angels;
508  SDS_object[18].fillvalue = &fill_values->sun_ref;
509  SDS_object[20].fillvalue = &fill_values->impulse_enc;
510  SDS_object[21].fillvalue = &fill_values->impulse_time;
511 
512  if (GEO_create_swath(number_of_scans, GEO_param->num_detectors, swfid) !=
513  PGS_S_SUCCESS)
514  {
515  ret_val = MODIS_E_GEO;
516  modsmf(MODIS_E_GEO, "GEO_create_swath()", filefunc);
517  }
518 
519  /* For this to work, the offsets must be the last objects in the array. */
520  if(GEO_param->geometry_params.N_samp[GEO_param->geometry_params.band_number]
521  == 1)
522  num_objs -= 3;
523 
524  /* Create the SDS arrays, and write their attributes. */
525  for (obj=0; obj<num_objs; obj++) {
526 
527  if ( SDS_object[obj].not_swath )
528  {
529  memset (dim_sizes, 0, sizeof(dim_sizes));
530  for (i=0; i<(int)SDS_object[obj].rank; i++)
531  dim_sizes[i] = dimensions[SDS_object[obj].dims[i]].value;
532 
533  if (createMODISarray(geo_file, SDS_object[obj].name,
534  SDS_object[obj].group, SDS_object[obj].data_type,
535  SDS_object[obj].rank, dim_sizes) != MAPIOK) {
536  sprintf(msgbuf,"createMODISarray(\"%s\",\n \"%s\", \"%s\")", geo_file->filename,
537  SDS_object[obj].name, SDS_object[obj].data_type);
538  modsmf(MODIS_E_GEO, msgbuf, filefunc);
539  ret_val = MODIS_E_GEO;
540  }
541  else {
542  for (dim=0; dim<(int)SDS_object[obj].rank; dim++){
543  if (putMODISdimname(geo_file, SDS_object[obj].name,
544  SDS_object[obj].group, (long)dim,
545  dimensions[SDS_object[obj].dims[dim]].name) != MAPIOK){
546  sprintf(msgbuf, "putMODISdimname(\"%s\",\n \"%s\", \"%s\", \"%s\")",
547  geo_file->filename, SDS_object[obj].name, SDS_object[obj].group,
548  dimensions[SDS_object[obj].dims[dim]].name);
549  modsmf(MODIS_E_GEO, msgbuf, filefunc);
550  ret_val = MODIS_E_GEO;
551  }
552  }
553  }
554  }
555 
556  if ((SDS_object[obj].units) && putMODISarinfo(geo_file,
557  SDS_object[obj].name, SDS_object[obj].group, MUNITS, TXT,
558  (long)strlen(SDS_object[obj].units), SDS_object[obj].units) != MAPIOK){
559  sprintf(msgbuf,
560  "putMODISarinfo(\"%s\",\n \"%s\", \"%s\", \"%s\", \"%s\")",
561  geo_file->filename, SDS_object[obj].name, SDS_object[obj].group,
562  MUNITS, SDS_object[obj].units);
563  modsmf(MODIS_E_GEO, msgbuf, filefunc);
564  ret_val = MODIS_E_GEO;
565  }
566 
567  if ((SDS_object[obj].range) && putMODISarinfo(geo_file,
568  SDS_object[obj].name, SDS_object[obj].group, MDATA_RANGE,
569  SDS_object[obj].data_type, 2L, SDS_object[obj].range) != MAPIOK) {
570  sprintf(msgbuf, "putMODISarinfo(\"%s\",\n \"%s\", \"%s\", \"%s\", \"%s\")",
571  geo_file->filename, SDS_object[obj].name,
572  SDS_object[obj].group, MDATA_RANGE, SDS_object[obj].data_type);
573  modsmf(MODIS_E_GEO, msgbuf, filefunc);
574  ret_val = MODIS_E_GEO;
575  }
576 
577  if (SDS_object[obj].fillvalue) {
578  dim_sizes[0] = dim_sizes[1] = dim_sizes[2] = 1;
579  if (putMODISarinfo(geo_file, SDS_object[obj].name,
580  SDS_object[obj].group, MFILL_VALUE, SDS_object[obj].data_type, 1L,
581  SDS_object[obj].fillvalue) != MAPIOK) {
582  sprintf(msgbuf, "putMODISarinfo(\"%s\",\n \"%s\", \"%s\", \"%s\", \"%s\")",
583  geo_file->filename, SDS_object[obj].name, SDS_object[obj].group,
584  MFILL_VALUE, SDS_object[obj].data_type);
585  modsmf(MODIS_E_GEO, msgbuf, filefunc);
586  ret_val = MODIS_E_GEO;
587  }
588  }
589 
590  if ((SDS_object[obj].scale_val) && putMODISarinfo(geo_file,
591  SDS_object[obj].name, SDS_object[obj].group, MSLOPE, R64, 1L,
592  SDS_object[obj].scale_val) != MAPIOK) {
593  sprintf(msgbuf,"putMODISarinfo(\"%s\"\n\"%s\", \"%s\", \"%s\", \"%s\")",
594  geo_file->filename, SDS_object[obj].name, SDS_object[obj].group,
595  MSLOPE, SDS_object[obj].data_type);
596  modsmf(MODIS_E_GEO, msgbuf, filefunc);
597  ret_val = MODIS_E_GEO;
598  }
599  }
600 
601  for (obj=0; obj<(int)(sizeof element / sizeof element[0]); obj++) {
602  if (putMODISarinfo(geo_file, ATTIT_ANG, SCAN_META_GRP,
603  element[obj].name, UI32, 1L, &element[obj].value) != MAPIOK)
604  {
605  sprintf(msgbuf, "putMODISarinfo(\"%s\",\n\"%s\", \"%s\")",
606  geo_file->filename, ATTIT_ANG, element[obj].name);
607  modsmf(MODIS_E_GEO, msgbuf, filefunc);
608  ret_val = MODIS_E_GEO;
609  }
610  if (putMODISarinfo(geo_file, THERMCORR, SCAN_META_GRP,
611  element[obj].name, UI32, 1L, &element[obj].value) != MAPIOK)
612  {
613  sprintf(msgbuf, "putMODISarinfo(\"%s\",\n\"%s\", \"%s\")",
614  geo_file->filename, THERMCORR, element[obj].name);
615  modsmf(MODIS_E_GEO, msgbuf, filefunc);
616  ret_val = MODIS_E_GEO;
617  }
618  }
619 
620  for (obj=0; obj<(int)(sizeof(quality_attr)/sizeof(quality_attr[0])); obj++)
621  {
622  if (putMODISarinfo(geo_file, ATT_QUALITY, SCAN_META_GRP,
623  quality_attr[obj].name, UI32, 1L, &quality_attr[obj].value) != MAPIOK)
624  {
625  sprintf(msgbuf, "putMODISarinfo(\"%s\",\n\"%s\", \"%s\")",
626  geo_file->filename, ATT_QUALITY, quality_attr[obj].name);
627  modsmf(MODIS_E_GEO, msgbuf, filefunc);
628  ret_val = MODIS_E_GEO;
629  }
630 
631  if (putMODISarinfo(geo_file, EPH_QUALITY, SCAN_META_GRP,
632  quality_attr[obj].name, UI32, 1L, &quality_attr[obj].value) != MAPIOK)
633  {
634  sprintf(msgbuf, "putMODISarinfo(\"%s\",\n\"%s\", \"%s\")",
635  geo_file->filename, EPH_QUALITY, quality_attr[obj].name);
636  modsmf(MODIS_E_GEO, msgbuf, filefunc);
637  ret_val = MODIS_E_GEO;
638  }
639  }
640 
641  return ret_val;
642 }
#define SOL_ZENITH
Definition: GEO_product.h:235
#define SUN_REF
Definition: GEO_product.h:182
#define EPH_OVERALL
Definition: GEO_product.h:197
integer, parameter int16
Definition: cubeio.f90:3
int32 value
Definition: Granule.c:1235
#define EPH_YELLOWHI
Definition: GEO_product.h:201
#define LAT_FVALUE
Definition: GEO_geo.h:147
#define SOLARZEN_FVALUE
Definition: GEO_geo.h:152
#define HEIGHT
Definition: GEO_product.h:231
#define SENSORAZIM_FVALUE
Definition: GEO_geo.h:150
@ SHALLOW_OCEAN
Definition: GEO_geo.h:128
#define L(lambda, T)
Definition: PreprocessP.h:185
#define SCAN_TYPE_LEN
#define ORB_POS
Definition: GEO_product.h:178
#define SV_FRAMES
Definition: GEO_product.h:167
#define FAIL
Definition: ObpgReadGrid.h:18
PGSt_SMF_status GEO_create_swath(int const number_of_scans, int const num_detectors, int32 const swfid)
#define SOL_AZIMUTH
Definition: GEO_product.h:236
#define NULL
Definition: decode_rs.h:63
#define ORB_VEL
Definition: GEO_product.h:179
#define MODIS_E_BAD_INPUT_ARG
#define NUM_TEMPS
#define MAX_FRAMES
Definition: GEO_geo.h:79
#define LONGITUDE
Definition: GEO_product.h:229
#define GEO_QUALITY
Definition: GEO_product.h:177
#define QFL_REPAIRED
Definition: GEO_product.h:224
#define EPH_LONG_FOLLOW
Definition: GEO_product.h:203
#define TEMP_FVALUE
Definition: GEO_geo.h:154
#define WATER_PRESENT
Definition: GEO_product.h:238
#define SCAN_GRP
Definition: GEO_product.h:149
#define MOON_VECTOR
Definition: GEO_product.h:175
#define ATTIT_ANG
Definition: GEO_product.h:181
#define SENSORZEN_FVALUE
Definition: GEO_geo.h:149
#define QFL_QFL_PROB
Definition: GEO_product.h:225
#define S_NUM
Definition: GEO_product.h:163
#define LONG_FVALUE
Definition: GEO_geo.h:146
@ DEEP_OCEAN
Definition: GEO_geo.h:129
#define EPH_QUALITY_UNAVAIL
Definition: GEO_product.h:208
@ L_SMASK_FVALUE
Definition: GEO_geo.h:130
#define GFLAGS
Definition: GEO_product.h:239
#define IMPULSE_ENC
Definition: GEO_product.h:184
#define IMPULSE_TIME
Definition: GEO_product.h:185
#define MODIS_E_GEO
#define TP_MF_Z_BKHD_BB
Definition: GEO_product.h:275
#define MSIDE
Definition: GEO_product.h:172
#define HEIGHT_OFFSET
Definition: GEO_product.h:244
#define QFL_RED_LO
Definition: GEO_product.h:216
#define EPH_REDLO
Definition: GEO_product.h:199
#define QFL_LONG_PREC
Definition: GEO_product.h:223
#define EPH_QUALITY
Definition: GEO_product.h:194
#define SEN_AZIMUTH
Definition: GEO_product.h:233
unsigned short N_samp[MAX_BAND_NUMBER_PLUS_ONE]
#define HGHT_FVALUE
Definition: GEO_geo.h:148
focal_plane_geometry_struct geometry_params
#define T_INST2ECR
Definition: GEO_product.h:180
#define SVTIME
Definition: GEO_product.h:170
#define EPH_DATA
Definition: GEO_product.h:198
#define TRACK_OFFSET
Definition: GEO_product.h:243
#define EPH_SHORT_FOLLOW
Definition: GEO_product.h:204
#define SEN_ZENITH
Definition: GEO_product.h:232
#define ATT_QUALITY
Definition: GEO_product.h:193
#define QFL_INTERP
Definition: GEO_product.h:226
#define TP_SR_SNOUT
Definition: GEO_product.h:277
#define NUMENC
Definition: GEO_product.h:296
#define NUM_L1A_QUALITY_FLAGS
Definition: GEO_geo.h:114
#define QFL_SHRT_FOLL
Definition: GEO_product.h:221
#define QFL_YEL_HI
Definition: GEO_product.h:218
#define QFL_LONG_FOLL
Definition: GEO_product.h:220
#define TP_MF_CALBKHD_SR
Definition: GEO_product.h:274
#define VECDIM
Definition: GEO_product.h:294
#define AVERAGE_TEMPERATURES
Definition: GEO_product.h:271
#define RANGE
Definition: GEO_product.h:234
#define EPH_SHORT_PRECEED
Definition: GEO_product.h:205
#define QFL_YEL_LO
Definition: GEO_product.h:217
#define SUN_AZIMUTH
Definition: GEO_product.h:174
#define EPH_REPAIRED
Definition: GEO_product.h:207
#define THERMCORR
Definition: GEO_product.h:192
#define EPH_REDHI
Definition: GEO_product.h:202
const int MAX_SCAN_NUMBER
#define HIRES_FVALUE
Definition: GEO_geo.h:157
#define MAX_IMPULSE_NUMBER
Definition: GEO_geo.h:91
#define GFLAGS_FVALUE
Definition: GEO_geo.h:156
#define EV_FRAMES
Definition: GEO_product.h:165
#define NUMQUAL
Definition: GEO_product.h:295
Extra metadata that will be written to the HDF4 file l2prod rank
#define TP_AO_SMIR_OBJ
Definition: GEO_product.h:273
#define MFRAMES
Definition: GEO_product.h:189
#define SDTIME
Definition: GEO_product.h:169
PGSt_SMF_status GEO_initialize_product(int const number_of_scans, fill_values_struct const *fill_values, MODFILE *const geo_file, int32 const swfid, GEO_param_struct const *GEO_param)
#define NUM_IMPULSE
Definition: GEO_product.h:183
#define EPH_LONG_PRECEED
Definition: GEO_product.h:206
const int NSCANS
Definition: RsViirs.h:63
#define TP_SA_RCT1_MIR
Definition: GEO_product.h:276
#define QFL_RED_HI
Definition: GEO_product.h:219
#define LAND_SEAMASK
Definition: GEO_product.h:237
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_FLOAT32
#define SCAN_OFFSET
Definition: GEO_product.h:242
#define QFL_DATASUM
Definition: GEO_product.h:215
#define SCTIME
Definition: GEO_product.h:171
#define TA_RC_SMIR_CFPA
Definition: GEO_product.h:272
#define EPH_YELLOWLO
Definition: GEO_product.h:200
#define SUN_ZENITH
Definition: GEO_product.h:173
#define EVTIME
Definition: GEO_product.h:168
#define LATITUDE
Definition: GEO_product.h:230
int i
Definition: decode_rs.h:71
#define SOLARAZIM_FVALUE
Definition: GEO_geo.h:153
#define RANGE_FVALUE
Definition: GEO_geo.h:151
#define QFL_OVERALL
Definition: GEO_product.h:214
#define SD_FRAMES
Definition: GEO_product.h:166
#define THERMCORR_FVALUE
Definition: GEO_geo.h:155
#define QFL_SHRT_PREC
Definition: GEO_product.h:222
#define S_TYPE
Definition: GEO_product.h:164
#define L1_QUALITY
Definition: GEO_product.h:176
#define SCAN_META_GRP
Definition: GEO_product.h:150