Go to the documentation of this file.
14 #include <boost/algorithm/string.hpp>
19 using namespace netCDF;
20 using namespace netCDF::exceptions;
32 static char mainProgramName[50];
37 static char *l1cgen_optionKeys[] = {
41 "-dump_options_paramfile",
42 "-dump_options_xmlfile",
93 L1C_input::L1C_input(){};
94 L1C_input::~L1C_input(){};
116 strcpy(mainProgramName, prog);
118 sprintf(tmpStr,
"Usage: %s argument-list\n\n", prog);
119 strcat(tmpStr,
" The argument-list is a set of keyword=value pairs. The arguments can\n");
120 strcat(tmpStr,
" be specified on the commandline, or put into a parameter file, or the\n");
121 strcat(tmpStr,
" two methods can be used together, with commandline over-riding.\n\n");
122 strcat(tmpStr,
" return value: 0=OK, 1=error, 110=north,south,east,west does not intersect\n");
123 strcat(tmpStr,
" file data.\n\n");
124 strcat(tmpStr,
"The list of valid keywords follows:\n");
131 strcpy(tmpStr,
"input L1b file name");
155 strcpy(tmpStr,
"bin resolution\n");
156 strcat(tmpStr,
" H: 0.5km\n");
157 strcat(tmpStr,
" Q: 250m\n");
158 strcat(tmpStr,
" HQ: 100m\n");
159 strcat(tmpStr,
" HH: 50m\n");
160 strcat(tmpStr,
" 1: 1.1km\n");
161 strcat(tmpStr,
" 2: 2.3km\n");
162 strcat(tmpStr,
" 4: 4.6km\n");
163 strcat(tmpStr,
" 9: 9.2km\n");
164 strcat(tmpStr,
" 18: 18.5km\n");
165 strcat(tmpStr,
" 36: 36km\n");
166 strcat(tmpStr,
" 1D: 1 degree\n");
167 strcat(tmpStr,
" HD: 0.5 degree\n");
168 strcat(tmpStr,
" QD: 0.25 degree");
176 strcpy(tmpStr,
"flags masked [see /SENSOR/l2bin_defaults.par]");
179 strcpy(tmpStr,
"l2prod = bin products [default=all products]\n");
180 strcat(tmpStr,
" Set to \"ALL\" or \"all\" for all L2 products in 1st input file.\n");
181 strcat(tmpStr,
" Use ':' or ',' or ' ' as delimiters.\n");
182 strcat(tmpStr,
" Use ';' or '=' to delineate minimum values.\n");
190 strcpy(tmpStr,
"L1C processing flag\n");
191 strcat(tmpStr,
" 1: L1C grid creation from L1B granules\n");
192 strcat(tmpStr,
" 2: SBS binning\n");
193 strcat(tmpStr,
" 3: weighted binning\n");
194 strcat(tmpStr,
" 4: L2 processing\n");
195 strcat(tmpStr,
" 5: L1C grid creation from HKT telemetry\n");
199 strcpy(tmpStr,
"L1C grid min binning latitude\n");
201 strcpy(tmpStr,
"L1C grid max binning latitude\n");
203 strcpy(tmpStr,
"L1C grid min binning longitude\n");
205 strcpy(tmpStr,
"L1C grid max binning longitude\n");
208 strcpy(tmpStr,
"L1C processing of granules\n");
209 strcpy(tmpStr,
"granule id (1 to 10) note: not indexes!\n");
210 clo_addOption(
list,
"selgran",
CLO_TYPE_INT,
"[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]", tmpStr);
212 strcpy(tmpStr,
"Index L1C product [0,0,0]\n");
213 strcat(tmpStr,
" 0: pc\n");
214 strcat(tmpStr,
" 1: vsf\n");
215 strcat(tmpStr,
" 2: dpr\n");
218 strcpy(tmpStr,
"Day of the year for processing L1C swath\n");
219 strcat(tmpStr,
" units in day number (1-365/366)\n");
222 strcpy(tmpStr,
"Month of the year for processing L1C swath\n");
223 strcat(tmpStr,
" units in month number (1-12)\n");
226 strcpy(tmpStr,
"Year for processing L1C swath\n");
227 strcat(tmpStr,
" units in year\n");
230 strcpy(tmpStr,
"Swath id\n");
231 strcat(tmpStr,
" units in swath number\n");
234 strcpy(tmpStr,
"Common grid resolution\n");
235 strcat(tmpStr,
" units in km\n");
238 strcpy(tmpStr,
"Common grid across bins\n");
239 strcat(tmpStr,
" OCI: 514, SPEXone: 40, HARP: 600\n");
242 strcpy(tmpStr,
"PACE sensor to be gridded\n");
243 strcat(tmpStr,
" SPEXone: 1, OCI: 2, HARP: 3\n");
246 strcpy(tmpStr,
"file index L1A--HKT\n");
247 strcat(tmpStr,
" 0-unlimited\n");
250 strcpy(tmpStr,
"granule size for telemetry-derived L1C files\n");
251 strcat(tmpStr,
" in minutes--5' by default\n");
254 strcpy(tmpStr,
"Projection type\n");
255 strcat(tmpStr,
" 0: SOCEA\n");
256 strcat(tmpStr,
" 1: SOCEA-2\n");
259 strcpy(tmpStr,
"Terrain correct flag\n");
260 strcat(tmpStr,
" DEM correction\n");
261 strcat(tmpStr,
" 0: off\n");
262 strcat(tmpStr,
" 1: on\n");
265 strcpy(tmpStr,
"Cloud correct flag\n");
266 strcat(tmpStr,
" Cloud height correction\n");
267 strcat(tmpStr,
" 0: off\n");
268 strcat(tmpStr,
" 1: on\n");
271 strcpy(tmpStr,
"overlap views flag\n");
272 strcat(tmpStr,
" 0: off\n");
273 strcat(tmpStr,
" 1: on\n");
276 strcpy(tmpStr,
"overlap polarizations flag\n");
277 strcat(tmpStr,
" 0: off\n");
278 strcat(tmpStr,
" 1: on\n");
281 strcpy(tmpStr,
"overlap spectral bands flag\n");
282 strcat(tmpStr,
" 0: off\n");
283 strcat(tmpStr,
" 1: on\n");
287 strcpy(tmpStr,
"Uncertainty calculation method\n");
288 strcat(tmpStr,
" 0: error propagation\n");
289 strcat(tmpStr,
" 1: Monte Carlo\n");
292 strcpy(tmpStr,
"Uncertainty threshold for angular merged product\n");
293 strcat(tmpStr,
" as percentage\n");
296 strcpy(tmpStr,
"Uncertainty threshold for polarization merged product\n");
297 strcat(tmpStr,
" as percentage\n");
300 strcpy(tmpStr,
"Uncertainty threshold for spectral bands merged product\n");
301 strcat(tmpStr,
" as percentage\n");
317 char tmp_file[FILENAME_MAX];
318 int numOptions, optionId;
325 for (optionId = 0; optionId < numOptions; optionId++) {
336 while (*tmp_str !=
'\0') {
337 if (isupper(*tmp_str)) *tmp_str = tolower(*tmp_str);
341 if (strcmp(keyword,
"help") == 0) {
343 else if (strcmp(keyword,
"version") == 0) {
345 else if (strncmp(keyword,
"dump_options", 12) == 0) {
347 else if (strncmp(keyword,
"par", 3) == 0) {
349 else if (strcmp(keyword,
"ifile") == 0) {
355 }
else if (strcmp(keyword,
"ofile") == 0) {
371 else if (strcmp(keyword,
"sday") == 0) {
375 }
else if (strcmp(keyword,
"eday") == 0) {
379 }
else if (strcmp(keyword,
"resolution") == 0) {
384 }
else if (strcmp(keyword,
"rowgroup") == 0) {
395 else if (strcmp(keyword,
"l2prod") == 0) {
412 else if (strcmp(keyword,
"suite") == 0) {
442 else if (strcmp(keyword,
"verbose") == 0) {
483 else if (strcmp(keyword,
"l1c_pflag") == 0) {
486 else if (strcmp(keyword,
"binlatmin") == 0) {
489 else if (strcmp(keyword,
"binlatmax") == 0) {
492 else if (strcmp(keyword,
"binlonmin") == 0) {
495 else if (strcmp(keyword,
"binlonmax") == 0) {
498 else if (strcmp(keyword,
"selgran") == 0) {
502 if(iArray[
i]<=10) l1ccli->
selgran[
i] = iArray[
i];
503 else{ printf(
"-E- %s: Granule Id cant be larger than 10.\n", __FILE__);exit(1);}
506 else{ printf(
"-E- %s: Max number of granules to be processed is 10.\n", __FILE__);exit(1);}
508 else if (strcmp(keyword,
"ix_l1cprod") == 0) {
514 else if (strcmp(keyword,
"gres") == 0) {
517 else if (strcmp(keyword,
"nbinx") == 0) {
520 else if (strcmp(keyword,
"fileix") == 0) {
523 else if (strcmp(keyword,
"sensor") == 0) {
526 else if (strcmp(keyword,
"gransize") == 0) {
530 else if (strcmp(keyword,
"selday") == 0) {
533 else if (strcmp(keyword,
"selmon") == 0) {
536 else if (strcmp(keyword,
"selyear") == 0) {
539 else if (strcmp(keyword,
"swtnum") == 0) {
543 else if (strcmp(keyword,
"l1c_proj") == 0) {
546 else if (strcmp(keyword,
"terrain_correct") == 0) {
549 else if (strcmp(keyword,
"cloud_correct") == 0) {
552 else if (strcmp(keyword,
"overlap_vflag") == 0) {
555 else if (strcmp(keyword,
"overlap_pflag") == 0) {
558 else if (strcmp(keyword,
"overlap_bflag") == 0) {
561 else if (strcmp(keyword,
"unc_meth") == 0) {
564 else if (strcmp(keyword,
"unc_thres_v") == 0) {
567 else if (strcmp(keyword,
"unc_thres_p") == 0) {
570 else if (strcmp(keyword,
"unc_thres_b") == 0) {
574 printf(
"-E- Invalid argument \"%s\"\n", keyword);
598 l1ccli->
ofile[0] =
'\0';
611 l1ccli->
sday = 1970001;
612 l1ccli->
eday = 2038018;
641 for (
int i=0;
i<3;
i++) {
650 for (
int i=0;
i<10;
i++) {
708 char localIfile[FILENAME_MAX];
731 printf(
"-E- %s: Error initializing l1c input structure.\n", __FILE__);
740 if (l1cinput->
files.size() == 0) {
741 printf(
"No NetCDF input files found in %s.\n", localIfile);
745 cout<<
"l1cinput->files[0].."<<l1cinput->
files[0]<<endl;
747 ifile_str = l1cinput->
files[0];
753 cout<<
"ifile.."<<
ifile<<endl;
756 printf(
"format.type....%d..",format.type);
757 printf(
"sensor id.....%d..",format.sensor_id);
761 l1cfile->
format=format.type;
764 cout<<
"sensor id.."<<format.sensor_id<<
"sensor name.."<<
sensorId2SensorName(format.sensor_id)<<endl;
768 printf(
"-E- %s Line %d: Could not find type for file %s.\n", __FILE__, __LINE__,
ifile);
775 if (format.sensor_id == -1) {
776 printf(
"-E- Can not look up sensor ID for PLEASE PROVIDE PLATFORM FOR OCIS--!! %s.\n ", localIfile);
777 cout<<
"forcing to be HARP2 when HARP2 L1B is beta from Meng/Richard"<<endl;
783 if ((dataRoot = getenv(
"OCDATAROOT")) ==
NULL) {
784 printf(
"OCDATAROOT environment variable is not defined.\n");
795 if (
want_verbose) printf(
"Loading command line parameters for L1C processing\n\n");
798 printf(
"-E- %s: Error loading options into input structure.\n", __FILE__);
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[])
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)
void clo_addAlias(clo_optionList_t *list, const char *key, const char *alias)
char * clo_getOptionRawString(clo_option_t *option)
int clo_getOptionInt(clo_option_t *option)
int32_t l1c_usage(const char *prog, const char *version)
int clo_isOptionSet(clo_option_t *option)
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()
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)
const char * sensorId2SensorName(int sensorId)
void clo_setVersion(const char *str)
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)