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