OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
VcstGeoParameters.h
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * NAME: VcstGeoParameters
4  *
5  * DESCRIPTION: Contains variables and structures used by the ProSdrViirs
6  * geolocation routines.
7  *
8  *
9  **************************************************************************/
10 /* file: VcstGeoParameters.h */
11 
12 #ifndef GEO_PARAMETERS_H
13 #define GEO_PARAMETERS_H
14 
15 #include <VcstCmnConsts.h>
16 #include <VcstCalLutStructures.h>
17 
18 #define DM_BADADDRESS ((void *) -1L)
19 
20 const int EV_FRAMES_375M = 6400;
21 const int EV_FRAMES_750M_UNAGG = 6304;
22 const int EV_FRAMES_750M = 3200;
23 const int EV_FRAMES_DNB = 4064;
24 
25 const int M_DETECTORS = 16;
26 const int I_DETECTORS = 32;
27 //const int NUM_DETECTORS_DNB = 16;
28 const int DNB_DETECTORS = 16;
29 
30 const int I_VIIRS_COLS = 6400;
32 const int M_VIIRS_COLS = 3200;
34 const int M_A_VIIRS_COLS = 5024;
35 const int DNB_VIIRS_COLS = 4064;
37 
38 // VIIRS Moderate dual gain number of Columns
39 const int M_D_VIIRS_COLS = 6304;
40 
41 //const int VEC_SIZE = 3;
42 const int VEC_RPY_SIZE = 3;
43 
44 const int NUM_BITS_PER_BYTE = 8;
45 //const int NUM_DETECTORS = 432;
46 //const int NUM_BANDS = 22;
47 
48 //const int NUM_THERMISTORS = 26;
50 const int MAX_BAND_NUMBER_PLUS_ONE = 37;
51 //const int NUM_ELECTRONICS_SIDE = 2;
52 const int MAX_THERMISTOR_ID_LEN = 40;
53 const int NUM_AGG_ZONES = 5;
54 //const int NUM_MOON_OFFSET_LIMITS = 4;
55 
56 const int MAX_BAND_NUMBER = 22;
58 const int MAX_DETECTORS = 32;
59 const int MAX_POLY_DEGREE = 4;
60 const int CHEBY_ORDER = 4;
61 
62 /* telescope encoder impulses/Earth view */
63 const int MAX_IMPULSE_NUMBER_TEL = 1290;
64 const int ENCODER_LENGTH_TEL = 1290;
65 
66 /* mirror encoder impulses/Earth view */
67 const int MAX_IMPULSE_NUMBER_HAM = 1290;
68 const int ENCODER_LENGTH_HAM = 1290;
69 
70 const int SECTOR_LENGTH = 32; /* no. of view sector def, words/scan */
71 const int ANCIL_LENGTH = 64; /* no. of S/C ancillary data words/scan */
72 
73 /* used for flags to indicate data quality */
74 const int GOOD_DATA = 0;
75 const int BAD_DATA = -1;
76 const int SERVO_CNTRL_BAD_DATA = -2;
77 const int DEGRADED_DATA = 2;
78 
79 const int GEO_FAIL = -1; /* GEO_FAIL represents a default index if no index
80  of the next unflagged value is found */
81 
82 const int mirr_lower_limit = 0;
83 const int mirr_upper_limit = 1;
84 
85 const int tel_lower_limit = 0;
86 const int tel_upper_limit = 1;
87 
88 // const double MAX_ANGLE = PIO2;
89 
90 // Desciption of interpolation rectangles
91 const int MOD_VIIRSI_NRCTNGL = 400;
92 const int MOD_VIIRSI_TWIDTH = 8;
93 const int MOD_MIDDLE_ROW = 7;
94 
95 const int DNB_VIIRSI_NRCTNGL = 508;
96 const int DNB_VIIRSI_TWIDTH = 8;
97 const int DNB_MIDDLE_ROW = 7;
98 
99 const int IMG_VIIRSI_NRCTNGL = 400;
100 const int IMG_VIIRSI_TWIDTH = 16;
101 const int IMG_MIDDLE_ROW = 15;
102 
104 
105 /* used for RPY time-based inst2sc adjustments */
106 const int MAX_RPY_COUNT = 1000;
107 const int RPY_TIMECODE_SIZE = 20;
108 
109 /************************************************************************
110  * Constants for the VIIRS resolution aggregation zones at the SDR level
111  **********************************************************************/
112 const int NumModImgAggZones = 5; // 5 zones because zone 3,4 are the same
113 
114 const int ViirsModPixPerZone[NumModImgAggZones] ={640, 368, 1184, 368, 640};
115 
116 const int ViirsImgPixPerZone[NumModImgAggZones] ={1280, 736, 2368, 736, 1280};
117 
118 // For DNB the array begins at the edge of scan and ends at nadir. The
119 // last number is the 2 nadir zones combined
120 const int NumDnbAggZones = 63; // 63 zones because zones 32,33 are the same
121 const int ViirsDnbPixPerZone[NumDnbAggZones] ={80, 16, 64, 64, 64, 32, 24, 72, 40, 56, 40, 48, 32, 48, 32, 72,
122  72, 72, 80, 56, 80, 64, 64, 64, 64, 64, 72, 80, 72, 88, 72, 368,
123  72, 88, 72, 80, 72, 64, 64, 64, 64, 64, 80, 56, 80, 72, 72,
124  72, 32, 48, 32, 48, 40, 56, 40, 72, 24, 32, 64, 64, 64, 16, 80};
125 
126 
127 // enumerated indexes for the temperature correction values
128 
130  ROLL_IDX = 0, // roll index
131  PITCH_IDX, // pitch index
132  YAW_IDX // yaw index
133 };
134 
136  FILL_POINT = 0, // fill a single point
137  FILL_DETECTOR_ARRAY, // fill all the detectors for a frame
138  FILL_SCAN_ARRAY // fill values for an entire scan level array
139 };
140 
141 const int MAX_SCAN_SAMPLE = 6400;
142 const int NUM_DNB_ZONES = 64;
143 
145 const int VECTOR_SIZE = 3; /* thermal correction vector */
146 
147 /* flag conditions */
148 const unsigned char INVALID_INPUT_DATA = 128;
149 const unsigned char NO_ELLIPSE_INTERSECT = 64;
150 const unsigned char BAD_TERRAIN = 32;
151 const unsigned char INVALID_SENSOR_ANGLES = 8;
152 
153 
154 const double MIN_TERRAIN_HEIGHT = -450.0; /* units in meters */
155 const double MAX_TERRAIN_HEIGHT = 9600.0; /* units in meters */
156 
157 const int ORDER_CHEBY = 4;
158 
160  LAT_IDX = 0,
163 };
164 
172 };
173 
174 
175 const unsigned short MAX_UINT16_VAL = 65535;
176 
181 };
182 
183 /* Constants for temperature correction LUT */
184 const int MAX_TEMPERATURE_BRKTS = 11; /*this is a guess */
185 const int MAX_TEMPERATURE_COEFS = 22; /*this is a guess */
186 const int MAX_TEMPERATURE_IND_VARS = 22; /*this is a guess */
187 const int IDXARRAY_SIZE = 9; /* set to match input file */
188 
189 /* constants used for interpolating moderate unaggregated from aggregated */
190 const double ONE = 1.0, TWO = 2.0, THREE = 3.0, FOUR = 4.0;
191 const double HALF = ONE / TWO;
192 const double THIRD = ONE / THREE;
193 const double TWOTHIRDS = TWO / THREE;
194 const double FOURTHIRDS = THIRD + ONE;
195 const double FIVETHIRDS = TWOTHIRDS + ONE;
196 const double FOURTH = ONE / FOUR;
197 const double THREEFOURTHS = THREE / FOUR;
198 const double FIVEFOURTHS = FOURTH + ONE;
199 const double SEVENFOURTHS = THREEFOURTHS + ONE;
200 
201 const int NUM_UNAGG_PRODUCTS = 8; // number of products interpolated
202 
203 // indices into arrays holding the interpolated products
204 
214 };
215 
217  LOWEREND = 0,
220 };
221 
222 // Start of aggregation zones (Moderate aggregated)
223 const int START_AGG_ZONE1 = 0;
224 const int START_AGG_ZONE2 = 640;
225 const int START_AGG_ZONE3 = 1008;
226 const int START_AGG_ZONE4 = 1600;
227 const int START_AGG_ZONE5 = 2192;
228 const int START_AGG_ZONE6 = 2560;
229 
230 // End of aggregation zones (Moderate aggregated)
236 const int END_AGG_ZONE6 = 3200;
237 
238 // Start of aggregation zones (Moderate unaggregated)
239 const int START_UNAGG_ZONE2 = 0;
240 const int START_UNAGG_ZONE3 = 736;
241 const int START_UNAGG_ZONE5 = 4288;
242 
243 // End of aggregation zones (Moderate unaggregated)
246 const int END_UNAGG_ZONE5 = 5023;
247 
248 typedef struct {
249  int band_number; // band no. to geolocate (0=ideal band)
250  char pad0[4];
252  double t_reset; // time to reset sample at beginning of frame
253 
254  unsigned short N_samp[MAX_BAND_NUMBER_PLUS_ONE];
255  char pad1[6];
257  double det_space_track[MAX_BAND_NUMBER_PLUS_ONE];
258  double det_space_scan[MAX_BAND_NUMBER_PLUS_ONE];
259  double DNB_space_track[32];
260  double DNB_space_scan[32];
261  double det_position[MAX_BAND_NUMBER_PLUS_ONE][2];
262 
263  // band center position
264  double band_position[MAX_BAND_NUMBER_PLUS_ONE];
265 
268  double scan_length;
269  int agg_zone_bounds[NUM_AGG_ZONES];
270  int DNB_aggregation[32][2];
271  int DNB_ag_zone_bounds[64][3];
272  char implicit_pad1[4];
275  double scan_ang_offsets[2];
277 
278 typedef struct {
279  double enc_scale; // Scale to convert from 14-bit to 16-bit
280  double mirr_abs_limit[MAX_LIMIT_CHECK]; // mirror encoder time absolute limits
281  double mirr_del_limit; // mirror encoder time delta limits
282  double tel_abs_limit[MAX_LIMIT_CHECK]; // telescope encoder time absolute limits
283  double tel_del_limit; // telescope encoder time delta limits
284  int sample_impulse_mirr; // encoder sample period in impulses
285  int sample_impulse_tel; // encoder sample period in impulses
286  int A_bit_adj[2]; // Encoder adjust [even SOS/odd SOS]
287  int B_HAM_adj[2]; // HAM enc adjust [side A/side B]
288  double t_encoder; // encoder time scale factor
290 
291 typedef struct {
292  double mirr_side1_range[2]; // mirror side 1 angle range (radians)
293  double alpha;
294  double beta;
295  double gammaa;
297 
298 typedef struct {
299  double position_abs_limit[2]; // orbit position absolute limits
300  double position_mag_limit[2]; // orbit position magnitude limits
301  double velocity_abs_limit[2]; // orbit velocity absolute limits
302  double velocity_mag_limit[2]; // orbit velocity magnitude limits
303  double ang_mom_limit[2]; // angular momentum magnitude limits
304  double ang_mom_z_limit[2]; // angular momentum Z component
305  double orbit_consistency; // orbit pos./vel. consistency limit
307 
308 typedef struct {
309  double attitude_abs_limit[2]; // attitude angle absolute limits
311 
312 typedef struct {
313  double T_inst2sc[3][3]; // instrument to spacecraft
314  double T_mirr2inst[3][3]; // mirror to instrument frame
315  double T_aft2inst[3][3]; // aft optics to instrument frame
316  double T_inst2SD[3][3]; // instrument to solar diffuse
317  double T_tel2inst[3][3]; // telescope to instrument
318  int rpy_count; // number of rpy adjustments that are included
319  char rpy_times[MAX_RPY_COUNT][RPY_TIMECODE_SIZE]; // timestamp for each rpy adjustment
320  double rpy_values[MAX_RPY_COUNT][3]; // rpy value for each adjustment
322 
323 typedef struct {
324  // Number of thermistors currently used in thermal correction.
326 
327  // Identifier for each thermistor.
328  unsigned char thermistor_id[MAX_THERMISTOR_ID_LEN][NUM_THERMISTORS];
329 
330  // Coefficient array for determination of instrument
331  // temperature from thermistor readings.
332  char implicit_pad1[4];
333  double thermistor_coeffs[NUM_THERMISTORS][6];
335 
336 // Filename,VcstGeoParameters
337 // Type,GEO_param_struct
338 
339 typedef struct {
340  unsigned char revision[10];
341  char pad1[6];
347 
348  double Mag[3][3];
349  double basis_in[3][3];
350  double basis_out[3][3];
351 
352 
353  // polynomial coefficients for HAM encoder-to-angle conversion
354  double poly_coef_mirr[MAX_POLY_DEGREE_PLUS_ONE];
355 
356  // polynomial coefficients for telescope encoder-to-angle conversion
358 
359  double tel_ref;
360  double min_cos_view; // minimum cos(SensorZenAngle)
361  // for near limb test
362 
364 
365  int num_detectors; // no. of band_number detectors
366 
367  // degree of polynomial used to calculate tel and mirr pos
369 
370  unsigned short N_frame; // no. frames per scan
371 
372  char pad2[2];
373 
374 
376 
377 
378 #endif
const double MAX_TERRAIN_HEIGHT
@ FILL_SCAN_ARRAY
const int END_AGG_ZONE5
const int IMG_VIIRSI_TWIDTH
unsigned short N_frame
InterpArrayIndexType
const int M_D_VIIRS_COLS
double position_mag_limit[2]
const double ONE
const int END_UNAGG_ZONE2
const int RPY_TIMECODE_SIZE
const int M_A_VIIRS_COLS
@ SOL_ZEN_IDX
const double HALF
const int IMG_MIDDLE_ROW
const int NumDnbAggZones
const int SERVO_CNTRL_BAD_DATA
const int MAX_TEMPERATURE_COEFS
const int MOD_VIIRSI_NRCTNGL
const double SEVENFOURTHS
double velocity_abs_limit[2]
const int EV_FRAMES_750M
const int DEGRADED_DATA
double T_mirr2inst[3][3]
const int NUM_ELECTRONICS_SIDE
const int M_VIIRS_ROWS
const int NUM_BITS_PER_BYTE
const int START_AGG_ZONE2
@ UPPEREND
internal_coord_trans_struct coord_trans
const int START_UNAGG_ZONE3
const int tel_lower_limit
const unsigned char NO_ELLIPSE_INTERSECT
const double TWO
@ FILL_DETECTOR_ARRAY
const int MAX_IMPULSE_NUMBER_TEL
const double THIRD
const int DNB_DETECTORS
@ FILL_POINT
const int MAX_POLY_DEGREE_PLUS_ONE
@ SOL_AZM_IDX
const int END_UNAGG_ZONE5
const double FOURTHIRDS
double ang_mom_limit[2]
@ PITCH_IDX
const int DNB_VIIRSI_NRCTNGL
const int BAD_DATA
const int MAX_SCAN_SAMPLE
const int MAX_RPY_COUNT
const int MAX_POLY_DEGREE
@ HT_IDX
double position_abs_limit[2]
const int START_AGG_ZONE1
@ azimuth_index
LocationType
@ I_SATA_IDX
const unsigned char BAD_TERRAIN
const int M_VIIRS_COLS
const int I_VIIRS_ROWS
@ I_LAT_IDX
const int EV_FRAMES_375M
const int NUM_AGG_ZONES
const int END_AGG_ZONE1
const double THREE
@ SAT_ZEN_IDX
#define Number_of_Scans
const double MIN_TERRAIN_HEIGHT
const int VECTOR_SIZE
const int START_AGG_ZONE4
const int MAX_IMPULSE_NUMBER_HAM
const int EV_FRAMES_750M_UNAGG
const int CHEBY_ORDER
const int NUM_TEMPERATURE_INPUTS
@ I_SATZ_IDX
@ YAW_IDX
const int I_VIIRS_COLS
const int END_AGG_ZONE6
const int SECTOR_LENGTH
const int EV_FRAMES_DNB
@ LOWEREND
const int MOD_VIIRSI_TWIDTH
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed as required for compatibility with version of the SDP toolkit Corrected test output file names to end in per delivery and then split off a new MYD_PR03 pcf file for Aqua Added AssociatedPlatformInstrumentSensor to the inventory metadata in MOD01 mcf and MOD03 mcf Created new versions named MYD01 mcf and MYD03 where AssociatedPlatformShortName is rather than Terra The program itself has been changed to read the Satellite Instrument validate it against the input L1A and LUT and to use it determine the correct files to retrieve the ephemeris and attitude data from Changed to produce a LocalGranuleID starting with MYD03 if run on Aqua data Added the Scan Type file attribute to the Geolocation copied from the L1A and attitude_angels to radians rather than degrees The accumulation of Cumulated gflags was moved from GEO_validate_earth_location c to GEO_locate_one_scan to ensure that all gflag bits get accumulated Changed GEO_write_ECS_metadata to write PGEVERSION as Changed GEO_locate_one_granule c to make a failure to find an orbit number in the staged ephemeris files be non fatal Updated GEO_parameters dat to reflect latest estimate of T_inst2sc
Definition: HISTORY.txt:472
const int END_AGG_ZONE4
double ang_mom_z_limit[2]
const double FOURTH
const int ORDER_CHEBY
const int ViirsImgPixPerZone[NumModImgAggZones]
const int MAX_THERMISTOR_ID_LEN
@ SAT_AZM_IDX
const int MAX_DETECTORS
@ MAX_LIMIT_CHECK
const int START_UNAGG_ZONE5
const int NUM_DNB_ZONES
@ LUN_AZM_IDX
focal_plane_geometry_struct geometry_params
const double FIVETHIRDS
const int MOD_MIDDLE_ROW
const int mirr_upper_limit
const int DNB_VIIRSI_TWIDTH
GeoFillActionType
const int NUM_THERMISTORS
const int IMG_VIIRSI_NRCTNGL
const unsigned char INVALID_SENSOR_ANGLES
const int ViirsDnbPixPerZone[NumDnbAggZones]
double velocity_mag_limit[2]
const double FOUR
double attitude_abs_limit[2]
const int GOOD_DATA
const int ViirsModPixPerZone[NumModImgAggZones]
@ ROLL_IDX
DirectionDistanceType
const int GEO_FAIL
const double FIVEFOURTHS
@ I_SOLZ_IDX
double T_tel2inst[3][3]
const int NUM_UNAGG_PRODUCTS
constexpr float focal_length
const int M_DETECTORS
const int MAX_TEMPERATURE_BRKTS
const int DNB_VIIRS_COLS
@ I_SOLA_IDX
const int START_AGG_ZONE6
const int I_DETECTORS
@ range_index
@ LON_IDX
thermistor_parameter_struct thermistor_params
const int START_AGG_ZONE3
const int NumModImgAggZones
const int END_AGG_ZONE3
AttitudeType
mirror_model_struct mirror_model
const int VEC_RPY_SIZE
@ LAT_IDX
const int MAX_TEMPERATURE_IND_VARS
const int MAX_SCAN_NUMBER
mirror_preparation_struct mirror_prep_params
const int START_UNAGG_ZONE2
DirectionType
const int END_AGG_ZONE2
const int MAX_BAND_NUMBER_PLUS_ONE
const int ANCIL_LENGTH
const int tel_upper_limit
ViirsGeoLimitCheck
@ z_angle_index
const int DNB_VIIRS_ROWS
const int DNB_MIDDLE_ROW
const int ENCODER_LENGTH_HAM
const int MAX_BAND_NUMBER
const unsigned char INVALID_INPUT_DATA
double mirr_side1_range[2]
const double TWOTHIRDS
@ LUN_ZEN_IDX
@ I_HT_IDX
@ I_LON_IDX
const int END_UNAGG_ZONE4
const int mirr_lower_limit
const int IDXARRAY_SIZE
const int ENCODER_LENGTH_TEL
@ I_RANGE_IDX
const double THREEFOURTHS
const int VIIRSI_MAX_NRCTNGL
const unsigned short MAX_UINT16_VAL
const int START_AGG_ZONE5