OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
finalize_scan_metadata.c
Go to the documentation of this file.
1 #include "MD_metadata.h"
2 #include "PH_pkt_hdr.h"
3 #include "hdfi.h"
4 #include "L1A_prototype.h"
5 
6 
8  int16 num_packets)
9 
10 /*
11 !C************************************************************************
12 
13 !Description: This function will set the "Missing packets in scan", "Total
14  Frames in scan", and "XX_start_time" fields in the scan-level
15  metadata.
16 
17 !Input Parameters:
18  int16 num_packets ** Number of packets in
19  this scan **
20 
21 !Output Parameters:
22  None
23 
24 !Input/Output Parameters:
25  MD_SCAN_MET_t *scan_meta ** Scan metadata **
26 
27 Return Values:
28  None
29 
30 Externally Defined:
31  int16 (hdfi.h)
32  MAX(a,b) (hdfi.h)
33  MD_SCAN_MET_t (MD_metadata.h)
34  MD_TOTAL_FRAMES_IN_SCAN (MD_metadata.h)
35  MD_EV_FRAMES_IN_SCAN (MD_metadata.h)
36  MD_SD_FRAMES_IN_SCAN (MD_metadata.h)
37  MD_SRCA_FRAMES_IN_SCAN (MD_metadata.h)
38  MD_BB_FRAMES_IN_SCAN (MD_metadata.h)
39  MD_SV_FRAMES_IN_SCAN (MD_metadata.h)
40  MD_MISSING_PACKET (MD_metadata.h)
41  MD_NIGHT_SCAN (MD_metadata.h)
42  PH_REALISTIC_NUM_SD_PACKETS (PH_pkt_hdr.h)
43  PH_REALISTIC_NUM_SRCA_PACKETS (PH_pkt_hdr.h)
44  PH_REALISTIC_NUM_BB_PACKETS (PH_pkt_hdr.h)
45  PH_REALISTIC_NUM_SV_PACKETS (PH_pkt_hdr.h)
46  PH_REALISTIC_NUM_EV_DAY_PACKETS (PH_pkt_hdr.h)
47  PH_REALISTIC_NUM_EV_NIGHT_PACKETS (PH_pkt_hdr.h)
48  global_time_offset_array (level1a)
49 
50 Called By:
51  process_a_scan
52 
53 Routines Called:
54  None
55 
56 !Revision History:
57  Revision 2.2 1997/09/03 15:20
58  Timi Adelekan/SAIC/GSC (adelekan@ltpmail.gsfc.nasa.gov)
59  Originated Code
60 
61  Revision 2.1 1997/08/27 10:35
62  Tom Johnson (johnson@ltpmail.gsfc.nasa.gov)
63  Incorporate PDL walkthru comments
64 
65  Revision 2.0 1997/07/25 10:00
66  Tom Johnson/GSC (johnson@ltpmail.gsfc.nasa.gov)
67  Updated for Version 2 from Version 1
68 
69  Revision 1.0 1997/06/18 16:40 EDT
70  Timi Adelekan/SAIC/GSC (adelekan@ltpmail.gsfc.nasa.gov)
71  Baseline from Version 1.
72 
73 !Team-unique Header:
74  This software is developed by the MODIS Science
75  Data Support Team (SDST) for the National Aeronautics
76  and Space Administration (NASA), Goddard Space Flight
77  Center (GSFC), under contract NAS5-32373.
78 
79 !References and Credits:
80  None
81 
82 !Design Notes:
83  This routine assumes that the packet has been validated
84  before this routine is executed. No validation of data
85  is performed in this routine.
86 
87  The following CODE was written in C language.
88 
89 !END**********************************************************************
90 */
91 
92  {
93  /**************************************************************************/
94  /* */
95  /* Define Global Variables */
96  /* */
97  /**************************************************************************/
98 
99  extern PGSt_double global_time_offset_array[5];
100  /* array containing the time */
101  /* offsets for each sector from */
102  /* the beginning of the scan */
103  /* (ie. SD sector) */
104 
105 
106  /**************************************************************************/
107  /* */
108  /* Declare the local variables and initialize them. */
109  /* */
110  /**************************************************************************/
111 
112  int16 max_SD_packets; /* Maximum number of SD packets in scan */
113  int16 max_SRCA_packets; /* Maximum number of SDCA packets in scan */
114  int16 max_BB_packets; /* Maximum number of BB packets in scan */
115  int16 max_SV_packets; /* Maximum number of SV packets in scan */
116  int16 max_EV_packets; /* Maximum number of EV packets in scan */
117 
118 
119  max_SD_packets = 0;
120  max_SRCA_packets = 0;
121  max_BB_packets = 0;
122  max_SV_packets = 0;
123  max_EV_packets = 0;
124 
125 
126 
127  /*************************************************************************/
128  /* */
129  /* Set max_SD_packets to the larger of either */
130  /* (MD_SCAN_MET_t.frame_count_array[MD_SD_FRAMES_IN_SCAN] * 2) or */
131  /* PH_REALISTIC_NUM_SD_PACKETS */
132  /* */
133  /* Set max_SRCA_packets to the larger of either */
134  /* (MD_SCAN_MET_t.frame_count_array[MD_SRCA_FRAMES_IN_SCAN] * 2) or */
135  /* PH_REALISTIC_NUM_SRCA_PACKETS */
136  /* */
137  /* Set max_BB_packets to the larger of either */
138  /* (MD_SCAN_MET_t.frame_count_array[MD_BB_FRAMES_IN_SCAN] * 2) or */
139  /* PH_REALISTIC_NUM_BB_PACKETS */
140  /* */
141  /* Set max_SV_packets to the larger of either */
142  /* (MD_SCAN_MET_t.frame_count_array[MD_SV_FRAMES_IN_SCAN] * 2) or */
143  /* PH_REALISTIC_NUM_SV_PACKETS */
144  /* */
145  /*************************************************************************/
146 
147  max_SD_packets =
148  MAX((scan_meta->frame_count_array[MD_SD_FRAMES_IN_SCAN] * 2),
150 
151  max_SRCA_packets =
152  MAX((scan_meta->frame_count_array[MD_SRCA_FRAMES_IN_SCAN] * 2),
154 
155  max_BB_packets =
156  MAX((scan_meta->frame_count_array[MD_BB_FRAMES_IN_SCAN] * 2),
158 
159  max_SV_packets =
160  MAX((scan_meta->frame_count_array[MD_SV_FRAMES_IN_SCAN] * 2),
162 
163 
164  /*************************************************************************/
165  /* */
166  /* IF MD_SCAN_MET_t.scan_type is equal to "Night" */
167  /* THEN */
168  /* Set max_EV_packets to the larger of either */
169  /* MD_SCAN_MET_t.frame_count_array[MD_EV_FRAMES_IN_SCAN] or */
170  /* PH_REALISTIC_NUM_EV_NIGHT_PACKETS */
171  /* ELSE */
172  /* Set max_EV_packets to the larger of either */
173  /* (MD_SCAN_MET_t.frame_count_array[MD_EV_FRAMES_IN_SCAN] * 2) or */
174  /* PH_REALISTIC_NUM_EV_DAY_PACKETS */
175  /* ENDIF */
176  /* */
177  /*************************************************************************/
178 
179  if (strcmp(scan_meta->scan_type, MD_NIGHT_SCAN) == 0)
180  max_EV_packets = MAX(scan_meta->frame_count_array[MD_EV_FRAMES_IN_SCAN],
182 
183  else
184  max_EV_packets =
185  MAX((scan_meta->frame_count_array[MD_EV_FRAMES_IN_SCAN] * 2),
187 
188 
189 
190  /*************************************************************************/
191  /* */
192  /* Set MD_SCAN_MET_t.scan_qual_array[MD_MISSING_PACKET] to */
193  /* (max_SD_packets + max_SRCA_packets + max_BB_packets + */
194  /* max_SV_packets + max_EV_packets + PH_REALISTIC_NUM_ENG_PACKETS) - */
195  /* num_packets */
196  /* */
197  /* Set MD_SCAN_MET_t.frame_count_array[MD_TOTAL_FRAMES_IN_SCAN] to */
198  /* MD_SCAN_MET_t.frame_count_array[MD_EV_FRAMES_IN_SCAN] + */
199  /* MD_SCAN_MET_t.frame_count_array[MD_SD_FRAMES_IN_SCAN] + */
200  /* MD_SCAN_MET_t.frame_count_array[MD_SRCA_FRAMES_IN_SCAN] + */
201  /* MD_SCAN_MET_t.frame_count_array[MD_BB_FRAMES_IN_SCAN] + */
202  /* MD_SCAN_MET_t.frame_count_array[MD_SV_FRAMES_IN_SCAN] */
203  /* */
204  /*************************************************************************/
205 
206  scan_meta->scan_qual_array[MD_MISSING_PACKET] =
207  (max_SD_packets +
208  max_SRCA_packets +
209  max_BB_packets +
210  max_SV_packets +
211  max_EV_packets +
212  PH_REALISTIC_NUM_ENG_PACKETS) - num_packets;
213 
220 
221 
222 
223  /*************************************************************************/
224  /* */
225  /* Set SD start time if it is fill value */
226  /* */
227  /*************************************************************************/
228  /* */
229  /* IF MD_SCAN_MET_t.sd_start_time is less than 0 (time is fill value) */
230  /* THEN */
231  /* IF MD_SCAN_MET_t.srca_start_time is not less than 0 */
232  /* THEN */
233  /* Set MD_SCAN_MET_t.sd_start_time to */
234  /* MD_SCAN_MET_t.srca_start_time - global_time_offset_array[1] */
235  /* ELSE */
236  /* IF MD_SCAN_MET_t.bb_start_time is not less than 0 */
237  /* THEN */
238  /* Set MD_SCAN_MET_t.sd_start_time to */
239  /* MD_SCAN_MET_t.bb_start_time - global_time_offset_array[2] */
240  /* ELSE */
241  /* IF MD_SCAN_MET_t.sv_start_time is not less than 0 */
242  /* THEN */
243  /* Set MD_SCAN_MET_t.sd_start_time to */
244  /* MD_SCAN_MET_t.sv_start_time - */
245  /* global_time_offset_array[3] */
246  /* ELSE */
247  /* Set MD_SCAN_MET_t.sd_start_time to */
248  /* MD_SCAN_MET_t.ev_start_time - */
249  /* global_time_offset_array[4] */
250  /* ENDIF */
251  /* ENDIF */
252  /* ENDIF */
253  /* ENDIF */
254  /* */
255  /*************************************************************************/
256 
257  if (scan_meta->sd_start_time < 0.0) {
258  if (scan_meta->srca_start_time >= 0.0)
259  scan_meta->sd_start_time = scan_meta->srca_start_time -
261  else if (scan_meta->bb_start_time >= 0.0)
262  scan_meta->sd_start_time = scan_meta->bb_start_time -
264  else if (scan_meta->sv_start_time >= 0.0)
265  scan_meta->sd_start_time = scan_meta->sv_start_time -
267  else if (scan_meta->ev_start_time >= 0.0)
268  scan_meta->sd_start_time = scan_meta->ev_start_time -
270  }
271  if (scan_meta->sd_start_time >= 0.0)
272  {
273  /*************************************************************************/
274  /* */
275  /* IF MD_SCAN_MET_t.srca_start_time is less than 0 (time is fill value) */
276  /* THEN */
277  /* Set MD_SCAN_MET_t.srca_start_time to MD_SCAN_MET_t.sd_start_time + */
278  /* global_time_offset_array[1] */
279  /* ENDIF */
280  /* */
281  /* IF MD_SCAN_MET_t.bb_start_time is less than 0 (time is fill value) */
282  /* THEN */
283  /* Set MD_SCAN_MET_t.bb_start_time to MD_SCAN_MET_t.sd_start_time + */
284  /* global_time_offset_array[2] */
285  /* ENDIF */
286  /* */
287  /* IF MD_SCAN_MET_t.sv_start_time is less than 0 (time is fill value) */
288  /* THEN */
289  /* Set MD_SCAN_MET_t.sv_start_time to MD_SCAN_MET_t.sd_start_time + */
290  /* global_time_offset_array[3] */
291  /* ENDIF */
292  /* */
293  /* IF MD_SCAN_MET_t.ev_start_time is less than 0 (time is fill value) */
294  /* THEN */
295  /* Set MD_SCAN_MET_t.ev_start_time to MD_SCAN_MET_t.sd_start_time + */
296  /* global_time_offset_array[4] */
297  /* ENDIF */
298  /* */
299  /*************************************************************************/
300 
301  if (scan_meta->srca_start_time < 0.0)
302  scan_meta->srca_start_time = scan_meta->sd_start_time +
304 
305  if (scan_meta->bb_start_time < 0.0)
306  scan_meta->bb_start_time = scan_meta->sd_start_time +
308 
309  if (scan_meta->sv_start_time < 0.0)
310  scan_meta->sv_start_time = scan_meta->sd_start_time +
312 
313  if (scan_meta->ev_start_time < 0.0)
314  scan_meta->ev_start_time = scan_meta->sd_start_time +
316 
317  }
318  } /* End of routine finalize_scan_metadata */
#define MAX(A, B)
Definition: swl0_utils.h:26
integer, parameter int16
Definition: cubeio.f90:3
#define MD_BB_FRAMES_IN_SCAN
Definition: MD_metadata.h:138
#define PH_REALISTIC_NUM_SV_PACKETS
Definition: PH_pkt_hdr.h:84
#define MD_EV_FRAMES_IN_SCAN
Definition: MD_metadata.h:135
#define PH_REALISTIC_NUM_BB_PACKETS
Definition: PH_pkt_hdr.h:83
#define MD_TOTAL_FRAMES_IN_SCAN
Definition: MD_metadata.h:134
float64 bb_start_time
Definition: MD_metadata.h:223
#define MD_MISSING_PACKET
Definition: MD_metadata.h:147
#define PH_REALISTIC_NUM_EV_DAY_PACKETS
Definition: PH_pkt_hdr.h:85
float64 sv_start_time
Definition: MD_metadata.h:224
#define MD_SD_FRAMES_IN_SCAN
Definition: MD_metadata.h:136
#define MD_NIGHT_SCAN
Definition: MD_metadata.h:98
int32 scan_qual_array[4]
Definition: MD_metadata.h:231
float64 ev_start_time
Definition: MD_metadata.h:225
#define MD_SV_FRAMES_IN_SCAN
Definition: MD_metadata.h:139
int16 frame_count_array[6]
Definition: MD_metadata.h:219
float64 sd_start_time
Definition: MD_metadata.h:221
#define PH_REALISTIC_NUM_SRCA_PACKETS
Definition: PH_pkt_hdr.h:82
#define PH_REALISTIC_NUM_SD_PACKETS
Definition: PH_pkt_hdr.h:81
PGSt_double global_time_offset_array[SECTOR_TIME_OFFSETS]
Definition: level1a.c:32
float64 srca_start_time
Definition: MD_metadata.h:222
void finalize_scan_metadata(MD_SCAN_MET_t *scan_meta, int16 num_packets)
#define MD_SRCA_FRAMES_IN_SCAN
Definition: MD_metadata.h:137
#define PH_REALISTIC_NUM_ENG_PACKETS
Definition: PH_pkt_hdr.h:87
#define PH_REALISTIC_NUM_EV_NIGHT_PACKETS
Definition: PH_pkt_hdr.h:86
char scan_type[10]
Definition: MD_metadata.h:220