OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
put_cal_data_in_scan.c
Go to the documentation of this file.
1 #include "hdfi.h"
2 #include "PH_pkt_hdr.h"
3 #include "PD_pkt_data.h"
4 #include "SC_scan.h"
5 #include "L1A_prototype.h"
6 
7 
9  uint16 *pkt_cont,
10  SC_CAL_250M SC_250m,
11  SC_CAL_500M SC_500m,
12  SC_CAL_1KM_DAY SC_1km_day,
13  SC_CAL_1KM_NIGHT SC_1km_night)
14 
15 /*
16 !C************************************************************************
17 
18 !Description: The routine takes an unpacked daymode packet containing
19  calibration data at one of the calibration targets, extracts
20  it, and places the data in the proper arrays within the scan
21  structure.
22 
23 !Input Parameters:
24  PH_PACKET_HEADER_t *pkt_header ** The structure containing **
25  ** the current packet's **
26  ** packet header **
27 
28  int16 *pkt_cont ** The structure containing **
29  ** the current packet's **
30  ** unpacked contents **
31 
32 !Output Parameters:
33  None
34 
35 !Input/Output Parameters:
36  SC_CAL_250M SC_250m ** array that holds earth/ **
37  ** calibration sector 250m **
38  ** radiances **
39 
40  SC_CAL_500M SC_500m ** array that holds earth/ **
41  ** calibration sector 500m **
42  ** radiances **
43 
44  SC_CAL_1KM_DAY SC_1km_day ** array that holds earth/ **
45  ** calibration sector 1km **
46  ** day radiances **
47 
48  SC_CAL_1KM_NIGHT SC_1km_night ** array that holds earth/ **
49  ** calibration sector 1km **
50  ** night radiances **
51 
52 Return Values:
53  None
54 
55 Externally Defined:
56  int16 (hdfi.h)
57  SC_CAL_250M (SC_scan.h)
58  SC_CAL_500M (SC_scan.h)
59  SC_CAL_1KM_DAY (SC_scan.h)
60  SC_CAL_1KM_NIGHT (SC_scan.h)
61  PH_PRI_SEQUENCE_FIRST_PKT_IN_GROUP (PH_pkt_hdr.h)
62  PH_PRI_SEQUENCE_SECOND_PKT_IN_GROUP (PH_pkt_hdr.h)
63  PD_DN_FIRST_250M_BAND (PD_pkt_data.h)
64  PD_DN_LAST_250M_BAND (PD_pkt_data.h)
65  PD_DN_BAND_RATIO_250M (PD_pkt_data.h)
66  PD_DN_FIRST_500M_BAND (PD_pkt_data.h)
67  PD_DN_LAST_500M_BAND (PD_pkt_data.h)
68  PD_DN_BAND_RATIO_500M (PD_pkt_data.h)
69  PD_DN_FIRST_1KM_DAY_BAND (PD_pkt_data.h)
70  PD_DN_LAST_1KM_DAY_BAND (PD_pkt_data.h)
71  PD_DN_FIRST_1KM_NIGHT_BAND (PD_pkt_data.h)
72  PD_DN_LAST_1KM_NIGHT_BAND (PD_pkt_data.h)
73  PD_DN_NUM_1KMDAY_DETECTORS (PD_pkt_data.h)
74  PD_DN_NUM_1KMNIGHT_DETECTORS (PD_pkt_data.h)
75  PD_DN_NUM_IFOVS_IN_DAY_PKT (PD_pkt_data.h)
76  PD_DN_FIRST_IFOV_DAY_PKT_1 (PD_pkt_data.h)
77  PD_DN_LAST_IFOV_DAY_PKT_1 (PD_pkt_data.h)
78  PD_DN_FIRST_IFOV_DAY_PKT_2 (PD_pkt_data.h)
79  PD_DN_LAST_IFOV_DAY_PKT_2 (PD_pkt_data.h)
80 
81 Called By:
82  output_daymode_data_to_scan
83 
84 Routines Called:
85  None
86 
87 !Revision History:
88  Revision 2.0 1997/06/18 16:40 EDT
89  Timi Adelekan/SAIC/GSC (adelekan@ltpmail.gsfc.nasa.gov)
90  Originated Code. (original design based on version1
91  routine: output_cal_data_to_scan)
92 
93 !Team-unique Header:
94  This software is developed by the MODIS Science
95  Data Support Team (SDST) for the National Aeronautics
96  and Space Administration (NASA), Goddard Space Flight
97  Center (GSFC), under contract NAS5-32373.
98 
99 !References and Credits:
100  None
101 
102 !Design Notes:
103  The CODE below was developed in C language.
104 
105  This routine was designed totally under the asumption that
106  the packet header has been priviously validated and there
107  is no need to test for error conditions.
108 
109  The structure of "SC_*" is determined by the Level 1A
110  project specification.
111 
112 !END*************************************************************************
113 */
114 
115  {
116  /*************************************************************************/
117  /* */
118  /* Declare the local variables and initialize them. */
119  /* */
120  /*************************************************************************/
121  /* */
122  /* set start_ifov to 0 */
123  /* set end_ifov equal to PD_DN_NUM_IFOVS_IN_DAY_PKT */
124  /* set pkt_cont_pos equal to PH_NUM_12BIT_WORDS_IN_HEADER */
125  /* */
126  /*************************************************************************/
127 
128  int start_ifov; /* starting ifov position within scan */
129  int end_ifov; /* ending ifov position within scan */
130  int ifov; /* loop variable holding current ifov */
131  int band; /* Band indicator (used as loop variable) */
132  int band_num; /* Band indicator corrected for each */
133  /* detector group's start position */
134  int sample; /* Sample indicator for 250m and 500m */
135  /* data (used as loop variable) */
136  int det; /* detector multiplier for 250m and 500m */
137  /* data (used as loop variable) */
138  int line_num; /* Calculated line number; used to */
139  /* properly place data in science arrays */
140  int frame; /* Calculated frame number; used to */
141  /* properly place data in science arrays */
142  int frame_ifov_offset; /* Offset used to adjust a packet's */
143  /* IFOVs to the proper scan location */
144  int scan_ifov; /* IFOV within the scan where the */
145  /* current packet's contents belong */
146  int pkt_cont_pos; /* index into packet_contents */
147  int8 frame_cnt; /* Frame count for Calibration packets */
148 
149 
150  band = 0;
151  band_num = 0;
152  sample = 0;
153  det = 0;
154  line_num = 0;
155  frame = 0;
156  frame_cnt = 0;
157  frame_ifov_offset = 0;
158  scan_ifov = 0;
159  ifov = 0;
160  start_ifov = 0;
161  end_ifov = PD_DN_NUM_IFOVS_IN_DAY_PKT;
162  pkt_cont_pos = PH_NUM_12BIT_WORDS_IN_HEADER;
163 
164 
165 
166  /**************************************************************************/
167  /* */
168  /* Get packet frame count. Then determine whether this packet contains */
169  /* IFOVs 1 through 5 or 6 through 10. */
170  /* */
171  /**************************************************************************/
172  /* */
173  /* Set frame_cnt equal to PH_PACKET_HEADER_t.cal_frame_cnt */
174  /* */
175  /* Set frame_ifov_offset equal to 0 */
176  /* IF PH_PACKET_HEADER_t.sequence_flag equals */
177  /* PH_PRI_SEQUENCE_SECOND_PKT_IN_GROUP */
178  /* THEN */
179  /* Set frame_ifov_offset equal to 5 */
180  /* ENDIF */
181  /* */
182  /**************************************************************************/
183 
184  frame_cnt = pkt_header->cal_frame_cnt;
185 
186  frame_ifov_offset = 0;
188  frame_ifov_offset = 5;
189 
190 
191  /**************************************************************************/
192  /* */
193  /* Extract the packet contents into the scan structure. */
194  /* */
195  /**************************************************************************/
196  /* */
197  /* FOR ifov equal to start_ifov to end_ifov */
198  /* set scan_ifov equal to (ifov + frame_ifov_offset) */
199  /* */
200  /**************************************************************************/
201 
202  for (ifov = start_ifov; ifov < end_ifov; ifov++) {
203  scan_ifov = ifov + frame_ifov_offset;
204 
205 
206  /**************************************************************************/
207  /* */
208  /* Within each ifov set, the 250 meter data appear first, organized by */
209  /* band_num, each band's radiances organized by the 4 samples taken by */
210  /* each detector, then by the 4 detectors within the ifov. And the line */
211  /* number is corrected to account for the instrument detector numbering. */
212  /* */
213  /**************************************************************************/
214  /* */
215  /* FOR band equal to PD_DN_FIRST_250M_BAND to PD_DN_LAST_250M_BAND */
216  /* set band_num equal to (band - PD_DN_FIRST_250M_BAND) */
217  /* FOR sample equal to 0 upto PD_DN_BAND_RATIO_250M */
218  /* set frame equal to ((frame_cnt - 1) * PD_DN_BAND_RATIO_250M) +*/
219  /* sample */
220  /* FOR det equals to 0 upto PD_DN_NUM_250M_DETECTORS_IN_IFOV */
221  /* set line_num equal to ((PD_DN_NUM_250M_DETECTORS - 1) - */
222  /* ((scan_ifov * PD_DN_NUM_250M_DETECTORS_IN_IFOV) + det))*/
223  /* set SC_250m(line_num,band_num,frame) equal to */
224  /* pkt_cont(pkt_cont_pos) */
225  /* set pkt_cont_pos to pkt_cont_pos + 1 */
226  /* ENDFOR (next det) */
227  /* ENDFOR (next sample) */
228  /* ENDFOR (next band) */
229  /* */
230  /**************************************************************************/
231 
233  band_num = band - PD_DN_FIRST_250M_BAND;
234  for (sample = 0; sample < PD_DN_BAND_RATIO_250M; sample++){
235  frame = ((frame_cnt - 1) * PD_DN_BAND_RATIO_250M) + sample;
236  for (det = 0; det < PD_DN_NUM_250M_DETECTORS_IN_IFOV; det++){
237  line_num = ((PD_DN_NUM_250M_DETECTORS - 1) -
238  ((scan_ifov * PD_DN_NUM_250M_DETECTORS_IN_IFOV) + det));
239  SC_250m[line_num][band_num][frame] = pkt_cont[pkt_cont_pos];
240  pkt_cont_pos++;
241  }
242  }
243  }
244 
245 
246  /**************************************************************************/
247  /* */
248  /* The 500 meter data is next, with each band's radiances organized be */
249  /* band_num, then by the 2 samples taken by each detector, then by the 2 */
250  /* detectors within the ifov. And the line number is corrected to */
251  /* account for the instrument detector numbering. */
252  /* */
253  /**************************************************************************/
254  /* */
255  /* FOR band equal to PD_DN_FIRST_500M_BAND to PD_DN_LAST_500M_BAND */
256  /* set band_num equal to (band - PD_DN_FIRST_500M_BAND) */
257  /* FOR sample equal to 0 upto PD_DN_BAND_RATIO_500M */
258  /* set frame equal to ((frame_cnt - 1) * PD_DN_BAND_RATIO_500M) +*/
259  /* sample */
260  /* FOR det equals to 0 upto PD_DN_NUM_500M_DETECTORS_IN_IFOV */
261  /* set line_num equal to ((PD_DN_NUM_500M_DETECTORS - 1) - */
262  /* ((scan_ifov * PD_DN_NUM_500M_DETECTORS_IN_IFOV) + det)) */
263  /* set SC_500m(line_num,band_num,frame) equal to */
264  /* pkt_cont(pkt_cont_pos) */
265  /* set pkt_cont_pos to pkt_cont_pos + 1 */
266  /* ENDFOR (next det) */
267  /* ENDFOR (next sample) */
268  /* ENDFOR (next band) */
269  /* */
270  /**************************************************************************/
271 
273  band_num = band - PD_DN_FIRST_500M_BAND;
274  for (sample = 0; sample < PD_DN_BAND_RATIO_500M; sample++){
275  frame = ((frame_cnt - 1) * PD_DN_BAND_RATIO_500M) + sample;
276  for (det = 0; det < PD_DN_NUM_500M_DETECTORS_IN_IFOV; det++){
277  line_num = ((PD_DN_NUM_500M_DETECTORS - 1) -
278  ((scan_ifov * PD_DN_NUM_500M_DETECTORS_IN_IFOV) + det));
279  SC_500m[line_num][band_num][frame] = pkt_cont[pkt_cont_pos];
280  pkt_cont_pos++;
281  }
282  }
283  }
284 
285 
286  /**************************************************************************/
287  /* */
288  /* The 1km day data is next in each ifov set, with one sample per band */
289  /* And the line number is corrected to account for the instrument */
290  /* detector numbering. */
291  /* */
292  /**************************************************************************/
293  /* */
294  /* set frame equal to frame_cnt - 1 */
295  /* FOR band = PD_DN_FIRST_1KM_DAY_BAND to PD_DN_LAST_1KM_DAY_BAND */
296  /* set band_num equal to (band - PD_DN_FIRST_1KM_DAY_BAND) */
297  /* set line_num equal to ((PD_DN_NUM_1KMDAY_DETECTORS - 1) - */
298  /* scan_ifov) */
299  /* set SC_1km_day(line_num,band_num,frame) equal to */
300  /* pkt_cont(pkt_cont_pos) */
301  /* set pkt_cont_pos to pkt_cont_pos + 1 */
302  /* ENDFOR (next band) */
303  /* */
304  /**************************************************************************/
305 
306  frame = frame_cnt - 1;
309  band++) {
310  band_num = band - PD_DN_FIRST_1KM_DAY_BAND;
311  line_num = ((PD_DN_NUM_1KMDAY_DETECTORS - 1) - scan_ifov);
312  SC_1km_day[line_num][band_num][frame] = pkt_cont[pkt_cont_pos];
313  pkt_cont_pos++;
314  }
315 
316 
317  /**************************************************************************/
318  /* */
319  /* The 1km night data is last in each ifov set, with one sample per band */
320  /* And the line number is corrected to account for the instrument */
321  /* detector numbering. */
322  /* */
323  /**************************************************************************/
324  /* */
325  /* set frame equal to frame_cnt - 1 */
326  /* FOR band = PD_DN_FIRST_1KM_NIGHT_BAND to PD_DN_LAST_1KM_NIGHT_BAND */
327  /* set band_num equal to (band - PD_DN_FIRST_1KM_NIGHT_BAND) */
328  /* set line_num equal to ((PD_DN_NUM_1KMNIGHT_DETECTORS - 1 ) - */
329  /* scan_ifov) */
330  /* set SC_1km_night(line_num,band_num,frame) equal to */
331  /* pkt_cont(pkt_cont_pos) */
332  /* set pkt_cont_pos to pkt_cont_pos + 1 */
333  /* ENDFOR (next band) */
334  /* ENDFOR (next ifov) */
335  /* */
336  /**************************************************************************/
337 
338  frame = frame_cnt - 1;
341  band++) {
342  band_num = band - PD_DN_FIRST_1KM_NIGHT_BAND;
343  line_num = ((PD_DN_NUM_1KMNIGHT_DETECTORS - 1 ) - scan_ifov);
344  SC_1km_night[line_num][band_num][frame] = pkt_cont[pkt_cont_pos];
345  pkt_cont_pos++;
346  }
347  } /* next ifov */
348 
349  } /* End of routine put_cal_data_in_scan */
#define PD_DN_FIRST_500M_BAND
Definition: PD_pkt_data.h:94
#define PD_DN_NUM_IFOVS_IN_DAY_PKT
Definition: PD_pkt_data.h:111
void put_cal_data_in_scan(PH_PACKET_HEADER_t *pkt_header, uint16 *pkt_cont, SC_CAL_250M SC_250m, SC_CAL_500M SC_500m, SC_CAL_1KM_DAY SC_1km_day, SC_CAL_1KM_NIGHT SC_1km_night)
#define PD_DN_BAND_RATIO_500M
Definition: PD_pkt_data.h:96
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second band
#define PH_PRI_SEQUENCE_SECOND_PKT_IN_GROUP
Definition: PH_pkt_hdr.h:128
int16 SC_CAL_500M[PD_DN_NUM_500M_DETECTORS][PD_DN_NUM_500M_BANDS][PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX *PD_DN_BAND_RATIO_500M]
Definition: SC_scan.h:161
#define PD_DN_NUM_250M_DETECTORS
Definition: PD_pkt_data.h:91
int16 SC_CAL_250M[PD_DN_NUM_250M_DETECTORS][PD_DN_NUM_250M_BANDS][PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX *PD_DN_BAND_RATIO_250M]
Definition: SC_scan.h:156
#define PD_DN_NUM_500M_DETECTORS
Definition: PD_pkt_data.h:98
#define PD_DN_NUM_1KMNIGHT_DETECTORS
Definition: PD_pkt_data.h:109
#define PD_DN_LAST_1KM_NIGHT_BAND
Definition: PD_pkt_data.h:104
#define PD_DN_FIRST_1KM_NIGHT_BAND
Definition: PD_pkt_data.h:103
#define PD_DN_NUM_250M_DETECTORS_IN_IFOV
Definition: PD_pkt_data.h:92
#define PD_DN_FIRST_1KM_DAY_BAND
Definition: PD_pkt_data.h:101
#define PH_NUM_12BIT_WORDS_IN_HEADER
Definition: PH_pkt_hdr.h:78
#define PD_DN_NUM_1KMDAY_DETECTORS
Definition: PD_pkt_data.h:107
#define PD_DN_FIRST_250M_BAND
Definition: PD_pkt_data.h:87
#define PD_DN_LAST_1KM_DAY_BAND
Definition: PD_pkt_data.h:102
#define PD_DN_BAND_RATIO_250M
Definition: PD_pkt_data.h:89
#define PD_DN_NUM_500M_DETECTORS_IN_IFOV
Definition: PD_pkt_data.h:99
#define PD_DN_LAST_500M_BAND
Definition: PD_pkt_data.h:95
int16 SC_CAL_1KM_NIGHT[PD_DN_NUM_1KMNIGHT_DETECTORS][PD_DN_NUM_1KMNIGHT_BANDS][PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX *PD_DN_BAND_RATIO_1KM]
Definition: SC_scan.h:171
int16 SC_CAL_1KM_DAY[PD_DN_NUM_1KMDAY_DETECTORS][PD_DN_NUM_1KMDAY_BANDS][PH_MOD_SOURCE_ID_CAL_FRAME_CNT_MAX *PD_DN_BAND_RATIO_1KM]
Definition: SC_scan.h:166
#define PD_DN_LAST_250M_BAND
Definition: PD_pkt_data.h:88