OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
update_pixel_qual_data.c
Go to the documentation of this file.
1 #include "PH_pkt_hdr.h"
2 #include "PD_pkt_data.h"
3 #include "SC_scan.h"
4 #include "hdfi.h"
5 #include "L1A_prototype.h"
6 
7 
9  int16 qual_value,
10  SC_PIXEL_QUALITY_DATA_t *scan_pix)
11 
12 /*
13 !C************************************************************************
14 
15 !Description: This function updates the scan pixel quality arrays, by
16  using the qual_value as the value to be inserted into the
17  pixel quality array locations.
18 
19 !Input Parameters:
20  PH_PACKET_HEADER_t pkt_header ** Current L0 data packet **
21  ** packet header **
22 
23  int16 qual_value ** Pixel quality value **
24 
25 !Output Parameters:
26  None
27 
28 !Input/Output Parameters:
29  SC_PIXEL_QUALITY_DATA_t *scan_pix ** The MODIS scan pixel **
30  ** quality structure **
31 
32 Return Values:
33  None
34 
35 !Externally Defined:
36  int16 (hdfi.h)
37  SC_PIXEL_QUALITY_DATA_t (SC_scan.h)
38  PD_DN_FIRST_IFOV_DAY_PKT_1 (PD_pkt_data.h)
39  PD_DN_LAST_IFOV_DAY_PKT_2 (PD_pkt_data.h)
40  PD_DN_FIRST_IFOV_DAY_PKT_1 (PD_pkt_data.h)
41  PD_DN_LAST_IFOV_DAY_PKT_2 (PD_pkt_data.h)
42  PD_DN_NUM_IFOVS_IN_NIGHT_PKT (PD_pkt_data.h)
43  PH_PRI_LONG_PKT_LENGTH (PH_pkt_hdr.h)
44  PH_PRI_SHORT_PKT_LENGTH (PH_pkt_hdr.h)
45  PH_SEC_PKT_TYPE_DAY_GROUP (PH_pkt_hdr.h)
46  PH_SEC_PKT_TYPE_NIGHT_GROUP (PH_pkt_hdr.h)
47  PH_SEC_PKT_TYPE_ENG1_GROUP (PH_pkt_hdr.h)
48  PH_SEC_PKT_TYPE_ENG2_GROUP (PH_pkt_hdr.h)
49  PH_PRI_SEQUENCE_FIRST_PKT_IN_GROUP (PH_pkt_hdr.h)
50  PH_PRI_SEQUENCE_SECOND_PKT_IN_GROUP (PH_pkt_hdr.h)
51  PH_MOD_SOURCE_ID_CAL_TYPE_SRCA_CAL_SOURCE (PH_pkt_hdr.h)
52  PH_MOD_SOURCE_ID_CAL_TYPE_BLACKBODY_SOURCE (PH_pkt_hdr.h)
53  PH_MOD_SOURCE_ID_CAL_TYPE_SPACE_SOURCE (PH_pkt_hdr.h)
54  PH_MOD_SOURCE_ID_TYPE_FLAG_EARTH (PH_pkt_hdr.h)
55  PH_MOD_SOURCE_ID_CAL_TYPE_SOLAR_DIFFUSER_SOURCE
56  (PH_pkt_hdr.h)
57 Called By:
58  process_a_scan
59 
60 Routines Called:
61  None
62 
63 !Revision History:
64  Revision 2.0 1997/09/02 13:43 EDT
65  Timi Adelekan/SAIC/GSC (adelekan@ltpmail.gsfc.nasa.gov)
66  Incorporate PDL walkthru comments in CODE.
67 
68  Revision 2.1 1997/08/27 10:30
69  Tom Johnson (johnson@ltpmail.gsfc.nasa.gov)
70  Incorporate PDL walkthru comments
71 
72  Revision 2.0 1997/08/11 11:40 EDT
73  Timi Adelekan/SAIC/GSC (adelekan@ltpmail.gsfc.nasa.gov)
74  Original design.
75 
76  Revision 1.0 1997/06/18 16:40 EDT
77  Timi Adelekan/SAIC/GSC (adelekan@ltpmail.gsfc.nasa.gov)
78  Baseline from Version 1.
79 
80 !Team-unique Header:
81  This software is developed by the MODIS Science
82  Data Support Team (SDST) for the National Aeronautics
83  and Space Administration (NASA), Goddard Space Flight
84  Center (GSFC), under contract NAS5-32373.
85 
86 !References and Credits:
87  None
88 
89 !Design Notes:
90  The CODE below was developed in C language.
91 
92  This routine assumes that the data contained in the
93  input parameters have been validated before this
94  routine is executed. No validation of data is performed
95  in this routine.
96 
97 !END**********************************************************************
98 */
99 
100  {
101 
102  /**************************************************************************/
103  /* */
104  /* Declare the local variables and initialize them. */
105  /* */
106  /**************************************************************************/
107 
108  int16 sequence; /* Packet sequence location */
109  int16 frame; /* Calculated frame number; used to */
110  /* properly place data in science arrays */
111 
112 
113  frame = 0;
114 
115 
116  /**************************************************************************/
117  /* */
118  /* IF ((PH_PACKET_HEADER_t.pkt_type is not equal to */
119  /* PH_SEC_PKT_TYPE_ENG1_GROUP) */
120  /* AND (PH_PACKET_HEADER_t.pkt_type is not equal to */
121  /* PH_SEC_PKT_TYPE_ENG2_GROUP) ) */
122  /* THEN */
123  /* */
124  /**************************************************************************/
125 
126  if ((pkt_header.pkt_type != PH_SEC_PKT_TYPE_ENG1_GROUP) &&
127  (pkt_header.pkt_type != PH_SEC_PKT_TYPE_ENG2_GROUP))
128  {
129 
130 
131  /**************************************************************************/
132  /* */
133  /* Calculate the array indices for the pixel quality array, based on */
134  /* this packet's location information. */
135  /* */
136  /**************************************************************************/
137  /* */
138  /* IF (PH_PACKET_HEADER_t.pkt_type equals PH_SEC_PKT_TYPE_DAY_GROUP) */
139  /* THEN */
140  /* set sequence equal to 0 */
141  /* IF (PH_PACKET_HEADER_t.sequence_flag equals */
142  /* PH_PRI_SEQUENCE_SECOND_PKT_IN_GROUP) */
143  /* THEN */
144  /* set sequence equal to 1 */
145  /* ENDIF */
146  /* */
147  /**************************************************************************/
148 
149  if (pkt_header.pkt_type == PH_SEC_PKT_TYPE_DAY_GROUP) {
150  sequence = 0;
152  sequence = 1;
153 
154 
155 
156  /**************************************************************************/
157  /* Determine the current packet's frame count and write the qual_value */
158  /* to the appropriate pixel quality array */
159  /* */
160  /**************************************************************************/
161  /* IF (PH_PACKET_HEADER_t.source_ID_type_flag equals */
162  /* PH_MOD_SOURCE_ID_TYPE_FLAG_EARTH) */
163  /* THEN */
164  /* IF PH_PACKET_HEADER_t.earth_frame_cnt is greater than 0 */
165  /* THEN */
166  /* set frame equal to PH_PACKET_HEADER_t.earth_frame_cnt - 1 */
167  /* set SC_PIXEL_QUALITY_DATA_t.EV_pix_qual[frame][sequence] */
168  /* to qual_value */
169  /* ENDIF */
170  /* */
171  /**************************************************************************/
172 
174  if (pkt_header.earth_frame_cnt > 0) {
175  frame = pkt_header.earth_frame_cnt - 1 ;
176  scan_pix->EV_pix_qual[frame][sequence] = qual_value;
177  }
178  }
179 
180 
181 
182  /**************************************************************************/
183  /* ELSE ** Must be a calibration frame ** */
184  /* IF PH_PACKET_HEADER_t.cal_frame_cnt is greater than 0 */
185  /* THEN */
186  /* set frame equal to PH_PACKET_HEADER_t.cal_frame_cnt - 1 */
187  /* */
188  /* SWITCH (PH_PACKET_HEADER_t.cal_type) */
189  /* CASE PH_MOD_SOURCE_ID_CAL_TYPE_SOLAR_DIFFUSER_SOURCE */
190  /* set SC_PIXEL_QUALITY_DATA_t.SD_pix_qual[frame] */
191  /* [sequence] */
192  /* to qual_value */
193  /* */
194  /* CASE PH_MOD_SOURCE_ID_CAL_TYPE_SRCA_CAL_SOURCE */
195  /* set SC_PIXEL_QUALITY_DATA_t.SRCA_pix_qual[frame] */
196  /* [sequence] */
197  /* to qual_value */
198  /* */
199  /* CASE PH_MOD_SOURCE_ID_CAL_TYPE_BLACKBODY_SOURCE */
200  /* set SC_PIXEL_QUALITY_DATA_t.BB_pix_qual[frame] */
201  /* [sequence] */
202  /* to qual_value */
203  /* */
204  /* CASE PH_MOD_SOURCE_ID_CAL_TYPE_SPACE_SOURCE */
205  /* set SC_PIXEL_QUALITY_DATA_t.SV_pix_qual[frame] */
206  /* [sequence] */
207  /* to qual_value */
208  /* */
209  /* END-SWITCH */
210  /* ENDIF */
211  /* ENDIF */
212  /* */
213  /**************************************************************************/
214 
215  else if (pkt_header.cal_frame_cnt > 0) {
216  frame = pkt_header.cal_frame_cnt - 1;
217  switch (pkt_header.cal_type) {
219  scan_pix->SD_pix_qual[frame][sequence] = qual_value;
220  break;
221 
223  scan_pix->SRCA_pix_qual[frame][sequence] = qual_value;
224  break;
225 
227  scan_pix->BB_pix_qual[frame][sequence] = qual_value;
228  break;
229 
231  scan_pix->SV_pix_qual[frame][sequence] = qual_value;
232  break;
233  }
234  }
235  }
236 
237  /**************************************************************************/
238  /* ELSE ** Set frame count for nightmode packets ** */
239  /* IF (PH_PACKET_HEADER_t.pkt_type equals */
240  /* PH_SEC_PKT_TYPE_NIGHT_GROUP) */
241  /* THEN ** Night packets can only be collected at Earth sector ** */
242  /* set frame equal to PH_PACKET_HEADER_t.earth_frame_cnt - 1 */
243  /* IF frame is greater than 0 */
244  /* THEN */
245  /* set SC_PIXEL_QUALITY_DATA_t.EV_pix_qual[frame][0] to */
246  /* qual_value */
247  /* set SC_PIXEL_QUALITY_DATA_t.EV_pix_qual[frame][1] to */
248  /* qual_value */
249  /* ENDIF */
250  /* ENDIF */
251  /* ENDIF */
252  /* ENDIF */
253  /* */
254  /**************************************************************************/
255 
256  else if (pkt_header.pkt_type == PH_SEC_PKT_TYPE_NIGHT_GROUP) {
257  frame = pkt_header.earth_frame_cnt - 1;
258  if (pkt_header.earth_frame_cnt > 0) {
259  scan_pix->EV_pix_qual[frame][0] = qual_value;
260  scan_pix->EV_pix_qual[frame][1] = qual_value;
261  }
262 
263  }
264 
265  } /* End check for Eng pkt */
266 
267  } /* End of routine update_pixel_qual_data */
integer, parameter int16
Definition: cubeio.f90:3
#define PH_PRI_SEQUENCE_SECOND_PKT_IN_GROUP
Definition: PH_pkt_hdr.h:128
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_CAL_TYPE_BLACKBODY_SOURCE
Definition: PH_pkt_hdr.h:202
#define PH_SEC_PKT_TYPE_ENG2_GROUP
Definition: PH_pkt_hdr.h:164
#define PH_MOD_SOURCE_ID_CAL_TYPE_SOLAR_DIFFUSER_SOURCE
Definition: PH_pkt_hdr.h:200
#define PH_MOD_SOURCE_ID_CAL_TYPE_SPACE_SOURCE
Definition: PH_pkt_hdr.h:203
#define PH_SEC_PKT_TYPE_NIGHT_GROUP
Definition: PH_pkt_hdr.h:162
#define PH_MOD_SOURCE_ID_TYPE_FLAG_EARTH
Definition: PH_pkt_hdr.h:188
void update_pixel_qual_data(PH_PACKET_HEADER_t pkt_header, int16 qual_value, SC_PIXEL_QUALITY_DATA_t *scan_pix)
#define PH_SEC_PKT_TYPE_DAY_GROUP
Definition: PH_pkt_hdr.h:161
#define PH_SEC_PKT_TYPE_ENG1_GROUP
Definition: PH_pkt_hdr.h:163
#define PH_MOD_SOURCE_ID_CAL_TYPE_SRCA_CAL_SOURCE
Definition: PH_pkt_hdr.h:201
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
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
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