Go to the documentation of this file.
10 int get_item(
char *arg, instr *input_str);
12 int par_file(
char *pfile, instr *input_str);
16 input_str->ifile[0] =
'\0';
17 input_str->ofile[0] =
'\0';
18 input_str->pfile[0] =
'\0';
19 input_str->prod [0] =
'\0';
20 input_str->parms[0] =
'\0';
24 input_str->datamin = 0.0;
25 input_str->datamax = 0.0;
27 input_str->lonwest = -180.0;
28 input_str->loneast = +180.0;
29 input_str->latsouth = -90.0;
30 input_str->latnorth = +90.0;
32 strcpy(input_str->pversion,
"Unspecified");
33 strcpy(input_str->projection,
"RECT");
34 strcpy(input_str->resolution,
"9km");
35 strcpy(input_str->palfile,
"DEFAULT");
37 input_str->gap_fill = 0;
38 input_str->seam_lon = -180;
40 input_str->proddesc[0] =
'\0';
41 input_str->units[0] =
'\0';
42 input_str->precision[0] =
'\0';
44 input_str->minobs = 0;
45 input_str->deflate = 0;
46 input_str->oformat[0] =
'\0';
73 if (argc == 1)
return (-1);
79 printf(
"-E- %s: Error initializing input structure.\n", __FILE__);
86 for (
i = 1;
i < argc;
i++)
94 if (strcmp(
input->prod,
"NDVI") == 0 ||
95 strcmp(
input->prod,
"EVI") == 0)
96 memcpy(
input->palette, ndvi_palette, 768);
97 else if (strcmp(
input->prod,
"sst") == 0 ||
98 strcmp(
input->prod,
"sst4") == 0)
99 memcpy(
input->palette, sst_palette, 768);
101 memcpy(
input->palette, default_palette, 768);
107 if (strcmp(
input->palfile,
"DEFAULT") != 0) {
109 if (!(
r = (
short *) calloc(256,
sizeof (
short)))) {
110 fprintf(
stderr,
"smigen: Error allocating space for red.\n");
113 if (!(
g = (
short *) calloc(256,
sizeof (
short)))) {
114 fprintf(
stderr,
"smigen: Error allocating space for green.\n");
117 if (!(
b = (
short *) calloc(256,
sizeof (
short)))) {
118 fprintf(
stderr,
"smigen: Error allocating space for blue.\n");
122 fprintf(
stderr,
"Error reading palette file %s\n",
input->pfile);
125 for (
i = 0;
i < 256;
i++) {
144 sprintf(str_buf,
"ifile = %s|",
input->ifile);
145 strcat(
input->parms, str_buf);
146 sprintf(str_buf,
"ofile = %s|",
input->ofile);
147 strcat(
input->parms, str_buf);
148 if (
input->pfile[0] !=
'\0') {
149 sprintf(str_buf,
"pfile = %s|",
input->pfile);
150 strcat(
input->parms, str_buf);
152 sprintf(str_buf,
"prod = %s|",
input->prod);
153 strcat(
input->parms, str_buf);
154 sprintf(str_buf,
"palfile = %s|",
input->palfile);
155 strcat(
input->parms, str_buf);
156 sprintf(str_buf,
"processing version = %s|",
input->pversion);
157 strcat(
input->parms, str_buf);
158 sprintf(str_buf,
"meas = %d|",
input->meas);
159 strcat(
input->parms, str_buf);
160 sprintf(str_buf,
"stype = %d|",
input->stype);
161 strcat(
input->parms, str_buf);
162 sprintf(str_buf,
"datamin = %f|",
input->datamin);
163 strcat(
input->parms, str_buf);
164 sprintf(str_buf,
"datamax = %f|",
input->datamax);
165 strcat(
input->parms, str_buf);
166 sprintf(str_buf,
"lonwest = %f|",
input->lonwest);
167 strcat(
input->parms, str_buf);
168 sprintf(str_buf,
"loneast = %f|",
input->loneast);
169 strcat(
input->parms, str_buf);
170 sprintf(str_buf,
"latsouth = %f|",
input->latsouth);
171 strcat(
input->parms, str_buf);
172 sprintf(str_buf,
"latnorth = %f|",
input->latnorth);
173 strcat(
input->parms, str_buf);
174 sprintf(str_buf,
"resolution = %s|",
input->resolution);
175 strcat(
input->parms, str_buf);
176 sprintf(str_buf,
"projection = %s|",
input->projection);
177 strcat(
input->parms, str_buf);
178 sprintf(str_buf,
"gap_fill = %d|",
input->gap_fill);
179 strcat(
input->parms, str_buf);
180 sprintf(str_buf,
"seam_lon = %f|",
input->seam_lon);
181 strcat(
input->parms, str_buf);
182 sprintf(str_buf,
"minobs = %d|",
input->minobs);
183 strcat(
input->parms, str_buf);
184 sprintf(str_buf,
"deflate = %d|",
input->deflate);
185 strcat(
input->parms, str_buf);
186 sprintf(str_buf,
"oformat = %s|",
input->oformat);
187 strcat(
input->parms, str_buf);
188 sprintf(str_buf,
"precision = %s|",
input->precision);
189 strcat(
input->parms, str_buf);
196 char tmp_file[FILENAME_MAX];
198 static int lon_limit_used = 0;
199 static int seam_used = 0;
201 if ((tmp_str = strchr(arg,
'=')) ==
NULL) {
202 printf(
"Invalid argument \"%s\"\n", arg);
206 ilen1 = tmp_str - arg;
208 keyword[ilen1] =
'\0';
209 strcpy(parm_str, tmp_str + 1);
213 while (*tmp_str !=
'\0') {
214 if (isupper(*tmp_str)) *tmp_str = tolower(*tmp_str);
218 if (strcmp(keyword,
"par") == 0) {
222 }
else if (strcmp(keyword,
"ifile") == 0) {
226 }
else if (strcmp(keyword,
"ofile") == 0) {
230 }
else if (strcmp(keyword,
"prod") == 0) {
234 }
else if (strcmp(keyword,
"palfile") == 0) {
238 }
else if (strcmp(keyword,
"pversion") == 0) {
242 }
else if (strcmp(keyword,
"stype") == 0) {
243 input->stype = atoi(parm_str);
245 }
else if (strcmp(keyword,
"meas") == 0) {
246 input->meas = atoi(parm_str);
250 }
else if (strcmp(keyword,
"datamin") == 0) {
251 input->datamin = atof(parm_str);
253 }
else if (strcmp(keyword,
"datamax") == 0) {
254 input->datamax = atof(parm_str);
256 }
else if (strcmp(keyword,
"lonwest") == 0) {
257 input->lonwest = atof(parm_str);
260 }
else if (strcmp(keyword,
"loneast") == 0) {
261 input->loneast = atof(parm_str);
264 }
else if (strcmp(keyword,
"latsouth") == 0) {
265 input->latsouth = atof(parm_str);
267 }
else if (strcmp(keyword,
"latnorth") == 0) {
268 input->latnorth = atof(parm_str);
270 }
else if (strcmp(keyword,
"resolution") == 0) {
274 }
else if (strcmp(keyword,
"projection") == 0) {
278 }
else if (strcmp(keyword,
"gap_fill") == 0) {
279 input->gap_fill = atoi(parm_str);
281 }
else if (strcmp(keyword,
"seam_lon") == 0) {
282 input->seam_lon = atof(parm_str);
285 }
else if (strcmp(keyword,
"proddesc") == 0) {
289 }
else if (strcmp(keyword,
"units") == 0) {
293 }
else if (strcmp(keyword,
"precision") == 0) {
297 }
else if (strcmp(keyword,
"minobs") == 0) {
298 input->minobs = atol(parm_str);
300 }
else if (strcmp(keyword,
"deflate") == 0) {
301 input->deflate = atoi(parm_str);
303 }
else if (strcmp(keyword,
"oformat") == 0) {
311 if (lon_limit_used == 1 && seam_used == 1) {
312 printf(
"LONEAST/LONWEST cannot be used with SEAM_LON.\n");
320 printf(
"Invalid argument \"%s\"\n", arg);
329 if ((fp = fopen(pfile,
"r")) ==
NULL) {
330 printf(
"Error on opening the parameter file - %s\n", pfile);
334 while ((fgets(arg, 2047, fp)) !=
NULL) {
336 if (arg[0] ==
'#' || arg[0] ==
';' || arg[0] ==
' ' || arg[0] ==
'\0' ||
340 arg[strlen(arg) - 1] =
'\0';
void parse_file_name(const char *inpath, char *outpath)
int getlut_file(char *lut_file, short *rlut, short *glut, short *blut)
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second and prod_ix set to PARAM_TYPE_INT name_prefix is compared with the beginning of the product name If name_suffix is not empty the it must match the end of the product name The characters right after the prefix are read as an integer and prod_ix is set to that number strncpy(l2prod->name_prefix, "myprod", UNITLEN)
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")