66 free(
input->xcal_opt);
68 free(
input->xcal_wave);
80 strcpy(tmpStr,
"processing version string");
83 strcpy(tmpStr,
"radiation correction option (sensor-specific)\n");
84 strcat(tmpStr,
" 0: no correction\n");
85 strcat(tmpStr,
" 1: apply MERIS Smile correction");
88 strcpy(tmpStr,
"VIIRS L1A calibration parameter file name (VIIRS only)");
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");
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");
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.");
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");
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);
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);
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)");
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");
193 const char *l1_defaults_prefix =
"msl12";
196 char tmpStr[FILENAME_MAX];
199 if ((dataRoot = getenv(
"OCDATAROOT")) ==
NULL) {
200 printf(
"-E- OCDATAROOT environment variable is not defined.\n");
207 printf(
"-E- %s Line %d: Could not find type for file %s.\n", __FILE__, __LINE__,
ifile);
210 l1file->format = format.type;
211 l1file->sensorID = format.sensor_id;
212 l1file->subsensorID = format.subsensor_id;
224 sprintf(tmpStr,
"%s/%s/%s_defaults.par", dataRoot,
227 printf(
"Loading default parameters for %s from %s\n",
232 if (
l1file->subsensorID >= 0) {
233 sprintf(tmpStr,
"%s/%s/%s/%s_defaults.par", dataRoot,
236 if (access(tmpStr, R_OK) != -1) {
238 printf(
"Loading default sub-sensor parameters for %s from %s\n",
252 char tmp_file[FILENAME_MAX];
275 if(strVal && strVal[0]) {
290 char xcaldir[FILENAME_MAX];
291 if ((varRoot = getenv(
"OCVARROOT")) ==
NULL) {
292 printf(
"-E- %s, %d: OCVARROOT env variable undefined.\n", __FILE__,
298 for (
i = 0; lcsensor[
i];
i++) {
299 lcsensor[
i] = tolower(lcsensor[
i]);
301 strcat(xcaldir,
"/");
302 strcat(xcaldir, lcsensor);
303 strcat(xcaldir,
"/xcal/OPER");
308 if ((dir = opendir(xcaldir)) !=
NULL) {
310 while ((ent = readdir(dir)) !=
NULL) {
311 if (strncmp(ent->d_name,
"xcal_", 5) == 0)
315 char *xcalfile_prefix =
strdup(ent->d_name);
317 char *tmpptr = strrchr(xcalfile_prefix,
'_');
319 strcat(xcaldir,
"/");
320 strcat(xcaldir, xcalfile_prefix);
321 free(xcalfile_prefix);
332 printf(
"-E- number of xcal_opt elements (%d) must be %d or less\n",
count,
l1file->nbands);
343 printf(
"-E- number of xcal_wave elements (%d) must be %d or less\n",
count,
l1file->nbands);
347 printf(
"-W- Number of xcal_wave elements (%d) should be equal to xcal_opt number elements (%d)\n",
count,
l1_input->xcal_nwave);
370 printf(
"-E- number of ch22detcor elements must be 10 \n");
378 printf(
"-E- number of ch23detcor elements must be 10 \n");
415 printf(
"-E- number of gain elements (%d) must be equal to number of bands (%d)\n",
count,
l1file->nbands);
426 printf(
"-E- number of offset elements (%d) must be equal to nu,ber of bands (%d)\n",
count,
l1file->nbands);
446 char str_buf[FILENAME_MAX];
448 sprintf(str_buf,
"pversion = %s",
l1_input->pversion);
449 strcat(input_parms, str_buf);
450 strcat(input_parms,
"\n");
452 sprintf(str_buf,
"viirscalparfile = %s",
l1_input->viirscalparfile);
453 strcat(input_parms, str_buf);
454 strcat(input_parms,
"\n");
456 sprintf(str_buf,
"rad_opt = %3d",
l1_input->rad_opt);
457 strcat(input_parms, str_buf);
458 strcat(input_parms,
"\n");
460 sprintf(str_buf,
"calfile = %s",
l1_input->calfile);
461 strcat(input_parms, str_buf);
462 strcat(input_parms,
"\n");
464 sprintf(str_buf,
"geom_per_band = %3d",
l1_input->geom_per_band);
465 strcat(input_parms, str_buf);
466 strcat(input_parms,
"\n");
468 sprintf(str_buf,
"xcalfile = %s",
l1_input->xcal_file);
469 strcat(input_parms, str_buf);
470 strcat(input_parms,
"\n");
472 sprintf(str_buf,
"xcal_opt = %3d",
l1_input->xcal_opt[0]);
473 strcat(input_parms, str_buf);
475 sprintf(str_buf,
", %3d",
l1_input->xcal_opt[
i]);
476 strcat(input_parms, str_buf);
479 strcat(input_parms,
"\n");
480 sprintf(str_buf,
"xcal_wave = %8.4f",
l1_input->xcal_wave[0]);
481 strcat(input_parms, str_buf);
483 sprintf(str_buf,
", %8.4f",
l1_input->xcal_wave[
i]);
484 strcat(input_parms, str_buf);
486 strcat(input_parms,
"\n");
488 sprintf(str_buf,
"btfile = %s",
l1_input->btfile);
489 strcat(input_parms, str_buf);
490 strcat(input_parms,
"\n");
492 sprintf(str_buf,
"resolution = %3d",
l1_input->resolution);
493 strcat(input_parms, str_buf);
494 strcat(input_parms,
"\n");
496 sprintf(str_buf,
"newavhrrcal = %d",
l1_input->newavhrrcal);
497 strcat(input_parms, str_buf);
498 strcat(input_parms,
"\n");
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);
506 strcat(input_parms,
"\n");
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);
514 strcat(input_parms,
"\n");
516 sprintf(str_buf,
"sl_pixl = %3d",
l1_input->sl_pixl);
517 strcat(input_parms, str_buf);
518 strcat(input_parms,
"\n");
520 sprintf(str_buf,
"sl_frac = %8.4f",
l1_input->sl_frac);
521 strcat(input_parms, str_buf);
522 strcat(input_parms,
"\n");
524 sprintf(str_buf,
"outband_opt = %3d",
l1_input->outband_opt);
525 strcat(input_parms, str_buf);
526 strcat(input_parms,
"\n");
528 sprintf(str_buf,
"eval = %5d",
l1_input->evalmask);
529 strcat(input_parms, str_buf);
530 strcat(input_parms,
"\n");
532 sprintf(str_buf,
"maskland = %2d",
l1_input->landmask);
533 strcat(input_parms, str_buf);
534 strcat(input_parms,
"\n");
536 sprintf(str_buf,
"maskbath = %2d",
l1_input->bathmask);
537 strcat(input_parms, str_buf);
538 strcat(input_parms,
"\n");
540 sprintf(str_buf,
"maskcloud = %2d",
l1_input->cloudmask);
541 strcat(input_parms, str_buf);
542 strcat(input_parms,
"\n");
544 sprintf(str_buf,
"maskglint = %2d",
l1_input->glintmask);
545 strcat(input_parms, str_buf);
546 strcat(input_parms,
"\n");
548 sprintf(str_buf,
"masksunzen = %2d",
l1_input->sunzenmask);
549 strcat(input_parms, str_buf);
550 strcat(input_parms,
"\n");
552 sprintf(str_buf,
"masksatzen = %2d",
l1_input->satzenmask);
553 strcat(input_parms, str_buf);
554 strcat(input_parms,
"\n");
556 sprintf(str_buf,
"maskhilt = %2d",
l1_input->hiltmask);
557 strcat(input_parms, str_buf);
558 strcat(input_parms,
"\n");
560 sprintf(str_buf,
"maskstlight = %2d",
l1_input->stlightmask);
561 strcat(input_parms, str_buf);
562 strcat(input_parms,
"\n");
564 sprintf(str_buf,
"sunzen = %8.3f",
l1_input->sunzen);
565 strcat(input_parms, str_buf);
566 strcat(input_parms,
"\n");
568 sprintf(str_buf,
"satzen = %8.3f",
l1_input->satzen);
569 strcat(input_parms, str_buf);
570 strcat(input_parms,
"\n");
572 sprintf(str_buf,
"hipol = %8.3f",
l1_input->hipol);
573 strcat(input_parms, str_buf);
574 strcat(input_parms,
"\n");
576 sprintf(str_buf,
"glint_thresh = %8.3f",
l1_input->glint);
577 strcat(input_parms, str_buf);
578 strcat(input_parms,
"\n");
580 sprintf(str_buf,
"cloud_thresh = %8.3f",
l1_input->albedo);
581 strcat(input_parms, str_buf);
582 strcat(input_parms,
"\n");
584 sprintf(str_buf,
"cloud_wave = %8.3f",
l1_input->cloud_wave);
585 strcat(input_parms, str_buf);
586 strcat(input_parms,
"\n");
588 sprintf(str_buf,
"cloud_eps = %8.3f",
l1_input->cloud_eps);
589 strcat(input_parms, str_buf);
590 strcat(input_parms,
"\n");
592 sprintf(str_buf,
"cloud_mask_file= %s",
l1_input->cld_msk_file);
593 strcat(input_parms, str_buf);
594 strcat(input_parms,
"\n");
596 sprintf(str_buf,
"gain = %8.4f",
l1_input->gain[0]);
597 strcat(input_parms, str_buf);
599 sprintf(str_buf,
", %8.4f",
l1_input->gain[
i]);
600 strcat(input_parms, str_buf);
602 strcat(input_parms,
"\n");
604 sprintf(str_buf,
"offset = %8.5f",
l1_input->offset[0]);
605 strcat(input_parms, str_buf);
607 sprintf(str_buf,
", %8.5f",
l1_input->offset[
i]);
608 strcat(input_parms, str_buf);
610 strcat(input_parms,
"\n");
612 sprintf(str_buf,
"spixl = %5d",
l1_input->spixl);
613 strcat(input_parms, str_buf);
614 strcat(input_parms,
"\n");
616 sprintf(str_buf,
"epixl = %5d",
l1_input->epixl);
617 strcat(input_parms, str_buf);
618 strcat(input_parms,
"\n");
620 sprintf(str_buf,
"dpixl = %5d",
l1_input->dpixl);
621 strcat(input_parms, str_buf);
622 strcat(input_parms,
"\n");
624 sprintf(str_buf,
"sline = %5d",
l1_input->sline);
625 strcat(input_parms, str_buf);
626 strcat(input_parms,
"\n");
628 sprintf(str_buf,
"eline = %5d",
l1_input->eline);
629 strcat(input_parms, str_buf);
630 strcat(input_parms,
"\n");
632 sprintf(str_buf,
"dline = %5d",
l1_input->dline);
633 strcat(input_parms, str_buf);
634 strcat(input_parms,
"\n");
646 char str_buf[FILENAME_MAX];
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);
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);
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);
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);
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);