OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
update_global_metadata.c
Go to the documentation of this file.
1 #include <ctype.h>
2 #include "L1A_prototype.h"
3 #include "hdf.h"
4 #include "hdfi.h"
5 #include "MD_metadata.h"
6 
7 
9  MD_ECS_GRA_INV_MET_t *ecs_gra_inv_met,
10  MD_L1A_SPECIFIC_MET_t *l1a_specific_met)
11 /*
12 !C***************************************************************************
13 
14 !Description: Function update_global_metadata updates ECS Inventory Granule
15  Metadata (MD_ECS_INV_MET_t) and MODIS L1A Specific Metadata
16  (MD_L1A_SPECIFIC_MET_t).
17 
18 !Input Parameters:
19  MD_SCAN_MET_t scan_meta ** Scan level metadata **
20 
21 !Output Parameters:
22  None
23 
24 !Input/Output Parameters:
25  MD_ECS_INV_MET_t ecs_gra_inv_met ** ECS Inventory Granule
26  Metadata **
27  MD_L1A_SPECIFIC_MET_t l1a_specific_met ** L1A Specific Metadata **
28 
29 Return Values:
30  None
31 
32 Externally Defined:
33  MD_SCAN_MET_t (MD_metadata.h)
34  MD_ECS_INV_MET_t (MD_metadata.h)
35  MD_L1A_SPECIFIC_MET_t (MD_metadata.h)
36  MD_INPUT_POINTER (MD_metadata.h)
37  MD_TOTAL_FRAMES_IN_SCAN (MD_metadata.h)
38  MD_EV_FRAMES_IN_SCAN (MD_metadata.h)
39  MD_SD_FRAMES_IN_SCAN (MD_metadata.h)
40  MD_SRCA_FRAMES_IN_SCAN (MD_metadata.h)
41  MD_BB_FRAMES_IN_SCAN (MD_metadata.h)
42  MD_SV_FRAMES_IN_SCAN (MD_metadata.h)
43  MD_MISSING_PACKET (MD_metadata.h)
44  MD_BAD_CHECKSUM_PACKET (MD_metadata.h)
45  MD_DISCARDED_PACKET (MD_metadata.h)
46  MD_BOTH (MD_metadata.h)
47  MD_MODIS_BOTH (MD_metadata.h)
48  MD_MIXED_SCAN (MD_metadata.h)
49  MD_DAY_STRING (MD_metadata.h)
50  MD_NIGHT_STRING (MD_metadata.h)
51  MAX (hdfi.h)
52 
53 Called By:
54  process_a_granule
55  handle_missing_scans
56 
57 Routines Called:
58  None
59 
60 !Revision History:
61 
62  revision 1.0 1997/08/20 17:30:00
63  Qi Huang/RDC (qhuang@ltpmail.gsfc.nasa.gov)
64  Original development
65 
66 !Team-unique Header:
67  This software is developed by the MODIS Science Data Support Team
68  Team (SDST) for the National Aeronautics and Space Administration
69  (NASA), Goddard Space Flight Center (GSFC), under contract
70  NAS5-32373.
71 
72 !References and Credits:
73  None
74 
75 !Design Notes:
76  None
77 
78 !END***************************************************************************
79 */
80 {
81 
82  /****************************************************************************/
83  /* */
84  /* IF MD_SCAN_MET_t.scan_type is not equal to "Other" */
85  /* THEN */
86  /* IF MD_ECS_INV_MET_t.day_night_flag is not "BOTH" */
87  /* THEN */
88  /* IF MD_ECS_INV_MET_t.day_night_flag is not equal to */
89  /* MD_SCAN_MET_t.scan_type AND MD_ECS_INV_MET_t.day_night_flag */
90  /* is not equal to "NA" */
91  /* THEN */
92  /* Set MD_ECS_INV_MET_t.day_night_flag to "Both" */
93  /* Set MD_ECS_INV_MET_t.operation_mode to "MODIS_Both" */
94  /* Set MD_L1A_SPECIFIC_MET_t.scan_types_product to "Mixed" */
95  /* ELSE */
96  /* Set MD_ECS_INV_MET_t.day_night_flag to MD_SCAN_MET_t.scan_type */
97  /* Set MD_L1A_SPECIFIC_MET_t.scan_types_product to */
98  /* MD_SCAN_MET_t.scan_type */
99  /* Set MD_ECS_INV_MET_t.operation_mode to "MODIS_" appended to */
100  /* MD_SCAN_MET_t.scan_type */
101  /* ENDIF */
102  /* ENDIF */
103  /* ENDIF */
104  /* */
105  /****************************************************************************/
106 
107  if (strcmp(scan_meta->scan_type,MD_OTHER_STRING) != 0)
108  if (strcmp(ecs_gra_inv_met->day_night_flag,MD_BOTH) != 0)
109  {
110  if ((strcmp(ecs_gra_inv_met->day_night_flag,scan_meta->scan_type) != 0)
111  && (strcmp(ecs_gra_inv_met->day_night_flag,MD_NA) != 0))
112  {
113  strcpy(ecs_gra_inv_met->day_night_flag,MD_BOTH);
114  memset(l1a_specific_met->scan_types_product, '\0',
115  sizeof(l1a_specific_met->scan_types_product));
116  strcpy(l1a_specific_met->scan_types_product,MD_MIXED_SCAN);
117  }
118  else
119  {
120  strcpy(ecs_gra_inv_met->day_night_flag,scan_meta->scan_type);
121  memset(l1a_specific_met->scan_types_product, '\0',
122  sizeof(l1a_specific_met->scan_types_product));
123  strcpy(l1a_specific_met->scan_types_product,scan_meta->scan_type);
124  }
125  }
126 
127 
128  /****************************************************************************/
129  /* */
130  /* Increment MD_L1A_SPECIFIC_MET_t.num_scans by 1 */
131  /* */
132  /****************************************************************************/
133 
134  l1a_specific_met->num_scans ++;
135 
136 
137  /****************************************************************************/
138  /* */
139  /* IF MD_SCAN_MET_t.scan_type is "DAY" */
140  /* THEN */
141  /* Increment MD_L1A_SPECIFIC_MET_t.num_day_scans by 1 */
142  /* ENDIF */
143  /* */
144  /****************************************************************************/
145 
146  if (strcmp(scan_meta->scan_type,MD_DAY_SCAN) == 0)
147  l1a_specific_met->num_day_scans ++;
148 
149 
150  /****************************************************************************/
151  /* */
152  /* IF MD_SCAN_MET_t.scan_type is "NIGHT" */
153  /* THEN */
154  /* Increment MD_L1A_SPECIFIC_MET_t.num_night_scans by 1 */
155  /* ENDIF */
156  /* */
157  /****************************************************************************/
158 
159  if (strcmp(scan_meta->scan_type,MD_NIGHT_SCAN) == 0)
160  l1a_specific_met->num_night_scans ++;
161 
162 
163  /****************************************************************************/
164  /* */
165  /* Set MD_L1A_SPECIFIC_MET_t.max_total_frames to the larger of either the */
166  /* previous MD_L1A_SPECIFIC_MET_t.max_total_frames or */
167  /* MD_SCAN_MET_t.frame_count_array[MD_TOTAL_FRAMES_IN_SCAN] */
168  /* */
169  /****************************************************************************/
170 
171  l1a_specific_met->max_total_frames = MAX(l1a_specific_met->max_total_frames,
173 
174 
175  /****************************************************************************/
176  /* */
177  /* Set MD_L1A_SPECIFIC_MET_t.max_earth_frames to the larger of either the */
178  /* previous MD_L1A_SPECIFIC_MET_t.max_earth_frames or */
179  /* MD_SCAN_MET_t.frame_count_array[MD_EV_FRAMES_IN_SCAN] */
180  /* */
181  /****************************************************************************/
182 
183  l1a_specific_met->max_earth_frames = MAX(l1a_specific_met->max_earth_frames,
185 
186 
187  /****************************************************************************/
188  /* */
189  /* Set MD_L1A_SPECIFIC_MET_t.max_sd_frames to the larger of either the */
190  /* previous MD_L1A_SPECIFIC_MET_t.max_sd_frames or */
191  /* MD_SCAN_MET_t.frame_count_array[MD_SD_FRAMES_IN_SCAN] */
192  /* */
193  /****************************************************************************/
194 
195  l1a_specific_met->max_sd_frames = MAX(l1a_specific_met->max_sd_frames,
197 
198 
199  /****************************************************************************/
200  /* */
201  /* Set MD_L1A_SPECIFIC_MET_t.max_srca_frames to the larger of either the */
202  /* previous MD_L1A_SPECIFIC_MET_t.max_srca_frames or */
203  /* MD_SCAN_MET_t.frame_count_array[MD_SRCA_FRAMES_IN_SCAN] */
204  /* */
205  /****************************************************************************/
206 
207  l1a_specific_met->max_srca_frames = MAX(l1a_specific_met->max_srca_frames,
209 
210 
211  /****************************************************************************/
212  /* */
213  /* Set MD_L1A_SPECIFIC_MET_t.max_bb_frames to the larger of either the */
214  /* previous MD_L1A_SPECIFIC_MET_t.max_bb_frames or */
215  /* MD_SCAN_MET_t.frame_count_array[MD_BB_FRAMES_IN_SCAN] */
216  /* */
217  /****************************************************************************/
218 
219  l1a_specific_met->max_bb_frames = MAX(l1a_specific_met->max_bb_frames,
221 
222 
223  /****************************************************************************/
224  /* */
225  /* Set MD_L1A_SPECIFIC_MET_t.max_sv_frames to the larger of either the */
226  /* previous MD_L1A_SPECIFIC_MET_t.max_sv_frames or */
227  /* MD_SCAN_MET_t.frame_count_array[MD_SV_FRAMES_IN_SCAN] */
228  /* */
229  /****************************************************************************/
230 
231  l1a_specific_met->max_sv_frames = MAX(l1a_specific_met->max_sv_frames,
233 
234 
235  /*******************************************************************************/
236  /* */
237  /* IF (MD_SCAN_MET_t.scan_qual_array[MD_MISSING_PACKET] is greater than 0) OR */
238  /* (MD_SCAN_MET_t.scan_qual_array[MD_BAD_CHECKSUM] is greater than 0) OR */
239  /* (MD_SCAN_MET_t.scan_qual_array[MD_DISCARDED_PACKET] is greater than 0) */
240  /* THEN */
241  /* Set MD_L1A_SPECIFIC_MET_t.incomplete_scans to */
242  /* MD_L1A_SPECIFIC_MET_t.incomplete_scans + 1 */
243  /* ENDIF */
244  /* */
245  /*******************************************************************************/
246 
247  if ( (scan_meta->scan_qual_array[MD_MISSING_PACKET] > 0) ||
248  (scan_meta->scan_qual_array[MD_BAD_CHECKSUM_PACKET] > 0) ||
249  (scan_meta->scan_qual_array[MD_DISCARDED_PACKET] > 0) )
250  l1a_specific_met->incomplete_scans ++;
251 
252 
253  /****************************************************************************/
254  /* */
255  /* IF MD_L1A_SPECIFIC_MET_t.num_scans is equal to 1 */
256  /* THEN */
257  /* Set MD_L1A_SPECIFIC_MET_t.missing_packets to */
258  /* MD_SCAN_MET_t.scan_qual_array[MD_MISSING_PACKET] */
259  /* ELSE */
260  /* Set MD_L1A_SPECIFIC_MET_t.missing_packets to */
261  /* MD_L1A_SPECIFIC_MET_t.missing_packets + */
262  /* MD_SCAN_MET_t.scan_qual_array[MD_MISSING_PACKET] */
263  /* ENDIF */
264  /* */
265  /****************************************************************************/
266 
267  if (l1a_specific_met->num_scans == 1)
268  l1a_specific_met->missing_packets = scan_meta->scan_qual_array[MD_MISSING_PACKET];
269  else
270  l1a_specific_met->missing_packets += scan_meta->scan_qual_array[MD_MISSING_PACKET];
271 
272 
273  /****************************************************************************/
274  /* */
275  /* Set MD_L1A_SPECIFIC_MET_t.packets_bad_crc to */
276  /* MD_L1A_SPECIFIC_MET_t.packets_bad_crc + */
277  /* MD_SCAN_MET_t.scan_qual_array[MD_BAD_CHECKSUM] */
278  /* */
279  /****************************************************************************/
280 
281  l1a_specific_met->packets_bad_crc += scan_meta->scan_qual_array[MD_BAD_CHECKSUM_PACKET];
282 
283 
284  /****************************************************************************/
285  /* */
286  /* Set MD_L1A_SPECIFIC_MET_t.discarded_packets to */
287  /* MD_L1A_SPECIFIC_MET_t.discarded_packets + */
288  /* MD_SCAN_MET_t.scan_qual_array[MD_DISCARDED_PACKET] */
289  /* */
290  /****************************************************************************/
291 
292  l1a_specific_met->discarded_packets += scan_meta->scan_qual_array[MD_DISCARDED_PACKET];
293 
294 
295  /****************************************************************************/
296  /*RETURN */
297  /****************************************************************************/
298 
299  return;
300 
301 }
#define MD_NA
Definition: MD_metadata.h:100
#define MAX(A, B)
Definition: swl0_utils.h:26
char scan_types_product[10]
Definition: MD_metadata.h:203
#define MD_BB_FRAMES_IN_SCAN
Definition: MD_metadata.h:138
#define MD_BOTH
Definition: MD_metadata.h:99
#define MD_EV_FRAMES_IN_SCAN
Definition: MD_metadata.h:135
#define MD_TOTAL_FRAMES_IN_SCAN
Definition: MD_metadata.h:134
#define MD_DAY_SCAN
Definition: MD_metadata.h:97
void update_global_metadata(MD_SCAN_MET_t *scan_meta, MD_ECS_GRA_INV_MET_t *ecs_gra_inv_met, MD_L1A_SPECIFIC_MET_t *l1a_specific_met)
#define MD_MISSING_PACKET
Definition: MD_metadata.h:147
#define MD_OTHER_STRING
Definition: MD_metadata.h:95
#define MD_BAD_CHECKSUM_PACKET
Definition: MD_metadata.h:148
#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
#define MD_SV_FRAMES_IN_SCAN
Definition: MD_metadata.h:139
int16 frame_count_array[6]
Definition: MD_metadata.h:219
#define MD_DISCARDED_PACKET
Definition: MD_metadata.h:149
#define MD_SRCA_FRAMES_IN_SCAN
Definition: MD_metadata.h:137
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
#define MD_MIXED_SCAN
Definition: MD_metadata.h:96
char scan_type[10]
Definition: MD_metadata.h:220