Go to the documentation of this file.
15 #include <boost/algorithm/string.hpp>
20 using namespace netCDF;
21 using namespace netCDF::exceptions;
32 static char mainProgramName[50];
36 static char *l1cgen_optionKeys[] = {
37 "-help",
"-version",
"-dump_options",
"-dump_options_paramfile",
"-dump_options_xmlfile",
"par",
38 "pversion",
"doi",
"verbose",
"ifile",
"ofile",
"outlist",
"l1c_grid",
"l1c_anc",
"mode",
"south",
"north",
"west",
39 "east",
"history",
"l2prod",
"ix_l1cprod",
46 "gransize",
"grantype",
"bintype",
"start_timeflag",
68 L1C_input::L1C_input(){};
69 L1C_input::~L1C_input(){};
85 if (strcmp(prog,
"l1cgen"))
89 strcpy(mainProgramName, prog);
91 sprintf(tmpStr,
"Usage: %s argument-list\n\n", prog);
92 strcat(tmpStr,
" The argument-list is a set of keyword=value pairs. The arguments can\n");
93 strcat(tmpStr,
" be specified on the commandline, or put into a parameter file, or the\n");
94 strcat(tmpStr,
" two methods can be used together, with commandline over-riding.\n\n");
95 strcat(tmpStr,
" return value: 0=ALL GOOD, 1=ERROR, 110=NO PIXELS BINNED\n");
96 strcat(tmpStr,
" file data.\n\n");
97 strcat(tmpStr,
"The list of valid keywords follows:\n");
102 strcpy(tmpStr,
"input L1b or L2 file name");
105 strcpy(tmpStr,
"input L1C file name");
114 strcpy(tmpStr,
"flags masked [see /SENSOR/l2bin_defaults.par]");
115 strcpy(tmpStr,
"l2prod = bin products [default=all products]\n");
116 strcat(tmpStr,
" Set to \"ALL\" or \"all\" for all L2 products in 1st input file.\n");
117 strcat(tmpStr,
" Use ',' as delimiters.\n");
121 strcpy(tmpStr,
"L1C processing flag\n");
122 strcat(tmpStr,
" 5: L1C grid creation from HKT telemetry\n");
124 " 7: CTH-corrected L1B (cloud height parallax) and L1C grid at cloud height from L1C "
125 "granules with CTH=0--\n");
127 " 8: L1C FULL file creation from L1B granules-and input L1C grid SOCEA-L1 readers\n");
132 strcpy(tmpStr,
"L1C grid min binning latitude");
134 strcpy(tmpStr,
"L1C grid max binning latitude");
136 strcpy(tmpStr,
"L1C grid min binning longitude");
138 strcpy(tmpStr,
"L1C grid max binning longitude");
141 strcpy(tmpStr,
"L1C processing of granules");
142 strcpy(tmpStr,
"granule id (1 to 10) note: not indexes!");
143 clo_addOption(
list,
"selgran",
CLO_TYPE_INT,
"[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]", tmpStr);
146 strcpy(tmpStr,
"Index L1C product [0,0,0]");
147 strcat(tmpStr,
" 0: pc");
148 strcat(tmpStr,
" 1: vsf");
149 strcat(tmpStr,
" 2: dpr");
153 strcpy(tmpStr,
"Day of the year for processing L1C swath");
154 strcat(tmpStr,
" units in day number (1-365/366)");
157 strcpy(tmpStr,
"Month of the year for processing L1C swath");
158 strcat(tmpStr,
" units in month number (1-12)");
161 strcpy(tmpStr,
"Year for processing L1C swath");
162 strcat(tmpStr,
" units in year");
166 strcpy(tmpStr,
"Common grid resolution");
167 strcat(tmpStr,
" units in km");
170 strcpy(tmpStr,
"PACE sensor to be gridded");
171 strcat(tmpStr,
" e.g. SPEXONE, OCI, HARP2, MISR");
173 strcpy(tmpStr,
"granule size for telemetry-derived L1C files");
174 strcat(tmpStr,
" in minutes--5' by default");
177 strcpy(tmpStr,
"granule type processing for telemetry-derived L1C files");
178 strcat(tmpStr,
" 0: granules, 1: swath, 0 by default");
181 strcpy(tmpStr,
"binning type for binned L1C products");
182 strcat(tmpStr,
" 0: discrete, 1: area-weighting, 0 by default");
185 strcpy(tmpStr,
"Initial time as ISO for processing HKT granules ->L1C files");
186 strcat(tmpStr,
" units as ISO");
189 strcpy(tmpStr,
"End time as ISO for processing HKT granules ->L1C files");
190 strcat(tmpStr,
" units as ISO ");
193 strcpy(tmpStr,
"log command history");
196 strcpy(tmpStr,
"initial time flag for L1C granule ");
198 " 0: time zero seconds of the day 00:00:00, 1: starting coverage time for the HKT file by "
199 "default, 0 by default");
202 strcpy(tmpStr,
"swath # for 1 full orbit processing for telemetry-derived L1C files");
203 strcat(tmpStr,
" 1 or 2, ascending or descending");
206 strcpy(tmpStr,
"Projection type");
207 strcat(tmpStr,
" 0: SOCEA(default)");
208 strcat(tmpStr,
" 1: SOCEA-2");
211 strcpy(tmpStr,
"Binning sorting type");
212 strcat(tmpStr,
" 0: Orbital-vectorsdefault)");
213 strcat(tmpStr,
" 1: SADDLEBACK SEARCH");
216 strcpy(tmpStr,
"height type flag");
217 strcat(tmpStr,
" 0: geoid or L1C height");
218 strcat(tmpStr,
" 1: orthometric or dem height");
221 strcpy(tmpStr,
"Cloud top height for L1C corrections");
222 strcat(tmpStr,
" (km)");
225 strcpy(tmpStr,
"Terrain correct flag");
226 strcat(tmpStr,
" DEM correction");
227 strcat(tmpStr,
" 0: off");
228 strcat(tmpStr,
" 1: on");
231 strcpy(tmpStr,
"Cloud correct flag for L1C");
232 strcat(tmpStr,
" 0: CTH=0 no parallax correction (default)");
233 strcat(tmpStr,
" 1: CTH=k, constant CTH from ANC");
234 strcat(tmpStr,
" 2: CTH=k, constant CTH from L1C grid height");
237 strcpy(tmpStr,
"Cloud type for parallax correction");
238 strcat(tmpStr,
" 0: water (default)");
239 strcat(tmpStr,
" 1: ice");
242 strcpy(tmpStr,
"overlap views flag");
243 strcat(tmpStr,
" 0: off");
244 strcat(tmpStr,
" 1: on");
247 strcpy(tmpStr,
"overlap polarizations flag");
248 strcat(tmpStr,
" 0: off");
249 strcat(tmpStr,
" 1: on");
252 strcpy(tmpStr,
"overlap spectral bands flag");
253 strcat(tmpStr,
" 0: off");
254 strcat(tmpStr,
" 1: on");
257 strcpy(tmpStr,
"Uncertainty calculation method");
258 strcat(tmpStr,
" 0: error propagation");
259 strcat(tmpStr,
" 1: Monte Carlo");
262 strcpy(tmpStr,
"Uncertainty threshold for angular merged product");
263 strcat(tmpStr,
" as percentage");
266 strcpy(tmpStr,
"Uncertainty threshold for polarization merged product");
267 strcat(tmpStr,
" as percentage");
270 strcpy(tmpStr,
"Uncertainty threshold for spectral bands merged product");
271 strcat(tmpStr,
" as percentage");
274 strcpy(tmpStr,
"Digital Elevation Model file");
275 strcat(tmpStr,
" *.nc file");
289 char tmp_file[FILENAME_MAX];
290 int numOptions, optionId;
298 for (optionId = 0; optionId < numOptions; optionId++) {
309 while (*tmp_str !=
'\0') {
310 if (isupper(*tmp_str))
311 *tmp_str = tolower(*tmp_str);
315 if (strcmp(keyword,
"help") == 0) {
316 }
else if (strcmp(keyword,
"version") == 0) {
317 }
else if (strncmp(keyword,
"dump_options", 12) == 0) {
318 }
else if (strncmp(keyword,
"par", 3) == 0) {
319 }
else if (strcmp(keyword,
"ifile") == 0) {
325 }
else if (strcmp(keyword,
"ofile") == 0) {
331 }
else if (strcmp(keyword,
"outlist") == 0) {
337 }
else if (strcmp(keyword,
"l1c_grid") == 0) {
345 else if (strcmp(keyword,
"l1c_anc") == 0) {
352 }
else if (strcmp(keyword,
"l2prod") == 0) {
356 }
else if (strcmp(keyword,
"verbose") == 0) {
359 }
else if (strcmp(keyword,
"pversion") == 0) {
363 }
else if (strcmp(keyword,
"doi") == 0) {
370 else if (strcmp(keyword,
"mode") == 0) {
372 }
else if (strcmp(keyword,
"south") == 0) {
374 }
else if (strcmp(keyword,
"north") == 0) {
376 }
else if (strcmp(keyword,
"west") == 0) {
378 }
else if (strcmp(keyword,
"east") == 0) {
380 }
else if (strcmp(keyword,
"selgran") == 0) {
387 printf(
"-E- %s: Granule Id cant be larger than 10.\n", __FILE__);
392 printf(
"-E- %s: Max number of granules to be processed is 10.\n", __FILE__);
395 }
else if (strcmp(keyword,
"ix_l1cprod") == 0) {
401 else if (strcmp(keyword,
"grid_resolution") == 0) {
403 }
else if (strcmp(keyword,
"sensor") == 0) {
408 }
else if (strcmp(keyword,
"gransize") == 0) {
410 }
else if (strcmp(keyword,
"grantype") == 0) {
412 }
else if (strcmp(keyword,
"bintype") == 0) {
414 }
else if (strcmp(keyword,
"history") == 0) {
419 string s1(cArray[
i]);
424 }
else if (strcmp(keyword,
"start_time") == 0) {
427 string s1(cArray[0]), s2(cArray[1]), s3(cArray[2]);
428 string start_time = s1 +
":" + s2 +
":" + s3.substr(0, 2) +
"Z";
431 }
else if (strcmp(keyword,
"end_time") == 0) {
434 string s1(cArray[0]), s2(cArray[1]), s3(cArray[2]);
435 string gran_end_time = s1 +
":" + s2 +
":" + s3.substr(0, 2) +
"Z";
439 else if (strcmp(keyword,
"demfile") == 0) {
442 string s1(cArray[0]);
443 string gran_demfile = s1;
451 else if (strcmp(keyword,
"start_timeflag") == 0) {
453 }
else if (strcmp(keyword,
"selday") == 0) {
455 }
else if (strcmp(keyword,
"selmon") == 0) {
457 }
else if (strcmp(keyword,
"selyear") == 0) {
459 }
else if (strcmp(keyword,
"swath_num") == 0) {
461 }
else if (strcmp(keyword,
"projection") == 0) {
463 }
else if (strcmp(keyword,
"sort_method") == 0) {
465 }
else if (strcmp(keyword,
"demcloud_flag") == 0) {
467 }
else if (strcmp(keyword,
"cloud_height") == 0) {
469 }
else if (strcmp(keyword,
"terrain_correct") == 0) {
471 }
else if (strcmp(keyword,
"cloud_correct") == 0) {
473 }
else if (strcmp(keyword,
"cloud_type") == 0) {
475 }
else if (strcmp(keyword,
"overlap_vflag") == 0) {
477 }
else if (strcmp(keyword,
"overlap_pflag") == 0) {
479 }
else if (strcmp(keyword,
"overlap_bflag") == 0) {
481 }
else if (strcmp(keyword,
"unc_meth") == 0) {
483 }
else if (strcmp(keyword,
"unc_thres_v") == 0) {
485 }
else if (strcmp(keyword,
"unc_thres_p") == 0) {
487 }
else if (strcmp(keyword,
"unc_thres_b") == 0) {
490 printf(
"-E- Invalid argument \"%s\"\n", keyword);
504 l1ccli->
ofile[0] =
'\0';
510 l1ccli->
doi[0] =
'\0';
512 for (
int i = 0;
i < 3;
i++) {
521 for (
int i = 0;
i < 10;
i++) {
580 const char *prog,
const char *
version) {
583 char localIfile[FILENAME_MAX], localIfile_l1c[FILENAME_MAX];
605 printf(
"-E- %s: Error initializing l1c input structure.\n", __FILE__);
613 if (l1cinput->
files.size() == 0) {
614 printf(
"No NetCDF input files found in %s.\n", localIfile);
618 ifile_str = l1cinput->
files[0];
619 ifile = (
char*)ifile_str.c_str();
625 l1cfile->
format = format.type;
629 cout<<
"l1cinput->files[0].."<<l1cfile->
l1b_name<<endl;
630 printf(
"format.type....%d..",format.type);
631 printf(
"sensor id.....%d..",format.sensor_id);
634 l1cfile->
format = format.type;
639 printf(
"-E- %s Line %d: Could not find type for file %s.\n", __FILE__, __LINE__,
ifile);
643 if (format.sensor_id == -1) {
644 printf(
"-E- Can not look up sensor ID for PLEASE PROVIDE PLATFORM FOR OCIS--!! %s.\n ", localIfile);
645 cout <<
"forcing to be HARP2 when HARP2 L1B is beta from Meng/Richard" << endl;
649 if ((dataRoot = getenv(
"OCDATAROOT")) ==
NULL) {
650 printf(
"OCDATAROOT environment variable is not defined.\n");
661 printf(
"Loading command line parameters for L1C processing\n\n");
664 printf(
"-E- %s: Error loading options into input structure.\n", __FILE__);
673 cout << localIfile_l1c << endl;
674 cout << l1cinput->
files_l1c.size() << endl;
678 printf(
"No NetCDF L1C input files found in %s.\n", localIfile_l1c);
683 if(l1cinput->
verbose) cout <<
"processing mode...." << l1cinput->
l1c_pflag << endl;
clo_option_t * clo_addOption(clo_optionList_t *list, const char *key, enum clo_dataType_t dataType, const char *defaultVal, const char *desc)
float clo_getOptionFloat(clo_option_t *option)
int32_t l1c_input_init(L1C_input *l1cinput)
int32_t l1c_load_input(clo_optionList_t *list, L1C_input *l1cinput)
char * clo_getString(clo_optionList_t *list, const char *key)
void clo_readArgs(clo_optionList_t *list, int argc, char *argv[])
void clo_addAlias(clo_optionList_t *list, const char *key, const char *alias)
char ** clo_getOptionStrings(clo_option_t *option, int *count)
char * clo_getOptionRawString(clo_option_t *option)
int sensorName2SensorId(const char *name)
int clo_getOptionInt(clo_option_t *option)
int32_t l1c_usage(const char *prog, const char *version)
int clo_isOptionSet(clo_option_t *option)
void clo_setVersion2(const char *programName, const char *versionStr)
int32_t l1c_init_options(clo_optionList_t *list, const char *prog, const char *version)
void clo_setSelectOptionKeys(char **keys)
void clo_setEnableDumpOptions(int val)
clo_optionList_t * clo_createList()
list(APPEND LIBS ${NETCDF_LIBRARIES}) find_package(GSL REQUIRED) include_directories($
void clo_setHelpStr(const char *str)
file_format getFormat(char *filename)
char * clo_getOptionString(clo_option_t *option)
int * clo_getOptionInts(clo_option_t *option, int *count)
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)
int clo_getNumOptions(clo_optionList_t *list)
void parse_file_name(const char *inpath, char *outpath)
std::vector< std::string > readFileList(std::string fileName)
const char * sensorId2SensorName(int sensorId)
void clo_deleteList(clo_optionList_t *list)
void clo_dumpOption(clo_option_t *option)
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")
int32_t l1c_inputmain(int argc, char **argv, L1C_input *l1cinput, l1c_filehandle *l1cfile, const char *prog, const char *version)
int clo_getOptionBool(clo_option_t *option)