OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
smeta_exploit.c
Go to the documentation of this file.
1 /*
2  * Name: smeta_exploit.c
3  *
4  * Purpose:
5  * Source file containing the functions that use the product metadata to calculate
6  * viewing and solar illumination angles. These functions operate on the SMETA data
7  * type defined in "smeta.h".
8  */
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <math.h>
13 #include "ias_logging.h"
14 #include "ias_math.h"
15 #include "ias_odl.h" /* ODL access routines for reading metadata */
16 #include "ias_geo.h" /* NOVAS calls for sun angle computation */
17 #include "smeta_exploit.h" /* Definition of SMETA structure and
18  function prototypes. */
19 
20 #define MAX_FIELD_NAME 128 /* Maximum number of characters in an ODL
21  field name in the enhanced metadata file */
22 
23 int smeta_read(
24  SMETA *smeta, /* Product metadata structure to load */
25  const char *smeta_filename ) /* Input file name to read */
26 {
27  IAS_OBJ_DESC *smeta_odl; /* Product metadata ODL object */
28  int i; /* Loop index */
29 
30  /* Open file */
31  smeta_odl = ias_odl_read_tree( smeta_filename );
32  if ( smeta_odl == NULL )
33  {
34  IAS_LOG_ERROR("Opening input metadata file %s.", smeta_filename);
35  return(ERROR);
36  }
37 
38  /* Read data */
39  /* File information group */
40  if ( smeta_read_file_header( smeta, smeta_odl ) != SUCCESS )
41  {
42  IAS_LOG_ERROR("Reading PRODUCT_METADATA group from %s.", smeta_filename);
43  ias_odl_free_tree( smeta_odl );
44  return(ERROR);
45  }
46 
47  /* Projection information group */
48  if ( smeta_read_projection( &smeta->projection, smeta_odl ) != SUCCESS )
49  {
50  IAS_LOG_ERROR("Reading PROJECTION_PARAMETERS group from %s.", smeta_filename);
51  ias_odl_free_tree( smeta_odl );
52  return(ERROR);
53  }
54 
55  /* Band information */
56  for ( i=0; i<smeta->num_band; i++ )
57  {
58  if (smeta->sensor_id == IAS_OLI_TIRS)
59  {
60  smeta_read_band_meta( &smeta->band_smeta[i], smeta_odl );
62  }
63  else if ( (smeta->sensor_id == IAS_ETM) || (smeta->sensor_id == IAS_TM) )/* for Landsat 5 and older sensors */
64  {
65  smeta_read_band_meta_ls( &smeta->band_smeta_ls[i], smeta_odl );
66  smeta_load_band_model_ls( smeta, &smeta->band_smeta_ls[i] );
67  }
68  else
69  {
70  IAS_LOG_ERROR("Reading sensor_id %d.", smeta->sensor_id);
71  ias_odl_free_tree( smeta_odl );
72  return(ERROR);
73  }
74  }
75 
76  /* Release the ODL structure */
77  ias_odl_free_tree( smeta_odl );
78 
79  return(SUCCESS);
80 }
81 
83  SMETA *smeta, /* Product metadata structure to load */
84  IAS_OBJ_DESC *smeta_odl ) /* Product metadata ODL object */
85 {
86  int i; /* Loop index */
87  int count; /* Counter for ODL read routines */
88  char fname[MAX_FIELD_NAME]; /* Band file field names */
89  char bname[MAX_FIELD_NAME]; /* Band file names */
90  char str[MAX_FIELD_NAME]; /* file names */
91 
92  /* Read data */
93  /* File information fields */
94  if ( ias_odl_get_field( smeta->scene_id, sizeof(smeta->scene_id), IAS_ODL_String, smeta_odl,
95  "METADATA_FILE_INFO", "LANDSAT_SCENE_ID", &count ) != SUCCESS )
96  {
97  IAS_LOG_ERROR("Reading LANDSAT_SCENE_ID from PRODUCT_METADATA group.");
98  return(ERROR);
99  }
100  if ( ias_odl_get_field( &smeta->wrs_path, sizeof(int), IAS_ODL_Int, smeta_odl,
101  "PRODUCT_METADATA", "WRS_PATH", &count ) != SUCCESS )
102  {
103  IAS_LOG_ERROR("Reading WRS_PATH from PRODUCT_METADATA group.");
104  return(ERROR);
105  }
106  if ( ias_odl_get_field( &smeta->wrs_row, sizeof(int), IAS_ODL_Int, smeta_odl,
107  "PRODUCT_METADATA", "WRS_ROW", &count ) != SUCCESS )
108  {
109  IAS_LOG_ERROR("Reading WRS_ROW from PRODUCT_METADATA group.");
110  return(ERROR);
111  }
112 
113  /* Read in speacecraft id to handle OLI and older LS sensors little differently */
114  if ( ias_odl_get_field( str, sizeof(str), IAS_ODL_String, smeta_odl,
115  "PRODUCT_METADATA", "SPACECRAFT_ID", &count ) != SUCCESS )
116  {
117  IAS_LOG_ERROR("Reading SPACECRAFT_ID from PRODUCT_METADATA group.");
118  return(ERROR);
119  }
120 
121  if( strcmp(str,"LANDSAT_5") == 0 )
122  smeta->spacecraft_id = IAS_L5;
123  else if( strcmp(str,"LANDSAT_7") == 0 )
124  smeta->spacecraft_id = IAS_L7;
125  else if( strcmp(str,"LANDSAT_8") == 0 )
126  smeta->spacecraft_id = IAS_L8;
127  else
128  {
129  IAS_LOG_ERROR("Unsupported Landsat SPACECRAFT_ID from PRODUCT_METADATA group.");
130  return(ERROR);
131  }
132 
133  if ( ias_odl_get_field( str, sizeof(str), IAS_ODL_String, smeta_odl,
134  "PRODUCT_METADATA", "SENSOR_ID", &count ) != SUCCESS )
135  {
136  IAS_LOG_ERROR("Reading SENSOR_ID from PRODUCT_METADATA group.");
137  return(ERROR);
138  }
139 
140  if( strcmp(str,"TM") == 0)
141  {
142  smeta->sensor_id = IAS_TM;
143  smeta->sensor_mode = TM_SAM;
144  }
145  else if( strcmp(str,"ETM") == 0 )
146  {
147  smeta->sensor_id = IAS_ETM;
148  smeta->sensor_mode = TM_SAM;
149  }
150  else if( strcmp(str,"OLI_TIRS") == 0 )
151  {
152  smeta->sensor_id = IAS_OLI_TIRS;
153  smeta->sensor_mode = OLI;
154  }
155  else
156  {
157  IAS_LOG_ERROR("Unsupported Landsat SENSOR_ID from PRODUCT_METADATA group.");
158  return(ERROR);
159  }
160 
161  if ( (smeta->spacecraft_id == IAS_L5 && smeta->sensor_id == IAS_TM) || smeta->sensor_id == IAS_ETM )
162  {
163  if ( ias_odl_get_field( str, sizeof(str), IAS_ODL_String, smeta_odl,
164  "PRODUCT_METADATA", "SENSOR_MODE", &count ) != SUCCESS )
165  {
166  IAS_LOG_ERROR("Reading SENSOR_MODE from PRODUCT_METADATA group.");
167  return(ERROR);
168  }
169  if( strcmp(str,"BUMPER") == 0 )
170  smeta->sensor_mode = TM_BUMPER;
171  }
172 
173  if ( smeta->sensor_mode == TM_SAM ) printf("SAM mode data!\n");
174  if ( smeta->sensor_mode == TM_BUMPER ) printf("Bumper mode data!\n");
175 
176  if ( ias_odl_get_field( str, sizeof(str), IAS_ODL_String, smeta_odl,
177  "PRODUCT_METADATA", "DATE_ACQUIRED", &count ) != SUCCESS )
178  {
179  IAS_LOG_ERROR("Reading DATE_ACQUIRED from PRODUCT_METADATA group.");
180  return(ERROR);
181  }
182 
183  if ( sscanf( str, "%04d-%02d-%02d", &smeta->acq_date[0], &smeta->acq_date[1], &smeta->acq_date[2] ) != 3 )
184  {
185  IAS_LOG_ERROR("Parsing acquisition date from DATE_ACQUIRED field.");
186  return(ERROR);
187  }
188 
189  printf("spacecraft_id = %d, sensor_id = %d, sensor_mode = %d\n", smeta->spacecraft_id, smeta->sensor_id, smeta->sensor_mode);
190 
191 
192  /* We have to count the bands by looking at the product band file names */
193  smeta->num_band = 0;
194  if (smeta->spacecraft_id == IAS_L8)
195  for (i=0; i<IAS_MAX_NBANDS; i++)
196  {
197  sprintf( fname, "FILE_NAME_BAND_%d", i+1 );
198  if ( ias_odl_get_field( bname, sizeof(bname), IAS_ODL_String, smeta_odl,
199  "PRODUCT_METADATA", fname, &count ) == SUCCESS )
200  {
201  if ( strlen(bname) > 0 )
202  {
203  smeta->band_smeta[smeta->num_band].band = i + 1;
204  smeta->num_band++;
205  }
206  }
207  }
208  else
209  for (i=0; i<IAS_MAX_NBANDS_LS; i++)
210  {
211  sprintf( fname, "FILE_NAME_BAND_%d", i+1 );
212  if ( (smeta->spacecraft_id == IAS_L7) && ((i+1) == 6) ) sprintf( fname, "FILE_NAME_BAND_%d_VCID_1", i+1 );
213  if ( ias_odl_get_field( bname, sizeof(bname), IAS_ODL_String, smeta_odl,
214  "PRODUCT_METADATA", fname, &count ) == SUCCESS )
215  {
216  if ( strlen(bname) > 0 )
217  {
218  smeta->band_smeta_ls[smeta->num_band].band = i + 1;
219  smeta->num_band++;
220  }
221  }
222  }
223 
224  /* For the L4/5 TM sensors, add an extra "optical axis" band for framing purposes. */
225  /* This will be suppressed prior to angle band generation. */
226  if ( smeta->sensor_id == IAS_TM )
227  {
228  smeta->band_smeta_ls[smeta->num_band].band = 0;
229  smeta->num_band++;
230  }
231 
232  /* Read the off-nadir roll angle */
233  if ( smeta->spacecraft_id == IAS_L8 )
234  {
235  if ( ias_odl_get_field( &smeta->roll_angle, sizeof(double), IAS_ODL_Double, smeta_odl,
236  "IMAGE_ATTRIBUTES", "ROLL_ANGLE", &count ) != SUCCESS )
237  {
238  IAS_LOG_ERROR("Reading ROLL_ANGLE from IMAGE_ATTRIBUTES group.");
239  smeta->roll_angle = 0.0;
240  }
241  }
242  else
243  smeta->roll_angle = 0.0;
244 
245  /* Read the scene center sun angles */
246  if ( ias_odl_get_field( &smeta->sun_azimuth, sizeof(double), IAS_ODL_Double, smeta_odl,
247  "IMAGE_ATTRIBUTES", "SUN_AZIMUTH", &count ) != SUCCESS )
248  {
249  IAS_LOG_ERROR("Reading SUN_AZIMUTH from IMAGE_ATTRIBUTES group.");
250  return(ERROR);
251  }
252  if ( ias_odl_get_field( &smeta->sun_elevation, sizeof(double), IAS_ODL_Double, smeta_odl,
253  "IMAGE_ATTRIBUTES", "SUN_ELEVATION", &count ) != SUCCESS )
254  {
255  IAS_LOG_ERROR("Reading SUN_ELEVATION from IMAGE_ATTRIBUTES group.");
256  return(ERROR);
257  }
258 
259  return(SUCCESS);
260 }
261 
263  SMETA_SCENE_PROJ *projection, /* Projection structure to load */
264  IAS_OBJ_DESC *smeta_odl ) /* Enhanced metadata ODL object */
265 {
266  int i; /* Parameter loop index */
267  char projname[MAX_FIELD_NAME]; /* Text projection code must be UTM or PS */
268  int count; /* Counter for ODL read routines */
269 
270  /* Read data */
271  /* Projection information group */
272  projection->wgs84_major_axis = 6378137.0;
273  projection->wgs84_minor_axis = 6356752.314;
274  /* Get the projection code from the metadata and populate default parameters appropriately */
275  if ( ias_odl_get_field( projname, sizeof(projname), IAS_ODL_String, smeta_odl,
276  "PROJECTION_PARAMETERS", "MAP_PROJECTION", &count ) != SUCCESS )
277  {
278  IAS_LOG_ERROR("Reading MAP_PROJECTION from PROJECTION_PARAMETERS group.");
279  return(ERROR);
280  }
281  for (i=0; i<IAS_PROJ_PARAM_SIZE; i++)
282  projection->projprms[i] = 0.0;
283  if ( strncmp( projname, "UTM", 3 ) == 0 )
284  {
285  projection->code = 1;
286  /* Read zone number if UTM */
287  if ( ias_odl_get_field( &projection->zone, sizeof(int), IAS_ODL_Int, smeta_odl,
288  "PROJECTION_PARAMETERS", "UTM_ZONE", &count ) != SUCCESS )
289  {
290  IAS_LOG_ERROR("Reading UTM_ZONE from PROJECTION_PARAMETERS group.");
291  return(ERROR);
292  }
293  }
294  else if ( strncmp( projname, "PS", 2 ) == 0 )
295  {
296  projection->code = 6;
297  projection->projprms[0] = projection->wgs84_major_axis;
298  projection->projprms[1] = projection->wgs84_minor_axis;
299  projection->projprms[5] = -71000000.0;
300  }
301  else
302  {
303  IAS_LOG_ERROR("Invalid projection read from MAP_PROJECTION in PROJECTION_PARAMETERS group.");
304  return(ERROR);
305  }
306  strcpy( projection->units, "METERS");
307  strcpy( projection->datum, "WGS84" );
308  projection->spheroid = 12;
309 
310  /* Read scene corners */
311  if ( ias_odl_get_field( &projection->corners.upleft.x, sizeof(double), IAS_ODL_Double, smeta_odl,
312  "PRODUCT_METADATA", "CORNER_UL_PROJECTION_X_PRODUCT", &count ) != SUCCESS )
313  {
314  IAS_LOG_ERROR("Reading CORNER_UL_PROJECTION_X_PRODUCT from PRODUCT_METADATA group.");
315  return(ERROR);
316  }
317  if ( ias_odl_get_field( &projection->corners.upleft.y, sizeof(double), IAS_ODL_Double, smeta_odl,
318  "PRODUCT_METADATA", "CORNER_UL_PROJECTION_Y_PRODUCT", &count ) != SUCCESS )
319  {
320  IAS_LOG_ERROR("Reading CORNER_UL_PROJECTION_Y_PRODUCT from PRODUCT_METADATA group.");
321  return(ERROR);
322  }
323  if ( ias_odl_get_field( &projection->corners.upright.x, sizeof(double), IAS_ODL_Double, smeta_odl,
324  "PRODUCT_METADATA", "CORNER_UR_PROJECTION_X_PRODUCT", &count ) != SUCCESS )
325  {
326  IAS_LOG_ERROR("Reading CORNER_UR_PROJECTION_X_PRODUCT from PRODUCT_METADATA group.");
327  return(ERROR);
328  }
329  if ( ias_odl_get_field( &projection->corners.upright.y, sizeof(double), IAS_ODL_Double, smeta_odl,
330  "PRODUCT_METADATA", "CORNER_UR_PROJECTION_Y_PRODUCT", &count ) != SUCCESS )
331  {
332  IAS_LOG_ERROR("Reading CORNER_UR_PROJECTION_Y_PRODUCT from PRODUCT_METADATA group.");
333  return(ERROR);
334  }
335  if ( ias_odl_get_field( &projection->corners.loleft.x, sizeof(double), IAS_ODL_Double, smeta_odl,
336  "PRODUCT_METADATA", "CORNER_LL_PROJECTION_X_PRODUCT", &count ) != SUCCESS )
337  {
338  IAS_LOG_ERROR("Reading CORNER_LL_PROJECTION_X_PRODUCT from PRODUCT_METADATA group.");
339  return(ERROR);
340  }
341  if ( ias_odl_get_field( &projection->corners.loleft.y, sizeof(double), IAS_ODL_Double, smeta_odl,
342  "PRODUCT_METADATA", "CORNER_LL_PROJECTION_Y_PRODUCT", &count ) != SUCCESS )
343  {
344  IAS_LOG_ERROR("Reading CORNER_LL_PROJECTION_Y_PRODUCT from PRODUCT_METADATA group.");
345  return(ERROR);
346  }
347  if ( ias_odl_get_field( &projection->corners.loright.x, sizeof(double), IAS_ODL_Double, smeta_odl,
348  "PRODUCT_METADATA", "CORNER_LR_PROJECTION_X_PRODUCT", &count ) != SUCCESS )
349  {
350  IAS_LOG_ERROR("Reading CORNER_LR_PROJECTION_X_PRODUCT from PRODUCT_METADATA group.");
351  return(ERROR);
352  }
353  if ( ias_odl_get_field( &projection->corners.loright.y, sizeof(double), IAS_ODL_Double, smeta_odl,
354  "PRODUCT_METADATA", "CORNER_LR_PROJECTION_Y_PRODUCT", &count ) != SUCCESS )
355  {
356  IAS_LOG_ERROR("Reading CORNER_LR_PROJECTION_Y_PRODUCT from PRODUCT_METADATA group.");
357  return(ERROR);
358  }
359 
360  return(SUCCESS);
361 }
362 
364  SMETA_BAND *band_smeta, /* Product metadata structure to load */
365  IAS_OBJ_DESC *smeta_odl ) /* Product metadata ODL object */
366 {
367  int count; /* Counter for ODL read routines */
368 
369  /* Check the current user band number */
370  if ( band_smeta->band == 8 ) /* pan */
371  {
372  /* Read the number of L1T lines for this band */
373  if ( ias_odl_get_field( &band_smeta->l1t_lines, sizeof(int), IAS_ODL_Int, smeta_odl,
374  "PRODUCT_METADATA", "PANCHROMATIC_LINES", &count ) != SUCCESS )
375  {
376  IAS_LOG_ERROR("Reading PANCHROMATIC_LINES from PRODUCT_METADATA group.");
377  return(ERROR);
378  }
379  /* Read the number of L1T samples for this band */
380  if ( ias_odl_get_field( &band_smeta->l1t_samps, sizeof(int), IAS_ODL_Int, smeta_odl,
381  "PRODUCT_METADATA", "PANCHROMATIC_SAMPLES", &count ) != SUCCESS )
382  {
383  IAS_LOG_ERROR("Reading PANCHROMATIC_SAMPLES from PRODUCT_METADATA group.");
384  return(ERROR);
385  }
386  /* Read the pixel size for this band */
387  if ( ias_odl_get_field( &band_smeta->pixsize, sizeof(double), IAS_ODL_Double, smeta_odl,
388  "PROJECTION_PARAMETERS", "GRID_CELL_SIZE_PANCHROMATIC", &count ) != SUCCESS )
389  {
390  IAS_LOG_ERROR("Reading GRID_CELL_SIZE_PANCHROMATIC from PROJECTION_PARAMETERS group.");
391  return(ERROR);
392  }
393  }
394  else if ( band_smeta->band > 9 ) /* thermal */
395  {
396  /* Read the number of L1T lines for this band */
397  if ( ias_odl_get_field( &band_smeta->l1t_lines, sizeof(int), IAS_ODL_Int, smeta_odl,
398  "PRODUCT_METADATA", "THERMAL_LINES", &count ) != SUCCESS )
399  {
400  IAS_LOG_ERROR("Reading THERMAL_LINES from PRODUCT_METADATA group.");
401  return(ERROR);
402  }
403  /* Read the number of L1T samples for this band */
404  if ( ias_odl_get_field( &band_smeta->l1t_samps, sizeof(int), IAS_ODL_Int, smeta_odl,
405  "PRODUCT_METADATA", "THERMAL_SAMPLES", &count ) != SUCCESS )
406  {
407  IAS_LOG_ERROR("Reading THERMAL_SAMPLES from PRODUCT_METADATA group.");
408  return(ERROR);
409  }
410  /* Read the pixel size for this band */
411  if ( ias_odl_get_field( &band_smeta->pixsize, sizeof(double), IAS_ODL_Double, smeta_odl,
412  "PROJECTION_PARAMETERS", "GRID_CELL_SIZE_THERMAL", &count ) != SUCCESS )
413  {
414  IAS_LOG_ERROR("Reading GRID_CELL_SIZE_THERMAL from PROJECTION_PARAMETERS group.");
415  return(ERROR);
416  }
417  }
418  else
419  {
420  /* Read the number of L1T lines for this band */
421  if ( ias_odl_get_field( &band_smeta->l1t_lines, sizeof(int), IAS_ODL_Int, smeta_odl,
422  "PRODUCT_METADATA", "REFLECTIVE_LINES", &count ) != SUCCESS )
423  {
424  IAS_LOG_ERROR("Reading REFLECTIVE_LINES from PRODUCT_METADATA group.");
425  return(ERROR);
426  }
427  /* Read the number of L1T samples for this band */
428  if ( ias_odl_get_field( &band_smeta->l1t_samps, sizeof(int), IAS_ODL_Int, smeta_odl,
429  "PRODUCT_METADATA", "REFLECTIVE_SAMPLES", &count ) != SUCCESS )
430  {
431  IAS_LOG_ERROR("Reading REFLECTIVE_SAMPLES from PRODUCT_METADATA group.");
432  return(ERROR);
433  }
434  /* Read the pixel size for this band */
435  if ( ias_odl_get_field( &band_smeta->pixsize, sizeof(double), IAS_ODL_Double, smeta_odl,
436  "PROJECTION_PARAMETERS", "GRID_CELL_SIZE_REFLECTIVE", &count ) != SUCCESS )
437  {
438  IAS_LOG_ERROR("Reading GRID_CELL_SIZE_REFLECTIVE from PROJECTION_PARAMETERS group.");
439  return(ERROR);
440  }
441  }
442 
443  return(SUCCESS);
444 }
445 
447  SMETA_BAND_LS *band_smeta, /* Product metadata structure to load */
448  IAS_OBJ_DESC *smeta_odl ) /* Product metadata ODL object */
449 {
450  int count; /* Counter for ODL read routines */
451 
452  /* Check the current user band number */
453  if ( band_smeta->band == 8 ) /* pan */
454  {
455  /* Read the number of L1T lines for this band */
456  if ( ias_odl_get_field( &band_smeta->l1t_lines, sizeof(int), IAS_ODL_Int, smeta_odl,
457  "PRODUCT_METADATA", "PANCHROMATIC_LINES", &count ) != SUCCESS )
458  {
459  IAS_LOG_ERROR("Reading PANCHROMATIC_LINES from PRODUCT_METADATA group.");
460  return(ERROR);
461  }
462  /* Read the number of L1T samples for this band */
463  if ( ias_odl_get_field( &band_smeta->l1t_samps, sizeof(int), IAS_ODL_Int, smeta_odl,
464  "PRODUCT_METADATA", "PANCHROMATIC_SAMPLES", &count ) != SUCCESS )
465  {
466  IAS_LOG_ERROR("Reading PANCHROMATIC_SAMPLES from PRODUCT_METADATA group.");
467  return(ERROR);
468  }
469  /* Read the pixel size for this band */
470  if ( ias_odl_get_field( &band_smeta->pixsize, sizeof(double), IAS_ODL_Double, smeta_odl,
471  "PROJECTION_PARAMETERS", "GRID_CELL_SIZE_PANCHROMATIC", &count ) != SUCCESS )
472  {
473  IAS_LOG_ERROR("Reading GRID_CELL_SIZE_PANCHROMATIC from PROJECTION_PARAMETERS group.");
474  return(ERROR);
475  }
476  }
477  else if ( band_smeta->band == 6 ) /* thermal */
478  {
479  /* Read the number of L1T lines for this band */
480  if ( ias_odl_get_field( &band_smeta->l1t_lines, sizeof(int), IAS_ODL_Int, smeta_odl,
481  "PRODUCT_METADATA", "THERMAL_LINES", &count ) != SUCCESS )
482  {
483  IAS_LOG_ERROR("Reading THERMAL_LINES from PRODUCT_METADATA group.");
484  return(ERROR);
485  }
486  /* Read the number of L1T samples for this band */
487  if ( ias_odl_get_field( &band_smeta->l1t_samps, sizeof(int), IAS_ODL_Int, smeta_odl,
488  "PRODUCT_METADATA", "THERMAL_SAMPLES", &count ) != SUCCESS )
489  {
490  IAS_LOG_ERROR("Reading THERMAL_SAMPLES from PRODUCT_METADATA group.");
491  return(ERROR);
492  }
493  /* Read the pixel size for this band */
494  if ( ias_odl_get_field( &band_smeta->pixsize, sizeof(double), IAS_ODL_Double, smeta_odl,
495  "PROJECTION_PARAMETERS", "GRID_CELL_SIZE_THERMAL", &count ) != SUCCESS )
496  {
497  IAS_LOG_ERROR("Reading GRID_CELL_SIZE_THERMAL from PROJECTION_PARAMETERS group.");
498  return(ERROR);
499  }
500  }
501  else
502  {
503  /* Read the number of L1T lines for this band */
504  if ( ias_odl_get_field( &band_smeta->l1t_lines, sizeof(int), IAS_ODL_Int, smeta_odl,
505  "PRODUCT_METADATA", "REFLECTIVE_LINES", &count ) != SUCCESS )
506  {
507  IAS_LOG_ERROR("Reading REFLECTIVE_LINES from PRODUCT_METADATA group.");
508  return(ERROR);
509  }
510  /* Read the number of L1T samples for this band */
511  if ( ias_odl_get_field( &band_smeta->l1t_samps, sizeof(int), IAS_ODL_Int, smeta_odl,
512  "PRODUCT_METADATA", "REFLECTIVE_SAMPLES", &count ) != SUCCESS )
513  {
514  IAS_LOG_ERROR("Reading REFLECTIVE_SAMPLES from PRODUCT_METADATA group.");
515  return(ERROR);
516  }
517  /* Read the pixel size for this band */
518  if ( ias_odl_get_field( &band_smeta->pixsize, sizeof(double), IAS_ODL_Double, smeta_odl,
519  "PROJECTION_PARAMETERS", "GRID_CELL_SIZE_REFLECTIVE", &count ) != SUCCESS )
520  {
521  IAS_LOG_ERROR("Reading GRID_CELL_SIZE_REFLECTIVE from PROJECTION_PARAMETERS group.");
522  return(ERROR);
523  }
524  }
525 
526  return(SUCCESS);
527 }
528 
530  SMETA_BAND *band_smeta ) /* Product metadata structure to load */
531 {
532  /* Set defaults based upon OLI */
533  band_smeta->nsca = 14;
534  band_smeta->align[0][0] = 0.999997951;
535  band_smeta->align[0][1] = -0.000530673;
536  band_smeta->align[0][2] = -0.001953614;
537  band_smeta->align[1][0] = 0.000527690;
538  band_smeta->align[1][1] = 0.999998695;
539  band_smeta->align[1][2] = -0.001527061;
540  band_smeta->align[2][0] = 0.001954422;
541  band_smeta->align[2][1] = 0.001526027;
542  band_smeta->align[2][2] = 0.999996925;
543 
544  /* Switch on the current user band number */
545  switch ( band_smeta->band )
546  {
547  case 1:
548  /* Sudipta new addition for OLI to extract SCA and Det numbers */
549  band_smeta->num_detectors = 494;
550  /* End Sudipta new addition for OLI */
551  band_smeta->legendre[0][0][0] = 6.700457E-03; band_smeta->legendre[0][0][1] = -3.401961E-04; band_smeta->legendre[0][0][2] = 3.020421E-06; band_smeta->legendre[0][0][3] = 0.000000E+00; /* Band 01 SCA 01 X */
552  band_smeta->legendre[0][1][0] = 1.247760E-01; band_smeta->legendre[0][1][1] = -1.022901E-02; band_smeta->legendre[0][1][2] = 1.129022E-05; band_smeta->legendre[0][1][3] = 0.000000E+00; /* Band 01 SCA 01 Y */
553  band_smeta->legendre[1][0][0] = -5.513364E-03; band_smeta->legendre[1][0][1] = -2.558301E-04; band_smeta->legendre[1][0][2] = 2.493720E-06; band_smeta->legendre[1][0][3] = 0.000000E+00; /* Band 01 SCA 02 X */
554  band_smeta->legendre[1][1][0] = 1.054260E-01; band_smeta->legendre[1][1][1] = -1.014920E-02; band_smeta->legendre[1][1][2] = 9.369339E-06; band_smeta->legendre[1][1][3] = 0.000000E+00; /* Band 01 SCA 02 Y */
555  band_smeta->legendre[2][0][0] = 6.323671E-03; band_smeta->legendre[2][0][1] = -2.358493E-04; band_smeta->legendre[2][0][2] = 2.698207E-06; band_smeta->legendre[2][0][3] = 0.000000E+00; /* Band 01 SCA 03 X */
556  band_smeta->legendre[2][1][0] = 8.611552E-02; band_smeta->legendre[2][1][1] = -1.012057E-02; band_smeta->legendre[2][1][2] = 8.258542E-06; band_smeta->legendre[2][1][3] = 0.000000E+00; /* Band 01 SCA 03 Y */
557  band_smeta->legendre[3][0][0] = -5.784523E-03; band_smeta->legendre[3][0][1] = -1.612340E-04; band_smeta->legendre[3][0][2] = 2.520839E-06; band_smeta->legendre[3][0][3] = 0.000000E+00; /* Band 01 SCA 04 X */
558  band_smeta->legendre[3][1][0] = 6.694656E-02; band_smeta->legendre[3][1][1] = -1.006099E-02; band_smeta->legendre[3][1][2] = 6.206345E-06; band_smeta->legendre[3][1][3] = 0.000000E+00; /* Band 01 SCA 04 Y */
559  band_smeta->legendre[4][0][0] = 6.078253E-03; band_smeta->legendre[4][0][1] = -1.311456E-04; band_smeta->legendre[4][0][2] = 3.930979E-06; band_smeta->legendre[4][0][3] = 0.000000E+00; /* Band 01 SCA 05 X */
560  band_smeta->legendre[4][1][0] = 4.779359E-02; band_smeta->legendre[4][1][1] = -1.004966E-02; band_smeta->legendre[4][1][2] = 5.199712E-06; band_smeta->legendre[4][1][3] = 0.000000E+00; /* Band 01 SCA 05 Y */
561  band_smeta->legendre[5][0][0] = -5.924803E-03; band_smeta->legendre[5][0][1] = -7.073287E-05; band_smeta->legendre[5][0][2] = 2.868175E-06; band_smeta->legendre[5][0][3] = 0.000000E+00; /* Band 01 SCA 06 X */
562  band_smeta->legendre[5][1][0] = 2.872972E-02; band_smeta->legendre[5][1][1] = -1.001174E-02; band_smeta->legendre[5][1][2] = 2.787794E-06; band_smeta->legendre[5][1][3] = 0.000000E+00; /* Band 01 SCA 06 Y */
563  band_smeta->legendre[6][0][0] = 5.971097E-03; band_smeta->legendre[6][0][1] = -2.815200E-05; band_smeta->legendre[6][0][2] = 3.190979E-06; band_smeta->legendre[6][0][3] = 0.000000E+00; /* Band 01 SCA 07 X */
564  band_smeta->legendre[6][1][0] = 9.658241E-03; band_smeta->legendre[6][1][1] = -1.002124E-02; band_smeta->legendre[6][1][2] = 1.087904E-06; band_smeta->legendre[6][1][3] = 0.000000E+00; /* Band 01 SCA 07 Y */
565  band_smeta->legendre[7][0][0] = -5.966687E-03; band_smeta->legendre[7][0][1] = 2.091761E-05; band_smeta->legendre[7][0][2] = 2.181517E-06; band_smeta->legendre[7][0][3] = 0.000000E+00; /* Band 01 SCA 08 X */
566  band_smeta->legendre[7][1][0] = -9.381294E-03; band_smeta->legendre[7][1][1] = -1.000203E-02; band_smeta->legendre[7][1][2] = -1.944770E-06; band_smeta->legendre[7][1][3] = 0.000000E+00; /* Band 01 SCA 08 Y */
567  band_smeta->legendre[8][0][0] = 6.006426E-03; band_smeta->legendre[8][0][1] = 7.643835E-05; band_smeta->legendre[8][0][2] = 3.298299E-06; band_smeta->legendre[8][0][3] = 0.000000E+00; /* Band 01 SCA 09 X */
568  band_smeta->legendre[8][1][0] = -2.843993E-02; band_smeta->legendre[8][1][1] = -1.003132E-02; band_smeta->legendre[8][1][2] = -2.784321E-06; band_smeta->legendre[8][1][3] = 0.000000E+00; /* Band 01 SCA 09 Y */
569  band_smeta->legendre[9][0][0] = -5.884010E-03; band_smeta->legendre[9][0][1] = 1.143512E-04; band_smeta->legendre[9][0][2] = 3.354213E-06; band_smeta->legendre[9][0][3] = 0.000000E+00; /* Band 01 SCA 10 X */
570  band_smeta->legendre[9][1][0] = -4.752226E-02; band_smeta->legendre[9][1][1] = -1.003170E-02; band_smeta->legendre[9][1][2] = -4.403675E-06; band_smeta->legendre[9][1][3] = 0.000000E+00; /* Band 01 SCA 10 Y */
571  band_smeta->legendre[10][0][0] = 6.170485E-03; band_smeta->legendre[10][0][1] = 1.818443E-04; band_smeta->legendre[10][0][2] = 3.255665E-06; band_smeta->legendre[10][0][3] = 0.000000E+00; /* Band 01 SCA 11 X */
572  band_smeta->legendre[10][1][0] = -6.664497E-02; band_smeta->legendre[10][1][1] = -1.007982E-02; band_smeta->legendre[10][1][2] = -6.278005E-06; band_smeta->legendre[10][1][3] = 0.000000E+00; /* Band 01 SCA 11 Y */
573  band_smeta->legendre[11][0][0] = -5.686986E-03; band_smeta->legendre[11][0][1] = 2.051895E-04; band_smeta->legendre[11][0][2] = 2.350731E-06; band_smeta->legendre[11][0][3] = 0.000000E+00; /* Band 01 SCA 12 X */
574  band_smeta->legendre[11][1][0] = -8.585954E-02; band_smeta->legendre[11][1][1] = -1.009955E-02; band_smeta->legendre[11][1][2] = -6.930943E-06; band_smeta->legendre[11][1][3] = 0.000000E+00; /* Band 01 SCA 12 Y */
575  band_smeta->legendre[12][0][0] = 6.476124E-03; band_smeta->legendre[12][0][1] = 2.880301E-04; band_smeta->legendre[12][0][2] = 4.495383E-06; band_smeta->legendre[12][0][3] = 0.000000E+00; /* Band 01 SCA 13 X */
576  band_smeta->legendre[12][1][0] = -1.051198E-01; band_smeta->legendre[12][1][1] = -1.016743E-02; band_smeta->legendre[12][1][2] = -1.114517E-05; band_smeta->legendre[12][1][3] = 0.000000E+00; /* Band 01 SCA 13 Y */
577  band_smeta->legendre[13][0][0] = -5.351748E-03; band_smeta->legendre[13][0][1] = 2.992144E-04; band_smeta->legendre[13][0][2] = 3.867663E-06; band_smeta->legendre[13][0][3] = 0.000000E+00; /* Band 01 SCA 14 X */
578  band_smeta->legendre[13][1][0] = -1.245202E-01; band_smeta->legendre[13][1][1] = -1.020712E-02; band_smeta->legendre[13][1][2] = -1.109152E-05; band_smeta->legendre[13][1][3] = 0.000000E+00; /* Band 01 SCA 14 Y */
579  break;
580  case 2:
581  /* Sudipta new addition for OLI to extract SCA and Det numbers */
582  band_smeta->num_detectors = 494;
583  /* End Sudipta new addition for OLI */
584  band_smeta->legendre[0][0][0] = 5.465425E-03; band_smeta->legendre[0][0][1] = -3.383192E-04; band_smeta->legendre[0][0][2] = 3.087230E-06; band_smeta->legendre[0][0][3] = 0.000000E+00; /* Band 02 SCA 01 X */
585  band_smeta->legendre[0][1][0] = 1.247768E-01; band_smeta->legendre[0][1][1] = -1.022709E-02; band_smeta->legendre[0][1][2] = 1.132283E-05; band_smeta->legendre[0][1][3] = 0.000000E+00; /* Band 02 SCA 01 Y */
586  band_smeta->legendre[1][0][0] = -4.283082E-03; band_smeta->legendre[1][0][1] = -2.570051E-04; band_smeta->legendre[1][0][2] = 2.581862E-06; band_smeta->legendre[1][0][3] = 0.000000E+00; /* Band 02 SCA 02 X */
587  band_smeta->legendre[1][1][0] = 1.054274E-01; band_smeta->legendre[1][1][1] = -1.015115E-02; band_smeta->legendre[1][1][2] = 9.453706E-06; band_smeta->legendre[1][1][3] = 0.000000E+00; /* Band 02 SCA 02 Y */
588  band_smeta->legendre[2][0][0] = 5.092865E-03; band_smeta->legendre[2][0][1] = -2.346027E-04; band_smeta->legendre[2][0][2] = 2.631629E-06; band_smeta->legendre[2][0][3] = 0.000000E+00; /* Band 02 SCA 03 X */
589  band_smeta->legendre[2][1][0] = 8.611595E-02; band_smeta->legendre[2][1][1] = -1.011873E-02; band_smeta->legendre[2][1][2] = 8.174708E-06; band_smeta->legendre[2][1][3] = 0.000000E+00; /* Band 02 SCA 03 Y */
590  band_smeta->legendre[3][0][0] = -4.558100E-03; band_smeta->legendre[3][0][1] = -1.621403E-04; band_smeta->legendre[3][0][2] = 2.460853E-06; band_smeta->legendre[3][0][3] = 0.000000E+00; /* Band 02 SCA 04 X */
591  band_smeta->legendre[3][1][0] = 6.694782E-02; band_smeta->legendre[3][1][1] = -1.006298E-02; band_smeta->legendre[3][1][2] = 6.285042E-06; band_smeta->legendre[3][1][3] = 0.000000E+00; /* Band 02 SCA 04 Y */
592  band_smeta->legendre[4][0][0] = 4.850894E-03; band_smeta->legendre[4][0][1] = -1.301959E-04; band_smeta->legendre[4][0][2] = 3.883217E-06; band_smeta->legendre[4][0][3] = 0.000000E+00; /* Band 02 SCA 05 X */
593  band_smeta->legendre[4][1][0] = 4.779369E-02; band_smeta->legendre[4][1][1] = -1.004771E-02; band_smeta->legendre[4][1][2] = 5.218173E-06; band_smeta->legendre[4][1][3] = 0.000000E+00; /* Band 02 SCA 05 Y */
594  band_smeta->legendre[5][0][0] = -4.700814E-03; band_smeta->legendre[5][0][1] = -7.089173E-05; band_smeta->legendre[5][0][2] = 3.002382E-06; band_smeta->legendre[5][0][3] = 0.000000E+00; /* Band 02 SCA 06 X */
595  band_smeta->legendre[5][1][0] = 2.873005E-02; band_smeta->legendre[5][1][1] = -1.001389E-02; band_smeta->legendre[5][1][2] = 2.839258E-06; band_smeta->legendre[5][1][3] = 0.000000E+00; /* Band 02 SCA 06 Y */
596  band_smeta->legendre[6][0][0] = 4.745216E-03; band_smeta->legendre[6][0][1] = -2.763869E-05; band_smeta->legendre[6][0][2] = 3.292341E-06; band_smeta->legendre[6][0][3] = 0.000000E+00; /* Band 02 SCA 07 X */
597  band_smeta->legendre[6][1][0] = 9.658213E-03; band_smeta->legendre[6][1][1] = -1.001938E-02; band_smeta->legendre[6][1][2] = 9.347606E-07; band_smeta->legendre[6][1][3] = 0.000000E+00; /* Band 02 SCA 07 Y */
598  band_smeta->legendre[7][0][0] = -4.743515E-03; band_smeta->legendre[7][0][1] = 2.140725E-05; band_smeta->legendre[7][0][2] = 2.208777E-06; band_smeta->legendre[7][0][3] = 0.000000E+00; /* Band 02 SCA 08 X */
599  band_smeta->legendre[7][1][0] = -9.381283E-03; band_smeta->legendre[7][1][1] = -1.000392E-02; band_smeta->legendre[7][1][2] = -2.009904E-06; band_smeta->legendre[7][1][3] = 0.000000E+00; /* Band 02 SCA 08 Y */
600  band_smeta->legendre[8][0][0] = 4.779561E-03; band_smeta->legendre[8][0][1] = 7.629733E-05; band_smeta->legendre[8][0][2] = 3.299964E-06; band_smeta->legendre[8][0][3] = 0.000000E+00; /* Band 02 SCA 09 X */
601  band_smeta->legendre[8][1][0] = -2.844043E-02; band_smeta->legendre[8][1][1] = -1.002930E-02; band_smeta->legendre[8][1][2] = -2.795610E-06; band_smeta->legendre[8][1][3] = 0.000000E+00; /* Band 02 SCA 09 Y */
602  band_smeta->legendre[9][0][0] = -4.658966E-03; band_smeta->legendre[9][0][1] = 1.150612E-04; band_smeta->legendre[9][0][2] = 3.388692E-06; band_smeta->legendre[9][0][3] = 0.000000E+00; /* Band 02 SCA 10 X */
603  band_smeta->legendre[9][1][0] = -4.752238E-02; band_smeta->legendre[9][1][1] = -1.003369E-02; band_smeta->legendre[9][1][2] = -4.345525E-06; band_smeta->legendre[9][1][3] = 0.000000E+00; /* Band 02 SCA 10 Y */
604  band_smeta->legendre[10][0][0] = 4.941977E-03; band_smeta->legendre[10][0][1] = 1.813334E-04; band_smeta->legendre[10][0][2] = 3.257583E-06; band_smeta->legendre[10][0][3] = 0.000000E+00; /* Band 02 SCA 11 X */
605  band_smeta->legendre[10][1][0] = -6.664576E-02; band_smeta->legendre[10][1][1] = -1.007792E-02; band_smeta->legendre[10][1][2] = -6.299673E-06; band_smeta->legendre[10][1][3] = 0.000000E+00; /* Band 02 SCA 11 Y */
606  band_smeta->legendre[11][0][0] = -4.458698E-03; band_smeta->legendre[11][0][1] = 2.065198E-04; band_smeta->legendre[11][0][2] = 2.463545E-06; band_smeta->legendre[11][0][3] = 0.000000E+00; /* Band 02 SCA 12 X */
607  band_smeta->legendre[11][1][0] = -8.586029E-02; band_smeta->legendre[11][1][1] = -1.010161E-02; band_smeta->legendre[11][1][2] = -6.999770E-06; band_smeta->legendre[11][1][3] = 0.000000E+00; /* Band 02 SCA 12 Y */
608  band_smeta->legendre[12][0][0] = 5.243743E-03; band_smeta->legendre[12][0][1] = 2.868757E-04; band_smeta->legendre[12][0][2] = 4.569801E-06; band_smeta->legendre[12][0][3] = 0.000000E+00; /* Band 02 SCA 13 X */
609  band_smeta->legendre[12][1][0] = -1.051210E-01; band_smeta->legendre[12][1][1] = -1.016548E-02; band_smeta->legendre[12][1][2] = -1.108402E-05; band_smeta->legendre[12][1][3] = 0.000000E+00; /* Band 02 SCA 13 Y */
610  band_smeta->legendre[13][0][0] = -4.119881E-03; band_smeta->legendre[13][0][1] = 3.013370E-04; band_smeta->legendre[13][0][2] = 3.925234E-06; band_smeta->legendre[13][0][3] = 0.000000E+00; /* Band 02 SCA 14 X */
611  band_smeta->legendre[13][1][0] = -1.245216E-01; band_smeta->legendre[13][1][1] = -1.020916E-02; band_smeta->legendre[13][1][2] = -1.096852E-05; band_smeta->legendre[13][1][3] = 0.000000E+00; /* Band 02 SCA 14 Y */
612  break;
613  case 3:
614  /* Sudipta new addition for OLI to extract SCA and Det numbers */
615  band_smeta->num_detectors = 494;
616  /* End Sudipta new addition for OLI */
617  band_smeta->legendre[0][0][0] = 1.041906E-02; band_smeta->legendre[0][0][1] = -3.454704E-04; band_smeta->legendre[0][0][2] = 3.539931E-06; band_smeta->legendre[0][0][3] = 0.000000E+00; /* Band 03 SCA 01 X */
618  band_smeta->legendre[0][1][0] = 1.247782E-01; band_smeta->legendre[0][1][1] = -1.023510E-02; band_smeta->legendre[0][1][2] = 1.118006E-05; band_smeta->legendre[0][1][3] = 0.000000E+00; /* Band 03 SCA 01 Y */
619  band_smeta->legendre[1][0][0] = -9.193152E-03; band_smeta->legendre[1][0][1] = -2.515110E-04; band_smeta->legendre[1][0][2] = 2.328476E-06; band_smeta->legendre[1][0][3] = 0.000000E+00; /* Band 03 SCA 02 X */
620  band_smeta->legendre[1][1][0] = 1.054261E-01; band_smeta->legendre[1][1][1] = -1.014363E-02; band_smeta->legendre[1][1][2] = 9.462277E-06; band_smeta->legendre[1][1][3] = 0.000000E+00; /* Band 03 SCA 02 Y */
621  band_smeta->legendre[2][0][0] = 1.002762E-02; band_smeta->legendre[2][0][1] = -2.394232E-04; band_smeta->legendre[2][0][2] = 2.684126E-06; band_smeta->legendre[2][0][3] = 0.000000E+00; /* Band 03 SCA 03 X */
622  band_smeta->legendre[2][1][0] = 8.611718E-02; band_smeta->legendre[2][1][1] = -1.012686E-02; band_smeta->legendre[2][1][2] = 8.323528E-06; band_smeta->legendre[2][1][3] = 0.000000E+00; /* Band 03 SCA 03 Y */
623  band_smeta->legendre[3][0][0] = -9.452204E-03; band_smeta->legendre[3][0][1] = -1.587866E-04; band_smeta->legendre[3][0][2] = 2.513854E-06; band_smeta->legendre[3][0][3] = 0.000000E+00; /* Band 03 SCA 04 X */
624  band_smeta->legendre[3][1][0] = 6.694558E-02; band_smeta->legendre[3][1][1] = -1.005562E-02; band_smeta->legendre[3][1][2] = 6.345248E-06; band_smeta->legendre[3][1][3] = 0.000000E+00; /* Band 03 SCA 04 Y */
625  band_smeta->legendre[4][0][0] = 9.773615E-03; band_smeta->legendre[4][0][1] = -1.328606E-04; band_smeta->legendre[4][0][2] = 3.930089E-06; band_smeta->legendre[4][0][3] = 0.000000E+00; /* Band 03 SCA 05 X */
626  band_smeta->legendre[4][1][0] = 4.779474E-02; band_smeta->legendre[4][1][1] = -1.005598E-02; band_smeta->legendre[4][1][2] = 5.093887E-06; band_smeta->legendre[4][1][3] = 0.000000E+00; /* Band 03 SCA 05 Y */
627  band_smeta->legendre[5][0][0] = -9.586577E-03; band_smeta->legendre[5][0][1] = -6.942392E-05; band_smeta->legendre[5][0][2] = 2.734550E-06; band_smeta->legendre[5][0][3] = 0.000000E+00; /* Band 03 SCA 06 X */
628  band_smeta->legendre[5][1][0] = 2.872934E-02; band_smeta->legendre[5][1][1] = -1.000625E-02; band_smeta->legendre[5][1][2] = 2.671157E-06; band_smeta->legendre[5][1][3] = 0.000000E+00; /* Band 03 SCA 06 Y */
629  band_smeta->legendre[6][0][0] = 9.663069E-03; band_smeta->legendre[6][0][1] = -2.837736E-05; band_smeta->legendre[6][0][2] = 3.214780E-06; band_smeta->legendre[6][0][3] = 0.000000E+00; /* Band 03 SCA 07 X */
630  band_smeta->legendre[6][1][0] = 9.658657E-03; band_smeta->legendre[6][1][1] = -1.002772E-02; band_smeta->legendre[6][1][2] = 1.041097E-06; band_smeta->legendre[6][1][3] = 0.000000E+00; /* Band 03 SCA 07 Y */
631  band_smeta->legendre[7][0][0] = -9.626794E-03; band_smeta->legendre[7][0][1] = 2.058298E-05; band_smeta->legendre[7][0][2] = 2.040849E-06; band_smeta->legendre[7][0][3] = 0.000000E+00; /* Band 03 SCA 08 X */
632  band_smeta->legendre[7][1][0] = -9.381404E-03; band_smeta->legendre[7][1][1] = -9.997013E-03; band_smeta->legendre[7][1][2] = -1.657774E-06; band_smeta->legendre[7][1][3] = 0.000000E+00; /* Band 03 SCA 08 Y */
633  band_smeta->legendre[8][0][0] = 9.699190E-03; band_smeta->legendre[8][0][1] = 7.755539E-05; band_smeta->legendre[8][0][2] = 3.520416E-06; band_smeta->legendre[8][0][3] = 0.000000E+00; /* Band 03 SCA 09 X */
634  band_smeta->legendre[8][1][0] = -2.843975E-02; band_smeta->legendre[8][1][1] = -1.003745E-02; band_smeta->legendre[8][1][2] = -2.736407E-06; band_smeta->legendre[8][1][3] = 0.000000E+00; /* Band 03 SCA 09 Y */
635  band_smeta->legendre[9][0][0] = -9.548452E-03; band_smeta->legendre[9][0][1] = 1.123876E-04; band_smeta->legendre[9][0][2] = 3.198573E-06; band_smeta->legendre[9][0][3] = 0.000000E+00; /* Band 03 SCA 10 X */
636  band_smeta->legendre[9][1][0] = -4.752309E-02; band_smeta->legendre[9][1][1] = -1.002628E-02; band_smeta->legendre[9][1][2] = -4.235382E-06; band_smeta->legendre[9][1][3] = 0.000000E+00; /* Band 03 SCA 10 Y */
637  band_smeta->legendre[10][0][0] = 9.869869E-03; band_smeta->legendre[10][0][1] = 1.847020E-04; band_smeta->legendre[10][0][2] = 3.332958E-06; band_smeta->legendre[10][0][3] = 0.000000E+00; /* Band 03 SCA 11 X */
638  band_smeta->legendre[10][1][0] = -6.664501E-02; band_smeta->legendre[10][1][1] = -1.008613E-02; band_smeta->legendre[10][1][2] = -6.192518E-06; band_smeta->legendre[10][1][3] = 0.000000E+00; /* Band 03 SCA 11 Y */
639  band_smeta->legendre[11][0][0] = -9.360033E-03; band_smeta->legendre[11][0][1] = 2.019728E-04; band_smeta->legendre[11][0][2] = 2.378572E-06; band_smeta->legendre[11][0][3] = 0.000000E+00; /* Band 03 SCA 12 X */
640  band_smeta->legendre[11][1][0] = -8.586034E-02; band_smeta->legendre[11][1][1] = -1.009405E-02; band_smeta->legendre[11][1][2] = -7.055363E-06; band_smeta->legendre[11][1][3] = 0.000000E+00; /* Band 03 SCA 12 Y */
641  band_smeta->legendre[12][0][0] = 1.018724E-02; band_smeta->legendre[12][0][1] = 2.922704E-04; band_smeta->legendre[12][0][2] = 4.712555E-06; band_smeta->legendre[12][0][3] = 0.000000E+00; /* Band 03 SCA 13 X */
642  band_smeta->legendre[12][1][0] = -1.051198E-01; band_smeta->legendre[12][1][1] = -1.017391E-02; band_smeta->legendre[12][1][2] = -1.079104E-05; band_smeta->legendre[12][1][3] = 0.000000E+00; /* Band 03 SCA 13 Y */
643  band_smeta->legendre[13][0][0] = -9.039467E-03; band_smeta->legendre[13][0][1] = 2.943692E-04; band_smeta->legendre[13][0][2] = 3.845812E-06; band_smeta->legendre[13][0][3] = 0.000000E+00; /* Band 03 SCA 14 X */
644  band_smeta->legendre[13][1][0] = -1.245210E-01; band_smeta->legendre[13][1][1] = -1.020184E-02; band_smeta->legendre[13][1][2] = -1.093841E-05; band_smeta->legendre[13][1][3] = 0.000000E+00; /* Band 03 SCA 14 Y */
645  break;
646  case 4:
647  /* Sudipta new addition for OLI to extract SCA and Det numbers */
648  band_smeta->num_detectors = 494;
649  /* End Sudipta new addition for OLI */
650  band_smeta->legendre[0][0][0] = 9.181792E-03; band_smeta->legendre[0][0][1] = -3.437803E-04; band_smeta->legendre[0][0][2] = 3.514507E-06; band_smeta->legendre[0][0][3] = 0.000000E+00; /* Band 04 SCA 01 X */
651  band_smeta->legendre[0][1][0] = 1.247782E-01; band_smeta->legendre[0][1][1] = -1.023295E-02; band_smeta->legendre[0][1][2] = 1.115630E-05; band_smeta->legendre[0][1][3] = 0.000000E+00; /* Band 04 SCA 01 Y */
652  band_smeta->legendre[1][0][0] = -7.964812E-03; band_smeta->legendre[1][0][1] = -2.526059E-04; band_smeta->legendre[1][0][2] = 2.288381E-06; band_smeta->legendre[1][0][3] = 0.000000E+00; /* Band 04 SCA 02 X */
653  band_smeta->legendre[1][1][0] = 1.054266E-01; band_smeta->legendre[1][1][1] = -1.014554E-02; band_smeta->legendre[1][1][2] = 9.445541E-06; band_smeta->legendre[1][1][3] = 0.000000E+00; /* Band 04 SCA 02 Y */
654  band_smeta->legendre[2][0][0] = 8.795319E-03; band_smeta->legendre[2][0][1] = -2.381021E-04; band_smeta->legendre[2][0][2] = 2.517772E-06; band_smeta->legendre[2][0][3] = 0.000000E+00; /* Band 04 SCA 03 X */
655  band_smeta->legendre[2][1][0] = 8.611717E-02; band_smeta->legendre[2][1][1] = -1.012488E-02; band_smeta->legendre[2][1][2] = 8.379305E-06; band_smeta->legendre[2][1][3] = 0.000000E+00; /* Band 04 SCA 03 Y */
656  band_smeta->legendre[3][0][0] = -8.228379E-03; band_smeta->legendre[3][0][1] = -1.594470E-04; band_smeta->legendre[3][0][2] = 2.492521E-06; band_smeta->legendre[3][0][3] = 0.000000E+00; /* Band 04 SCA 04 X */
657  band_smeta->legendre[3][1][0] = 6.694637E-02; band_smeta->legendre[3][1][1] = -1.005741E-02; band_smeta->legendre[3][1][2] = 6.281542E-06; band_smeta->legendre[3][1][3] = 0.000000E+00; /* Band 04 SCA 04 Y */
658  band_smeta->legendre[4][0][0] = 8.544355E-03; band_smeta->legendre[4][0][1] = -1.320504E-04; band_smeta->legendre[4][0][2] = 3.817695E-06; band_smeta->legendre[4][0][3] = 0.000000E+00; /* Band 04 SCA 05 X */
659  band_smeta->legendre[4][1][0] = 4.779462E-02; band_smeta->legendre[4][1][1] = -1.005398E-02; band_smeta->legendre[4][1][2] = 5.000550E-06; band_smeta->legendre[4][1][3] = 0.000000E+00; /* Band 04 SCA 05 Y */
660  band_smeta->legendre[5][0][0] = -8.364217E-03; band_smeta->legendre[5][0][1] = -6.971393E-05; band_smeta->legendre[5][0][2] = 2.768567E-06; band_smeta->legendre[5][0][3] = 0.000000E+00; /* Band 04 SCA 06 X */
661  band_smeta->legendre[5][1][0] = 2.872965E-02; band_smeta->legendre[5][1][1] = -1.000810E-02; band_smeta->legendre[5][1][2] = 2.539207E-06; band_smeta->legendre[5][1][3] = 0.000000E+00; /* Band 04 SCA 06 Y */
662  band_smeta->legendre[6][0][0] = 8.434648E-03; band_smeta->legendre[6][0][1] = -2.821683E-05; band_smeta->legendre[6][0][2] = 3.377552E-06; band_smeta->legendre[6][0][3] = 0.000000E+00; /* Band 04 SCA 07 X */
663  band_smeta->legendre[6][1][0] = 9.658525E-03; band_smeta->legendre[6][1][1] = -1.002580E-02; band_smeta->legendre[6][1][2] = 8.874323E-07; band_smeta->legendre[6][1][3] = 0.000000E+00; /* Band 04 SCA 07 Y */
664  band_smeta->legendre[7][0][0] = -8.405057E-03; band_smeta->legendre[7][0][1] = 2.086813E-05; band_smeta->legendre[7][0][2] = 2.009307E-06; band_smeta->legendre[7][0][3] = 0.000000E+00; /* Band 04 SCA 08 X */
665  band_smeta->legendre[7][1][0] = -9.381472E-03; band_smeta->legendre[7][1][1] = -9.998813E-03; band_smeta->legendre[7][1][2] = -1.491295E-06; band_smeta->legendre[7][1][3] = 0.000000E+00; /* Band 04 SCA 08 Y */
666  band_smeta->legendre[8][0][0] = 8.470769E-03; band_smeta->legendre[8][0][1] = 7.719387E-05; band_smeta->legendre[8][0][2] = 3.390413E-06; band_smeta->legendre[8][0][3] = 0.000000E+00; /* Band 04 SCA 09 X */
667  band_smeta->legendre[8][1][0] = -2.844009E-02; band_smeta->legendre[8][1][1] = -1.003532E-02; band_smeta->legendre[8][1][2] = -2.782992E-06; band_smeta->legendre[8][1][3] = 0.000000E+00; /* Band 04 SCA 09 Y */
668  band_smeta->legendre[9][0][0] = -8.324964E-03; band_smeta->legendre[9][0][1] = 1.130198E-04; band_smeta->legendre[9][0][2] = 3.245731E-06; band_smeta->legendre[9][0][3] = 0.000000E+00; /* Band 04 SCA 10 X */
669  band_smeta->legendre[9][1][0] = -4.752317E-02; band_smeta->legendre[9][1][1] = -1.002807E-02; band_smeta->legendre[9][1][2] = -4.149779E-06; band_smeta->legendre[9][1][3] = 0.000000E+00; /* Band 04 SCA 10 Y */
670  band_smeta->legendre[10][0][0] = 8.639555E-03; band_smeta->legendre[10][0][1] = 1.841130E-04; band_smeta->legendre[10][0][2] = 3.334931E-06; band_smeta->legendre[10][0][3] = 0.000000E+00; /* Band 04 SCA 11 X */
671  band_smeta->legendre[10][1][0] = -6.664536E-02; band_smeta->legendre[10][1][1] = -1.008416E-02; band_smeta->legendre[10][1][2] = -6.288042E-06; band_smeta->legendre[10][1][3] = 0.000000E+00; /* Band 04 SCA 11 Y */
672  band_smeta->legendre[11][0][0] = -8.133795E-03; band_smeta->legendre[11][0][1] = 2.031498E-04; band_smeta->legendre[11][0][2] = 2.449548E-06; band_smeta->legendre[11][0][3] = 0.000000E+00; /* Band 04 SCA 12 X */
673  band_smeta->legendre[11][1][0] = -8.586056E-02; band_smeta->legendre[11][1][1] = -1.009593E-02; band_smeta->legendre[11][1][2] = -7.113677E-06; band_smeta->legendre[11][1][3] = 0.000000E+00; /* Band 04 SCA 12 Y */
674  band_smeta->legendre[12][0][0] = 8.952379E-03; band_smeta->legendre[12][0][1] = 2.909075E-04; band_smeta->legendre[12][0][2] = 4.675834E-06; band_smeta->legendre[12][0][3] = 0.000000E+00; /* Band 04 SCA 13 X */
675  band_smeta->legendre[12][1][0] = -1.051203E-01; band_smeta->legendre[12][1][1] = -1.017182E-02; band_smeta->legendre[12][1][2] = -1.086626E-05; band_smeta->legendre[12][1][3] = 0.000000E+00; /* Band 04 SCA 13 Y */
676  band_smeta->legendre[13][0][0] = -7.808343E-03; band_smeta->legendre[13][0][1] = 2.961812E-04; band_smeta->legendre[13][0][2] = 3.975986E-06; band_smeta->legendre[13][0][3] = 0.000000E+00; /* Band 04 SCA 14 X */
677  band_smeta->legendre[13][1][0] = -1.245214E-01; band_smeta->legendre[13][1][1] = -1.020366E-02; band_smeta->legendre[13][1][2] = -1.070862E-05; band_smeta->legendre[13][1][3] = 0.000000E+00; /* Band 04 SCA 14 Y */
678  break;
679  case 5:
680  /* Sudipta new addition for OLI to extract SCA and Det numbers */
681  band_smeta->num_detectors = 494;
682  /* End Sudipta new addition for OLI */
683  band_smeta->legendre[0][0][0] = 7.945358E-03; band_smeta->legendre[0][0][1] = -3.421326E-04; band_smeta->legendre[0][0][2] = 3.381643E-06; band_smeta->legendre[0][0][3] = 0.000000E+00; /* Band 05 SCA 01 X */
684  band_smeta->legendre[0][1][0] = 1.247794E-01; band_smeta->legendre[0][1][1] = -1.023102E-02; band_smeta->legendre[0][1][2] = 1.116419E-05; band_smeta->legendre[0][1][3] = 0.000000E+00; /* Band 05 SCA 01 Y */
685  band_smeta->legendre[1][0][0] = -6.733936E-03; band_smeta->legendre[1][0][1] = -2.540458E-04; band_smeta->legendre[1][0][2] = 2.394016E-06; band_smeta->legendre[1][0][3] = 0.000000E+00; /* Band 05 SCA 02 X */
686  band_smeta->legendre[1][1][0] = 1.054282E-01; band_smeta->legendre[1][1][1] = -1.014777E-02; band_smeta->legendre[1][1][2] = 9.520113E-06; band_smeta->legendre[1][1][3] = 0.000000E+00; /* Band 05 SCA 02 Y */
687  band_smeta->legendre[2][0][0] = 7.563138E-03; band_smeta->legendre[2][0][1] = -2.368287E-04; band_smeta->legendre[2][0][2] = 2.428350E-06; band_smeta->legendre[2][0][3] = 0.000000E+00; /* Band 05 SCA 03 X */
688  band_smeta->legendre[2][1][0] = 8.611789E-02; band_smeta->legendre[2][1][1] = -1.012312E-02; band_smeta->legendre[2][1][2] = 8.413135E-06; band_smeta->legendre[2][1][3] = 0.000000E+00; /* Band 05 SCA 03 Y */
689  band_smeta->legendre[3][0][0] = -7.001234E-03; band_smeta->legendre[3][0][1] = -1.606825E-04; band_smeta->legendre[3][0][2] = 2.504449E-06; band_smeta->legendre[3][0][3] = 0.000000E+00; /* Band 05 SCA 04 X */
690  band_smeta->legendre[3][1][0] = 6.694778E-02; band_smeta->legendre[3][1][1] = -1.005950E-02; band_smeta->legendre[3][1][2] = 6.469021E-06; band_smeta->legendre[3][1][3] = 0.000000E+00; /* Band 05 SCA 04 Y */
691  band_smeta->legendre[4][0][0] = 7.316009E-03; band_smeta->legendre[4][0][1] = -1.313087E-04; band_smeta->legendre[4][0][2] = 3.569648E-06; band_smeta->legendre[4][0][3] = 0.000000E+00; /* Band 05 SCA 05 X */
692  band_smeta->legendre[4][1][0] = 4.779486E-02; band_smeta->legendre[4][1][1] = -1.005205E-02; band_smeta->legendre[4][1][2] = 4.945513E-06; band_smeta->legendre[4][1][3] = 0.000000E+00; /* Band 05 SCA 05 Y */
693  band_smeta->legendre[5][0][0] = -7.139484E-03; band_smeta->legendre[5][0][1] = -7.031057E-05; band_smeta->legendre[5][0][2] = 2.654483E-06; band_smeta->legendre[5][0][3] = 0.000000E+00; /* Band 05 SCA 06 X */
694  band_smeta->legendre[5][1][0] = 2.873013E-02; band_smeta->legendre[5][1][1] = -1.001012E-02; band_smeta->legendre[5][1][2] = 2.652368E-06; band_smeta->legendre[5][1][3] = 0.000000E+00; /* Band 05 SCA 06 Y */
695  band_smeta->legendre[6][0][0] = 7.207137E-03; band_smeta->legendre[6][0][1] = -2.804846E-05; band_smeta->legendre[6][0][2] = 3.291859E-06; band_smeta->legendre[6][0][3] = 0.000000E+00; /* Band 05 SCA 07 X */
696  band_smeta->legendre[6][1][0] = 9.658464E-03; band_smeta->legendre[6][1][1] = -1.002388E-02; band_smeta->legendre[6][1][2] = 9.340756E-07; band_smeta->legendre[6][1][3] = 0.000000E+00; /* Band 05 SCA 07 Y */
697  band_smeta->legendre[7][0][0] = -7.181242E-03; band_smeta->legendre[7][0][1] = 2.117720E-05; band_smeta->legendre[7][0][2] = 1.919988E-06; band_smeta->legendre[7][0][3] = 0.000000E+00; /* Band 05 SCA 08 X */
698  band_smeta->legendre[7][1][0] = -9.381726E-03; band_smeta->legendre[7][1][1] = -1.000084E-02; band_smeta->legendre[7][1][2] = -1.522459E-06; band_smeta->legendre[7][1][3] = 0.000000E+00; /* Band 05 SCA 08 Y */
699  band_smeta->legendre[8][0][0] = 7.242036E-03; band_smeta->legendre[8][0][1] = 7.672176E-05; band_smeta->legendre[8][0][2] = 3.365141E-06; band_smeta->legendre[8][0][3] = 0.000000E+00; /* Band 05 SCA 09 X */
700  band_smeta->legendre[8][1][0] = -2.844051E-02; band_smeta->legendre[8][1][1] = -1.003335E-02; band_smeta->legendre[8][1][2] = -2.731339E-06; band_smeta->legendre[8][1][3] = 0.000000E+00; /* Band 05 SCA 09 Y */
701  band_smeta->legendre[9][0][0] = -7.100034E-03; band_smeta->legendre[9][0][1] = 1.137035E-04; band_smeta->legendre[9][0][2] = 3.345888E-06; band_smeta->legendre[9][0][3] = 0.000000E+00; /* Band 05 SCA 10 X */
702  band_smeta->legendre[9][1][0] = -4.752333E-02; band_smeta->legendre[9][1][1] = -1.002998E-02; band_smeta->legendre[9][1][2] = -3.887477E-06; band_smeta->legendre[9][1][3] = 0.000000E+00; /* Band 05 SCA 10 Y */
703  band_smeta->legendre[10][0][0] = 7.408601E-03; band_smeta->legendre[10][0][1] = 1.832994E-04; band_smeta->legendre[10][0][2] = 3.243504E-06; band_smeta->legendre[10][0][3] = 0.000000E+00; /* Band 05 SCA 11 X */
704  band_smeta->legendre[10][1][0] = -6.664623E-02; band_smeta->legendre[10][1][1] = -1.008223E-02; band_smeta->legendre[10][1][2] = -6.298208E-06; band_smeta->legendre[10][1][3] = 0.000000E+00; /* Band 05 SCA 11 Y */
705  band_smeta->legendre[11][0][0] = -6.905101E-03; band_smeta->legendre[11][0][1] = 2.040341E-04; band_smeta->legendre[11][0][2] = 2.331336E-06; band_smeta->legendre[11][0][3] = 0.000000E+00; /* Band 05 SCA 12 X */
706  band_smeta->legendre[11][1][0] = -8.586151E-02; band_smeta->legendre[11][1][1] = -1.009786E-02; band_smeta->legendre[11][1][2] = -6.992614E-06; band_smeta->legendre[11][1][3] = 0.000000E+00; /* Band 05 SCA 12 Y */
707  band_smeta->legendre[12][0][0] = 7.719478E-03; band_smeta->legendre[12][0][1] = 2.901260E-04; band_smeta->legendre[12][0][2] = 4.403218E-06; band_smeta->legendre[12][0][3] = 0.000000E+00; /* Band 05 SCA 13 X */
708  band_smeta->legendre[12][1][0] = -1.051216E-01; band_smeta->legendre[12][1][1] = -1.016991E-02; band_smeta->legendre[12][1][2] = -1.088250E-05; band_smeta->legendre[12][1][3] = 0.000000E+00; /* Band 05 SCA 13 Y */
709  band_smeta->legendre[13][0][0] = -6.574756E-03; band_smeta->legendre[13][0][1] = 2.975856E-04; band_smeta->legendre[13][0][2] = 4.196313E-06; band_smeta->legendre[13][0][3] = 0.000000E+00; /* Band 05 SCA 14 X */
710  band_smeta->legendre[13][1][0] = -1.245227E-01; band_smeta->legendre[13][1][1] = -1.020588E-02; band_smeta->legendre[13][1][2] = -1.075484E-05; band_smeta->legendre[13][1][3] = 0.000000E+00; /* Band 05 SCA 14 Y */
711  break;
712  case 6:
713  /* Sudipta new addition for OLI to extract SCA and Det numbers */
714  band_smeta->num_detectors = 494;
715  /* End Sudipta new addition for OLI */
716  band_smeta->legendre[0][0][0] = 1.345912E-02; band_smeta->legendre[0][0][1] = -3.507767E-04; band_smeta->legendre[0][0][2] = 3.365172E-06; band_smeta->legendre[0][0][3] = 0.000000E+00; /* Band 06 SCA 01 X */
717  band_smeta->legendre[0][1][0] = 1.247818E-01; band_smeta->legendre[0][1][1] = -1.024032E-02; band_smeta->legendre[0][1][2] = 1.115348E-05; band_smeta->legendre[0][1][3] = 0.000000E+00; /* Band 06 SCA 01 Y */
718  band_smeta->legendre[1][0][0] = -1.218389E-02; band_smeta->legendre[1][0][1] = -2.475154E-04; band_smeta->legendre[1][0][2] = 2.156406E-06; band_smeta->legendre[1][0][3] = 0.000000E+00; /* Band 06 SCA 02 X */
719  band_smeta->legendre[1][1][0] = 1.054227E-01; band_smeta->legendre[1][1][1] = -1.013990E-02; band_smeta->legendre[1][1][2] = 9.126058E-06; band_smeta->legendre[1][1][3] = 0.000000E+00; /* Band 06 SCA 02 Y */
720  band_smeta->legendre[2][0][0] = 1.305455E-02; band_smeta->legendre[2][0][1] = -2.415685E-04; band_smeta->legendre[2][0][2] = 2.632453E-06; band_smeta->legendre[2][0][3] = 0.000000E+00; /* Band 06 SCA 03 X */
721  band_smeta->legendre[2][1][0] = 8.611989E-02; band_smeta->legendre[2][1][1] = -1.013291E-02; band_smeta->legendre[2][1][2] = 8.623916E-06; band_smeta->legendre[2][1][3] = 0.000000E+00; /* Band 06 SCA 03 Y */
722  band_smeta->legendre[3][0][0] = -1.243446E-02; band_smeta->legendre[3][0][1] = -1.554256E-04; band_smeta->legendre[3][0][2] = 2.220429E-06; band_smeta->legendre[3][0][3] = 0.000000E+00; /* Band 06 SCA 04 X */
723  band_smeta->legendre[3][1][0] = 6.694548E-02; band_smeta->legendre[3][1][1] = -1.005139E-02; band_smeta->legendre[3][1][2] = 6.148496E-06; band_smeta->legendre[3][1][3] = 0.000000E+00; /* Band 06 SCA 04 Y */
724  band_smeta->legendre[4][0][0] = 1.279823E-02; band_smeta->legendre[4][0][1] = -1.341889E-04; band_smeta->legendre[4][0][2] = 3.601708E-06; band_smeta->legendre[4][0][3] = 0.000000E+00; /* Band 06 SCA 05 X */
725  band_smeta->legendre[4][1][0] = 4.779607E-02; band_smeta->legendre[4][1][1] = -1.006207E-02; band_smeta->legendre[4][1][2] = 4.764069E-06; band_smeta->legendre[4][1][3] = 0.000000E+00; /* Band 06 SCA 05 Y */
726  band_smeta->legendre[5][0][0] = -1.257318E-02; band_smeta->legendre[5][0][1] = -6.746209E-05; band_smeta->legendre[5][0][2] = 2.480779E-06; band_smeta->legendre[5][0][3] = 0.000000E+00; /* Band 06 SCA 06 X */
727  band_smeta->legendre[5][1][0] = 2.872349E-02; band_smeta->legendre[5][1][1] = -1.000256E-02; band_smeta->legendre[5][1][2] = 2.217992E-06; band_smeta->legendre[5][1][3] = 0.000000E+00; /* Band 06 SCA 06 Y */
728  band_smeta->legendre[6][0][0] = 1.268643E-02; band_smeta->legendre[6][0][1] = -2.811526E-05; band_smeta->legendre[6][0][2] = 3.152612E-06; band_smeta->legendre[6][0][3] = 0.000000E+00; /* Band 06 SCA 07 X */
729  band_smeta->legendre[6][1][0] = 9.656995E-03; band_smeta->legendre[6][1][1] = -1.003314E-02; band_smeta->legendre[6][1][2] = 8.068465E-07; band_smeta->legendre[6][1][3] = 0.000000E+00; /* Band 06 SCA 07 Y */
730  band_smeta->legendre[7][0][0] = -1.260225E-02; band_smeta->legendre[7][0][1] = 2.167850E-05; band_smeta->legendre[7][0][2] = 2.183492E-06; band_smeta->legendre[7][0][3] = 0.000000E+00; /* Band 06 SCA 08 X */
731  band_smeta->legendre[7][1][0] = -9.385234E-03; band_smeta->legendre[7][1][1] = -9.993460E-03; band_smeta->legendre[7][1][2] = -1.362179E-06; band_smeta->legendre[7][1][3] = 0.000000E+00; /* Band 06 SCA 08 Y */
732  band_smeta->legendre[8][0][0] = 1.272556E-02; band_smeta->legendre[8][0][1] = 7.837853E-05; band_smeta->legendre[8][0][2] = 3.701194E-06; band_smeta->legendre[8][0][3] = 0.000000E+00; /* Band 06 SCA 09 X */
733  band_smeta->legendre[8][1][0] = -2.844315E-02; band_smeta->legendre[8][1][1] = -1.004286E-02; band_smeta->legendre[8][1][2] = -2.888487E-06; band_smeta->legendre[8][1][3] = 0.000000E+00; /* Band 06 SCA 09 Y */
734  band_smeta->legendre[9][0][0] = -1.253014E-02; band_smeta->legendre[9][0][1] = 1.099448E-04; band_smeta->legendre[9][0][2] = 3.396994E-06; band_smeta->legendre[9][0][3] = 0.000000E+00; /* Band 06 SCA 10 X */
735  band_smeta->legendre[9][1][0] = -4.752943E-02; band_smeta->legendre[9][1][1] = -1.002233E-02; band_smeta->legendre[9][1][2] = -3.839305E-06; band_smeta->legendre[9][1][3] = 0.000000E+00; /* Band 06 SCA 10 Y */
736  band_smeta->legendre[10][0][0] = 1.289617E-02; band_smeta->legendre[10][0][1] = 1.875573E-04; band_smeta->legendre[10][0][2] = 3.327206E-06; band_smeta->legendre[10][0][3] = 0.000000E+00; /* Band 06 SCA 11 X */
737  band_smeta->legendre[10][1][0] = -6.665283E-02; band_smeta->legendre[10][1][1] = -1.009191E-02; band_smeta->legendre[10][1][2] = -6.373350E-06; band_smeta->legendre[10][1][3] = 0.000000E+00; /* Band 06 SCA 11 Y */
738  band_smeta->legendre[11][0][0] = -1.234174E-02; band_smeta->legendre[11][0][1] = 1.996667E-04; band_smeta->legendre[11][0][2] = 2.215343E-06; band_smeta->legendre[11][0][3] = 0.000000E+00; /* Band 06 SCA 12 X */
739  band_smeta->legendre[11][1][0] = -8.585719E-02; band_smeta->legendre[11][1][1] = -1.008995E-02; band_smeta->legendre[11][1][2] = -7.394567E-06; band_smeta->legendre[11][1][3] = 0.000000E+00; /* Band 06 SCA 12 Y */
740  band_smeta->legendre[12][0][0] = 1.322300E-02; band_smeta->legendre[12][0][1] = 2.949716E-04; band_smeta->legendre[12][0][2] = 4.877904E-06; band_smeta->legendre[12][0][3] = 0.000000E+00; /* Band 06 SCA 13 X */
741  band_smeta->legendre[12][1][0] = -1.051175E-01; band_smeta->legendre[12][1][1] = -1.017975E-02; band_smeta->legendre[12][1][2] = -1.073654E-05; band_smeta->legendre[12][1][3] = 0.000000E+00; /* Band 06 SCA 13 Y */
742  band_smeta->legendre[13][0][0] = -1.203830E-02; band_smeta->legendre[13][0][1] = 2.901823E-04; band_smeta->legendre[13][0][2] = 4.433538E-06; band_smeta->legendre[13][0][3] = 0.000000E+00; /* Band 06 SCA 14 X */
743  band_smeta->legendre[13][1][0] = -1.245163E-01; band_smeta->legendre[13][1][1] = -1.019838E-02; band_smeta->legendre[13][1][2] = -1.073917E-05; band_smeta->legendre[13][1][3] = 0.000000E+00; /* Band 06 SCA 14 Y */
744  break;
745  case 7:
746  /* Sudipta new addition for OLI to extract SCA and Det numbers */
747  band_smeta->num_detectors = 494;
748  /* End Sudipta new addition for OLI */
749  band_smeta->legendre[0][0][0] = 1.222355E-02; band_smeta->legendre[0][0][1] = -3.488484E-04; band_smeta->legendre[0][0][2] = 3.503357E-06; band_smeta->legendre[0][0][3] = 0.000000E+00; /* Band 07 SCA 01 X */
750  band_smeta->legendre[0][1][0] = 1.247830E-01; band_smeta->legendre[0][1][1] = -1.023845E-02; band_smeta->legendre[0][1][2] = 1.085608E-05; band_smeta->legendre[0][1][3] = 0.000000E+00; /* Band 07 SCA 01 Y */
751  band_smeta->legendre[1][0][0] = -1.095263E-02; band_smeta->legendre[1][0][1] = -2.488298E-04; band_smeta->legendre[1][0][2] = 2.346719E-06; band_smeta->legendre[1][0][3] = 0.000000E+00; /* Band 07 SCA 02 X */
752  band_smeta->legendre[1][1][0] = 1.054242E-01; band_smeta->legendre[1][1][1] = -1.014190E-02; band_smeta->legendre[1][1][2] = 9.456518E-06; band_smeta->legendre[1][1][3] = 0.000000E+00; /* Band 07 SCA 02 Y */
753  band_smeta->legendre[2][0][0] = 1.182350E-02; band_smeta->legendre[2][0][1] = -2.402396E-04; band_smeta->legendre[2][0][2] = 2.531902E-06; band_smeta->legendre[2][0][3] = 0.000000E+00; /* Band 07 SCA 03 X */
754  band_smeta->legendre[2][1][0] = 8.612055E-02; band_smeta->legendre[2][1][1] = -1.013097E-02; band_smeta->legendre[2][1][2] = 8.766255E-06; band_smeta->legendre[2][1][3] = 0.000000E+00; /* Band 07 SCA 03 Y */
755  band_smeta->legendre[3][0][0] = -1.120772E-02; band_smeta->legendre[3][0][1] = -1.560388E-04; band_smeta->legendre[3][0][2] = 2.279632E-06; band_smeta->legendre[3][0][3] = 0.000000E+00; /* Band 07 SCA 04 X */
756  band_smeta->legendre[3][1][0] = 6.694686E-02; band_smeta->legendre[3][1][1] = -1.005347E-02; band_smeta->legendre[3][1][2] = 5.960465E-06; band_smeta->legendre[3][1][3] = 0.000000E+00; /* Band 07 SCA 04 Y */
757  band_smeta->legendre[4][0][0] = 1.157019E-02; band_smeta->legendre[4][0][1] = -1.332875E-04; band_smeta->legendre[4][0][2] = 3.610566E-06; band_smeta->legendre[4][0][3] = 0.000000E+00; /* Band 07 SCA 05 X */
758  band_smeta->legendre[4][1][0] = 4.779614E-02; band_smeta->legendre[4][1][1] = -1.006004E-02; band_smeta->legendre[4][1][2] = 4.781929E-06; band_smeta->legendre[4][1][3] = 0.000000E+00; /* Band 07 SCA 05 Y */
759  band_smeta->legendre[5][0][0] = -1.134847E-02; band_smeta->legendre[5][0][1] = -6.763984E-05; band_smeta->legendre[5][0][2] = 2.478512E-06; band_smeta->legendre[5][0][3] = 0.000000E+00; /* Band 07 SCA 06 X */
760  band_smeta->legendre[5][1][0] = 2.872411E-02; band_smeta->legendre[5][1][1] = -1.000435E-02; band_smeta->legendre[5][1][2] = 2.127892E-06; band_smeta->legendre[5][1][3] = 0.000000E+00; /* Band 07 SCA 06 Y */
761  band_smeta->legendre[6][0][0] = 1.145985E-02; band_smeta->legendre[6][0][1] = -2.758350E-05; band_smeta->legendre[6][0][2] = 2.975109E-06; band_smeta->legendre[6][0][3] = 0.000000E+00; /* Band 07 SCA 07 X */
762  band_smeta->legendre[6][1][0] = 9.656917E-03; band_smeta->legendre[6][1][1] = -1.003119E-02; band_smeta->legendre[6][1][2] = 9.144357E-07; band_smeta->legendre[6][1][3] = 0.000000E+00; /* Band 07 SCA 07 Y */
763  band_smeta->legendre[7][0][0] = -1.137774E-02; band_smeta->legendre[7][0][1] = 2.186020E-05; band_smeta->legendre[7][0][2] = 2.301565E-06; band_smeta->legendre[7][0][3] = 0.000000E+00; /* Band 07 SCA 08 X */
764  band_smeta->legendre[7][1][0] = -9.385022E-03; band_smeta->legendre[7][1][1] = -9.995444E-03; band_smeta->legendre[7][1][2] = -1.412133E-06; band_smeta->legendre[7][1][3] = 0.000000E+00; /* Band 07 SCA 08 Y */
765  band_smeta->legendre[8][0][0] = 1.149831E-02; band_smeta->legendre[8][0][1] = 7.811905E-05; band_smeta->legendre[8][0][2] = 3.758388E-06; band_smeta->legendre[8][0][3] = 0.000000E+00; /* Band 07 SCA 09 X */
766  band_smeta->legendre[8][1][0] = -2.844359E-02; band_smeta->legendre[8][1][1] = -1.004084E-02; band_smeta->legendre[8][1][2] = -2.853792E-06; band_smeta->legendre[8][1][3] = 0.000000E+00; /* Band 07 SCA 09 Y */
767  band_smeta->legendre[9][0][0] = -1.130446E-02; band_smeta->legendre[9][0][1] = 1.109295E-04; band_smeta->legendre[9][0][2] = 3.599788E-06; band_smeta->legendre[9][0][3] = 0.000000E+00; /* Band 07 SCA 10 X */
768  band_smeta->legendre[9][1][0] = -4.752999E-02; band_smeta->legendre[9][1][1] = -1.002429E-02; band_smeta->legendre[9][1][2] = -3.890668E-06; band_smeta->legendre[9][1][3] = 0.000000E+00; /* Band 07 SCA 10 Y */
769  band_smeta->legendre[10][0][0] = 1.166728E-02; band_smeta->legendre[10][0][1] = 1.869466E-04; band_smeta->legendre[10][0][2] = 3.371033E-06; band_smeta->legendre[10][0][3] = 0.000000E+00; /* Band 07 SCA 11 X */
770  band_smeta->legendre[10][1][0] = -6.665389E-02; band_smeta->legendre[10][1][1] = -1.008986E-02; band_smeta->legendre[10][1][2] = -6.451903E-06; band_smeta->legendre[10][1][3] = 0.000000E+00; /* Band 07 SCA 11 Y */
771  band_smeta->legendre[11][0][0] = -1.111281E-02; band_smeta->legendre[11][0][1] = 2.009141E-04; band_smeta->legendre[11][0][2] = 2.472552E-06; band_smeta->legendre[11][0][3] = 0.000000E+00; /* Band 07 SCA 12 X */
772  band_smeta->legendre[11][1][0] = -8.585818E-02; band_smeta->legendre[11][1][1] = -1.009201E-02; band_smeta->legendre[11][1][2] = -7.282292E-06; band_smeta->legendre[11][1][3] = 0.000000E+00; /* Band 07 SCA 12 Y */
773  band_smeta->legendre[12][0][0] = 1.199052E-02; band_smeta->legendre[12][0][1] = 2.939047E-04; band_smeta->legendre[12][0][2] = 4.901800E-06; band_smeta->legendre[12][0][3] = 0.000000E+00; /* Band 07 SCA 13 X */
774  band_smeta->legendre[12][1][0] = -1.051191E-01; band_smeta->legendre[12][1][1] = -1.017766E-02; band_smeta->legendre[12][1][2] = -1.058382E-05; band_smeta->legendre[12][1][3] = 0.000000E+00; /* Band 07 SCA 13 Y */
775  band_smeta->legendre[13][0][0] = -1.080512E-02; band_smeta->legendre[13][0][1] = 2.924805E-04; band_smeta->legendre[13][0][2] = 4.558129E-06; band_smeta->legendre[13][0][3] = 0.000000E+00; /* Band 07 SCA 14 X */
776  band_smeta->legendre[13][1][0] = -1.245180E-01; band_smeta->legendre[13][1][1] = -1.020024E-02; band_smeta->legendre[13][1][2] = -1.066432E-05; band_smeta->legendre[13][1][3] = 0.000000E+00; /* Band 07 SCA 14 Y */
777  break;
778  case 8:
779  /* Sudipta new addition for OLI to extract SCA and Det numbers */
780  band_smeta->num_detectors = 988;
781  /* End Sudipta new addition for OLI */
782  band_smeta->legendre[0][0][0] = 4.252524E-03; band_smeta->legendre[0][0][1] = -3.375425E-04; band_smeta->legendre[0][0][2] = 3.093750E-06; band_smeta->legendre[0][0][3] = 0.000000E+00; /* Band 08 SCA 01 X */
783  band_smeta->legendre[0][1][0] = 1.247783E-01; band_smeta->legendre[0][1][1] = -1.023544E-02; band_smeta->legendre[0][1][2] = 1.111046E-05; band_smeta->legendre[0][1][3] = 0.000000E+00; /* Band 08 SCA 01 Y */
784  band_smeta->legendre[1][0][0] = -3.029343E-03; band_smeta->legendre[1][0][1] = -2.585621E-04; band_smeta->legendre[1][0][2] = 2.478111E-06; band_smeta->legendre[1][0][3] = 0.000000E+00; /* Band 08 SCA 02 X */
785  band_smeta->legendre[1][1][0] = 1.054291E-01; band_smeta->legendre[1][1][1] = -1.016342E-02; band_smeta->legendre[1][1][2] = 9.522094E-06; band_smeta->legendre[1][1][3] = 0.000000E+00; /* Band 08 SCA 02 Y */
786  band_smeta->legendre[2][0][0] = 3.884395E-03; band_smeta->legendre[2][0][1] = -2.339566E-04; band_smeta->legendre[2][0][2] = 2.524238E-06; band_smeta->legendre[2][0][3] = 0.000000E+00; /* Band 08 SCA 03 X */
787  band_smeta->legendre[2][1][0] = 8.611699E-02; band_smeta->legendre[2][1][1] = -1.012730E-02; band_smeta->legendre[2][1][2] = 8.254239E-06; band_smeta->legendre[2][1][3] = 0.000000E+00; /* Band 08 SCA 03 Y */
788  band_smeta->legendre[3][0][0] = -3.307669E-03; band_smeta->legendre[3][0][1] = -1.635348E-04; band_smeta->legendre[3][0][2] = 2.517627E-06; band_smeta->legendre[3][0][3] = 0.000000E+00; /* Band 08 SCA 04 X */
789  band_smeta->legendre[3][1][0] = 6.694935E-02; band_smeta->legendre[3][1][1] = -1.007514E-02; band_smeta->legendre[3][1][2] = 6.410045E-06; band_smeta->legendre[3][1][3] = 0.000000E+00; /* Band 08 SCA 04 Y */
790  band_smeta->legendre[4][0][0] = 3.645584E-03; band_smeta->legendre[4][0][1] = -1.298436E-04; band_smeta->legendre[4][0][2] = 3.693088E-06; band_smeta->legendre[4][0][3] = 0.000000E+00; /* Band 08 SCA 05 X */
791  band_smeta->legendre[4][1][0] = 4.779417E-02; band_smeta->legendre[4][1][1] = -1.005610E-02; band_smeta->legendre[4][1][2] = 5.053775E-06; band_smeta->legendre[4][1][3] = 0.000000E+00; /* Band 08 SCA 05 Y */
792  band_smeta->legendre[5][0][0] = -3.452992E-03; band_smeta->legendre[5][0][1] = -7.148948E-05; band_smeta->legendre[5][0][2] = 3.033732E-06; band_smeta->legendre[5][0][3] = 0.000000E+00; /* Band 08 SCA 06 X */
793  band_smeta->legendre[5][1][0] = 2.873058E-02; band_smeta->legendre[5][1][1] = -1.002593E-02; band_smeta->legendre[5][1][2] = 2.745292E-06; band_smeta->legendre[5][1][3] = 0.000000E+00; /* Band 08 SCA 06 Y */
794  band_smeta->legendre[6][0][0] = 3.540947E-03; band_smeta->legendre[6][0][1] = -2.783162E-05; band_smeta->legendre[6][0][2] = 3.269470E-06; band_smeta->legendre[6][0][3] = 0.000000E+00; /* Band 08 SCA 07 X */
795  band_smeta->legendre[6][1][0] = 9.658145E-03; band_smeta->legendre[6][1][1] = -1.002781E-02; band_smeta->legendre[6][1][2] = 1.039589E-06; band_smeta->legendre[6][1][3] = 0.000000E+00; /* Band 08 SCA 07 Y */
796  band_smeta->legendre[7][0][0] = -3.495677E-03; band_smeta->legendre[7][0][1] = 2.132260E-05; band_smeta->legendre[7][0][2] = 2.430337E-06; band_smeta->legendre[7][0][3] = 0.000000E+00; /* Band 08 SCA 08 X */
797  band_smeta->legendre[7][1][0] = -9.381522E-03; band_smeta->legendre[7][1][1] = -1.001653E-02; band_smeta->legendre[7][1][2] = -1.630559E-06; band_smeta->legendre[7][1][3] = 0.000000E+00; /* Band 08 SCA 08 Y */
798  band_smeta->legendre[8][0][0] = 3.575055E-03; band_smeta->legendre[8][0][1] = 7.565249E-05; band_smeta->legendre[8][0][2] = 3.355898E-06; band_smeta->legendre[8][0][3] = 0.000000E+00; /* Band 08 SCA 09 X */
799  band_smeta->legendre[8][1][0] = -2.844108E-02; band_smeta->legendre[8][1][1] = -1.003763E-02; band_smeta->legendre[8][1][2] = -2.853618E-06; band_smeta->legendre[8][1][3] = 0.000000E+00; /* Band 08 SCA 09 Y */
800  band_smeta->legendre[9][0][0] = -3.410597E-03; band_smeta->legendre[9][0][1] = 1.155142E-04; band_smeta->legendre[9][0][2] = 3.409904E-06; band_smeta->legendre[9][0][3] = 0.000000E+00; /* Band 08 SCA 10 X */
801  band_smeta->legendre[9][1][0] = -4.752315E-02; band_smeta->legendre[9][1][1] = -1.004586E-02; band_smeta->legendre[9][1][2] = -4.291685E-06; band_smeta->legendre[9][1][3] = 0.000000E+00; /* Band 08 SCA 10 Y */
802  band_smeta->legendre[10][0][0] = 3.735765E-03; band_smeta->legendre[10][0][1] = 1.805677E-04; band_smeta->legendre[10][0][2] = 3.377491E-06; band_smeta->legendre[10][0][3] = 0.000000E+00; /* Band 08 SCA 11 X */
803  band_smeta->legendre[10][1][0] = -6.664703E-02; band_smeta->legendre[10][1][1] = -1.008641E-02; band_smeta->legendre[10][1][2] = -6.321028E-06; band_smeta->legendre[10][1][3] = 0.000000E+00; /* Band 08 SCA 11 Y */
804  band_smeta->legendre[11][0][0] = -3.206932E-03; band_smeta->legendre[11][0][1] = 2.077678E-04; band_smeta->legendre[11][0][2] = 2.716352E-06; band_smeta->legendre[11][0][3] = 0.000000E+00; /* Band 08 SCA 12 X */
805  band_smeta->legendre[11][1][0] = -8.586160E-02; band_smeta->legendre[11][1][1] = -1.011377E-02; band_smeta->legendre[11][1][2] = -7.109927E-06; band_smeta->legendre[11][1][3] = 0.000000E+00; /* Band 08 SCA 12 Y */
806  band_smeta->legendre[12][0][0] = 4.033433E-03; band_smeta->legendre[12][0][1] = 2.857025E-04; band_smeta->legendre[12][0][2] = 4.541956E-06; band_smeta->legendre[12][0][3] = 0.000000E+00; /* Band 08 SCA 13 X */
807  band_smeta->legendre[12][1][0] = -1.051228E-01; band_smeta->legendre[12][1][1] = -1.017396E-02; band_smeta->legendre[12][1][2] = -1.083649E-05; band_smeta->legendre[12][1][3] = 0.000000E+00; /* Band 08 SCA 13 Y */
808  band_smeta->legendre[13][0][0] = -2.862726E-03; band_smeta->legendre[13][0][1] = 3.030336E-04; band_smeta->legendre[13][0][2] = 4.139959E-06; band_smeta->legendre[13][0][3] = 0.000000E+00; /* Band 08 SCA 14 X */
809  band_smeta->legendre[13][1][0] = -1.245235E-01; band_smeta->legendre[13][1][1] = -1.022128E-02; band_smeta->legendre[13][1][2] = -1.074760E-05; band_smeta->legendre[13][1][3] = 0.000000E+00; /* Band 08 SCA 14 Y */
810  break;
811  case 9:
812  /* Sudipta new addition for OLI to extract SCA and Det numbers */
813  band_smeta->num_detectors = 494;
814  /* End Sudipta new addition for OLI */
815  band_smeta->legendre[0][0][0] = 1.469991E-02; band_smeta->legendre[0][0][1] = -3.526521E-04; band_smeta->legendre[0][0][2] = 2.996944E-06; band_smeta->legendre[0][0][3] = 0.000000E+00; /* Band 09 SCA 01 X */
816  band_smeta->legendre[0][1][0] = 1.247814E-01; band_smeta->legendre[0][1][1] = -1.024292E-02; band_smeta->legendre[0][1][2] = 1.250792E-05; band_smeta->legendre[0][1][3] = 0.000000E+00; /* Band 09 SCA 01 Y */
817  band_smeta->legendre[1][0][0] = -1.340998E-02; band_smeta->legendre[1][0][1] = -2.443003E-04; band_smeta->legendre[1][0][2] = 3.343894E-06; band_smeta->legendre[1][0][3] = 0.000000E+00; /* Band 09 SCA 02 X */
818  band_smeta->legendre[1][1][0] = 1.054212E-01; band_smeta->legendre[1][1][1] = -1.013747E-02; band_smeta->legendre[1][1][2] = 8.813593E-06; band_smeta->legendre[1][1][3] = 0.000000E+00; /* Band 09 SCA 02 Y */
819  band_smeta->legendre[2][0][0] = 1.428952E-02; band_smeta->legendre[2][0][1] = -2.433210E-04; band_smeta->legendre[2][0][2] = 2.593979E-06; band_smeta->legendre[2][0][3] = 0.000000E+00; /* Band 09 SCA 03 X */
820  band_smeta->legendre[2][1][0] = 8.611970E-02; band_smeta->legendre[2][1][1] = -1.013474E-02; band_smeta->legendre[2][1][2] = 8.225067E-06; band_smeta->legendre[2][1][3] = 0.000000E+00; /* Band 09 SCA 03 Y */
821  band_smeta->legendre[3][0][0] = -1.365834E-02; band_smeta->legendre[3][0][1] = -1.516531E-04; band_smeta->legendre[3][0][2] = 1.819539E-06; band_smeta->legendre[3][0][3] = 0.000000E+00; /* Band 09 SCA 04 X */
822  band_smeta->legendre[3][1][0] = 6.694384E-02; band_smeta->legendre[3][1][1] = -1.004983E-02; band_smeta->legendre[3][1][2] = 5.962782E-06; band_smeta->legendre[3][1][3] = 0.000000E+00; /* Band 09 SCA 04 Y */
823  band_smeta->legendre[4][0][0] = 1.403122E-02; band_smeta->legendre[4][0][1] = -1.362427E-04; band_smeta->legendre[4][0][2] = 4.626827E-06; band_smeta->legendre[4][0][3] = 0.000000E+00; /* Band 09 SCA 05 X */
824  band_smeta->legendre[4][1][0] = 4.779595E-02; band_smeta->legendre[4][1][1] = -1.006435E-02; band_smeta->legendre[4][1][2] = 4.306440E-06; band_smeta->legendre[4][1][3] = 0.000000E+00; /* Band 09 SCA 05 Y */
825  band_smeta->legendre[5][0][0] = -1.379413E-02; band_smeta->legendre[5][0][1] = -6.633253E-05; band_smeta->legendre[5][0][2] = 2.684987E-06; band_smeta->legendre[5][0][3] = 0.000000E+00; /* Band 09 SCA 06 X */
826  band_smeta->legendre[5][1][0] = 2.872240E-02; band_smeta->legendre[5][1][1] = -1.000079E-02; band_smeta->legendre[5][1][2] = 1.858352E-06; band_smeta->legendre[5][1][3] = 0.000000E+00; /* Band 09 SCA 06 Y */
827  band_smeta->legendre[6][0][0] = 1.391807E-02; band_smeta->legendre[6][0][1] = -2.867362E-05; band_smeta->legendre[6][0][2] = 4.334720E-06; band_smeta->legendre[6][0][3] = 0.000000E+00; /* Band 09 SCA 07 X */
828  band_smeta->legendre[6][1][0] = 9.655709E-03; band_smeta->legendre[6][1][1] = -1.003472E-02; band_smeta->legendre[6][1][2] = 1.728144E-06; band_smeta->legendre[6][1][3] = 0.000000E+00; /* Band 09 SCA 07 Y */
829  band_smeta->legendre[7][0][0] = -1.382212E-02; band_smeta->legendre[7][0][1] = 2.140439E-05; band_smeta->legendre[7][0][2] = 2.211910E-06; band_smeta->legendre[7][0][3] = 0.000000E+00; /* Band 09 SCA 08 X */
830  band_smeta->legendre[7][1][0] = -9.385835E-03; band_smeta->legendre[7][1][1] = -9.991244E-03; band_smeta->legendre[7][1][2] = -9.635907E-07; band_smeta->legendre[7][1][3] = 0.000000E+00; /* Band 09 SCA 08 Y */
831  band_smeta->legendre[8][0][0] = 1.395698E-02; band_smeta->legendre[8][0][1] = 7.925795E-05; band_smeta->legendre[8][0][2] = 3.245003E-06; band_smeta->legendre[8][0][3] = 0.000000E+00; /* Band 09 SCA 09 X */
832  band_smeta->legendre[8][1][0] = -2.844433E-02; band_smeta->legendre[8][1][1] = -1.004471E-02; band_smeta->legendre[8][1][2] = -2.439607E-06; band_smeta->legendre[8][1][3] = 0.000000E+00; /* Band 09 SCA 09 Y */
833  band_smeta->legendre[9][0][0] = -1.375203E-02; band_smeta->legendre[9][0][1] = 1.076389E-04; band_smeta->legendre[9][0][2] = 2.116246E-06; band_smeta->legendre[9][0][3] = 0.000000E+00; /* Band 09 SCA 10 X */
834  band_smeta->legendre[9][1][0] = -4.753074E-02; band_smeta->legendre[9][1][1] = -1.002063E-02; band_smeta->legendre[9][1][2] = -3.717124E-06; band_smeta->legendre[9][1][3] = 0.000000E+00; /* Band 09 SCA 10 Y */
835  band_smeta->legendre[10][0][0] = 1.413111E-02; band_smeta->legendre[10][0][1] = 1.889807E-04; band_smeta->legendre[10][0][2] = 3.500592E-06; band_smeta->legendre[10][0][3] = 0.000000E+00; /* Band 09 SCA 11 X */
836  band_smeta->legendre[10][1][0] = -6.665388E-02; band_smeta->legendre[10][1][1] = -1.009329E-02; band_smeta->legendre[10][1][2] = -6.154595E-06; band_smeta->legendre[10][1][3] = 0.000000E+00; /* Band 09 SCA 11 Y */
837  band_smeta->legendre[11][0][0] = -1.356603E-02; band_smeta->legendre[11][0][1] = 1.957164E-04; band_smeta->legendre[11][0][2] = 2.889459E-06; band_smeta->legendre[11][0][3] = 0.000000E+00; /* Band 09 SCA 12 X */
838  band_smeta->legendre[11][1][0] = -8.585872E-02; band_smeta->legendre[11][1][1] = -1.008862E-02; band_smeta->legendre[11][1][2] = -7.131130E-06; band_smeta->legendre[11][1][3] = 0.000000E+00; /* Band 09 SCA 12 Y */
839  band_smeta->legendre[12][0][0] = 1.446188E-02; band_smeta->legendre[12][0][1] = 2.980366E-04; band_smeta->legendre[12][0][2] = 5.004141E-06; band_smeta->legendre[12][0][3] = 0.000000E+00; /* Band 09 SCA 13 X */
840  band_smeta->legendre[12][1][0] = -1.051188E-01; band_smeta->legendre[12][1][1] = -1.018152E-02; band_smeta->legendre[12][1][2] = -1.215252E-05; band_smeta->legendre[12][1][3] = 0.000000E+00; /* Band 09 SCA 13 Y */
841  band_smeta->legendre[13][0][0] = -1.326883E-02; band_smeta->legendre[13][0][1] = 2.858092E-04; band_smeta->legendre[13][0][2] = 4.411644E-06; band_smeta->legendre[13][0][3] = 0.000000E+00; /* Band 09 SCA 14 X */
842  band_smeta->legendre[13][1][0] = -1.245172E-01; band_smeta->legendre[13][1][1] = -1.019636E-02; band_smeta->legendre[13][1][2] = -1.009994E-05; band_smeta->legendre[13][1][3] = 0.000000E+00; /* Band 09 SCA 14 Y */
843  break;
844  case 10:
845  band_smeta->nsca = 3;
846  /* Sudipta new addition for OLI to extract SCA and Det numbers */
847  band_smeta->num_detectors = 640;
848  /* End Sudipta new addition for OLI */
849  band_smeta->align[0][0] = 0.999995230;
850  band_smeta->align[0][1] = 0.002234010;
851  band_smeta->align[0][2] = -0.002132570;
852  band_smeta->align[1][0] = -0.002233663;
853  band_smeta->align[1][1] = 0.999997491;
854  band_smeta->align[1][2] = 0.000165723;
855  band_smeta->align[2][0] = 0.002132934;
856  band_smeta->align[2][1] = -0.000160959;
857  band_smeta->align[2][2] = 0.999997712;
858  band_smeta->legendre[0][0][0] = -4.600619E-02; band_smeta->legendre[0][0][1] = 5.355540E-05; band_smeta->legendre[0][0][2] = -2.367151E-05; band_smeta->legendre[0][0][3] = 2.580050E-06; /* Band 10 SCA 01 X */
859  band_smeta->legendre[0][1][0] = -8.639810E-02; band_smeta->legendre[0][1][1] = 4.553034E-02; band_smeta->legendre[0][1][2] = -1.224341E-04; band_smeta->legendre[0][1][3] = 2.005583E-05; /* Band 10 SCA 01 Y */
860  band_smeta->legendre[1][0][0] = 4.041600E-02; band_smeta->legendre[1][0][1] = -6.367114E-05; band_smeta->legendre[1][0][2] = 1.486799E-05; band_smeta->legendre[1][0][3] = 8.984839E-07; /* Band 10 SCA 02 X */
861  band_smeta->legendre[1][1][0] = 7.383249E-04; band_smeta->legendre[1][1][1] = 4.520092E-02; band_smeta->legendre[1][1][2] = 1.186375E-06; band_smeta->legendre[1][1][3] = 1.059907E-05; /* Band 10 SCA 02 Y */
862  band_smeta->legendre[2][0][0] = -4.582177E-02; band_smeta->legendre[2][0][1] = -1.780177E-04; band_smeta->legendre[2][0][2] = -2.521064E-05; band_smeta->legendre[2][0][3] = -3.017250E-06; /* Band 10 SCA 03 X */
863  band_smeta->legendre[2][1][0] = 8.748055E-02; band_smeta->legendre[2][1][1] = 4.553768E-02; band_smeta->legendre[2][1][2] = 1.243330E-04; band_smeta->legendre[2][1][3] = 1.840046E-05; /* Band 10 SCA 03 Y */
864  break;
865  case 11:
866  band_smeta->nsca = 3;
867  /* Sudipta new addition for OLI to extract SCA and Det numbers */
868  band_smeta->num_detectors = 640;
869  /* End Sudipta new addition for OLI */
870  band_smeta->align[0][0] = 0.999995230;
871  band_smeta->align[0][1] = 0.002234010;
872  band_smeta->align[0][2] = -0.002132570;
873  band_smeta->align[1][0] = -0.002233663;
874  band_smeta->align[1][1] = 0.999997491;
875  band_smeta->align[1][2] = 0.000165723;
876  band_smeta->align[2][0] = 0.002132934;
877  band_smeta->align[2][1] = -0.000160959;
878  band_smeta->align[2][2] = 0.999997712;
879  band_smeta->legendre[0][0][0] = -2.818374E-02; band_smeta->legendre[0][0][1] = 1.420312E-05; band_smeta->legendre[0][0][2] = -1.583177E-05; band_smeta->legendre[0][0][3] = 4.703008E-07; /* Band 11 SCA 01 X */
880  band_smeta->legendre[0][1][0] = -8.634943E-02; band_smeta->legendre[0][1][1] = 4.550868E-02; band_smeta->legendre[0][1][2] = -1.188939E-04; band_smeta->legendre[0][1][3] = 2.004849E-05; /* Band 11 SCA 01 Y */
881  band_smeta->legendre[1][0][0] = 2.190447E-02; band_smeta->legendre[1][0][1] = -6.403253E-05; band_smeta->legendre[1][0][2] = 9.479177E-06; band_smeta->legendre[1][0][3] = -8.414291E-07; /* Band 11 SCA 02 X */
882  band_smeta->legendre[1][1][0] = 7.106738E-04; band_smeta->legendre[1][1][1] = 4.518972E-02; band_smeta->legendre[1][1][2] = 2.959635E-06; band_smeta->legendre[1][1][3] = 9.602212E-06; /* Band 11 SCA 02 Y */
883  band_smeta->legendre[2][0][0] = -2.910073E-02; band_smeta->legendre[2][0][1] = -1.301388E-04; band_smeta->legendre[2][0][2] = -1.422378E-05; band_smeta->legendre[2][0][3] = -2.167499E-06; /* Band 11 SCA 03 X */
884  band_smeta->legendre[2][1][0] = 8.747419E-02; band_smeta->legendre[2][1][1] = 4.551648E-02; band_smeta->legendre[2][1][2] = 1.202780E-04; band_smeta->legendre[2][1][3] = 1.648944E-05; /* Band 11 SCA 03 Y */
885  break;
886  default:
887  IAS_LOG_ERROR("No LOS model for user band number %d.", band_smeta->band);
888  return(ERROR);
889  }
890 
891  return(SUCCESS);
892 }
893 
894 
896  SMETA *smeta, /* Product metadata input */
897  SMETA_BAND_LS *band_smeta ) /* Band metadata structure to load */
898 {
899  int l5_bumper_date[] = { 2002, 3, 27 }; /* Date the L5 TM was switched to bumper mode */
900  int l7_bumper_date[] = { 2007, 3, 31 }; /* Date the L7 ETM+ was switched to bumper mode */
901  double *Along_Scan_Band_Offsets;
902  double *Across_Scan_Band_Offsets;
903  double L7_Along_Scan_Band_Offsets[IAS_MAX_NBANDS_LS] =
904  {+3627.908,+2564.326,+1500.619,+438.054,-2579.286,-4073.554,-1474.955,+4692.000};
905  double L7_Across_Scan_Band_Offsets[IAS_MAX_NBANDS_LS] =
906  {+1.255,+0.592,-0.028,-1.466,+17.242,+32.479,+17.042,+0.000};
907  double L5_Along_Scan_Band_Offsets[IAS_MAX_NBANDS_LS] =
908  {+3616.293,+2554.010,+1491.440,+429.773,-2576.042,-4077.805,-1473.056};
909  double L5_Across_Scan_Band_Offsets[IAS_MAX_NBANDS_LS] =
910  {-12.147,-12.250,-13.203,-12.902,+4.675,-6.354,+5.719};
911  //double L4_Along_Scan_Band_Offsets[IAS_MAX_NBANDS_LS] =
912  // {+3571.222,+2510.043,+1448.742,+388.334,-2600.691,-4078.296,-1496.897};
913  //double L4_Across_Scan_Band_Offsets[IAS_MAX_NBANDS_LS] =
914  // {+16.008,+16.015,+17.933,+18.136,-0.850,-16.723,-1.307};
915  double fs2m, fm2e, rs2m, rm2e; /* First half/second half scan angles */
916  int bumper_days; /* Days since switch to bumper mode */
917 
918  /* Set defaults based upon spacecraft ID */
919  band_smeta->nsca = 1;
920 
921  if ( smeta->spacecraft_id == IAS_L5 )
922  {
923  band_smeta->nscans = 374;
924  band_smeta->align[0][0] = 9.99999851E-01;
925  band_smeta->align[0][1] = +5.45640973E-04;
926  band_smeta->align[0][2] = -9.00000000E-06;
927  band_smeta->align[1][0] = -5.45647569E-04;
928  band_smeta->align[1][1] = 9.99999570E-01;
929  band_smeta->align[1][2] = -7.49999930E-04;
930  band_smeta->align[2][0] = +8.59076544E-06;
931  band_smeta->align[2][1] = +7.50004729E-04;
932  band_smeta->align[2][2] = 9.99999719E-01;
933  Along_Scan_Band_Offsets = L5_Along_Scan_Band_Offsets;
934  Across_Scan_Band_Offsets = L5_Across_Scan_Band_Offsets;
935  }
936  else
937  {
938  band_smeta->nscans = 375;
939  band_smeta->align[0][0] = 9.99999845E-01;
940  band_smeta->align[0][1] = +1.18363752E-04;
941  band_smeta->align[0][2] = +5.43986578E-04;
942  band_smeta->align[1][0] = -1.18213574E-04;
943  band_smeta->align[1][1] = 9.99999955E-01;
944  band_smeta->align[1][2] = -2.76092898E-04;
945  band_smeta->align[2][0] = -5.44019232E-04;
946  band_smeta->align[2][1] = +2.76028548E-04;
947  band_smeta->align[2][2] = 9.99999814E-01;
948  Along_Scan_Band_Offsets = L7_Along_Scan_Band_Offsets;
949  Across_Scan_Band_Offsets = L7_Across_Scan_Band_Offsets;
950  }
951 
952  band_smeta->center_sample = 0.0;
953  band_smeta->sample_slope = 0.0;
954 
955  if ( smeta->sensor_mode == TM_BUMPER )
956  {
957  if ( smeta->spacecraft_id == IAS_L5 )
958  {
959  bumper_days = delta_date( l5_bumper_date, smeta->acq_date );
960  fs2m = 67764.2 + 0.27638 * bumper_days;
961  fm2e = 69765.4 + 0.25420 * bumper_days;
962  rs2m = 67943.7 + 0.34734 * bumper_days;
963  rm2e = 69275.2 + 0.07921 * bumper_days;
964  }
965  else
966  {
967  bumper_days = delta_date( l7_bumper_date, smeta->acq_date );
968  fs2m = 68407.8 + 0.22954 * bumper_days;
969  fm2e = 69116.3 + 0.42045 * bumper_days;
970  rs2m = 68281.3 + 0.46290 * bumper_days;
971  rm2e = 69001.8 + 0.14103 * bumper_days;
972  }
973  }
974  else
975  {
976  if ( smeta->spacecraft_id == IAS_L5 )
977  {
978  fs2m = 67171.0;
979  fm2e = 67159.0;
980  rs2m = 67159.0;
981  rm2e = 67171.0;
982  }
983  else
984  {
985  fs2m = 67167.9;
986  fm2e = 67145.8;
987  rs2m = 67145.8;
988  rm2e = 67167.9;
989  }
990  }
991 
992  /* Scale to radians */
993  fs2m *= 2.0/1000000.0;
994  fm2e *= 2.0/1000000.0;
995  rs2m *= 2.0/1000000.0;
996  rm2e *= 2.0/1000000.0;
997 
998  /* Switch on the current user band number */
999  band_smeta->fascan = ( fs2m > rm2e ? fs2m : rm2e );
1000  band_smeta->rascan = ( fm2e > rs2m ? fm2e : rs2m );
1001 
1002  switch ( band_smeta->band )
1003  {
1004  case 0:
1005  band_smeta->nsamps = 6320.0;
1006  band_smeta->nlines = 16.0;
1007  band_smeta->afov = 42.5e-6;
1008  band_smeta->xfov = 42.5e-6;
1009  band_smeta->aoffset = 0.0;
1010  band_smeta->xoffset = 0.0;
1011  band_smeta->xscan = band_smeta->xfov * (band_smeta->nlines - 1.0);
1012  break;
1013  case 1:
1014  band_smeta->nsamps = 6320.0;
1015  band_smeta->nlines = 16.0;
1016  band_smeta->afov = 42.5e-6;
1017  band_smeta->xfov = 42.5e-6;
1018  band_smeta->aoffset = Along_Scan_Band_Offsets[0] / 1.0e6;
1019  band_smeta->xoffset = Across_Scan_Band_Offsets[0] / 1.0e6;
1020  band_smeta->xscan = band_smeta->xfov * (band_smeta->nlines - 1.0);
1021  break;
1022  case 2:
1023  band_smeta->nsamps = 6320.0;
1024  band_smeta->nlines = 16.0;
1025  band_smeta->afov = 42.5e-6;
1026  band_smeta->xfov = 42.5e-6;
1027  band_smeta->aoffset = Along_Scan_Band_Offsets[1] / 1.0e6;
1028  band_smeta->xoffset = Across_Scan_Band_Offsets[1] / 1.0e6;
1029  band_smeta->xscan = band_smeta->xfov * (band_smeta->nlines - 1.0);
1030  break;
1031  case 3:
1032  band_smeta->nsamps = 6320.0;
1033  band_smeta->nlines = 16.0;
1034  band_smeta->afov = 42.5e-6;
1035  band_smeta->xfov = 42.5e-6;
1036  band_smeta->aoffset = Along_Scan_Band_Offsets[2] / 1.0e6;
1037  band_smeta->xoffset = Across_Scan_Band_Offsets[2] / 1.0e6;
1038  band_smeta->xscan = band_smeta->xfov * (band_smeta->nlines - 1.0);
1039  break;
1040  case 4:
1041  band_smeta->nsamps = 6320.0;
1042  band_smeta->nlines = 16.0;
1043  band_smeta->afov = 42.5e-6;
1044  band_smeta->xfov = 42.5e-6;
1045  band_smeta->aoffset = Along_Scan_Band_Offsets[3] / 1.0e6;
1046  band_smeta->xoffset = Across_Scan_Band_Offsets[3] / 1.0e6;
1047  band_smeta->xscan = band_smeta->xfov * (band_smeta->nlines - 1.0);
1048  break;
1049  case 5:
1050  band_smeta->nsamps = 6320.0;
1051  band_smeta->nlines = 16.0;
1052  band_smeta->afov = 39.4e-6;
1053  band_smeta->xfov = 42.5e-6;
1054  band_smeta->aoffset = Along_Scan_Band_Offsets[4] / 1.0e6;
1055  band_smeta->xoffset = Across_Scan_Band_Offsets[4] / 1.0e6;
1056  band_smeta->xscan = band_smeta->xfov * (band_smeta->nlines - 1.0);
1057  break;
1058  case 6:
1059  band_smeta->nsamps = 3160.0;
1060  band_smeta->nlines = 8.0;
1061  band_smeta->afov = 85.0e-6;
1062  band_smeta->xfov = 85.0e-6;
1063  band_smeta->aoffset = Along_Scan_Band_Offsets[5] / 1.0e6;
1064  band_smeta->xoffset = Across_Scan_Band_Offsets[5] / 1.0e6;
1065  band_smeta->xscan = band_smeta->xfov * (band_smeta->nlines - 1.0);
1066  break;
1067  case 7:
1068  band_smeta->nsamps = 6320.0;
1069  band_smeta->nlines = 16.0;
1070  band_smeta->afov = 39.4e-6;
1071  band_smeta->xfov = 42.5e-6;
1072  band_smeta->aoffset = Along_Scan_Band_Offsets[6] / 1.0e6;
1073  band_smeta->xoffset = Across_Scan_Band_Offsets[6] / 1.0e6;
1074  band_smeta->xscan = band_smeta->xfov * (band_smeta->nlines - 1.0);
1075  break;
1076  case 8:
1077  band_smeta->nsamps = 12640.0;
1078  band_smeta->nlines = 32.0;
1079  band_smeta->afov = 18.5e-6;
1080  band_smeta->xfov = 21.25e-6;
1081  band_smeta->aoffset = Along_Scan_Band_Offsets[7] / 1.0e6;
1082  band_smeta->xoffset = Across_Scan_Band_Offsets[7] / 1.0e6;
1083  band_smeta->xscan = band_smeta->xfov * (band_smeta->nlines - 1.0);
1084  break;
1085  default:
1086  IAS_LOG_ERROR("No LOS model for user band number %d.", band_smeta->band);
1087  return(ERROR);
1088  }
1089 
1090  return(SUCCESS);
1091 }
1093 int meta_write_angfile(
1094  char *root_filename, /* Output root file name */
1095  short *sat_zn, /* Array of satellite zenith angles */
1096  short *sat_az, /* Array of satellite azimuth angles */
1097  short *sun_zn, /* Array of solar zenith angles */
1098  short *sun_az, /* Array of solar azimuth angles */
1099  META_FRAME *frame ) /* Output image framing information */
1100 {
1101  FILE *ofp; /* Output file pointer */
1102  char ang_filename[PATH_MAX]; /* Output angle file name */
1103  int count; /* Total number of samples */
1104 
1105  /* Construct satellite view angle output file name */
1106  sprintf( ang_filename, "%s_V%02d.img", root_filename, frame->band );
1107  printf("Writing view angle band file %s.\n", ang_filename);
1108 
1109  /* Open output file */
1110  if ( (ofp = fopen( ang_filename, "wb" )) == NULL )
1111  {
1112  IAS_LOG_ERROR("Opening output view angle band file %s.", ang_filename);
1113  return(ERROR);
1114  }
1115 
1116  /* Calculate the total number of samples */
1117  count = frame->nlines * frame->nsamps;
1118 
1119  /* Write the Satellite Zenith Angle layer */
1120  if ( fwrite( sat_zn, sizeof(short), count, ofp ) != count )
1121  {
1122  IAS_LOG_ERROR("Writing satellite zenith angle layer for band %d.", frame->band);
1123  fclose(ofp);
1124  return(ERROR);
1125  }
1126 
1127  /* Write the Satellite Azimuth Angle layer */
1128  if ( fwrite( sat_az, sizeof(short), count, ofp ) != count )
1129  {
1130  IAS_LOG_ERROR("Writing satellite azimuth angle layer for band %d.", frame->band);
1131  fclose(ofp);
1132  return(ERROR);
1133  }
1134 
1135  /* Close the output image file */
1136  fclose(ofp);
1137 
1138  /* Create the output header file name */
1139  strcat( ang_filename, ".hdr" );
1140  printf("Writing view angle band header file %s.\n", ang_filename);
1141 
1142  /* Open the output header file */
1143  if ( (ofp = fopen( ang_filename, "w" )) == NULL )
1144  {
1145  IAS_LOG_ERROR("Opening output ENVI header file %s.", ang_filename);
1146  return(ERROR);
1147  }
1148 
1149  /* Write the output header file */
1150  fprintf( ofp, "ENVI\n" );
1151  fprintf( ofp, "description = {\n" );
1152  fprintf( ofp, " L8 View Angle Band File for %s.}\n", root_filename );
1153  fprintf( ofp, "samples = %d\n", frame->nsamps );
1154  fprintf( ofp, "lines = %d\n", frame->nlines );
1155  fprintf( ofp, "bands = 2\n" );
1156  fprintf( ofp, "header offset = 0\n" );
1157  fprintf( ofp, "file type = ENVI Standard\n" );
1158  fprintf( ofp, "data type = 2\n" );
1159  fprintf( ofp, "interleave = bsq\n" );
1160  fprintf( ofp, "sensor type = Unknown\n" );
1161  fprintf( ofp, "byte order = 0\n" );
1162  if ( frame->code == 1 )
1163  {
1164  fprintf( ofp, "map info = {UTM, 1.500, 1.500, %6.3lf, %6.3lf, %6.3lf, %6.3lf, %d, North, WGS-84, units=Meters}\n",
1165  frame->ul_x, frame->ul_y, frame->pixsize, frame->pixsize, frame->zone );
1166  }
1167  else if ( frame->code == 6 )
1168  {
1169  fprintf( ofp, "map info = {Polar Stereographic, 1.500, 1.500, %6.3lf, %6.3lf, %6.3lf, %6.3lf, WGS-84, units=Meters}\n",
1170  frame->ul_x, frame->ul_y, frame->pixsize, frame->pixsize );
1171  fprintf( ofp, "projection info = {31, 6378137.000, 6356752.314, -71.000000, 0.000000, 0.0, 0.0, WGS-84, Polar Stereographic, units=Meters}\n" );
1172  }
1173  else
1174  {
1175  IAS_LOG_ERROR("Invalid map projection, not UTM or LIMA PS");
1176  return(ERROR);
1177  }
1178  fprintf( ofp, "wavelength units = Unknown\n" );
1179 
1180  /* Close the output header file */
1181  fclose(ofp);
1182 
1183  /* Construct solar angle output file name */
1184  sprintf( ang_filename, "%s_S%02d.img", root_filename, frame->band );
1185  printf("Writing sun angle band file %s.\n", ang_filename);
1186 
1187  /* Open output file */
1188  if ( (ofp = fopen( ang_filename, "wb" )) == NULL )
1189  {
1190  IAS_LOG_ERROR("Opening output sun angle band file %s.", ang_filename);
1191  return(ERROR);
1192  }
1193 
1194  /* Write the Solar Zenith Angle layer */
1195  if ( fwrite( sun_zn, sizeof(short), count, ofp ) != count )
1196  {
1197  IAS_LOG_ERROR("Writing solar zenith angle layer for band %d.", frame->band);
1198  fclose(ofp);
1199  return(ERROR);
1200  }
1201 
1202  /* Write the Solar Azimuth Angle layer */
1203  if ( fwrite( sun_az, sizeof(short), count, ofp ) != count )
1204  {
1205  IAS_LOG_ERROR("Writing solar azimuth angle layer for band %d.", frame->band);
1206  fclose(ofp);
1207  return(ERROR);
1208  }
1209 
1210  /* Close the output image file */
1211  fclose(ofp);
1212 
1213  /* Create the output header file name */
1214  strcat( ang_filename, ".hdr" );
1215  printf("Writing sun angle band header file %s.\n", ang_filename);
1216 
1217  /* Open the output header file */
1218  if ( (ofp = fopen( ang_filename, "w" )) == NULL )
1219  {
1220  IAS_LOG_ERROR("Opening output ENVI header file %s.", ang_filename);
1221  return(ERROR);
1222  }
1223 
1224  /* Write the output header file */
1225  fprintf( ofp, "ENVI\n" );
1226  fprintf( ofp, "description = {\n" );
1227  fprintf( ofp, " L8 Sun Angle Band File for %s.}\n", root_filename );
1228  fprintf( ofp, "samples = %d\n", frame->nsamps );
1229  fprintf( ofp, "lines = %d\n", frame->nlines );
1230  fprintf( ofp, "bands = 2\n" );
1231  fprintf( ofp, "header offset = 0\n" );
1232  fprintf( ofp, "file type = ENVI Standard\n" );
1233  fprintf( ofp, "data type = 2\n" );
1234  fprintf( ofp, "interleave = bsq\n" );
1235  fprintf( ofp, "sensor type = Unknown\n" );
1236  fprintf( ofp, "byte order = 0\n" );
1237  if ( frame->code == 1 )
1238  {
1239  fprintf( ofp, "map info = {UTM, 1.500, 1.500, %6.3lf, %6.3lf, %6.3lf, %6.3lf, %d, North, WGS-84, units=Meters}\n",
1240  frame->ul_x, frame->ul_y, frame->pixsize, frame->pixsize, frame->zone );
1241  }
1242  else if ( frame->code == 6 )
1243  {
1244  fprintf( ofp, "map info = {Polar Stereographic, 1.500, 1.500, %6.3lf, %6.3lf, %6.3lf, %6.3lf, WGS-84, units=Meters}\n",
1245  frame->ul_x, frame->ul_y, frame->pixsize, frame->pixsize );
1246  fprintf( ofp, "projection info = {31, 6378137.000, 6356752.314, -71.000000, 0.000000, 0.0, 0.0, WGS-84, Polar Stereographic, units=Meters}\n" );
1247  }
1248  else
1249  {
1250  IAS_LOG_ERROR("Invalid map projection, not UTM or LIMA PS");
1251  return(ERROR);
1252  }
1253  fprintf( ofp, "wavelength units = Unknown\n" );
1254 
1255  /* Close the output header file */
1256  fclose(ofp);
1257 
1258  return(SUCCESS);
1259 }
1261 int delta_date(
1262  int date1[3], /* Base date year, month, day */
1263  int date2[3] ) /* Final date year, month, day */
1264 {
1265  struct tm d1; /* Time structure for base date */
1266  struct tm d2; /* Time structure for final date */
1267  time_t t1; /* Seconds from epoch for base date */
1268  time_t t2; /* Seconds from epoch for final date */
1269  double secs; /* Seconds elapsed */
1270  int days; /* Days elapsed */
1271 
1272  d1.tm_sec = 0;
1273  d1.tm_min = 0;
1274  d1.tm_hour = 0;
1275  d1.tm_mday = date1[2];
1276  d1.tm_mon = date1[1] - 1;
1277  d1.tm_year = date1[0] - 1900;
1278  d1.tm_wday = -1;
1279  d1.tm_yday = -1;
1280  d1.tm_isdst = 0;
1281  d2.tm_sec = 0;
1282  d2.tm_min = 0;
1283  d2.tm_hour = 0;
1284  d2.tm_mday = date2[2];
1285  d2.tm_mon = date2[1] - 1;
1286  d2.tm_year = date2[0] - 1900;
1287  d2.tm_wday = -1;
1288  d2.tm_yday = -1;
1289  d2.tm_isdst = 0;
1290 
1291  t1 = mktime( &d1 );
1292  t2 = mktime( &d2 );
1293 
1294  secs = difftime( t2, t1 );
1295  days = (int)floor( secs / 86400.0 + 0.5 );
1296 
1297  return( days );
1298 }
void ias_odl_free_tree(IAS_OBJ_DESC *p_lp)
int band
Definition: smeta.h:82
SMETA_SCENE_PROJ projection
Definition: smeta.h:130
#define SUCCESS
Definition: ObpgReadGrid.h:15
int smeta_read_band_meta_ls(SMETA_BAND_LS *band_smeta, IAS_OBJ_DESC *smeta_odl)
#define IAS_LOG_ERROR(format,...)
Definition: ias_logging.h:96
IAS_DBL_XY upright
int nscans
Definition: smeta.h:101
int smeta_load_band_model(SMETA_BAND *band_smeta)
double rascan
Definition: smeta.h:107
int l1t_samps
Definition: smeta.h:99
#define NULL
Definition: decode_rs.h:63
#define IAS_MAX_NBANDS
Definition: emeta.h:17
double sun_elevation
Definition: smeta.h:129
double sample_slope
Definition: smeta.h:114
int num_band
Definition: smeta.h:131
float tm[MODELMAX]
int delta_date(int date1[3], int date2[3])
double fascan
Definition: smeta.h:106
int meta_write_angfile(char *root_filename, short *sat_zn, short *sat_az, short *sun_zn, short *sun_az, META_FRAME *frame)
int nlines
Definition: smeta.h:102
double ul_y
Definition: smeta_exploit.h:25
@ IAS_ETM
Definition: smeta.h:43
int smeta_load_band_model_ls(SMETA *smeta, SMETA_BAND_LS *band_smeta)
character(len=1000) if
Definition: names.f90:13
IAS_DBL_XY loleft
double sun_azimuth
Definition: smeta.h:128
double xfov
Definition: smeta.h:110
double aoffset
Definition: smeta.h:111
int l1t_samps
Definition: smeta.h:84
int nsamps
Definition: smeta.h:103
int smeta_read(SMETA *smeta, const char *smeta_filename)
Definition: smeta_exploit.c:22
double legendre[IAS_MAX_NSCAS][2][4]
Definition: smeta.h:91
#define PATH_MAX
Definition: config.h:129
double wgs84_major_axis
Definition: smeta.h:60
double align[3][3]
Definition: smeta.h:90
int l1t_lines
Definition: smeta.h:83
IAS_OBJ_DESC * ias_odl_read_tree(const char *p_ODLFile)
int wrs_path
Definition: smeta.h:124
int smeta_read_band_meta(SMETA_BAND *band_smeta, IAS_OBJ_DESC *smeta_odl)
IAS_DBL_XY loright
#define MAX_FIELD_NAME
Definition: smeta_exploit.c:20
@ IAS_OLI_TIRS
Definition: smeta.h:44
@ IAS_L8
Definition: smeta.h:35
char units[IAS_UNITS_SIZE]
Definition: smeta.h:63
SMETA_BAND band_smeta[IAS_MAX_NBANDS]
Definition: smeta.h:132
double pixsize
Definition: smeta.h:104
int band
Definition: smeta.h:97
double roll_angle
Definition: smeta.h:126
@ TM_BUMPER
Definition: smeta.h:52
double pixsize
Definition: smeta_exploit.h:26
@ IAS_L5
Definition: smeta.h:33
LANDSAT_SPACECRAFT spacecraft_id
Definition: smeta.h:121
@ IAS_ODL_Double
Definition: ias_odl.h:29
double xscan
Definition: smeta.h:108
@ TM_SAM
Definition: smeta.h:51
#define IAS_MAX_NBANDS_LS
Definition: smeta.h:15
int num_detectors
Definition: smeta.h:87
const char * str
Definition: l1c_msi.cpp:35
int nsca
Definition: smeta.h:100
SMETA_BAND_LS band_smeta_ls[IAS_MAX_NBANDS_LS]
Definition: smeta.h:133
IAS_DBL_XY upleft
struct IAS_CORNERS corners
Definition: smeta.h:76
int acq_date[3]
Definition: smeta.h:127
double afov
Definition: smeta.h:109
double ul_x
Definition: smeta_exploit.h:24
@ IAS_L7
Definition: smeta.h:34
@ IAS_TM
Definition: smeta.h:42
double xoffset
Definition: smeta.h:112
int nsca
Definition: smeta.h:85
int spheroid
Definition: smeta.h:68
double center_sample
Definition: smeta.h:113
double align[3][3]
Definition: smeta.h:105
char datum[IAS_DATUM_SIZE]
Definition: smeta.h:67
int smeta_read_file_header(SMETA *smeta, IAS_OBJ_DESC *smeta_odl)
Definition: smeta_exploit.c:81
int smeta_read_projection(SMETA_SCENE_PROJ *projection, IAS_OBJ_DESC *smeta_odl)
char scene_id[22]
Definition: smeta.h:120
Definition: smeta.h:118
int i
Definition: decode_rs.h:71
int wrs_row
Definition: smeta.h:125
@ IAS_ODL_Int
Definition: ias_odl.h:32
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
int ias_odl_get_field(void *p_MemoryAddr, int MemorySize, IAS_ODL_TYPE ValueType, IAS_OBJ_DESC *p_ODLTree, const char *p_ClassName, const char *p_LabelName, int *p_Count)
SENSOR_MODE sensor_mode
Definition: smeta.h:123
double wgs84_minor_axis
Definition: smeta.h:61
@ OLI
Definition: smeta.h:53
double projprms[IAS_PROJ_PARAM_SIZE]
Definition: smeta.h:71
int l1t_lines
Definition: smeta.h:98
#define IAS_PROJ_PARAM_SIZE
Definition: ias_const.h:61
#define ERROR
Definition: ancil.h:24
double pixsize
Definition: smeta.h:89
@ IAS_ODL_String
Definition: ias_odl.h:31
LANDSAT_SENSOR sensor_id
Definition: smeta.h:122
int count
Definition: decode_rs.h:79