OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
init_L1A_scan_meta_HDF_sdss.c
Go to the documentation of this file.
1 #include "L1A_prototype.h"
2 #include "PGS_MODIS_35005.h"
3 #include "mapi.h"
4 #include "mapiL1A.h"
5 #include "PGS_SMF.h"
6 #include "SC_scan.h"
7 
8 
9 PGSt_SMF_status init_L1A_scan_meta_HDF_sdss (MODFILE *mfile,
10  int nscans)
11 
12 /*
13 !C*****************************************************************************
14 
15 !Description: Function init_L1A_scan_meta_HDF_sdss creates all the Scan Level
16  Metadata (section 2 of the MODIS Level 1A Data Product Format
17  SDSs (arrays) that will be written to by L1A processing.
18 
19 !Input Parameters:
20  MODFILE mfile ** Pointer to MODFILE structure **
21  int nscans ** Number of scans **
22 
23 !Output Parameters:
24  None
25 
26 Return Values:
27  MODIS_S_SUCCESS (PGS_MODIS_35005.h)
28  MODIS_E_SDS_CREATE_FAILED (PGS_MODIS_35005.h)
29 
30 Externally Defined:
31  PGSt_SMF_status (PGS_SMF.h)
32  M01SCAN_NUMBER (mapiL1A.h)
33  M01FRAME_COUNT_ARRAY (mapiL1A.h)
34  M01SCAN_TYPE (mapiL1A.h)
35  M01SD_START_TIME (mapiL1A.h)
36  M01SRCA_START_TIME (mapiL1A.h)
37  M01BB_START_TIME (mapiL1A.h)
38  M01SV_START_TIME (mapiL1A.h)
39  M01EV_START_TIME (mapiL1A.h)
40  M01SRCA_CALIBRATION_MODE (mapiL1A.h)
41  M01PACKET_SCAN_COUNT (mapiL1A.h)
42  M01CCSDS_APID (mapiL1A.h)
43  M01PACKET_QL (mapiL1A.h)
44  M01MIRROR_SIDE (mapiL1A.h)
45  M01SCAN_QUALITY_ARRAY (mapiL1A.h)
46  MAPIOK (mapi.h)
47  MFAIL (mapi.h)
48  MODFILE (mapi.h)
49  DATATYPELENMAX (mapic.h)
50  MFILL_VALUE (mapi.h)
51 
52 Called By:
53  init_L1A_HDF_sdss
54 
55 Routines Called:
56  log_fmt_msg
57  createMODISarray
58  putMODISarinfo
59 
60 !Revision History:
61 $Log: init_L1A_scan_meta_HDF_sdss.c,v $
62 Revision 6.2 2015/08/21 20:13:17 jkuyper
63 Finished resolving Bug 1492 by setting two additional _FillValue attribute
64 length to 1.
65 
66 Revision 6.1 2010/08/24 15:36:55 kuyper
67 Corrected length of _FillValue attribute to 1.
68 
69 Revision 5.1 2004/09/23 18:48:46 seaton
70 Collection 5 changed. Added _FillValue attribute to SDSs.
71 seaton@saicmodis.com
72 
73  Revision 1.0 1997/09/10 17:30:00
74  Qi Huang/RDC (qhuang@ltpmail.gsfc.nasa.gov)
75  Original development
76 
77 !Team-unique Header:
78  This software is developed by the MODIS Science Data Support
79  Team (SDST) for the National Aeronautics and Space Administration
80  (NASA), Goddard Space Flight Center (GSFC), under contract
81  NAS5-32373.
82 
83 References and Credits:
84  None
85 
86 Design Notes:
87  None
88 
89 !END***************************************************************************
90 */
91 {
92  /*************************************************************************/
93  /* */
94  /* Define and Initialize Local Variables */
95  /* */
96  /*************************************************************************/
97 
98  char *routine = "init_L1A_scan_meta_HDF_sdss";
99  char msg[300];
100  char data_type[14][DATATYPELENMAX] = {I16,I16,TXT,R64,R64,R64,R64,
101  R64,I16,I16,I16,I16,I16,I32};
102  long int rank[14] = {1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2};
103  long int dimsizes[14][2] ={{0,0},{0,6},{0,10},{0,0},{0,0},{0,0},{0,0},
104  {0,0},{0,0},{0,0},{0,3},{0,0},{0,0},{0,4}};
105  char array_name[14][256] = {M01SCAN_NUMBER, M01FRAME_COUNT_ARRAY,
106  M01SCAN_TYPE, M01SD_START_TIME,
107  M01SRCA_START_TIME, M01BB_START_TIME,
108  M01SV_START_TIME, M01EV_START_TIME,
109  M01SRCA_CALIBRATION_MODE,
110  M01PACKET_SCAN_COUNT, M01CCSDS_APID,
111  M01PACKET_QL, M01MIRROR_SIDE,
112  M01SCAN_QUALITY_ARRAY};
113  int i;
114  PGSt_SMF_status returnStatus;
115  int16 fill_zero = 0;
116  float64 fill_time = TIME_FILL_VALUE;
117  int16 fill_neg_one = SC_FILL_VALUE;
118 
119  /*******************************************************************************/
120  /* */
121  /* Set mapi_status to MAPIOK */
122  /* */
123  /* Set returnStatus to MODIS_S_SUCCESS */
124  /* */
125  /*******************************************************************************/
126 
127  returnStatus = MODIS_S_SUCCESS;
128 
129 
130  /*******************************************************************************/
131  /* */
132  /* Store all array names (M01SCAN_NUMBER, M01FRAME_COUNT_ARRAY, M01SCAN_TYPE, */
133  /* M01SD_START_TIME, M01SRCA_START_TIME, M01BB_START_TIME, M01SV_START_TIME,*/
134  /* M01EV_START_TIME, M01SRCA_CALIBRATION_MODE, M01PACKET_SCAN_COUNT, */
135  /* M01CCSDS_APID, M01PACKET_QL, M01MIRROR_SIDE, M01SCAN_QUALITY_ARRAY) in */
136  /* array_name (done during declaration) */
137  /* */
138  /* Store all data types (int16, int16, char, float64, float64, float64, */
139  /* float64, float64, int16, int16, int16, int16, int16, int32) in data_type */
140  /* (done during declaration) */
141  /* */
142  /* Store all dimension sizes (nscans; nscans,6; nscans,10; nscans; nscans; */
143  /* nscans; nscans; nscans; nscans; nscans; nscans,3; nscans; nscans; */
144  /* nscans,4) in dimsizes */
145  /* */
146  /* Store all ranks (1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2) in rank (done */
147  /* during declaration) */
148  /* */
149  /*******************************************************************************/
150 
151  dimsizes[0][0] = dimsizes[1][0] = dimsizes[2][0] = dimsizes[3][0] = dimsizes[4][0] =
152  dimsizes[5][0] = dimsizes[6][0] = dimsizes[7][0] = dimsizes[8][0] = dimsizes[9][0] =
153  dimsizes[10][0] = dimsizes[11][0] = dimsizes[12][0] = dimsizes[13][0] = nscans;
154 
155 
156  /*******************************************************************************/
157  /* */
158  /* FOR i equals all elements of Scan Level Metadata (14) */
159  /* CALL createMODISarray to create the appropriate SDS in the L1A file */
160  /* INPUT: mfile, array_name[i], NULL, data_type[i], rank[i], dimsizes[i] */
161  /* OUTPUT: None */
162  /* RETURN: mapi_status */
163  /* */
164  /* IF mapi_status is equal to MFAIL */
165  /* THEN */
166  /* Set returnStatus to MODIS_E_SDS_CREATE_FAILED */
167  /* Set msg to "unable to create the 'array_name' SDS" */
168  /* Set routine to "init_L1A_scan_meta_HDF_sdss" */
169  /* CALL log_fmt_msg to report that the 'array_name' SDS was not created */
170  /* INPUT: returnStatus, routine, msg */
171  /* OUTPUT: None */
172  /* RETURN: None */
173  /* ENDIF */
174  /* */
175  /* ENDFOR */
176  /* */
177  /*******************************************************************************/
178 
179  for (i=0; i<14; i++) {
180  if (createMODISarray(mfile, array_name[i], NULL, data_type[i], rank[i],
181  dimsizes[i]) == MFAIL)
182  {
183  returnStatus = MODIS_E_SDS_CREATE_FAILED;
184  sprintf(msg, "SDS Name: %s", array_name[i]);
186  }
187 
188  switch (i) {
189  case 0: if (putMODISarinfo(mfile, array_name[i], NULL, MFILL_VALUE,
190  data_type[i], 1, &fill_zero) != MAPIOK)
191  {
192  returnStatus = MODIS_E_SDS_CREATE_FAILED;
193  sprintf(msg, "Could not initialize SDS to 0 for SDS Name: %s", array_name[i]);
195  }
196  break;
197  case 3:
198  case 4:
199  case 5:
200  case 6:
201  case 7: if (putMODISarinfo(mfile, array_name[i], NULL, MFILL_VALUE,
202  data_type[i], 1, &fill_time) != MAPIOK)
203  {
204  returnStatus = MODIS_E_SDS_CREATE_FAILED;
205  sprintf(msg, "Could not initialize SDS to 0 for SDS Name: %s", array_name[i]);
207  }
208  break;
209  case 8:
210  case 9:
211  case 10:
212  case 11:
213  case 12: if (putMODISarinfo(mfile, array_name[i], NULL, MFILL_VALUE,
214  data_type[i], 1, &fill_neg_one) != MAPIOK)
215  {
216  returnStatus = MODIS_E_SDS_CREATE_FAILED;
217  sprintf(msg, "Could not initialize SDS to 0 for SDS Name: %s", array_name[i]);
219  }
220  break;
221 
222  } /* end switch */
223 
224  } /* end for */
225 
226  /*******************************************************************************/
227  /* */
228  /* RETURN returnStatus */
229  /* */
230  /*******************************************************************************/
231 
232  return returnStatus;
233 }
integer, parameter int16
Definition: cubeio.f90:3
#define NULL
Definition: decode_rs.h:63
#define MODIS_E_SDS_CREATE_FAILED
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
PGSt_SMF_status init_L1A_scan_meta_HDF_sdss(MODFILE *mfile, int nscans)
#define SC_FILL_VALUE
Definition: SC_scan.h:141
#define TIME_FILL_VALUE
Definition: SC_scan.h:142
#define MODIS_S_SUCCESS
Extra metadata that will be written to the HDF4 file l2prod rank
string msg
Definition: mapgen.py:227
int i
Definition: decode_rs.h:71