OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
l1_options.c
Go to the documentation of this file.
1 #include "l1.h"
2 
3 #include <ctype.h>
4 #include <dirent.h>
5 #include <stdlib.h>
6 #include <unistd.h>
7 
8 // global L1 input pointer
9 l1_input_t *l1_input;
10 
11 void l1_input_init() {
12  int i;
13 
14  l1_input = allocateMemory(sizeof(l1_input_t), "l1_input");
15 
16  l1_input->calfile[0] = 0;
17  l1_input->xcal_file[0] = 0;
18  l1_input->btfile[0] = 0;
19 
20  strcpy(l1_input->pversion, "Unspecified");
21  l1_input->input_parms[0] = 0;
22  l1_input->input_files[0] = 0;
23  l1_input->rad_opt = 1;
24  l1_input->geom_per_band = 0;
25  l1_input->xcal_nwave = 0;
26  l1_input->xcal_opt = NULL;
27  l1_input->xcal_wave = NULL;
28  l1_input->resolution = -1;
29  l1_input->newavhrrcal = 0;
30  l1_input->sl_pixl = -1;
31  l1_input->sl_frac = 0.25;
32  for (i = 0; i < 10; i++) l1_input->ch22detcor[i] = 1.0; /* for modis: Ltir = Ltir / detcor */
33  for (i = 0; i < 10; i++) l1_input->ch23detcor[i] = 1.0;
34  for (i = 0; i < 2; i++) l1_input->cirrus_thresh[i] = -1;
35  l1_input->albedo = -1.0;
36  l1_input->cloud_wave = 865.0;
37  l1_input->cloud_eps = -1.0;
38  l1_input->glint = 0.005;
39  l1_input->sunzen = 75.0;
40  l1_input->satzen = 60.0;
41  l1_input->hipol = 0.50;
42  l1_input->gain = NULL;
43  l1_input->offset = NULL;
44 
45  l1_input->outband_opt = 99;
46 
47  l1_input->spixl = 1;
48  l1_input->epixl = -1;
49  l1_input->dpixl = 1;
50  l1_input->sline = 1;
51  l1_input->eline = -1;
52  l1_input->dline = 1;
53 
54  l1_input->evalmask = 0;
55  l1_input->landmask = 1;
56  l1_input->bathmask = 0;
57  l1_input->cloudmask = 0;
58  l1_input->glintmask = 0;
59  l1_input->sunzenmask = 0;
60  l1_input->satzenmask = 0;
61  l1_input->hiltmask = 0;
62  l1_input->stlightmask = 0;
63 }
64 
65 void l1_input_delete(l1_input_t *input) {
66  free(input->xcal_opt);
67  input->xcal_opt = NULL;
68  free(input->xcal_wave);
69  input->xcal_wave = NULL;
70  free(input->gain);
71  input->gain = NULL;
72  free(input->offset);
73  input->offset = NULL;
74 }
75 
77  char tmpStr[2048];
78  clo_option_t *option;
79 
80  strcpy(tmpStr, "processing version string");
81  clo_addOption(list, "pversion", CLO_TYPE_STRING, "Unspecified", tmpStr);
82 
83  strcpy(tmpStr, "radiation correction option (sensor-specific)\n");
84  strcat(tmpStr, " 0: no correction\n");
85  strcat(tmpStr, " 1: apply MERIS Smile correction");
86  clo_addOption(list, "rad_opt", CLO_TYPE_INT, "0", tmpStr);
87 
88  strcpy(tmpStr, "VIIRS L1A calibration parameter file name (VIIRS only)");
89  clo_addOption(list, "viirscalparfile", CLO_TYPE_IFILE, NULL, tmpStr);
90 
91  clo_addOption(list, "calfile", CLO_TYPE_IFILE, NULL, "system calibration file");
92 
93  strcpy(tmpStr, "geometry per band option:\n");
94  strcat(tmpStr, " 0: use nominal viewing geometry - same for all bands\n");
95  strcat(tmpStr, " 1: use band-specific viewing geometry (if available)\n");
96  clo_addOption(list, "geom_per_band", CLO_TYPE_BOOL, "0", tmpStr);
97 
98 
99  clo_addOption(list, "xcalfile", CLO_TYPE_IFILE, NULL, "cross-calibration file");
100 
101  strcpy(tmpStr, "cross-calibration option (sensor-specific) comma separated\n");
102  strcat(tmpStr, " list of option values, 1 per band, with bands listed in xcal_wave.\n");
103  strcat(tmpStr, " 3: apply cross-calibration corrections (polarization and rvs)\n");
104  strcat(tmpStr, " 2: apply cross-calibration polarization corrections\n");
105  strcat(tmpStr, " 1: apply cross-calibration rvs corrections\n");
106  strcat(tmpStr, " 0: no correction");
107  clo_addOption(list, "xcal_opt", CLO_TYPE_INT, NULL, tmpStr);
108 
109  strcpy(tmpStr, "wavelengths at which to apply cross-calibration. Comma\n");
110  strcat(tmpStr, " separated list of sensor wavelength values associated with xcal_opt.");
111  clo_addOption(list, "xcal_wave", CLO_TYPE_FLOAT, NULL, tmpStr);
112 
113  clo_addOption(list, "btfile", CLO_TYPE_IFILE, NULL, "IR brightness temperature file");
114 
115  strcpy(tmpStr, "processing resolution (MODIS only)\n");
116  strcat(tmpStr, " -1: standard ocean 1km processing\n");
117  strcat(tmpStr, " 1000: 1km resolution including aggregated 250 and 500m land bands\n");
118  strcat(tmpStr, " 500: 500m resolution including aggregated 250 land bands and\n");
119  strcat(tmpStr, " replication for lower resolution bands\n");
120  strcat(tmpStr, " 250: 250m resolution with replication for lower resolution bands");
121  clo_addOption(list, "resolution", CLO_TYPE_INT, "-1", tmpStr);
122 
123  clo_addOption(list, "newavhrrcal", CLO_TYPE_INT, "0", "=1 for new noaa-16 calibration");
124 
125  strcpy(tmpStr, "\n Channel 22 detector corrections (MODIS only)");
126  clo_addOption(list, "ch22detcor", CLO_TYPE_FLOAT, "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]", tmpStr);
127 
128  strcpy(tmpStr, "\n Channel 23 detector corrections (MODIS only)");
129  clo_addOption(list, "ch23detcor", CLO_TYPE_FLOAT, "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]", tmpStr);
130 
131  clo_addOption(list, "sl_pixl", CLO_TYPE_INT, "-1", "SeaWiFS only, number of LAC pixels for\n straylight flagging");
132  clo_addOption(list, "sl_frac", CLO_TYPE_FLOAT, "0.25", "SeaWiFS only, straylight fractional\n threshold on Ltypical");
133 
134  strcpy(tmpStr, "out-of-band correction for water-leaving\n");
135  strcat(tmpStr, " radiances\n");
136  strcat(tmpStr, " 2: On (default for MODIS, SeaWiFS, OCTS)\n");
137  strcat(tmpStr, " 0: Off (default for MOS, OSMI)");
138  clo_addOption(list, "outband_opt", CLO_TYPE_INT, "99", tmpStr);
139 
140  strcpy(tmpStr, "evaluation bitmask\n");
141  strcat(tmpStr, " 0: standard processing\n");
142  strcat(tmpStr, " 1: init to old aerosol models\n");
143  strcat(tmpStr, " 2: enables MODIS and MERIS cloud Mask for HABS\n");
144  strcat(tmpStr, " 16: enables MODIS cirrus mask\n");
145  strcat(tmpStr, " 32: use test sensor info file\n");
146  strcat(tmpStr, " 64: use test rayleigh tables\n");
147  strcat(tmpStr, " 128: use test aerosol tables\n");
148  strcat(tmpStr, " 256: use test polarization tables\n");
149  strcat(tmpStr, " 1024: mask modis mirror-side 1 (navfail)\n");
150  strcat(tmpStr, " 2048: mask modis mirror-side 2 (navfail)\n");
151  strcat(tmpStr, " 4096: don't apply 'cold-only' or equatorial aerosol tests for SST\n");
152  strcat(tmpStr, " 8192: use alt sensor info file in eval\n");
153  strcat(tmpStr, " 32768: enables spherical path geom for dtran");
154  clo_addOption(list, "eval", CLO_TYPE_INT, "0", tmpStr);
155 
156  clo_addOption(list, "maskland", CLO_TYPE_BOOL, "on", "land mask option");
157  clo_addOption(list, "maskbath", CLO_TYPE_BOOL, "off", "shallow water mask option");
158  clo_addOption(list, "maskcloud", CLO_TYPE_BOOL, "on", "cloud mask option");
159  clo_addOption(list, "maskglint", CLO_TYPE_BOOL, "off", "glint mask option");
160  clo_addOption(list, "masksunzen", CLO_TYPE_BOOL, "off", "large sun zenith angle mask option");
161  clo_addOption(list, "masksatzen", CLO_TYPE_BOOL, "off", "large satellite zenith angle mask option");
162  clo_addOption(list, "maskhilt", CLO_TYPE_BOOL, "on", "high Lt masking");
163  clo_addOption(list, "maskstlight", CLO_TYPE_BOOL, "on", "stray light masking");
164 
165  clo_addOption(list, "sunzen", CLO_TYPE_FLOAT, "75.0", "sun zenith angle threshold in deg.");
166  clo_addOption(list, "satzen", CLO_TYPE_FLOAT, "60.0", "satellite zenith angle threshold");
167  clo_addOption(list, "hipol", CLO_TYPE_FLOAT, "0.5", "threshold on degree-of-polarization to set\n HIPOL flag");
168 
169  option = clo_addOption(list, "glint_thresh", CLO_TYPE_FLOAT, "0.005", "high sun glint threshold");
170  clo_addOptionAlias(option, "glint");
171 
172  option = clo_addOption(list, "cloud_thresh", CLO_TYPE_FLOAT, "0.027", "cloud reflectance\n threshold");
173  clo_addOptionAlias(option, "albedo");
174  clo_addOption(list, "cloud_wave", CLO_TYPE_FLOAT, "865.0", "wavelength of cloud reflectance test");
175  clo_addOption(list, "cloud_eps", CLO_TYPE_FLOAT, "-1.0", "cloud reflectance ratio threshold\n (-1.0=disabled)");
176 
177  clo_addOption(list, "cloud_mask_file", CLO_TYPE_IFILE, NULL, "cloud mask file - with CF_CATEGORY cloud designations");
178 
179  clo_addOption(list, "gain", CLO_TYPE_FLOAT, NULL, "calibration gain multiplier");
180  clo_addOption(list, "offset", CLO_TYPE_FLOAT, NULL, "calibration offset adjustment");
181 
182  clo_addOption(list, "spixl", CLO_TYPE_INT, "1", "start pixel number");
183  clo_addOption(list, "epixl", CLO_TYPE_INT, "-1", "end pixel number (-1=the last pixel)");
184  clo_addOption(list, "dpixl", CLO_TYPE_INT, "1", "pixel sub-sampling interval");
185  clo_addOption(list, "sline", CLO_TYPE_INT, "1", "start line number");
186  clo_addOption(list, "eline", CLO_TYPE_INT, "-1", "end line number (-1=the last line)");
187  clo_addOption(list, "dline", CLO_TYPE_INT, "1", "line sub-sampling interval");
188 
189 }
190 
191 
192 void l1_read_default_files(clo_optionList_t *list, filehandle *l1file, const char *ifile) {
193  const char *l1_defaults_prefix = "msl12";
194 
195  char *dataRoot;
196  char tmpStr[FILENAME_MAX];
197 
198 
199  if ((dataRoot = getenv("OCDATAROOT")) == NULL) {
200  printf("-E- OCDATAROOT environment variable is not defined.\n");
201  exit(EXIT_FAILURE);
202  }
203 
204  strcpy(l1file->name, ifile);
205  file_format format = getFormat(l1file->name);
206  if (format.type == FT_INVALID) {
207  printf("-E- %s Line %d: Could not find type for file %s.\n", __FILE__, __LINE__, ifile);
208  exit(EXIT_FAILURE);
209  }
210  l1file->format = format.type;
211  l1file->sensorID = format.sensor_id;
212  l1file->subsensorID = format.subsensor_id;
213  l1file->nbands = rdsensorinfo(l1file->sensorID, 0, "Nbands", NULL);
214 
215 
216  // load l1 defaults
217  //sprintf(tmpStr, "%s/common/%s_defaults.par", dataRoot, l1_defaults_prefix);
218  //if (want_verbose)
219  // printf("Loading default parameters from %s\n", tmpStr);
220  //clo_readFile(list, tmpStr);
221 
222 
223  // load the sensor specific defaults file
224  sprintf(tmpStr, "%s/%s/%s_defaults.par", dataRoot,
225  sensorId2SensorDir(l1file->sensorID), l1_defaults_prefix);
226  if (want_verbose)
227  printf("Loading default parameters for %s from %s\n",
228  sensorId2SensorName(l1file->sensorID), tmpStr);
229  clo_readFile(list, tmpStr);
230 
231  // load the sub-sensor specific defaults file
232  if (l1file->subsensorID >= 0) {
233  sprintf(tmpStr, "%s/%s/%s/%s_defaults.par", dataRoot,
234  sensorId2SensorDir(l1file->sensorID),
235  subsensorId2SubsensorDir(l1file->subsensorID), l1_defaults_prefix);
236  if (access(tmpStr, R_OK) != -1) {
237  if (want_verbose)
238  printf("Loading default sub-sensor parameters for %s from %s\n",
239  sensorId2SensorName(l1file->sensorID), tmpStr);
240  clo_readFile(list, tmpStr);
241  }
242  } // if sub-sensor
243 
244 }
245 
246 
248 
249  clo_option_t *option;
250  int count;
251  int i;
252  char tmp_file[FILENAME_MAX];
253  char *strVal;
254  int *iArray;
255  float *fArray;
256 
257  l1_input->xcal_opt = calloc_nbandsi32t(l1file->nbands, l1_input->xcal_opt, 0);
258  l1_input->xcal_wave = calloc_nbandsf(l1file->nbands, l1_input->xcal_wave, -1.0);
259  l1_input->gain = calloc_nbandsf(l1file->nbands, l1_input->gain, 1.0);
260  l1_input->offset = calloc_nbandsf(l1file->nbands, l1_input->offset, 0.0);
261 
262  strVal = clo_getString(list, "pversion");
263  strcpy(l1_input->pversion, strVal);
264 
265  option = clo_findOption(list, "viirscalparfile");
266  if (clo_isOptionSet(option)) {
267  strVal = clo_getOptionString(option);
268  parse_file_name(strVal, tmp_file);
269  strcpy(l1_input->viirscalparfile, tmp_file);
270  }
271 
272  l1_input->rad_opt = clo_getInt(list, "rad_opt");
273 
274  strVal = clo_getString(list, "calfile");
275  if(strVal && strVal[0]) {
276  parse_file_name(strVal, tmp_file);
277  strcpy(l1_input->calfile, tmp_file);
278  }
279 
280  l1_input->geom_per_band = clo_getBool(list, "geom_per_band");
281 
282  option = clo_findOption(list, "xcalfile");
283  if (clo_isOptionSet(option)) {
284  strVal = clo_getOptionString(option);
285  parse_file_name(strVal, tmp_file);
286  strcpy(l1_input->xcal_file, tmp_file);
287  } else {
288  // Look for default xcalfile if not previously provided
289  char *varRoot;
290  char xcaldir[FILENAME_MAX];
291  if ((varRoot = getenv("OCVARROOT")) == NULL) {
292  printf("-E- %s, %d: OCVARROOT env variable undefined.\n", __FILE__,
293  __LINE__);
294  exit(EXIT_FAILURE);
295  }
296  strcpy(xcaldir, varRoot);
297  char *lcsensor = strdup(sensorId2SensorName(l1file->sensorID));
298  for (i = 0; lcsensor[i]; i++) {
299  lcsensor[i] = tolower(lcsensor[i]);
300  }
301  strcat(xcaldir, "/");
302  strcat(xcaldir, lcsensor);
303  strcat(xcaldir, "/xcal/OPER");
304  free(lcsensor);
305 
306  DIR *dir;
307  struct dirent *ent;
308  if ((dir = opendir(xcaldir)) != NULL) {
309  /* print all the files and directories within directory */
310  while ((ent = readdir(dir)) != NULL) {
311  if (strncmp(ent->d_name, "xcal_", 5) == 0)
312  break;
313  }
314  if(ent) {
315  char *xcalfile_prefix = strdup(ent->d_name);
316  closedir(dir);
317  char *tmpptr = strrchr(xcalfile_prefix, '_');
318  *tmpptr = 0;
319  strcat(xcaldir, "/");
320  strcat(xcaldir, xcalfile_prefix);
321  free(xcalfile_prefix);
322  strcpy(l1_input->xcal_file, xcaldir);
323  }
324  }
325  }
326 
327  option = clo_findOption(list, "xcal_opt");
328  if (clo_isOptionSet(option)) {
329  iArray = clo_getOptionInts(option, &count);
330  l1_input->xcal_nwave = count;
331  if (count > l1file->nbands) {
332  printf("-E- number of xcal_opt elements (%d) must be %d or less\n", count, l1file->nbands);
333  exit(1);
334  }
335  for (i = 0; i < count; i++)
336  l1_input->xcal_opt[i] = iArray[i];
337  }
338 
339  option = clo_findOption(list, "xcal_wave");
340  if (clo_isOptionSet(option)) {
341  fArray = clo_getOptionFloats(option, &count);
342  if (count > l1file->nbands) {
343  printf("-E- number of xcal_wave elements (%d) must be %d or less\n", count, l1file->nbands);
344  exit(1);
345  }
346  if (count != l1_input->xcal_nwave) {
347  printf("-W- Number of xcal_wave elements (%d) should be equal to xcal_opt number elements (%d)\n", count, l1_input->xcal_nwave);
348  }
349  l1_input->xcal_nwave = count;
350  for (i = 0; i < count; i++)
351  l1_input->xcal_wave[i] = fArray[i];
352  }
353 
354  option = clo_findOption(list, "btfile");
355  if (clo_isOptionSet(option)) {
356  strVal = clo_getOptionString(option);
357  parse_file_name(strVal, tmp_file);
358  strcpy(l1_input->btfile, tmp_file);
359  }
360 
361  l1_input->resolution = clo_getInt(list, "resolution");
362  if (l1_input->resolution == -1000)
363  l1_input->resolution = 1000;
364 
365 
366  l1_input->newavhrrcal = clo_getInt(list, "newavhrrcal");
367 
368  fArray = clo_getFloats(list, "ch22detcor", &count);
369  if (count != 10) {
370  printf("-E- number of ch22detcor elements must be 10 \n");
371  exit(1);
372  }
373  for (i = 0; i < count; i++)
374  l1_input->ch22detcor[i] = fArray[i];
375 
376  fArray = clo_getFloats(list, "ch23detcor", &count);
377  if (count != 10) {
378  printf("-E- number of ch23detcor elements must be 10 \n");
379  exit(1);
380  }
381  for (i = 0; i < count; i++)
382  l1_input->ch23detcor[i] = fArray[i];
383 
384  l1_input->sl_pixl = clo_getInt(list, "sl_pixl");
385  l1_input->sl_frac = clo_getFloat(list, "sl_frac");
386  l1_input->outband_opt = clo_getInt(list, "outband_opt");
387  l1_input->evalmask = clo_getInt(list, "eval");
388  l1_input->landmask = clo_getBool(list, "maskland");
389  l1_input->bathmask = clo_getBool(list, "maskbath");
390  l1_input->cloudmask = clo_getBool(list, "maskcloud");
391  l1_input->glintmask = clo_getBool(list, "maskglint");
392  l1_input->sunzenmask = clo_getBool(list, "masksunzen");
393  l1_input->satzenmask = clo_getBool(list, "masksatzen");
394  l1_input->hiltmask = clo_getBool(list, "maskhilt");
395  l1_input->stlightmask = clo_getBool(list, "maskstlight");
396  l1_input->sunzen = clo_getFloat(list, "sunzen");
397  l1_input->satzen = clo_getFloat(list, "satzen");
398  l1_input->hipol = clo_getFloat(list, "hipol");
399  l1_input->glint = clo_getFloat(list, "glint_thresh");
400  l1_input->albedo = clo_getFloat(list, "cloud_thresh");
401  l1_input->cloud_wave = clo_getFloat(list, "cloud_wave");
402  l1_input->cloud_eps = clo_getFloat(list, "cloud_eps");
403 
404  option = clo_findOption(list, "cloud_mask_file");
405  if (clo_isOptionSet(option)) {
406  strVal = clo_getOptionString(option);
407  parse_file_name(strVal, tmp_file);
408  strcpy(l1_input->cld_msk_file, tmp_file);
409  }
410 
411  option = clo_findOption(list, "gain");
412  if (clo_isOptionSet(option)) {
413  fArray = clo_getOptionFloats(option, &count);
414  if (count != l1file->nbands) {
415  printf("-E- number of gain elements (%d) must be equal to number of bands (%d)\n", count, l1file->nbands);
416  exit(1);
417  }
418  for (i = 0; i < count; i++)
419  l1_input->gain[i] = fArray[i];
420  }
421 
422  option = clo_findOption(list, "offset");
423  if (clo_isOptionSet(option)) {
424  fArray = clo_getOptionFloats(option, &count);
425  if (count != l1file->nbands) {
426  printf("-E- number of offset elements (%d) must be equal to nu,ber of bands (%d)\n", count, l1file->nbands);
427  exit(1);
428  }
429  for (i = 0; i < count; i++)
430  l1_input->offset[i] = fArray[i];
431  }
432 
433  l1_input->spixl = clo_getInt(list, "spixl");
434  l1_input->epixl = clo_getInt(list, "epixl");
435  l1_input->dpixl = clo_getInt(list, "dpixl");
436  l1_input->sline = clo_getInt(list, "sline");
437  l1_input->eline = clo_getInt(list, "eline");
438  l1_input->dline = clo_getInt(list, "dline");
439 
440 }
441 
442 
443 
444 void l1_get_input_params(filehandle *l1file, char *input_parms) {
445  int i;
446  char str_buf[FILENAME_MAX];
447 
448  sprintf(str_buf, "pversion = %s", l1_input->pversion);
449  strcat(input_parms, str_buf);
450  strcat(input_parms, "\n");
451 
452  sprintf(str_buf, "viirscalparfile = %s", l1_input->viirscalparfile);
453  strcat(input_parms, str_buf);
454  strcat(input_parms, "\n");
455 
456  sprintf(str_buf, "rad_opt = %3d", l1_input->rad_opt);
457  strcat(input_parms, str_buf);
458  strcat(input_parms, "\n");
459 
460  sprintf(str_buf, "calfile = %s", l1_input->calfile);
461  strcat(input_parms, str_buf);
462  strcat(input_parms, "\n");
463 
464  sprintf(str_buf, "geom_per_band = %3d", l1_input->geom_per_band);
465  strcat(input_parms, str_buf);
466  strcat(input_parms, "\n");
467 
468  sprintf(str_buf, "xcalfile = %s", l1_input->xcal_file);
469  strcat(input_parms, str_buf);
470  strcat(input_parms, "\n");
471 
472  sprintf(str_buf, "xcal_opt = %3d", l1_input->xcal_opt[0]);
473  strcat(input_parms, str_buf);
474  for (i = 1; i < l1_input->xcal_nwave; i++) {
475  sprintf(str_buf, ", %3d", l1_input->xcal_opt[i]);
476  strcat(input_parms, str_buf);
477  }
478 
479  strcat(input_parms, "\n");
480  sprintf(str_buf, "xcal_wave = %8.4f", l1_input->xcal_wave[0]);
481  strcat(input_parms, str_buf);
482  for (i = 1; i < l1_input->xcal_nwave; i++) {
483  sprintf(str_buf, ", %8.4f", l1_input->xcal_wave[i]);
484  strcat(input_parms, str_buf);
485  }
486  strcat(input_parms, "\n");
487 
488  sprintf(str_buf, "btfile = %s", l1_input->btfile);
489  strcat(input_parms, str_buf);
490  strcat(input_parms, "\n");
491 
492  sprintf(str_buf, "resolution = %3d", l1_input->resolution);
493  strcat(input_parms, str_buf);
494  strcat(input_parms, "\n");
495 
496  sprintf(str_buf, "newavhrrcal = %d", l1_input->newavhrrcal);
497  strcat(input_parms, str_buf);
498  strcat(input_parms, "\n");
499 
500  sprintf(str_buf, "ch22detcor = %9.6f", l1_input->ch22detcor[0]);
501  strcat(input_parms, str_buf);
502  for (i = 1; i < 10; i++) {
503  sprintf(str_buf, ", %9.6f", l1_input->ch22detcor[i]);
504  strcat(input_parms, str_buf);
505  }
506  strcat(input_parms, "\n");
507 
508  sprintf(str_buf, "ch23detcor = %9.6f", l1_input->ch23detcor[0]);
509  strcat(input_parms, str_buf);
510  for (i = 1; i < 10; i++) {
511  sprintf(str_buf, ", %9.6f", l1_input->ch23detcor[i]);
512  strcat(input_parms, str_buf);
513  }
514  strcat(input_parms, "\n");
515 
516  sprintf(str_buf, "sl_pixl = %3d", l1_input->sl_pixl);
517  strcat(input_parms, str_buf);
518  strcat(input_parms, "\n");
519 
520  sprintf(str_buf, "sl_frac = %8.4f", l1_input->sl_frac);
521  strcat(input_parms, str_buf);
522  strcat(input_parms, "\n");
523 
524  sprintf(str_buf, "outband_opt = %3d", l1_input->outband_opt);
525  strcat(input_parms, str_buf);
526  strcat(input_parms, "\n");
527 
528  sprintf(str_buf, "eval = %5d", l1_input->evalmask);
529  strcat(input_parms, str_buf);
530  strcat(input_parms, "\n");
531 
532  sprintf(str_buf, "maskland = %2d", l1_input->landmask);
533  strcat(input_parms, str_buf);
534  strcat(input_parms, "\n");
535 
536  sprintf(str_buf, "maskbath = %2d", l1_input->bathmask);
537  strcat(input_parms, str_buf);
538  strcat(input_parms, "\n");
539 
540  sprintf(str_buf, "maskcloud = %2d", l1_input->cloudmask);
541  strcat(input_parms, str_buf);
542  strcat(input_parms, "\n");
543 
544  sprintf(str_buf, "maskglint = %2d", l1_input->glintmask);
545  strcat(input_parms, str_buf);
546  strcat(input_parms, "\n");
547 
548  sprintf(str_buf, "masksunzen = %2d", l1_input->sunzenmask);
549  strcat(input_parms, str_buf);
550  strcat(input_parms, "\n");
551 
552  sprintf(str_buf, "masksatzen = %2d", l1_input->satzenmask);
553  strcat(input_parms, str_buf);
554  strcat(input_parms, "\n");
555 
556  sprintf(str_buf, "maskhilt = %2d", l1_input->hiltmask);
557  strcat(input_parms, str_buf);
558  strcat(input_parms, "\n");
559 
560  sprintf(str_buf, "maskstlight = %2d", l1_input->stlightmask);
561  strcat(input_parms, str_buf);
562  strcat(input_parms, "\n");
563 
564  sprintf(str_buf, "sunzen = %8.3f", l1_input->sunzen);
565  strcat(input_parms, str_buf);
566  strcat(input_parms, "\n");
567 
568  sprintf(str_buf, "satzen = %8.3f", l1_input->satzen);
569  strcat(input_parms, str_buf);
570  strcat(input_parms, "\n");
571 
572  sprintf(str_buf, "hipol = %8.3f", l1_input->hipol);
573  strcat(input_parms, str_buf);
574  strcat(input_parms, "\n");
575 
576  sprintf(str_buf, "glint_thresh = %8.3f", l1_input->glint);
577  strcat(input_parms, str_buf);
578  strcat(input_parms, "\n");
579 
580  sprintf(str_buf, "cloud_thresh = %8.3f", l1_input->albedo);
581  strcat(input_parms, str_buf);
582  strcat(input_parms, "\n");
583 
584  sprintf(str_buf, "cloud_wave = %8.3f", l1_input->cloud_wave);
585  strcat(input_parms, str_buf);
586  strcat(input_parms, "\n");
587 
588  sprintf(str_buf, "cloud_eps = %8.3f", l1_input->cloud_eps);
589  strcat(input_parms, str_buf);
590  strcat(input_parms, "\n");
591 
592  sprintf(str_buf, "cloud_mask_file= %s", l1_input->cld_msk_file);
593  strcat(input_parms, str_buf);
594  strcat(input_parms, "\n");
595 
596  sprintf(str_buf, "gain = %8.4f", l1_input->gain[0]);
597  strcat(input_parms, str_buf);
598  for (i = 1; i < l1file->nbands; i++) {
599  sprintf(str_buf, ", %8.4f", l1_input->gain[i]);
600  strcat(input_parms, str_buf);
601  }
602  strcat(input_parms, "\n");
603 
604  sprintf(str_buf, "offset = %8.5f", l1_input->offset[0]);
605  strcat(input_parms, str_buf);
606  for (i = 1; i < l1file->nbands; i++) {
607  sprintf(str_buf, ", %8.5f", l1_input->offset[i]);
608  strcat(input_parms, str_buf);
609  }
610  strcat(input_parms, "\n");
611 
612  sprintf(str_buf, "spixl = %5d", l1_input->spixl);
613  strcat(input_parms, str_buf);
614  strcat(input_parms, "\n");
615 
616  sprintf(str_buf, "epixl = %5d", l1_input->epixl);
617  strcat(input_parms, str_buf);
618  strcat(input_parms, "\n");
619 
620  sprintf(str_buf, "dpixl = %5d", l1_input->dpixl);
621  strcat(input_parms, str_buf);
622  strcat(input_parms, "\n");
623 
624  sprintf(str_buf, "sline = %5d", l1_input->sline);
625  strcat(input_parms, str_buf);
626  strcat(input_parms, "\n");
627 
628  sprintf(str_buf, "eline = %5d", l1_input->eline);
629  strcat(input_parms, str_buf);
630  strcat(input_parms, "\n");
631 
632  sprintf(str_buf, "dline = %5d", l1_input->dline);
633  strcat(input_parms, str_buf);
634  strcat(input_parms, "\n");
635 
636 
637 
638 
639 
640 }
641 
642 
643 
644 void l1_get_input_files(filehandle *l1file, char *input_files) {
645  char *tmp_str;
646  char str_buf[FILENAME_MAX];
647 
648  if (l1_input->viirscalparfile[0]) {
649  tmp_str = strrchr(l1_input->viirscalparfile, '/');
650  tmp_str = (tmp_str == 0x0) ? l1_input->viirscalparfile : tmp_str + 1;
651  sprintf(str_buf, ",%s", tmp_str);
652  strcat(input_files, str_buf);
653  }
654 
655  if (l1_input->calfile[0]) {
656  tmp_str = strrchr(l1_input->calfile, '/');
657  tmp_str = (tmp_str == 0x0) ? l1_input->calfile : tmp_str + 1;
658  sprintf(str_buf, ",%s", tmp_str);
659  strcat(input_files, str_buf);
660  }
661 
662  if (l1_input->xcal_file[0]) {
663  tmp_str = strrchr(l1_input->xcal_file, '/');
664  tmp_str = (tmp_str == 0x0) ? l1_input->xcal_file : tmp_str + 1;
665  sprintf(str_buf, ",%s", tmp_str);
666  strcat(input_files, str_buf);
667  }
668 
669  if (l1_input->btfile[0]) {
670  tmp_str = strrchr(l1_input->btfile, '/');
671  tmp_str = (tmp_str == 0x0) ? l1_input->btfile : tmp_str + 1;
672  sprintf(str_buf, ",%s", tmp_str);
673  strcat(input_files, str_buf);
674  }
675 
676  if (l1_input->cld_msk_file[0]) {
677  tmp_str = strrchr(l1_input->cld_msk_file, '/');
678  tmp_str = (tmp_str == 0x0) ? l1_input->cld_msk_file : tmp_str + 1;
679  sprintf(str_buf, ",%s", tmp_str);
680  strcat(input_files, str_buf);
681  }
682 }
int32 l1file(int32 sdfid, int32 *nsamp, int32 *nscans, int16 *dtynum)
Definition: l1stat_chk.c:586
clo_option_t * clo_addOption(clo_optionList_t *list, const char *key, enum clo_dataType_t dataType, const char *defaultVal, const char *desc)
Definition: clo.c:684
const char * sensorId2SensorDir(int sensorId)
Definition: sensorInfo.c:240
char * clo_getString(clo_optionList_t *list, const char *key)
Definition: clo.c:1357
l1_input_t * l1_input
Definition: l1_options.c:9
list(APPEND LIBS ${PGSTK_LIBRARIES}) add_executable(atteph_info_modis atteph_info_modis.c) target_link_libraries(atteph_info_modis $
Definition: CMakeLists.txt:7
void l1_load_options(clo_optionList_t *list, filehandle *l1file)
Definition: l1_options.c:247
void * allocateMemory(size_t numBytes, const char *name)
Definition: allocateMemory.c:7
#define NULL
Definition: decode_rs.h:63
void l1_get_input_params(filehandle *l1file, char *input_parms)
Definition: l1_options.c:444
clo_option_t * clo_findOption(clo_optionList_t *list, const char *key)
Definition: clo.c:967
@ CLO_TYPE_FLOAT
Definition: clo.h:81
int clo_getInt(clo_optionList_t *list, const char *key)
Definition: clo.c:1393
int clo_isOptionSet(clo_option_t *option)
Definition: clo.c:2257
@ CLO_TYPE_BOOL
Definition: clo.h:78
instr * input
void l1_get_input_files(filehandle *l1file, char *input_files)
Definition: l1_options.c:644
float * calloc_nbandsf(int32_t nbands, float *nbarray, float init_val)
void l1_add_options(clo_optionList_t *list)
Definition: l1_options.c:76
@ CLO_TYPE_INT
Definition: clo.h:79
char * strdup(const char *)
float clo_getFloat(clo_optionList_t *list, const char *key)
Definition: clo.c:1429
file_format getFormat(char *filename)
Definition: filetype.c:192
char * clo_getOptionString(clo_option_t *option)
Definition: clo.c:1050
float * clo_getOptionFloats(clo_option_t *option, int *count)
Definition: clo.c:1295
int * clo_getOptionInts(clo_option_t *option, int *count)
Definition: clo.c:1273
void l1_input_init()
Definition: l1_options.c:11
void l1_read_default_files(clo_optionList_t *list, filehandle *l1file, const char *ifile)
Definition: l1_options.c:192
float * clo_getFloats(clo_optionList_t *list, const char *key, int *count)
Definition: clo.c:1538
int want_verbose
@ CLO_TYPE_IFILE
Definition: clo.h:84
void clo_addOptionAlias(clo_option_t *option, const char *alias)
Definition: clo.c:632
void clo_readFile(clo_optionList_t *list, const char *fileName)
Definition: clo.c:2210
void parse_file_name(const char *inpath, char *outpath)
const char * sensorId2SensorName(int sensorId)
Definition: sensorInfo.c:198
@ FT_INVALID
Definition: filetype.h:12
int32_t rdsensorinfo(int32_t, int32_t, const char *, void **)
Definition: rdsensorinfo.c:69
for(i=0;i< NROOTS;i++) s[i]
Definition: decode_rs.h:85
const char * subsensorId2SubsensorDir(int subsensorId)
Definition: sensorInfo.c:254
int clo_getBool(clo_optionList_t *list, const char *key)
Definition: clo.c:1375
int i
Definition: decode_rs.h:71
@ CLO_TYPE_STRING
Definition: clo.h:83
int32_t * calloc_nbandsi32t(int32_t nbands, int32_t *nbarray, int32_t init_val)
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
void l1_input_delete(l1_input_t *input)
Definition: l1_options.c:65
int count
Definition: decode_rs.h:79