OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
write_pix_qual.c
Go to the documentation of this file.
1 #include "L1A_prototype.h"
2 #include "mapi.h"
3 #include "hdf.h"
4 #include "PGS_MODIS_35005.h"
5 #include "PH_pkt_hdr.h"
6 #include "SC_scan.h"
7 #include "mapiL1A.h"
8 #include "PGS_SMF.h"
9 
10 PGSt_SMF_status write_pix_qual ( MODFILE *L1A_file_ptr,
11  SC_PIXEL_QUALITY_DATA_t *pix_qual,
12  int16 scan_num )
13 /*
14 !C****************************************************************************
15 
16 !Description: This function will write out the Pixel Quality Data (section
17  3 of the MODIS Level 1A Data Product Format) to the L1A file.
18 
19 !Input Parameters:
20  MODFILE L1A_file_ptr ** A pointer to the L1A
21  file **
22  SC_PIXEL_QUALITY_DATA_t pix_qual ** Pixel quality data
23  for this scan **
24  int16 scan_num ** scan number **
25 
26 !Output Parameters:
27  None
28 
29 Return Values: MODIS_S_SUCCESS (PGS_MODIS_35005.h)
30  MODIS_E_ARRAY_OUTPUT_ERR (PGS_MODIS_35005.h)
31 
32 Externally Defined:
33  PGSt_SMF_status (PGS_SMF.h)
34  SC_PIXEL_QUALITY_DATA_t (SC_scan.h)
35  MODFILE (mapi.h)
36  M01SD_PIX_QUAL (mapiL1A.h)
37  M01SRCA_PIX_QUAL (mapiL1A.h)
38  M01BB_PIX_QUAL (mapiL1A.h)
39  M01SV_PIX_QUAL (mapiL1A.h)
40  M01EV_PIX_QUAL (mapiL1A.h)
41  PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX (PH_pkt_hdr.h)
42  PH_SEC_PKT_TYPE_MAX_PKTS_IN_GROUP (PH_pkt_hdr.h)
43  PH_MOD_SOURCE_ID_EARTH_FRAME_CNT_LIMIT (PH_pkt_hdr.h)
44 
45 Called By:
46  write_scan
47 
48 Routines Called:
49  putMODISarray
50  log_fmt_msg
51 
52 !Revision History:
53  revision 1.0 1997/08/29 17:30:00
54  Qi Huang/RDC (qhuang@ltpmail.gsfc.nasa.gov)
55  Original development
56 
57 !Team-unique Header:
58  This software is developed by the MODIS Science
59  Data Support Team (SDST) for the National Aeronautics
60  and Space Administration (NASA), Goddard Space Flight
61  Center (GSFC), under contract NAS5-32373.
62 
63 !References and Credits:
64  None
65 
66 !Design Notes:
67  None
68 
69 !END**********************************************************************
70 */
71 {
72  /****************************************************************************/
73  /* */
74  /* Define and Initialize Local Variables */
75  /* */
76  /****************************************************************************/
77 
78  char *routine = "write_pix_qual";
79  char msg[300];
80  PGSt_SMF_status returnStatus;
81  long int start[3] = {0, 0, 0};
82  long int dimsize[3] = {1, 0, 0};
83 
84  start[0] = scan_num - 1;
85 
86  /****************************************************************************/
87  /* */
88  /* set returnStatus to MODIS_S_SUCCESS */
89  /* */
90  /****************************************************************************/
91 
92  returnStatus = MODIS_S_SUCCESS;
93 
94 
95  /****************************************************************************/
96  /* */
97  /* Compute dimsize array for the SD pixel quality data */
98  /* Compute the start for the SD pixel quality data */
99  /* CALL putMODISarray to write the SD pixel quality data to the L1A */
100  /* granule */
101  /* INPUTS: MODFILE, M01SD_PIX_QUAL, NULL, start, dimsize array, */
102  /* SC_PIXEL_QUALITY_DATA_t.SD_pix_qual */
103  /* OUTPUT: None */
104  /* RETURN: mapiStatus */
105  /* */
106  /* IF mapiStatus equals MFAIL */
107  /* THEN */
108  /* set routine to "write_pix_qual" */
109  /* set msg to "The SD pixel quality data could not be written to the */
110  /* L1A granule" */
111  /* set returnStatus to MODIS_E_ARRAY_OUTPUT_ERR */
112  /* CALL log_fmt_msg to report that the SD pixel quality data could not */
113  /* be written to the L1A granule */
114  /* INPUTS: returnStatus, routine, msg */
115  /* OUTPUT: None */
116  /* RETURN: None */
117  /* ENDIF */
118  /* */
119  /****************************************************************************/
120 
123 
124  if (putMODISarray(L1A_file_ptr, M01SD_PIX_QUAL, NULL, start, dimsize,
125  pix_qual->SD_pix_qual) == MFAIL)
126  {
127  sprintf(msg,"The SD pixel quality data could not be written to the L1A granule: %s Scan Number: %d",
128  L1A_file_ptr->filename, scan_num);
129  returnStatus = MODIS_E_ARRAY_OUTPUT_ERR;
131  }
132 
133 
134  /****************************************************************************/
135  /* */
136  /* Compute dimsize array for the SRCA pixel quality data */
137  /* Compute the start for the SRCA pixel quality data */
138  /* CALL putMODISarray to write the SRCA pixel quality data to the L1A */
139  /* granule */
140  /* INPUTS: MODFILE, M01SRCA_PIX_QUAL, NULL, start, dimsize array, */
141  /* SC_PIXEL_QUALITY_DATA_t.SRCA_pix_qual */
142  /* OUTPUT: None */
143  /* RETURN: mapiStatus */
144  /* */
145  /* IF mapiStatus equals MFAIL */
146  /* THEN */
147  /* set routine to "write_pix_qual" */
148  /* set msg to "The SRCA pixel quality data could not be written to the */
149  /* L1A granule" */
150  /* set returnStatus to MODIS_E_ARRAY_OUTPUT_ERR */
151  /* CALL log_fmt_msg to report that the SRCA pixel quality data could not*/
152  /* be written to the L1A granule */
153  /* INPUTS: returnStatus, routine, msg */
154  /* OUTPUT: None */
155  /* RETURN: None */
156  /* ENDIF */
157  /* */
158  /****************************************************************************/
159 
160  if (putMODISarray(L1A_file_ptr, M01SRCA_PIX_QUAL, NULL, start, dimsize,
161  pix_qual->SRCA_pix_qual) == MFAIL)
162  {
163  sprintf(msg,"The SRCA pixel quality data could not be written to the L1A granule: %s Scan Number: %d",
164  L1A_file_ptr->filename, scan_num);
165  returnStatus = MODIS_E_ARRAY_OUTPUT_ERR;
167  }
168 
169 
170  /****************************************************************************/
171  /* */
172  /* Compute dimsize array for the BB pixel quality data */
173  /* Compute the start for the BB pixel quality data */
174  /* CALL putMODISarray to write the BB pixel quality data to the L1A */
175  /* granule */
176  /* INPUTS: MODFILE, M01BB_PIX_QUAL, NULL, start, dimsize array, */
177  /* SC_PIXEL_QUALITY_DATA_t.BB_pix_qual */
178  /* OUTPUT: None */
179  /* RETURN: mapiStatus */
180  /* */
181  /* IF mapiStatus equals MFAIL */
182  /* THEN */
183  /* set routine to "write_pix_qual" */
184  /* set msg to "The BB pixel quality data could not be written to the */
185  /* L1A granule" */
186  /* set returnStatus to MODIS_E_ARRAY_OUTPUT_ERR */
187  /* CALL log_fmt_msg to report that the BB pixel quality data could not */
188  /* be written to the L1A granule */
189  /* INPUTS: returnStatus, routine, msg */
190  /* OUTPUT: None */
191  /* RETURN: None */
192  /* ENDIF */
193  /* */
194  /****************************************************************************/
195 
196  if (putMODISarray(L1A_file_ptr, M01BB_PIX_QUAL, NULL, start, dimsize,
197  pix_qual->BB_pix_qual) == MFAIL)
198  {
199  sprintf(msg,"The BB pixel quality data could not be written to the L1A granule: %s Scan Number: %d ",
200  L1A_file_ptr->filename, scan_num);
201  returnStatus = MODIS_E_ARRAY_OUTPUT_ERR;
203  }
204 
205 
206  /****************************************************************************/
207  /* */
208  /* Compute dimsize array for the SV pixel quality data */
209  /* Compute the start for the SV pixel quality data */
210  /* CALL putMODISarray to write the SV pixel quality data to the L1A */
211  /* granule */
212  /* INPUTS: MODFILE, M01SV_PIX_QUAL, NULL, start, dimsize array, */
213  /* SC_PIXEL_QUALITY_DATA_t.SV_pix_qual */
214  /* OUTPUT: None */
215  /* RETURN: mapiStatus */
216  /* */
217  /* IF mapiStatus equals MFAIL */
218  /* THEN */
219  /* set routine to "write_pix_qual" */
220  /* set msg to "The SV pixel quality data could not be written to the */
221  /* L1A granule" */
222  /* set returnStatus to MODIS_E_ARRAY_OUTPUT_ERR */
223  /* CALL log_fmt_msg to report that the SV pixel quality data could not */
224  /* be written to the L1A granule */
225  /* INPUTS: returnStatus, routine, msg */
226  /* OUTPUT: None */
227  /* RETURN: None */
228  /* ENDIF */
229  /* */
230  /****************************************************************************/
231 
232  if (putMODISarray(L1A_file_ptr, M01SV_PIX_QUAL, NULL, start, dimsize,
233  pix_qual->SV_pix_qual) == MFAIL)
234  {
235  sprintf(msg,"The SV pixel quality data could not be written to the L1A granule: %s Scan Number: %d",
236  L1A_file_ptr->filename, scan_num);
237  returnStatus = MODIS_E_ARRAY_OUTPUT_ERR;
239  }
240 
241 
242  /****************************************************************************/
243  /* */
244  /* Compute dimsize array for the EV pixel quality data */
245  /* Compute the start for the EV pixel quality data */
246  /* CALL putMODISarray to write the EV pixel quality data to the L1A */
247  /* granule */
248  /* INPUTS: MODFILE, M01EV_PIX_QUAL, NULL, start, dimsize array, */
249  /* SC_PIXEL_QUALITY_DATA_t.EV_pix_qual */
250  /* OUTPUT: None */
251  /* RETURN: mapiStatus */
252  /* */
253  /* IF mapiStatus equals MFAIL */
254  /* THEN */
255  /* set routine to "write_pix_qual" */
256  /* set msg to "The EV pixel quality data could not be written to the */
257  /* L1A granule" */
258  /* set returnStatus to MODIS_E_ARRAY_OUTPUT_ERR */
259  /* CALL log_fmt_msg to report that the EV pixel quality data could not */
260  /* be written to the L1A granule */
261  /* INPUTS: returnStatus, routine, msg */
262  /* OUTPUT: None */
263  /* RETURN: None */
264  /* ENDIF */
265  /* */
266  /****************************************************************************/
267 
269 
270  if (putMODISarray(L1A_file_ptr, M01EV_PIX_QUAL, NULL, start, dimsize,
271  pix_qual->EV_pix_qual) == MFAIL)
272  {
273  sprintf(msg,"The EV pixel quality data could not be written to the L1A granule: %s Scan Number: %d",
274  L1A_file_ptr->filename, scan_num);
275  returnStatus = MODIS_E_ARRAY_OUTPUT_ERR;
277  }
278 
279 
280  /****************************************************************************/
281  /* */
282  /* return returnStatus */
283  /* */
284  /****************************************************************************/
285 
286  return (returnStatus);
287 }
integer, parameter int16
Definition: cubeio.f90:3
#define NULL
Definition: decode_rs.h:63
#define PH_SEC_PKT_TYPE_MAX_PKTS_IN_GROUP
Definition: PH_pkt_hdr.h:166
int16 EV_pix_qual[PH_MOD_SOURCE_ID_EARTH_FRAME_CNT_LIMIT][PH_SEC_PKT_TYPE_MAX_PKTS_IN_GROUP]
Definition: SC_scan.h:265
int16 SV_pix_qual[PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX][PH_SEC_PKT_TYPE_MAX_PKTS_IN_GROUP]
Definition: SC_scan.h:263
#define PH_MOD_SOURCE_ID_EARTH_FRAME_CNT_LIMIT
Definition: PH_pkt_hdr.h:195
#define PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX
Definition: PH_pkt_hdr.h:216
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
#define MODIS_E_ARRAY_OUTPUT_ERR
#define MODIS_S_SUCCESS
int16 SRCA_pix_qual[PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX][PH_SEC_PKT_TYPE_MAX_PKTS_IN_GROUP]
Definition: SC_scan.h:259
string msg
Definition: mapgen.py:227
int16 SD_pix_qual[PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX][PH_SEC_PKT_TYPE_MAX_PKTS_IN_GROUP]
Definition: SC_scan.h:257
PGSt_SMF_status write_pix_qual(MODFILE *L1A_file_ptr, SC_PIXEL_QUALITY_DATA_t *pix_qual, int16 scan_num)
int16 BB_pix_qual[PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX][PH_SEC_PKT_TYPE_MAX_PKTS_IN_GROUP]
Definition: SC_scan.h:261