Go to the documentation of this file.
9 #include <boost/algorithm/string.hpp>
12 using namespace netCDF;
13 using namespace netCDF::exceptions;
22 static char mainProgramName[50];
29 strcpy(mainProgramName, prog);
31 sprintf(tmpStr,
"Usage: %s argument-list\n\n", prog);
32 strcat(tmpStr,
" The argument-list is a set of keyword=value pairs. The arguments can\n");
33 strcat(tmpStr,
" be specified on the commandline, or put into a parameter file, or the\n");
34 strcat(tmpStr,
" two methods can be used together, with commandline over-riding.\n\n");
35 strcat(tmpStr,
" return value: 0=OK, 1=error, 110=north,south,east,west does not intersect\n");
36 strcat(tmpStr,
" file data.\n\n");
37 strcat(tmpStr,
"The list of valid keywords follows:\n");
43 strcpy(tmpStr,
"input L2 file name");
67 strcpy(tmpStr,
"equator crossing time delta in minutes\n");
68 strcat(tmpStr,
" Caveat...if zero, the sensor default equator crossing time will be used\n");
69 strcat(tmpStr,
" This is not necessarily noon");
72 strcpy(tmpStr,
"bin resolution\n");
73 strcat(tmpStr,
" H: 0.5km\n");
74 strcat(tmpStr,
" Q: 250m\n");
75 strcat(tmpStr,
" HQ: 100m\n");
76 strcat(tmpStr,
" HH: 50m\n");
77 strcat(tmpStr,
" 1: 1.1km\n");
78 strcat(tmpStr,
" 2: 2.3km\n");
79 strcat(tmpStr,
" 4: 4.6km\n");
80 strcat(tmpStr,
" 9: 9.2km\n");
81 strcat(tmpStr,
" 18: 18.5km\n");
82 strcat(tmpStr,
" 36: 36km\n");
83 strcat(tmpStr,
" 1D: 1 degree\n");
84 strcat(tmpStr,
" HD: 0.5 degree\n");
85 strcat(tmpStr,
" QD: 0.25 degree");
93 strcpy(tmpStr,
"flags masked [see /SENSOR/l2bin_defaults.par]");
96 strcpy(tmpStr,
"l3bprod = bin products [default=all products]\n");
97 strcat(tmpStr,
" Set to \"ALL\" or \"all\" for all L2 products in 1st input file.\n");
98 strcat(tmpStr,
" Use ':' or ',' or ' ' as delimiters.\n");
99 strcat(tmpStr,
" Use ';' or '=' to delineate minimum values.\n");
102 clo_addOption(
list,
"area_weighting",
CLO_TYPE_INT,
"0",
"Enable area weighting\n 0: off\n 1: pixel box\n 2: pixel bounding box\n 3: pixel polygon");
114 char tmp_file[FILENAME_MAX];
115 int numOptions, optionId;
119 for (optionId = 0; optionId < numOptions; optionId++) {
130 while (*tmp_str !=
'\0') {
131 if (isupper(*tmp_str)) *tmp_str = tolower(*tmp_str);
135 if (strcmp(keyword,
"help") == 0) {
137 else if (strcmp(keyword,
"version") == 0) {
139 else if (strncmp(keyword,
"dump_options", 12) == 0) {
141 else if (strncmp(keyword,
"par", 3) == 0) {
143 else if (strcmp(keyword,
"ifile") == 0) {
149 }
else if (strcmp(keyword,
"ofile") == 0) {
155 }
else if (strcmp(keyword,
"fileuse") == 0) {
161 }
else if (strcmp(keyword,
"sday") == 0) {
165 }
else if (strcmp(keyword,
"eday") == 0) {
169 }
else if (strcmp(keyword,
"resolution") == 0) {
174 }
else if (strcmp(keyword,
"rowgroup") == 0) {
177 }
else if (strcmp(keyword,
"flaguse") == 0) {
182 }
else if (strcmp(keyword,
"l3bprod") == 0) {
186 }
else if (strcmp(keyword,
"prodtype") == 0) {
190 }
else if (strcmp(keyword,
"output_wavelengths") == 0) {
194 }
else if (strcmp(keyword,
"pversion") == 0) {
198 }
else if (strcmp(keyword,
"suite") == 0) {
203 }
else if (strcmp(keyword,
"latsouth") == 0) {
206 }
else if (strcmp(keyword,
"latnorth") == 0) {
209 }
else if (strcmp(keyword,
"lonwest") == 0) {
212 }
else if (strcmp(keyword,
"loneast") == 0) {
215 }
else if (strcmp(keyword,
"meminfo") == 0) {
218 }
else if (strcmp(keyword,
"dcinfo") == 0) {
221 }
else if (strcmp(keyword,
"night") == 0) {
224 }
else if (strcmp(keyword,
"verbose") == 0) {
227 }
else if (strcmp(keyword,
"minobs") == 0) {
230 }
else if (strcmp(keyword,
"delta_crossing_time") == 0) {
233 }
else if (strcmp(keyword,
"deflate") == 0) {
236 }
else if (strcmp(keyword,
"qual_max") == 0) {
239 }
else if (strcmp(keyword,
"qual_prod") == 0) {
246 }
else if (strcmp(keyword,
"composite_prod") == 0) {
252 }
else if (strcmp(keyword,
"composite_scheme") == 0) {
258 }
else if (strcmp(keyword,
"area_weighting") == 0) {
262 input->area_weighting = 0;
274 printf(
"Invalid argument \"%s\"\n", keyword);
279 input_str->infile[0] =
'\0';
280 input_str->ofile[0] =
'\0';
281 input_str->pfile[0] =
'\0';
283 input_str->fileuse[0] =
'\0';
284 input_str->qual_prod[0] =
'\0';
285 input_str->composite_prod[0] =
'\0';
286 input_str->composite_scheme[0] =
'\0';
288 strcpy(input_str->pversion,
"Unspecified");
289 strcpy(input_str->prodtype,
"day");
291 strcpy(input_str->l3bprod,
"ALL");
292 strcpy(input_str->output_wavelengths,
"ALL");
294 input_str->sday = 1970001;
295 input_str->eday = 2038018;
297 input_str->resolve[0] =
'\0';
299 input_str->rowgroup = -1;
301 input_str->night = 0;
302 input_str->verbose = 0;
303 input_str->minobs = 0;
304 input_str->deltaeqcross = 0.0;
306 input_str->meminfo = 0;
307 input_str->dcinfo = 0;
309 input_str->latsouth = -90.0;
310 input_str->latnorth = +90.0;
311 input_str->lonwest = 0.0;
312 input_str->loneast = 0.0;
314 input_str->qual_max = 255;
316 input_str->deflate = 0;
318 strcpy(input_str->suite,
"");
320 input_str->area_weighting = 0;
351 int subsensorId = -1;
352 char localSuite[FILENAME_MAX];
353 char localIfile[FILENAME_MAX];
359 printf(
"-E- %s: Error initializing input structure.\n", __FILE__);
383 if (
input->files.size() == 0) {
384 printf(
"No NetCDF input files found in %s.\n", localIfile);
389 localSuite[0] =
'\0';
397 NcFile nc_input(
input->files[0], NcFile::read);
398 nc_input.getAtt(
"instrument").getValues(
instrument);
399 nc_input.getAtt(
"platform").getValues(
platform);
401 }
catch (NcException
const & e) {
408 if (sensorId == -1) {
409 printf(
"-E- Can not look up sensor ID for %s.\n", localIfile);
413 if ((dataRoot = getenv(
"OCDATAROOT")) ==
NULL) {
414 printf(
"OCDATAROOT environment variable is not defined.\n");
419 sprintf(str_buf,
"%s/common/l2bin_defaults.par", dataRoot);
420 if (access(str_buf, R_OK) != -1) {
422 printf(
"Loading default parameters from %s\n", str_buf);
428 if (access(str_buf, R_OK) != -1) {
430 printf(
"Loading default parameters from %s\n", str_buf);
435 if (subsensorId != -1) {
436 sprintf(str_buf,
"%s/%s/%s/l2bin_defaults.par", dataRoot,
438 if (access(str_buf, R_OK) != -1) {
440 printf(
"Loading default parameters from %s\n", str_buf);
446 if (localSuite[0] == 0) {
452 if (localSuite[0] != 0) {
456 sprintf(str_buf,
"%s/common/l2bin_defaults_%s.par", dataRoot, localSuite);
457 if (access(str_buf, R_OK) != -1) {
460 printf(
"Loading default parameters from %s\n", str_buf);
465 sprintf(str_buf,
"%s/%s/l2bin_defaults_%s.par", dataRoot,
467 if (access(str_buf, R_OK) != -1) {
470 printf(
"Loading default parameters from %s\n", str_buf);
475 if (subsensorId != -1) {
476 sprintf(str_buf,
"%s/%s/%s/l2bin_defaults_%s.par", dataRoot,
479 if (access(str_buf, R_OK) != -1) {
482 printf(
"Loading default parameters from %s\n", str_buf);
488 printf(
"-E- Failed to load parameters for suite %s for sensor %s\n", localSuite,
497 printf(
"Loading command line parameters\n\n");
503 printf(
"-E- %s: Error loading options into input structure.\n", __FILE__);
510 sprintf(str_buf,
"infile = %s\n",
input->infile);
511 strcat(
input->parms, str_buf);
512 sprintf(str_buf,
"ofile = %s\n",
input->ofile);
513 strcat(
input->parms, str_buf);
514 sprintf(str_buf,
"fileuse = %s\n",
input->fileuse);
515 strcat(
input->parms, str_buf);
517 sprintf(str_buf,
"sday = %d\n",
input->sday);
518 strcat(
input->parms, str_buf);
519 sprintf(str_buf,
"eday = %d\n",
input->eday);
520 strcat(
input->parms, str_buf);
522 sprintf(str_buf,
"latnorth = %f\n",
input->latnorth);
523 strcat(
input->parms, str_buf);
524 sprintf(str_buf,
"latsouth = %f\n",
input->latsouth);
525 strcat(
input->parms, str_buf);
526 sprintf(str_buf,
"loneast = %f\n",
input->loneast);
527 strcat(
input->parms, str_buf);
528 sprintf(str_buf,
"lonwest = %f\n",
input->lonwest);
529 strcat(
input->parms, str_buf);
531 sprintf(str_buf,
"resolve = %s\n",
input->resolve);
532 strcat(
input->parms, str_buf);
534 sprintf(str_buf,
"rowgroup = %d\n",
input->rowgroup);
535 strcat(
input->parms, str_buf);
537 sprintf(str_buf,
"flaguse = %s\n",
input->flaguse);
538 strcat(
input->parms, str_buf);
540 sprintf(str_buf,
"l3bprod = %s\n",
input->l3bprod);
541 strcat(
input->parms, str_buf);
543 sprintf(str_buf,
"output_wavelengths = %s\n",
input->output_wavelengths);
544 strcat(
input->parms, str_buf);
546 sprintf(str_buf,
"prodtype = %s\n",
input->prodtype);
547 strcat(
input->parms, str_buf);
549 sprintf(str_buf,
"pversion = %s\n",
input->pversion);
550 strcat(
input->parms, str_buf);
552 sprintf(str_buf,
"suite = %s\n",
input->suite);
553 strcat(
input->parms, str_buf);
555 sprintf(str_buf,
"night = %d\n",
input->night);
556 strcat(
input->parms, str_buf);
558 sprintf(str_buf,
"verbose = %d\n",
input->verbose);
559 strcat(
input->parms, str_buf);
561 sprintf(str_buf,
"minobs = %d\n",
input->minobs);
562 strcat(
input->parms, str_buf);
564 sprintf(str_buf,
"delta_crossing_time = %f\n",
input->deltaeqcross);
565 strcat(
input->parms, str_buf);
567 sprintf(str_buf,
"deflate = %d\n",
input->deflate);
568 strcat(
input->parms, str_buf);
570 sprintf(str_buf,
"qual_prod = %s\n",
input->qual_prod);
571 strcat(
input->parms, str_buf);
573 sprintf(str_buf,
"composite_prod = %s\n",
input->composite_prod);
574 strcat(
input->parms, str_buf);
576 sprintf(str_buf,
"composite_scheme = %s\n",
input->composite_scheme);
577 strcat(
input->parms, str_buf);
579 sprintf(str_buf,
"qual_max = %d\n",
input->qual_max);
580 strcat(
input->parms, str_buf);
582 strcat(
input->parms, str_buf);
clo_option_t * clo_addOption(clo_optionList_t *list, const char *key, enum clo_dataType_t dataType, const char *defaultVal, const char *desc)
const char * sensorId2SensorDir(int sensorId)
float clo_getOptionFloat(clo_option_t *option)
char * clo_getString(clo_optionList_t *list, const char *key)
void clo_readArgs(clo_optionList_t *list, int argc, char *argv[])
list(APPEND LIBS ${PGSTK_LIBRARIES}) add_executable(atteph_info_modis atteph_info_modis.c) target_link_libraries(atteph_info_modis $
vector< string > ncfiles(const char *filepath)
int instrumentPlatform2SensorId(const char *instrument, const char *platform)
void clo_addAlias(clo_optionList_t *list, const char *key, const char *alias)
char * clo_getOptionRawString(clo_option_t *option)
int clo_isSet(clo_optionList_t *list, const char *key)
int clo_getOptionInt(clo_option_t *option)
int sensorId2SubsensorId(int sensorId)
int clo_isOptionSet(clo_option_t *option)
void clo_setEnableDumpOptions(int val)
clo_optionList_t * clo_createList()
void clo_setHelpStr(const char *str)
char * clo_getOptionString(clo_option_t *option)
void clo_printUsage(clo_optionList_t *list)
clo_option_t * clo_getOption(clo_optionList_t *list, int i)
void clo_addOptionAlias(clo_option_t *option, const char *alias)
void clo_readFile(clo_optionList_t *list, const char *fileName)
int clo_getNumOptions(clo_optionList_t *list)
void parse_file_name(const char *inpath, char *outpath)
const char * sensorId2SensorName(int sensorId)
void clo_setVersion(const char *str)
void clo_deleteList(clo_optionList_t *list)
const char * subsensorId2SubsensorDir(int subsensorId)
enum clo_dataType_t dataType
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
int clo_getOptionBool(clo_option_t *option)