OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
L1A_prototype.h
Go to the documentation of this file.
1 #ifndef L1A_PROTOTYPE_H
2 #define L1A_PROTOTYPE_H
3 
4 /*
5 !C-INC************************************************************************
6 
7 !Description: This include file contains the prototypes for all L1A routines.
8 
9 !Input Parameters: N/A
10 
11 !Output Parameters: N/A
12 
13 Externally Defined:
14  PGSt_SMF_status (PGS_SMF.h)
15  PGSt_IO_L0_Packet (PGS_IO.h)
16  PGSt_IO_L0_VirtualDataSet (PGS_IO.h)
17  PH_PACKET_HEADER_t (PH_pkt_hdr.h)
18  FP_QUEUE_t (FP_failed_pkt_queue.h)
19  PGSt_scTime (PGS_TD.h)
20  PGSt_double (PGS_TD.h)
21 
22 !Revision History:
23  $Log: L1A_prototype.h,v $
24  Revision 5.1 2007/01/24 22:36:31 kuyper
25  Added gran_start_time parameter to handle_missing_scans().
26 
27  Revision 4.9 2003/11/12 21:04:52 kuyper
28  Changed to define and use MAX_INPUTS macro.
29 
30  Revision 4.8 2003/09/30 18:49:29 kuyper
31  Reinstated process_a_packet() prototype.
32 
33  Revision 4.7 2003/05/09 16:41:47 kuyper
34  Changed process_next_packet to accept packet_header as a pointer to a pointer.
35 
36  Revision 4.6 2003/03/05 22:10:56 kuyper
37  Added global_time_offset_array.
38 
39  Revision 4.5 2003/02/24 21:43:15 kuyper
40  Changed pointer parameters of log_fmt_msg() to be pointers to
41  const.
42 
43  Revision 4.4 2002/10/21 19:10:29 vlin
44  global variables "global_first_gran_start_time" & "global_last_gran_stop_time" added
45 
46  Revision 4.2 2002/09/19 14:31:58 vlin
47  prototype for function "initialize_level1a" updated.
48 
49  Revision 4.1 2002/08/28 18:44:43 vlin
50  Routines initialize_global_metadata, get_pcf_config_data, process_a_granule,
51  initialize_scan_data, process_next_packet, and process_a_packet are updated.
52  global_input_pointer added.
53  vlin@saicmodis.com
54 
55  Revision 3.0 1998/10/16 09:40:00 EDT
56  John Seaton/SAIC/GSC (seaton@ltpmail.gsfc.nasa.gov)
57  Added new procedure process_group2_packet1_vdata.
58 
59  Revision 2.0 1997/07/10 11:00
60  Tom Johnson/SAIC/GSC (johnson@ltpmail.gsfc.nasa.gov)
61  Added include files for packet processing
62 
63  Revision 1.0 1997/09/22 10:00
64  Qi Huang (qhuang@ltpmail.gsfc.nasa.gov)
65  Original include file
66 
67 !Team-unique Header:
68 
69  This software is developed by the MODIS Science Data Support Team
70  for the National Aeronautics and Space Administration,
71  Goddard Space Flight Center, under contract NAS5-32373.
72 
73  Design Notes:
74  The ".h" below was specifically written for development in C.
75  Any other language choice may require reworking of the ".h"
76  before coding can begin.
77 
78 !END**********************************************************************
79 */
80 
81 #include "hdf.h"
82 #include "mapi.h"
83 #include "PGS_IO.h"
84 #include "PGS_SMF.h"
85 #include "EN_eng_data.h"
86 #include "FP_failed_pkt_queue.h"
87 #include "MD_metadata.h"
88 #include "PD_pkt_data.h"
89 #include "PH_pkt_hdr.h"
90 #include "SC_scan.h"
91 #include "VU_vdata_utility.h"
92 #include "PC_pcf_info.h"
93 
94 
95 /************************* L1A Routine Prototype *****************************/
96 
97 PGSt_SMF_status accumulate_failed_packets (PGSt_IO_L0_Packet *pkt,
98  FP_QUEUE_t failed_pkts);
99 
101 
102 PGSt_SMF_status check_checksum (PH_PACKET_HEADER_t pkt_header,
103  uint16 *pkt_contents);
104 
105 void close_processing_run (PGSt_IO_L0_VirtualDataSet L0_file);
106 
107 PGSt_SMF_status close_Vdata (char *Vdata_name);
108 
109 void compute_SD_start_time (PH_PACKET_HEADER_t *pkt_header,
110  PGSt_double *SD_start_time);
111 
112 void compute_global_time_offsets (PGSt_double scan_rate);
113 
114 PGSt_SMF_status create_L1A_granule (EN_VDATA_TYPE_t *eng_data,
115  int16 nscans,
116  MODFILE **L1A_file_ptr);
117 
118 PGSt_SMF_status create_Vdata(char *Vdata_name,
119  char field_names[][VU_MAX_NAME_LENGTH],
120  char data_types[][VU_MAX_DATA_TYPE_STRING_LENGTH],
121  int16 num_fields,
122  uint16 order[]);
123 
124 PGSt_SMF_status create_Vdata_field (char *Vdata_name,
125  int32 Vdata_id,
126  char *field_name,
127  char *data_type,
128  int32 order);
129 
130 void create_eng_data_vdata_array (char *eng_data_name,
131  EN_VDATA_TYPE_t *eng_data,
132  uint16 *curr_eng_data_index,
133  uint16 *curr_field_index);
134 
135 void create_eng_data_vdata_array_field (char *field_name,
136  uint16 num_bits,
137  uint16 start_bit_pos,
138  uint16 order,
139  uint16 type,
140  EN_VDATA_TYPE_t *eng_data,
141  uint16 curr_eng_data_index,
142  uint16 *curr_field_index);
143 
144 void create_missing_scans (int16 prev_scan_num,
145  PGSt_double scan_rate,
146  PGSt_double *SD_start_time,
147  MD_SCAN_MET_t *scan_metadata,
148  SC_PIXEL_QUALITY_DATA_t *pixel_qual_data);
149 
150 char *dequeue (FP_QUEUE_t Q);
151 
152 PGSt_SMF_status end_Vdata_access_to_file (MODFILE *L1A_file);
153 
154 PGSt_SMF_status end_eng_data_access_to_file (MODFILE *L1A_file,
155  EN_VDATA_TYPE_t *eng_data);
156 
157 PGSt_SMF_status enqueue (char *item,
158  FP_QUEUE_t Q);
159 
160 int16 equal_strings (char *a,
161  char *b);
162 
163 uint32 extr_bits (uint8 *a,
164  int start_byte,
165  int start_bit,
166  int num_bits);
167 
169  MD_SCAN_MET_t *scan_meta);
170 
171 void finalize_scan_metadata (MD_SCAN_MET_t *scan_meta,
172  int16 num_packets);
173 
174 void forget (char *Vdata_name);
175 
176 void free_queue (FP_QUEUE_t Q);
177 
178 int16 get_empty_slot (void);
179 
180 int16 get_index (char *Vdata_name);
181 
182 #define MAX_INPUTS 3
183 extern char global_input_pointer[MAX_INPUTS][PGSd_PC_VALUE_LENGTH_MAX];
184  /* Names of the input files: List file name,
185  prior L0 file name, current L0 file name */
186 
187 #define SECTOR_TIME_OFFSETS 5
189  /* Aarray containing the time offsets for each sector */
190  /* from the beginning of the scan (i.e. SD sector) */
191 
192 extern PGSt_double global_first_gran_start_time;
193  /* Start time for the first L1A output granule */
194 
195 extern PGSt_double global_last_gran_stop_time;
196  /* Stop time for the last L1A output granule */
197 
199 
200 PGSt_SMF_status get_pcf_config_data(PCF_CONFIG_t *pcf_config);
201 
202 PGSt_SMF_status get_valid_L0_file (PGSt_tag spacecraft_tag,
203  PGSt_IO_L0_VirtualDataSet *L0_file,
204  PGSt_double *start_time,
205  PGSt_double *stop_time);
206 
207 PGSt_SMF_status handle_missing_scans (MODFILE *L1A_file_ptr,
208  PGSt_double SD_start_time,
209  PGSt_double *pre_SD_time,
210  PGSt_double scan_rate,
211  int *scan_number,
212  MD_ECS_GRA_INV_MET_t *ecs_gran_meta,
213  MD_L1A_SPECIFIC_MET_t *L1A_specific_meta,
214  PGSt_SMF_boolean *gran_start_time_used,
215  PGSt_double gran_start_time,
216  EN_VDATA_TYPE_t *eng_data);
217 
218 PGSt_SMF_status init_L1A_HDF_sdss (MODFILE *L1A_file_ptr,
219  int16 nscans);
220 
221 PGSt_SMF_status init_L1A_HDF_vdatas (EN_VDATA_TYPE_t *eng_data,
222  MODFILE *L1A_file);
223 
224 PGSt_SMF_status init_L1A_pix_qual_HDF_sdss (MODFILE *mfile,
225  int nscans);
226 
227 PGSt_SMF_status init_L1A_scan_data_HDF_sdss (MODFILE *mfile,
228  int nscans);
229 
230 PGSt_SMF_status init_L1A_scan_meta_HDF_sdss (MODFILE *mfile,
231  int nscans);
232 
233 PGSt_SMF_status initialize_global_metadata (PGSt_double gran_start_time,
234  PGSt_double gran_end_time,
235  int nscans,
236  PCF_CONFIG_t *pcf_config,
237  MD_ECS_GRA_INV_MET_t *ecs_gra_inv_met,
238  MD_L1A_SPECIFIC_MET_t *l1a_specific_met);
239 
240 void initialize_id_table (void);
241 
242 PGSt_SMF_status initialize_level1a (PCF_CONFIG_t *pcf_config,
243  EN_VDATA_TYPE_t *eng_data,
244  PGSt_IO_L0_Packet *pkt,
245  PH_PACKET_HEADER_t *pkt_header,
246  PGSt_IO_L0_VirtualDataSet *L0_file);
247 
249 
250 void initialize_scan (SC_SCAN_DATA_t *L1A_scan,
251  SC_PIXEL_QUALITY_DATA_t *scan_pixel,
252  MD_SCAN_MET_t *scan_meta);
253 
254 void initialize_scan_metadata (MD_SCAN_MET_t *scan_meta);
255 
256 void initialize_scan_data (SC_SCAN_DATA_t *L1A_scan);
257 
258 int32 L1A_datatype_to_DFNT(char *datatype);
259 
260 PGSt_SMF_status load_eng_data (PGSt_double scan_rate,
261  EN_VDATA_TYPE_t *eng_data,
262  PGSt_IO_L0_Packet *pkt,
263  PH_PACKET_HEADER_t *pkt_header,
264  PGSt_IO_L0_VirtualDataSet L0_file);
265 
266 void log_fmt_msg (PGSt_SMF_status code,
267  const char *routine,
268  const char *msg_fmt,
269  ...);
270 
271 FP_QUEUE_t make_queue (void);
272 
274  uint16 *pkt_contents,
275  SC_SCAN_DATA_t *L1A_scan);
276 
277 void output_eng1_pkt1_to_scan (PGSt_IO_L0_Packet *pkt,
278  SC_SCAN_DATA_t *L1A_scan);
279 
280 void output_eng1_pkt2_to_scan (PGSt_IO_L0_Packet *pkt,
281  SC_SCAN_DATA_t *L1A_scan);
282 
283 void output_eng2_pkt1_to_scan (PGSt_IO_L0_Packet *pkt,
284  SC_SCAN_DATA_t *L1A_scan);
285 
286 void output_eng2_pkt2_to_scan (PGSt_IO_L0_Packet *pkt,
287  SC_SCAN_DATA_t *L1A_scan);
288 
290  PGSt_IO_L0_Packet *pkt,
291  SC_SCAN_DATA_t *L1A_scan);
292 
294  uint16 *pkt_contents,
295  SC_EV_1KM_NIGHT EV_1km_night);
296 
297 PGSt_SMF_status packet_of_scan ( PH_PACKET_HEADER_t *pkt_header,
298  PGSt_double next_scan_start_time,
299  int8 *previous_scan_count,
300  SC_SCAN_PROC_STATE_t scan_proc_state[5],
301  PGSt_IO_L0_VirtualDataSet *L0_file );
302 
303 PGSt_SMF_status parse_eng_data_list (EN_VDATA_TYPE_t *eng_data);
304 
305 PGSt_SMF_status process_a_granule (PGSt_IO_L0_VirtualDataSet L0_file,
306  PGSt_double gran_start_time,
307  PGSt_double gran_end_time,
308  PCF_CONFIG_t *pcf_config,
309  EN_VDATA_TYPE_t *eng_data,
310  PH_PACKET_HEADER_t *pkt_header,
311  PGSt_IO_L0_Packet *pkt,
312  FP_QUEUE_t *failed_pkts);
313 
314 PGSt_SMF_status process_a_packet (PGSt_IO_L0_VirtualDataSet *L0_file,
315  PGSt_IO_L0_Packet *pkt,
316  PH_PACKET_HEADER_t *packet_header,
317  uint16 *packet_cont);
318 
319 PGSt_SMF_status process_a_scan (int *scan_number,
320  PGSt_IO_L0_Packet *pkt,
321  PGSt_double *scan_rate,
322  PGSt_double *scan_time,
323  SC_SCAN_DATA_t *L1A_scan,
324  MD_SCAN_MET_t *scan_meta,
325  EN_VDATA_TYPE_t *eng_data,
326  FP_QUEUE_t *failed_pkts,
327  PH_PACKET_HEADER_t *pkt_header,
328  SC_PIXEL_QUALITY_DATA_t *scan_pixel,
329  PGSt_IO_L0_VirtualDataSet *L0_file);
330 
331 void process_cp_hk_tlmy (EN_VDATA_TYPE_t *eng_data,
332  PGSt_IO_L0_Packet *eng_pkt_2_1,
333  uint16 scan_number);
334 
335 void process_eng_packet (EN_VDATA_TYPE_t *eng_data,
336  int scan_number,
337  PH_PACKET_HEADER_t *pkt_header,
338  PGSt_IO_L0_Packet *pkt);
339 
340 void process_group2_packet1_vdata (PGSt_IO_L0_Packet *pkt, EN_VDATA_TYPE_t *eng_data);
341 
342 PGSt_SMF_status process_next_packet(
343  PGSt_IO_L0_VirtualDataSet *L0_file,
344  PH_PACKET_HEADER_t **packet_header);
345 
346 void process_sci_eng_data (EN_VDATA_TYPE_t *eng_data,
347  PGSt_IO_L0_Packet *eng_pkt_1_2,
348  uint16 scan_number);
349 
350 void put_cal_data_in_scan (PH_PACKET_HEADER_t *pkt_header,
351  uint16 *pkt_cont,
352  SC_CAL_250M SC_250m,
353  SC_CAL_500M SC_500m,
354  SC_CAL_1KM_DAY SC_1km_day,
355  SC_CAL_1KM_NIGHT SC_1km_night);
356 
358  uint16 *pkt_cont,
359  SC_EV_250M SC_250m,
360  SC_EV_500M SC_500m,
361  SC_EV_1KM_DAY SC_1km_day,
362  SC_EV_1KM_NIGHT SC_1km_night);
363 
365  PGSt_IO_L0_Packet *pkt,
366  uint16 *pkt_contents,
367  SC_SCAN_DATA_t *L1A_scan);
368 
369 PGSt_SMF_status read_a_packet (PGSt_IO_L0_VirtualDataSet *L0_file,
370  PGSt_IO_L0_Packet *pkt);
371 
372 int32 recall_id (char *Vdata_name);
373 
374 void remember (char *Vdata_name,
375  int32 Vdata_id);
376 
377 void reset_last_valid_scan (EN_VDATA_TYPE_t *eng_data);
378 
379 PGSt_SMF_status set_start_position (PGSt_IO_L0_VirtualDataSet L0_file,
380  PGSt_double *preload_start_time,
381  PGSt_double start_time,
382  PGSt_double stop_time);
383 
384 PGSt_SMF_status unpack_MODIS_header (PGSt_IO_L0_Packet *pkt,
385  PH_PACKET_HEADER_t *packet_header);
386 
387 void unpack_packet_contents (PGSt_IO_L0_Packet *pkt,
388  PH_PACKET_HEADER_t *pkt_header,
389  uint16 *pkt_contents);
390 
391 PGSt_SMF_status unpack_packet_header (PGSt_IO_L0_Packet *pkt,
392  PH_PACKET_HEADER_t *packet_header);
393 
394 PGSt_SMF_status unpack_primary_header (PGSt_IO_L0_Packet *pkt,
395  PH_PACKET_HEADER_t *packet_header);
396 
397 PGSt_SMF_status unpack_secondary_header (PGSt_IO_L0_Packet *pkt,
398  PH_PACKET_HEADER_t *packet_header);
399 
400 void update_eng_data (uint16 index,
401  PGSt_IO_L0_Packet *eng_packet,
402  uint16 scan_number,
403  EN_VDATA_TYPE_t *eng_data,
404  int use_cp_prior_offset);
405 
406 void update_eng_data_for_maj_cycle_n (uint16 major_cycle,
407  PGSt_IO_L0_Packet *eng_pkt_2_1,
408  uint16 scan_number,
409  EN_VDATA_TYPE_t *eng_data,
410  int is_cp_hk_prior_section);
411 
412 void update_global_metadata (MD_SCAN_MET_t *scan_meta,
413  MD_ECS_GRA_INV_MET_t *ecs_gra_inv_met,
414  MD_L1A_SPECIFIC_MET_t *l1a_specific_met);
415 
417  int16 qual_value,
418  SC_PIXEL_QUALITY_DATA_t *scan_pix);
419 
420 void update_scan_metadata (PH_PACKET_HEADER_t packet_header,
421  PGSt_SMF_status packetStatus,
422  MD_SCAN_MET_t *scan_meta,
423  int16 *qual_value);
424 
425 int validate_L0_header (PGSt_IO_L0_VirtualDataSet L0_file);
426 
427 PGSt_SMF_status write_ECS_metadata (PGSt_MET_all_handles md_handles,
428  MD_ECS_GRA_INV_MET_t *ecs_gra_inv_met);
429 
430 PGSt_SMF_status write_Vdata (char *Vdata_name,
431  unsigned char *data,
432  int32 num_records);
433 
434 PGSt_SMF_status write_eng_data (EN_VDATA_TYPE_t *eng_data);
435 
436 PGSt_SMF_status write_failed_packets (FP_QUEUE_t failed_pkts);
437 
438 PGSt_SMF_status write_global_metadata (MODFILE *mfile,
439  PGSt_MET_all_handles md_handles,
440  MD_ECS_GRA_INV_MET_t *ecs_gra_inv_met,
441  MD_L1A_SPECIFIC_MET_t *l1a_specific_met);
442 
443 PGSt_SMF_status write_pix_qual (MODFILE *L1A_file_ptr,
444  SC_PIXEL_QUALITY_DATA_t *pix_qual,
445  int16 scan_num);
446 
447 PGSt_SMF_status write_scan (MODFILE *L1A_file_ptr,
448  SC_SCAN_DATA_t *L1A_scan,
449  MD_SCAN_MET_t *scan_meta,
450  SC_PIXEL_QUALITY_DATA_t *pix_qual,
451  FP_QUEUE_t failed_pkts,
452  EN_VDATA_TYPE_t *eng_data);
453 
454 PGSt_SMF_status write_scan_data (MODFILE *L1A_file_ptr,
455  SC_SCAN_DATA_t *L1A_scan,
456  int16 scan_num,
457  char *scan_type);
458 
459 PGSt_SMF_status write_scan_metadata (MODFILE *L1A_file_ptr,
460  MD_SCAN_MET_t *scan_meta);
461 
462 PGSt_SMF_status write_specific_granule_metadata (MODFILE *mfile,
463  MD_L1A_SPECIFIC_MET_t *l1a_specific_met);
464 
465 #endif
466 
FP_QUEUE_t make_queue(void)
Definition: make_queue.c:6
void initialize_scan_metadata(MD_SCAN_MET_t *scan_meta)
an array had not been initialized Several spelling and grammar corrections were which is read from the appropriate MCF the above metadata values were hard coded A problem calculating the average background DN for SWIR bands when the moon is in the space view port was corrected The new algorithm used to calculate the average background DN for all reflective bands when the moon is in the space view port is now the same as the algorithm employed by the thermal bands For non SWIR changes in the averages are typically less than Also for non SWIR the black body DNs remain a backup in case the SV DNs are not available For SWIR the changes in computed averages were larger because the old which used the black body suffered from contamination by the micron leak As a consequence of the if SV DNs are not available for the SWIR the EV pixels will not be the granule time is used to identify the appropriate tables within the set given for one LUT the first two or last two tables respectively will be used for the interpolation If there is only one LUT in the set of it will be treated as a constant LUT The manner in which Earth View data is checked for saturation was changed Previously the raw Earth View DNs and Space View DNs were checked against the lookup table values contained in the table dn_sat The change made is to check the raw Earth and Space View DNs to be sure they are less than the maximum saturation value and to check the Space View subtracted Earth View dns against a set of values contained in the new lookup table dn_sat_ev The metadata configuration and ASSOCIATEDINSTRUMENTSHORTNAME from the MOD02HKM product The same metatdata with extensions and were removed from the MOD021KM and MOD02OBC products ASSOCIATEDSENSORSHORTNAME was set to MODIS in all products These changes are reflected in new File Specification which users may consult for exact the pow functions were eliminated in Emissive_Cal and Emissive bands replaced by more efficient code Other calculations throughout the code were also made more efficient Aside from a few round off there was no difference to the product The CPU time decreased by about for a day case and for a night case A minor bug in calculating the uncertainty index for emissive bands was corrected The frame index(0-based) was previously being used the frame number(1-based) should have been used. There were only a few minor changes to the uncertainty index(maximum of 1 digit). 3. Some inefficient arrays(Sigma_RVS_norm_sq) were eliminated and some code lines in Preprocess_L1A_Data were moved into Process_OBCEng_Emiss. There were no changes to the product. Required RAM was reduced by 20 MB. Now
integer, parameter int16
Definition: cubeio.f90:3
int16 get_index(char *Vdata_name)
Definition: get_index.c:6
void initialize_id_table(void)
int validate_L0_header(PGSt_IO_L0_VirtualDataSet L0_file)
PGSt_SMF_status write_failed_packets(FP_QUEUE_t failed_pkts)
PGSt_SMF_status write_specific_granule_metadata(MODFILE *mfile, MD_L1A_SPECIFIC_MET_t *l1a_specific_met)
char * dequeue(FP_QUEUE_t Q)
Definition: dequeue.c:5
void finalize_scan_metadata(MD_SCAN_MET_t *scan_meta, int16 num_packets)
===========================================================================V4.1.3 12/18/2002============================================================================Changes which do not affect scientific output:1. The R *LUT was eliminated and the equivalent formulation for R *, i.e. 1/(m1 *e_sun_over_pi), was substituted for it in the only instance of its use, which is in the calculation of the RSB uncertainty index. This reduces the size of the Reflective LUT HDF file by approximately 1/4 to 1/3. The equivalent formulation of R *differed from the new by at most 0.056% in test granules and uncertainty differences of at most 1 count(out of a range of 0-15) were found in no more than 1 in 100, 000 pixels. 2. In Preprocess.c, a small error where the trailing dropped scan counter was incremented when the leading dropped scan counter should have been was fixed. This counter is internal only and is not yet used for any purpose. 3. NEW MYD02OBC Metadata Configuration Files. MCST wishes to have the OBC files archived even when the Orbit Number is recorded as "-1". Accordingly, ECS has delivered new MCF files for OBC output having all elements in the OrbitCalculatedSpatialDomain container set to "MANDATORY=FALSE". 4. pgs_in.version is now reset to "1" in Metadata.c before the call to look up the geolocation gringpoint information.============================================================================V4.1.1 CODE SPECIFIC TO MODIS/AQUA(FM1) 10/03/2002============================================================================Two changes were made to the code which do not affect scientific output:1. A bug which caused PGE02 to fail when scans were dropped between granules was fixed.(The length of the error message generated was shortened.) 2. Messages regarding an invalid MCST LUT Version or an invalid Write High Resolution Night Mode Output value in the PCF file were added.==============================================================================V4.1.0 CODE SPECIFIC TO MODIS/AQUA(FM1)(NEVER USED IN PRODUCTION) 07/30/2002==============================================================================Changes which impact scientific output of code:1. The LUT type of the RVS corrections was changed to piecewise linear. In addition the RVS LUTs were changed from listing the RVS corrections to listing the quadratic coefficients necessary to make the RVS corrections. The coefficients are now calculated by interpolating on the granule collection time and the RVS corrections are then generated using the interpolated coefficients. Previously used Emissive and Reflective RVS LUT tables were eliminated and new ones introduced. Several changes were made to the code which should not affect scientific output. They are:1. The ADC correction algorithm and related LUTs were stripped from the code.(The ADC correction has always been set to "0" so this has no scientific impact.) 2. Some small changes to the code, chiefly to casting of variables, were added to make it LINUX-compatible. Output of code run on LINUX machines displays differences of at most 1 scaled integer(SI) from output of code run on IRIX machines. The data type of the LUT "dn_sat_ev" was changed to float64 to avoid discrepancies seen between MOD_PR02 run on LINUX systems and IRIX systems where values were flagged under one operating system but not the other. 3. Checking for non-functioning detectors, sector rotation, incalculable values of the Emissive calibration factor "b1", and incalculable values of SV or BB averages was moved outside the loop over frames in Emissive_Cal.c since none of these quantities are frame-dependent. 4. The code was altered so that if up to five scans are dropped between the leading/middle or middle/trailing granules, the leading or trailing granule will still be used in emissive calibration to form a cross-granule average. QA bits 25 and 26 are set for a gap between the leading/middle and middle/trailing granules respectively. This may in rare instances lead to a change in emissive calibration coefficients for scans at the beginning or end of a granule. 5.(MODIS/AQUA ONLY) The name of the seed(error message) file was changed from "MODIS_36100.h" to "MODIS_36110.h". 6. Metadata.c was changed so that the source of the geolocation metadata is the input geolocation file rather than the L1A granule. 7. To reduce to overall size of the reflective LUT HDF files, fill values were eliminated from all LUTs previously dimensioned "BDSM"([NUM_REFLECTIVE_BANDS] *[MAX_DETECTORS_PER_BAND] *[MAX_SAMPLES_PER_BAND] *[NUM_MIRROR_SIDES]) in the LUT HDF files. Each table piece is stored in the HDF file with dimensions NUM_REFLECTIVE_INDICES, where NUM_REFLECTIVE_INDICES=[NUM_250M_BANDS *DETECTORS_PER_250M_BAND *SAMPLES_PER_250M_BAND *NUM_MIRROR_SIDES]+[NUM_500M_BANDS *DETECTORS_PER_500M_BAND *SAMPLES_PER_500M_BAND *NUM_MIRROR_SIDES]+[NUM_1000M_BANDS *DETECTORS_PER_1KM_BAND *SAMPLES_PER_1KM_BAND *NUM_MIRROR_SIDES] with SAMPLES_PER_250M_BAND=4, SAMPLES_PER_500M_BAND=2, and SAMPLES_PER_1KM_BAND=1. Values within each table piece appear in the order listed above. The overall dimensions of time dependent BDSM LUTs are now[NUM_TIMES] *[NUM_REFLECTIVE_INDICES], where NUM_TIMES is the number of time dependent table pieces. 8. Checking for non-functioning detectors, sector rotation, incalculable values of the Emissive calibration factor "b1", and incalculable values of SV or BB averages was moved outside the loop over frames in Emissive_Cal.c since none of these quantities are frame-dependent. 9. The code was altered so that if up to five scans are dropped between the leading/middle or middle/trailing granules, the leading or trailing granule will still be used in emissive calibration to form a cross-granule average. QA bits 25 and 26 are set for a gap between the leading/middle and middle/trailing granules respectively. This may in rare instances lead to a change in emissive calibration coefficients for scans at the beginning or end of a granule. 10. The array of b1s in Preprocess.c was being initialized to -1 outside the loop over bands, which meant that if b1 could not be computed, the value of b1 from the previous band for that scan/detector combination was used. The initialization was moved inside the band loop.============================================================================V3.1.0(Original Aqua-specific code version) 02/06/2002============================================================================AQUA-Specific changes made:1. A correction to a problem with blackbody warmup on bands 33, 35, and 36 was inserted. PC Bands 33, 35, and 36 on MODIS Aqua saturate on BB warmup before 310K, which means current code will not provide correct b1 calibration coefficients when the BB temperatures are above the saturation threshold. A LUT with default b1s and band-dependent temperature thresholds will be inserted in code. If the BB temperature is over the saturation threshold for the band, the default b1 from the table is used. 2. The number of possible wavelengths in the Emissive LUT RSR file was changed to 67 in order to accommodate the Aqua RSR tables. 3. Several changes to the upper and lower bound limits on LUT values were inserted. Changes to both Aqua and Terra Code:1. A check was put into Emissive_Cal.c to see whether the value of b1 being used to calibrate a pixel is negative. If so, the pixel is flagged with the newly created flag TEB_B1_NOT_CALCULATED, value 65526, and the number of pixels for which this occurs is counted in the QA_common table. 2. The array of b1s in Preprocess.c was being initialized to -1 outside the loop over bands, which meant that if b1 could not be computed, the value of b1 from the previous band for that scan/detector combination was used. The initialization was moved inside the band loop. 3. Minor code changes were made to eliminate compiler warnings when the code is compiled in 64-bit mode. 4. Temperature equations were upgraded to be MODIS/Aqua or MODIS/Terra specific and temperature conversion coefficients for Aqua were inserted.========================================================================================================================================================ALL CHANGES BELOW ARE TO COMMON TERRA/AQUA CODE USED BEFORE 02/06/2002========================================================================================================================================================v3.0.1 11/26/2001============================================================================Several small changes to the code were made, none of which changes the scientific output:1. The code was changed so that production of 250m and 500m resolution data when all scans of a granule are in night mode may be turned off/on through the PCF file. 2. A check on the times of the leading and trailing granules was inserted. If a leading or trailing granule does not immediately precede or follow(respectively) the middle granule, it is treated as a missing granule and a warning message is printed. 3. The code now reads the "MCST Version Number"(e.g. "3.0.1.0_Terra") from the PCF file and checks it against the MCST Version number contained in the LUT HDF files. This was done to allow the user to make sure the code is being run using the correct LUT files.(The designators "0_Terra", "1_Terra", etc.) refer to the LUT versions.) 4. A small bug in Preprocess.c was corrected code
Definition: HISTORY.txt:661
PGSt_SMF_status write_eng_data(EN_VDATA_TYPE_t *eng_data)
PGSt_SMF_status enqueue(char *item, FP_QUEUE_t Q)
Definition: enqueue.c:7
void create_missing_scans(int16 prev_scan_num, PGSt_double scan_rate, PGSt_double *SD_start_time, MD_SCAN_MET_t *scan_metadata, SC_PIXEL_QUALITY_DATA_t *pixel_qual_data)
PGSt_SMF_status read_a_packet(PGSt_IO_L0_VirtualDataSet *L0_file, PGSt_IO_L0_Packet *pkt)
Definition: read_a_packet.c:9
void put_pkt_cont_in_scan(PH_PACKET_HEADER_t pkt_header, PGSt_IO_L0_Packet *pkt, uint16 *pkt_contents, SC_SCAN_DATA_t *L1A_scan)
void update_eng_data_for_maj_cycle_n(uint16 major_cycle, PGSt_IO_L0_Packet *eng_pkt_2_1, uint16 scan_number, EN_VDATA_TYPE_t *eng_data, int is_cp_hk_prior_section)
void output_eng1_pkt2_to_scan(PGSt_IO_L0_Packet *pkt, SC_SCAN_DATA_t *L1A_scan)
void remember(char *Vdata_name, int32 Vdata_id)
Definition: remember.c:8
PGSt_SMF_status end_Vdata_access_to_file(MODFILE *L1A_file)
PGSt_SMF_status init_L1A_HDF_sdss(MODFILE *L1A_file_ptr, int16 nscans)
void close_processing_run(PGSt_IO_L0_VirtualDataSet L0_file)
PGSt_SMF_status write_scan(MODFILE *L1A_file_ptr, SC_SCAN_DATA_t *L1A_scan, MD_SCAN_MET_t *scan_meta, SC_PIXEL_QUALITY_DATA_t *pix_qual, FP_QUEUE_t failed_pkts, EN_VDATA_TYPE_t *eng_data)
Definition: write_scan.c:12
void unpack_packet_contents(PGSt_IO_L0_Packet *pkt, PH_PACKET_HEADER_t *pkt_header, uint16 *pkt_contents)
void output_eng2_pkt2_to_scan(PGSt_IO_L0_Packet *pkt, SC_SCAN_DATA_t *L1A_scan)
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
char global_input_pointer[MAX_INPUTS][PGSd_PC_VALUE_LENGTH_MAX]
Definition: level1a.c:23
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
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)
PGSt_SMF_status check_checksum(PH_PACKET_HEADER_t pkt_header, uint16 *pkt_contents)
Definition: check_checksum.c:9
PGSt_SMF_status unpack_packet_header(PGSt_IO_L0_Packet *pkt, PH_PACKET_HEADER_t *packet_header)
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
PGSt_SMF_status parse_eng_data_list(EN_VDATA_TYPE_t *eng_data)
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
PGSt_SMF_status create_Vdata_field(char *Vdata_name, int32 Vdata_id, char *field_name, char *data_type, int32 order)
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)
int16 attached_Vdata_counter(int16 action)
PGSt_SMF_status init_L1A_pix_qual_HDF_sdss(MODFILE *mfile, int nscans)
PGSt_SMF_status unpack_MODIS_header(PGSt_IO_L0_Packet *pkt, PH_PACKET_HEADER_t *packet_header)
PGSt_SMF_status process_a_scan(int *scan_number, PGSt_IO_L0_Packet *pkt, PGSt_double *scan_rate, PGSt_double *scan_time, SC_SCAN_DATA_t *L1A_scan, MD_SCAN_MET_t *scan_meta, EN_VDATA_TYPE_t *eng_data, FP_QUEUE_t *failed_pkts, PH_PACKET_HEADER_t *pkt_header, SC_PIXEL_QUALITY_DATA_t *scan_pixel, PGSt_IO_L0_VirtualDataSet *L0_file)
PGSt_SMF_status initialize_global_metadata(PGSt_double gran_start_time, PGSt_double gran_end_time, int nscans, PCF_CONFIG_t *pcf_config, MD_ECS_GRA_INV_MET_t *ecs_gra_inv_met, MD_L1A_SPECIFIC_MET_t *l1a_specific_met)
PGSt_SMF_status write_scan_data(MODFILE *L1A_file_ptr, SC_SCAN_DATA_t *L1A_scan, int16 scan_num, char *scan_type)
PGSt_SMF_status initialize_level1a(PCF_CONFIG_t *pcf_config, EN_VDATA_TYPE_t *eng_data, PGSt_IO_L0_Packet *pkt, PH_PACKET_HEADER_t *pkt_header, PGSt_IO_L0_VirtualDataSet *L0_file)
void initialize_pixel_qual_data(SC_PIXEL_QUALITY_DATA_t *scan_pixel)
void compute_SD_start_time(PH_PACKET_HEADER_t *pkt_header, PGSt_double *SD_start_time)
#define MAX_INPUTS
PGSt_SMF_status unpack_secondary_header(PGSt_IO_L0_Packet *pkt, PH_PACKET_HEADER_t *packet_header)
PGSt_SMF_status write_scan_metadata(MODFILE *L1A_file_ptr, MD_SCAN_MET_t *scan_meta)
void initialize_scan_data(SC_SCAN_DATA_t *L1A_scan)
void initialize_scan(SC_SCAN_DATA_t *L1A_scan, SC_PIXEL_QUALITY_DATA_t *scan_pixel, MD_SCAN_MET_t *scan_meta)
void finalize_pixel_qual_data(SC_PIXEL_QUALITY_DATA_t *scan_pixel, MD_SCAN_MET_t *scan_meta)
void create_eng_data_vdata_array_field(char *field_name, uint16 num_bits, uint16 start_bit_pos, uint16 order, uint16 type, EN_VDATA_TYPE_t *eng_data, uint16 curr_eng_data_index, uint16 *curr_field_index)
void update_pixel_qual_data(PH_PACKET_HEADER_t pkt_header, int16 qual_value, SC_PIXEL_QUALITY_DATA_t *scan_pix)
void update_eng_data(uint16 index, PGSt_IO_L0_Packet *eng_packet, uint16 scan_number, EN_VDATA_TYPE_t *eng_data, int use_cp_prior_offset)
PGSt_SMF_status process_next_packet(PGSt_IO_L0_VirtualDataSet *L0_file, PH_PACKET_HEADER_t **packet_header)
void output_eng1_pkt1_to_scan(PGSt_IO_L0_Packet *pkt, SC_SCAN_DATA_t *L1A_scan)
void output_daymode_data_to_scan(PH_PACKET_HEADER_t *pkt_header, uint16 *pkt_contents, SC_SCAN_DATA_t *L1A_scan)
PGSt_SMF_status process_a_packet(PGSt_IO_L0_VirtualDataSet *L0_file, PGSt_IO_L0_Packet *pkt, PH_PACKET_HEADER_t *packet_header, uint16 *packet_cont)
PGSt_SMF_status init_L1A_scan_data_HDF_sdss(MODFILE *mfile, int nscans)
int32 recall_id(char *Vdata_name)
Definition: recall_id.c:8
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
int16 get_empty_slot(void)
Definition: get_empty_slot.c:6
PGSt_SMF_status end_eng_data_access_to_file(MODFILE *L1A_file, EN_VDATA_TYPE_t *eng_data)
PGSt_SMF_status write_global_metadata(MODFILE *mfile, PGSt_MET_all_handles md_handles, MD_ECS_GRA_INV_MET_t *ecs_gra_inv_met, MD_L1A_SPECIFIC_MET_t *l1a_specific_met)
int32 L1A_datatype_to_DFNT(char *datatype)
void reset_last_valid_scan(EN_VDATA_TYPE_t *eng_data)
PGSt_SMF_status create_Vdata(char *Vdata_name, char field_names[][VU_MAX_NAME_LENGTH], char data_types[][VU_MAX_DATA_TYPE_STRING_LENGTH], int16 num_fields, uint16 order[])
Definition: create_Vdata.c:9
PGSt_double global_last_gran_stop_time
Definition: level1a.c:31
action
Definition: __init__.py:2
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)
PGSt_SMF_status init_L1A_scan_meta_HDF_sdss(MODFILE *mfile, int nscans)
void free_queue(FP_QUEUE_t Q)
Definition: free_queue.c:6
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude data
Definition: HISTORY.txt:356
PGSt_SMF_status write_ECS_metadata(PGSt_MET_all_handles md_handles, MD_ECS_GRA_INV_MET_t *ecs_gra_inv_met)
PGSt_SMF_status packet_of_scan(PH_PACKET_HEADER_t *pkt_header, PGSt_double next_scan_start_time, int8 *previous_scan_count, SC_SCAN_PROC_STATE_t scan_proc_state[5], PGSt_IO_L0_VirtualDataSet *L0_file)
PGSt_SMF_status get_valid_L0_file(PGSt_tag spacecraft_tag, PGSt_IO_L0_VirtualDataSet *L0_file, PGSt_double *start_time, PGSt_double *stop_time)
PGSt_SMF_status accumulate_failed_packets(PGSt_IO_L0_Packet *pkt, FP_QUEUE_t failed_pkts)
uint32 extr_bits(uint8 *a, int start_byte, int start_bit, int num_bits)
Definition: extr_bits.c:6
PGSt_SMF_status unpack_primary_header(PGSt_IO_L0_Packet *pkt, PH_PACKET_HEADER_t *packet_header)
PGSt_double global_first_gran_start_time
Definition: level1a.c:30
data_t b[NROOTS+1]
Definition: decode_rs.h:77
PGSt_SMF_status close_Vdata(char *Vdata_name)
Definition: close_Vdata.c:8
void update_scan_metadata(PH_PACKET_HEADER_t packet_header, PGSt_SMF_status packetStatus, MD_SCAN_MET_t *scan_meta, int16 *qual_value)
void compute_global_time_offsets(PGSt_double scan_rate)
void output_eng_data_to_scan(PH_PACKET_HEADER_t *pkt_header, PGSt_IO_L0_Packet *pkt, SC_SCAN_DATA_t *L1A_scan)
PGSt_SMF_status process_a_granule(PGSt_IO_L0_VirtualDataSet L0_file, PGSt_double gran_start_time, PGSt_double gran_end_time, PCF_CONFIG_t *pcf_config, EN_VDATA_TYPE_t *eng_data, PH_PACKET_HEADER_t *pkt_header, PGSt_IO_L0_Packet *pkt, FP_QUEUE_t *failed_pkts)
#define VU_MAX_NAME_LENGTH
void process_group2_packet1_vdata(PGSt_IO_L0_Packet *pkt, EN_VDATA_TYPE_t *eng_data)
int16 equal_strings(char *a, char *b)
Definition: equal_strings.c:6
void process_sci_eng_data(EN_VDATA_TYPE_t *eng_data, PGSt_IO_L0_Packet *eng_pkt_1_2, uint16 scan_number)
void create_eng_data_vdata_array(char *eng_data_name, EN_VDATA_TYPE_t *eng_data, uint16 *curr_eng_data_index, uint16 *curr_field_index)
int16 get_number_of_attached_Vdatas(void)
void forget(char *Vdata_name)
Definition: forget.c:8
PGSt_double global_time_offset_array[SECTOR_TIME_OFFSETS]
Definition: level1a.c:32
void output_nightmode_data_to_scan(PH_PACKET_HEADER_t *pkt_header, uint16 *pkt_contents, SC_EV_1KM_NIGHT EV_1km_night)
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
PGSt_SMF_status handle_missing_scans(MODFILE *L1A_file_ptr, PGSt_double SD_start_time, PGSt_double *pre_SD_time, PGSt_double scan_rate, int *scan_number, MD_ECS_GRA_INV_MET_t *ecs_gran_meta, MD_L1A_SPECIFIC_MET_t *L1A_specific_meta, PGSt_SMF_boolean *gran_start_time_used, PGSt_double gran_start_time, EN_VDATA_TYPE_t *eng_data)
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
PGSt_SMF_status write_Vdata(char *Vdata_name, unsigned char *data, int32 num_records)
Definition: write_Vdata.c:8
#define SECTOR_TIME_OFFSETS
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
void process_eng_packet(EN_VDATA_TYPE_t *eng_data, int scan_number, PH_PACKET_HEADER_t *pkt_header, PGSt_IO_L0_Packet *pkt)
#define VU_MAX_DATA_TYPE_STRING_LENGTH
PGSt_SMF_status load_eng_data(PGSt_double scan_rate, EN_VDATA_TYPE_t *eng_data, PGSt_IO_L0_Packet *pkt, PH_PACKET_HEADER_t *pkt_header, PGSt_IO_L0_VirtualDataSet L0_file)
Definition: load_eng_data.c:10
PGSt_SMF_status write_pix_qual(MODFILE *L1A_file_ptr, SC_PIXEL_QUALITY_DATA_t *pix_qual, int16 scan_num)
void process_cp_hk_tlmy(EN_VDATA_TYPE_t *eng_data, PGSt_IO_L0_Packet *eng_pkt_2_1, uint16 scan_number)
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to a
Definition: HISTORY.txt:424
PGSt_SMF_status init_L1A_HDF_vdatas(EN_VDATA_TYPE_t *eng_data, MODFILE *L1A_file)
void output_eng2_pkt1_to_scan(PGSt_IO_L0_Packet *pkt, SC_SCAN_DATA_t *L1A_scan)
PGSt_SMF_status get_pcf_config_data(PCF_CONFIG_t *pcf_config)
PGSt_SMF_status set_start_position(PGSt_IO_L0_VirtualDataSet L0_file, PGSt_double *preload_start_time, PGSt_double start_time, PGSt_double stop_time)
PGSt_SMF_status create_L1A_granule(EN_VDATA_TYPE_t *eng_data, int16 nscans, MODFILE **L1A_file_ptr)