OB.DAAC Logo
NASA Logo
Ocean Color Science Software

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