OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
update_eng_data.c
Go to the documentation of this file.
1 #include "L1A_prototype.h"
2 #include "hdf.h"
3 #include "PGS_IO_L0.h"
4 #include "EN_eng_data.h"
5 #include "PH_pkt_hdr.h"
6 #include "PD_pkt_data.h"
7 
8 void update_eng_data (uint16 index,
9  PGSt_IO_L0_Packet *eng_packet,
10  uint16 scan_number,
11  EN_VDATA_TYPE_t *eng_data,
12  int use_cp_prior_offset)
13 
14 /*
15 !C*****************************************************************************
16 
17 !Description: This function updates the Vdata referenced by 'index' in
18  the eng_data (array) structure with field values extracted
19  from the eng_packet, and updates the Vdata's LAST_VALID_SCAN
20  field with the scan_number. If use_cp_prior_offset is True
21  then the bit offset EN_CP_HK_TLMY_PRIOR_OFFSET will be added
22  to the start bit positions of the Vdata fields.
23 
24 !Input Parameters:
25  uint16 index ** The eng_data (array) index
26  of the eng Vdata to
27  update **
28  PGSt_IO_LO_Packet *eng_packet ** The eng packet from which
29  to extract values to update
30  the eng data with **
31  uint16 scan_number ** The scan number (counting
32  from 1) of the current scan
33  within the current
34  granule **
35 
36  boolean use_cp_prior_offset ** whether or not to use
37  the bit offset:
38  EN_CP_HK_TLMY_PRIOR_OFFSET
39  (should only be set to True
40  when updating eng_data for
41  the "prior" part of eng pkt
42  2-1 **
43 
44 !Output Parameters:
45  None
46 
47 !Input/Output Parameters:
48  EN_VDATA_TYPE_t *eng_data ** The Vdata array structure **
49 
50 Return Values:
51  None
52 
53 Externally Defined:
54  EN_VDATA_START_INDEX (EN_eng_data.h)
55  EN_CP_HK_TLMY_PRIOR_OFFSET (EN_eng_data.h)
56  EN_VDATA_TYPE_t (EN_eng_data.h)
57  PGSt_IO_LO_Packet (PGS_IO.h)
58  PD_NUM_BITS_IN_BYTE (PD_pkt_data.h)
59  PD_PKT_CONTENTS_BYTE_OFFSET (PD_pkt_data.h)
60 
61 Called By:
62  process_cp_hk_tlmy
63  process_sci_eng_data
64  update_eng_data_for_maj_cycle_n
65 
66 Routines Called:
67  extr_bits
68 
69 !Revision History:
70  revision 1.0 1997/09/12 17:30:00
71  Qi Huang/RDC (qhuang@ltpmail.gsfc.nasa.gov)
72  Original development
73 
74 !Team-unique Header:
75  This software is developed by the MODIS Science
76  Data Support Team (SDST) for the National Aeronautics
77  and Space Administration (NASA), Goddard Space Flight
78  Center (GSFC), under contract NAS5-32373.
79 
80 !References and Credits:
81  None
82 
83 !Design Notes:
84  (c.f. CDRL Table 30-5D and the Vdata_list file)
85 
86 !END************************************************************************
87 */
88 {
89  /******************************************************************************/
90  /* */
91  /* Define and Initialize Local Variables */
92  /* */
93  /******************************************************************************/
94 
95  int bit_offset;
96  int num_fields_this_vdata;
97  int start_pos;
98  int num_bits;
99  int start_byte;
100  int start_bit;
101  int i;
102 
103 
104  /******************************************************************************/
105  /* */
106  /* The sci eng Vdatas' start bit positions are relative to the start of the */
107  /* packet header, while those of the cp hk telemetry Vdatas' are relative */
108  /* to the start of the packet's data field... so if the vdata to update is */
109  /* one of the former (as shown by the index being >= ENG_VDATA_START_INDEX),*/
110  /* then subtract the number of header bits (144) to get the packet data */
111  /* start bit position. */
112  /* */
113  /* ----------------------------------------------------------------- */
114  /* */
115  /* IF ( index < EN_ENG_VDATA_START_INDEX ) THEN */
116  /* set bit_offset to 0 */
117  /* ELSE */
118  /* set bit_offset to -144 */
119  /* ENDIF */
120  /* */
121  /******************************************************************************/
122 
124  bit_offset = 0;
125  else
126  bit_offset = -144;
127 
128 
129  /******************************************************************************/
130  /* */
131  /* if use_cp_prior_offset is True then add EN_CP_HK_TLMY_PRIOR_OFFSET to */
132  /* the bit_offset */
133  /* */
134  /* ----------------------------------------------------------------- */
135  /* */
136  /* IF ( use_cp_prior_offset ) */
137  /* THEN */
138  /* increment bit_offset by EN_CP_HK_TLMY_PRIOR_OFFSET */
139  /* ENDIF */
140  /* */
141  /******************************************************************************/
142 
143  if (use_cp_prior_offset)
144  bit_offset += EN_CP_HK_TLMY_PRIOR_OFFSET;
145 
146 
147  /******************************************************************************/
148  /* */
149  /* set the LAST_VALID_SCAN field (the first field in */
150  /* every Vdata) to scan_number */
151  /* */
152  /* ----------------------------------------------------------------- */
153  /* */
154  /* set eng_data[index].field[0] to scan_number */
155  /* */
156  /* set num_fields_this_vdata to eng_data[index].num_fields */
157  /* */
158  /******************************************************************************/
159 
160  eng_data[index].field[0].value = scan_number;
161  num_fields_this_vdata = eng_data[index].num_fields;
162 
163 
164  /******************************************************************************/
165  /* */
166  /* DO FOR ( i = 1 to (num_fields_this_vdata - 1) ) */
167  /* */
168  /* set start_pos to (eng_data[index].field[i].start_bit_pos + bit_offset) */
169  /* */
170  /* set num_bits to eng_data[index].field[i].num_bits */
171  /* */
172  /* calculate start_byte and start_bit from start_pos */
173  /* */
174  /* CALL extr_bits to get the bits from the packet */
175  /* INPUTS: eng_packet, start_byte, start_bit, num_bits */
176  /* OUTPUTS: None */
177  /* RETURN: value */
178  /* set eng_data[index].field[i].value to the returned value */
179  /* */
180  /* END DO */
181  /* */
182  /******************************************************************************/
183 
184  for (i=1; i<num_fields_this_vdata; i++)
185  {
186  start_pos = eng_data[index].field[i].start_bit_pos + bit_offset;
187  num_bits = eng_data[index].field[i].num_bits;
188  start_byte = (start_pos / PD_NUM_BITS_IN_BYTE) + PD_PKT_CONTENTS_BYTE_OFFSET;
189  start_bit = start_pos % PD_NUM_BITS_IN_BYTE;
190  eng_data[index].field[i].value = extr_bits(eng_packet,start_bit,start_byte,
191  num_bits);
192  }
193 
194  return;
195 }
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
#define EN_ENG_VDATA_START_INDEX
Definition: EN_eng_data.h:65
EN_FIELD_TYPE_t field[EN_MAX_FIELDS_PER_VDATA]
Definition: EN_eng_data.h:125
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)
uint16 start_bit_pos
Definition: EN_eng_data.h:109
#define PD_NUM_BITS_IN_BYTE
Definition: PD_pkt_data.h:71
#define PD_PKT_CONTENTS_BYTE_OFFSET
Definition: PD_pkt_data.h:77
uint32 extr_bits(uint8 *a, int start_bit, int start_byte, int num_bits)
Definition: extr_bits.c:6
#define EN_CP_HK_TLMY_PRIOR_OFFSET
Definition: EN_eng_data.h:81
int i
Definition: decode_rs.h:71