67 free(
input->xcal_opt);
69 free(
input->xcal_wave);
81 strcpy(tmpStr,
"processing version string");
84 strcpy(tmpStr,
"radiation correction option (sensor-specific)\n");
85 strcat(tmpStr,
" 0: no correction\n");
86 strcat(tmpStr,
" 1: apply MERIS Smile correction");
89 strcpy(tmpStr,
"VIIRS L1A calibration parameter file name (VIIRS only)");
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");
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");
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.");
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");
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);
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);
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)");
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");
182 strcpy(tmpStr,
"cloud mask file variable name\n");
183 strcat(tmpStr,
" 0: cloud_flag\n");
184 strcat(tmpStr,
" 1: cloud_flag_dilated");
201 const char *l1_defaults_prefix =
"msl12";
204 char tmpStr[FILENAME_MAX];
207 if ((dataRoot = getenv(
"OCDATAROOT")) ==
NULL) {
208 printf(
"-E- OCDATAROOT environment variable is not defined.\n");
215 printf(
"-E- %s Line %d: Could not find type for file %s.\n", __FILE__, __LINE__,
ifile);
218 l1file->format = format.type;
219 l1file->sensorID = format.sensor_id;
220 l1file->subsensorID = format.subsensor_id;
232 sprintf(tmpStr,
"%s/%s/%s_defaults.par", dataRoot,
235 printf(
"Loading default parameters for %s from %s\n",
240 if (
l1file->subsensorID >= 0) {
241 sprintf(tmpStr,
"%s/%s/%s/%s_defaults.par", dataRoot,
244 if (access(tmpStr, R_OK) != -1) {
246 printf(
"Loading default sub-sensor parameters for %s from %s\n",
260 char tmp_file[FILENAME_MAX];
283 if(strVal && strVal[0]) {
298 char xcaldir[FILENAME_MAX];
299 if ((varRoot = getenv(
"OCVARROOT")) ==
NULL) {
300 printf(
"-E- %s, %d: OCVARROOT env variable undefined.\n", __FILE__,
306 for (
i = 0; lcsensor[
i];
i++) {
307 lcsensor[
i] = tolower(lcsensor[
i]);
309 strcat(xcaldir,
"/");
310 strcat(xcaldir, lcsensor);
311 strcat(xcaldir,
"/xcal/OPER");
316 if ((dir = opendir(xcaldir)) !=
NULL) {
318 while ((ent = readdir(dir)) !=
NULL) {
319 if (strncmp(ent->d_name,
"xcal_", 5) == 0)
323 char *xcalfile_prefix =
strdup(ent->d_name);
325 char *tmpptr = strrchr(xcalfile_prefix,
'_');
327 strcat(xcaldir,
"/");
328 strcat(xcaldir, xcalfile_prefix);
329 free(xcalfile_prefix);
340 printf(
"-E- number of xcal_opt elements (%d) must be %d or less\n",
count,
l1file->nbands);
351 printf(
"-E- number of xcal_wave elements (%d) must be %d or less\n",
count,
l1file->nbands);
355 printf(
"-W- Number of xcal_wave elements (%d) should be equal to xcal_opt number elements (%d)\n",
count,
l1_input->xcal_nwave);
378 printf(
"-E- number of ch22detcor elements must be 10 \n");
386 printf(
"-E- number of ch23detcor elements must be 10 \n");
425 printf(
"-E- number of gain elements (%d) must be equal to number of bands (%d)\n",
count,
l1file->nbands);
436 printf(
"-E- number of offset elements (%d) must be equal to nu,ber of bands (%d)\n",
count,
l1file->nbands);
456 char str_buf[FILENAME_MAX];
458 sprintf(str_buf,
"pversion = %s",
l1_input->pversion);
459 strcat(input_parms, str_buf);
460 strcat(input_parms,
"\n");
462 sprintf(str_buf,
"viirscalparfile = %s",
l1_input->viirscalparfile);
463 strcat(input_parms, str_buf);
464 strcat(input_parms,
"\n");
466 sprintf(str_buf,
"rad_opt = %3d",
l1_input->rad_opt);
467 strcat(input_parms, str_buf);
468 strcat(input_parms,
"\n");
470 sprintf(str_buf,
"calfile = %s",
l1_input->calfile);
471 strcat(input_parms, str_buf);
472 strcat(input_parms,
"\n");
474 sprintf(str_buf,
"geom_per_band = %3d",
l1_input->geom_per_band);
475 strcat(input_parms, str_buf);
476 strcat(input_parms,
"\n");
478 sprintf(str_buf,
"xcalfile = %s",
l1_input->xcal_file);
479 strcat(input_parms, str_buf);
480 strcat(input_parms,
"\n");
482 sprintf(str_buf,
"xcal_opt = %3d",
l1_input->xcal_opt[0]);
483 strcat(input_parms, str_buf);
485 sprintf(str_buf,
", %3d",
l1_input->xcal_opt[
i]);
486 strcat(input_parms, str_buf);
489 strcat(input_parms,
"\n");
490 sprintf(str_buf,
"xcal_wave = %8.4f",
l1_input->xcal_wave[0]);
491 strcat(input_parms, str_buf);
493 sprintf(str_buf,
", %8.4f",
l1_input->xcal_wave[
i]);
494 strcat(input_parms, str_buf);
496 strcat(input_parms,
"\n");
498 sprintf(str_buf,
"btfile = %s",
l1_input->btfile);
499 strcat(input_parms, str_buf);
500 strcat(input_parms,
"\n");
502 sprintf(str_buf,
"resolution = %3d",
l1_input->resolution);
503 strcat(input_parms, str_buf);
504 strcat(input_parms,
"\n");
506 sprintf(str_buf,
"newavhrrcal = %d",
l1_input->newavhrrcal);
507 strcat(input_parms, str_buf);
508 strcat(input_parms,
"\n");
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);
516 strcat(input_parms,
"\n");
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);
524 strcat(input_parms,
"\n");
526 sprintf(str_buf,
"sl_pixl = %3d",
l1_input->sl_pixl);
527 strcat(input_parms, str_buf);
528 strcat(input_parms,
"\n");
530 sprintf(str_buf,
"sl_frac = %8.4f",
l1_input->sl_frac);
531 strcat(input_parms, str_buf);
532 strcat(input_parms,
"\n");
534 sprintf(str_buf,
"outband_opt = %3d",
l1_input->outband_opt);
535 strcat(input_parms, str_buf);
536 strcat(input_parms,
"\n");
538 sprintf(str_buf,
"eval = %5d",
l1_input->evalmask);
539 strcat(input_parms, str_buf);
540 strcat(input_parms,
"\n");
542 sprintf(str_buf,
"maskland = %2d",
l1_input->landmask);
543 strcat(input_parms, str_buf);
544 strcat(input_parms,
"\n");
546 sprintf(str_buf,
"maskbath = %2d",
l1_input->bathmask);
547 strcat(input_parms, str_buf);
548 strcat(input_parms,
"\n");
550 sprintf(str_buf,
"maskcloud = %2d",
l1_input->cloudmask);
551 strcat(input_parms, str_buf);
552 strcat(input_parms,
"\n");
554 sprintf(str_buf,
"maskglint = %2d",
l1_input->glintmask);
555 strcat(input_parms, str_buf);
556 strcat(input_parms,
"\n");
558 sprintf(str_buf,
"masksunzen = %2d",
l1_input->sunzenmask);
559 strcat(input_parms, str_buf);
560 strcat(input_parms,
"\n");
562 sprintf(str_buf,
"masksatzen = %2d",
l1_input->satzenmask);
563 strcat(input_parms, str_buf);
564 strcat(input_parms,
"\n");
566 sprintf(str_buf,
"maskhilt = %2d",
l1_input->hiltmask);
567 strcat(input_parms, str_buf);
568 strcat(input_parms,
"\n");
570 sprintf(str_buf,
"maskstlight = %2d",
l1_input->stlightmask);
571 strcat(input_parms, str_buf);
572 strcat(input_parms,
"\n");
574 sprintf(str_buf,
"sunzen = %8.3f",
l1_input->sunzen);
575 strcat(input_parms, str_buf);
576 strcat(input_parms,
"\n");
578 sprintf(str_buf,
"satzen = %8.3f",
l1_input->satzen);
579 strcat(input_parms, str_buf);
580 strcat(input_parms,
"\n");
582 sprintf(str_buf,
"hipol = %8.3f",
l1_input->hipol);
583 strcat(input_parms, str_buf);
584 strcat(input_parms,
"\n");
586 sprintf(str_buf,
"glint_thresh = %8.3f",
l1_input->glint);
587 strcat(input_parms, str_buf);
588 strcat(input_parms,
"\n");
590 sprintf(str_buf,
"extreme_glint = %8.3f",
l1_input->extreme_glint);
591 strcat(input_parms, str_buf);
592 strcat(input_parms,
"\n");
594 sprintf(str_buf,
"cloud_thresh = %8.3f",
l1_input->albedo);
595 strcat(input_parms, str_buf);
596 strcat(input_parms,
"\n");
598 sprintf(str_buf,
"cloud_wave = %8.3f",
l1_input->cloud_wave);
599 strcat(input_parms, str_buf);
600 strcat(input_parms,
"\n");
602 sprintf(str_buf,
"cloud_eps = %8.3f",
l1_input->cloud_eps);
603 strcat(input_parms, str_buf);
604 strcat(input_parms,
"\n");
606 sprintf(str_buf,
"cloud_mask_file= %s",
l1_input->cld_msk_file);
607 strcat(input_parms, str_buf);
608 strcat(input_parms,
"\n");
610 sprintf(str_buf,
"gain = %8.4f",
l1_input->gain[0]);
611 strcat(input_parms, str_buf);
613 sprintf(str_buf,
", %8.4f",
l1_input->gain[
i]);
614 strcat(input_parms, str_buf);
616 strcat(input_parms,
"\n");
618 sprintf(str_buf,
"offset = %8.5f",
l1_input->offset[0]);
619 strcat(input_parms, str_buf);
621 sprintf(str_buf,
", %8.5f",
l1_input->offset[
i]);
622 strcat(input_parms, str_buf);
624 strcat(input_parms,
"\n");
626 sprintf(str_buf,
"spixl = %5d",
l1_input->spixl);
627 strcat(input_parms, str_buf);
628 strcat(input_parms,
"\n");
630 sprintf(str_buf,
"epixl = %5d",
l1_input->epixl);
631 strcat(input_parms, str_buf);
632 strcat(input_parms,
"\n");
634 sprintf(str_buf,
"dpixl = %5d",
l1_input->dpixl);
635 strcat(input_parms, str_buf);
636 strcat(input_parms,
"\n");
638 sprintf(str_buf,
"sline = %5d",
l1_input->sline);
639 strcat(input_parms, str_buf);
640 strcat(input_parms,
"\n");
642 sprintf(str_buf,
"eline = %5d",
l1_input->eline);
643 strcat(input_parms, str_buf);
644 strcat(input_parms,
"\n");
646 sprintf(str_buf,
"dline = %5d",
l1_input->dline);
647 strcat(input_parms, str_buf);
648 strcat(input_parms,
"\n");
660 char str_buf[FILENAME_MAX];
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);
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);
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);
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);
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);