Go to the documentation of this file.
26 #define SENSOR_INFO_FILENAME "msl12_sensor_info.dat"
30 #define NEWSENSINFO 32
39 p = strchr(
line,
'=');
75 const char* subsensorDir;
85 static int32_t sensorID_s = -999;
87 static int32_t nbandsir = 0;
88 static int32_t nbandsvis = 0;
90 static int32_t *
bindx;
91 static int32_t *iwave;
105 static float *awhite;
111 static float *ooblw01;
112 static float *ooblw02;
113 static float *ooblw03;
115 static float *oobwv01;
116 static float *oobwv02;
117 static float *oobwv03;
118 static float *oobwv04;
119 static float *oobwv05;
120 static float *oobwv06;
121 static float *oobwv07;
122 static float *oobwv08;
123 static float *oobwv09;
124 static float *oobwv10;
125 static float *oobwv11;
126 static float *oobwv12;
136 if ((filedir = getenv(
"OCDATAROOT")) ==
NULL) {
137 printf(
"-E- %s: OCDATAROOT env variable undefined.\n", __FILE__);
166 fprintf(
stderr,
"-E- %s line %d: unable to open %s for reading\n",
173 printf(
"Opening sensor information file %s\n",
filename);
177 while (fgets(
line, 80, fp)) {
184 if (
line[0] ==
'#' ||
line[0] ==
'\n')
186 if (!(
p = strchr(
line,
'=')))
193 if (strcmp(
name,
"Nbands") == 0) {
200 printf(
"-E- %s: error find Nbands in %s.\n", __FILE__,
filename);
209 if ((iwave = (int32_t*) calloc(
nbands,
sizeof (int32_t))) ==
NULL)
211 if ((fwave = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
213 if ((Fo = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
215 if ((Tau_r = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
217 if ((k_oz = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
219 if ((awhite = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
221 if ((aw = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
223 if ((bbw = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
225 if ((wed = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
227 if ((waph = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
229 if ((a_h2o = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
231 if ((b_h2o = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
233 if ((c_h2o = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
235 if ((d_h2o = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
237 if ((e_h2o = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
239 if ((f_h2o = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
241 if ((g_h2o = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
243 if ((t_co2 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
245 if ((k_no2 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
247 if ((ooblw01 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
249 if ((ooblw02 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
251 if ((ooblw03 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
253 if ((oobwv01 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
255 if ((oobwv02 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
257 if ((oobwv03 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
259 if ((oobwv04 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
261 if ((oobwv05 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
263 if ((oobwv06 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
265 if ((oobwv07 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
267 if ((oobwv08 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
269 if ((oobwv09 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
271 if ((oobwv10 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
273 if ((oobwv11 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
275 if ((oobwv12 = (
float*) calloc(
nbands,
sizeof (
float))) ==
NULL)
279 "-E- %s: error allocating space for %d bands in sensor info.\n",
297 while (fgets(
line, 80, fp)) {
304 if (
line[0] ==
'#' ||
line[0] ==
'\n')
306 if (!(
p = strchr(
line,
'=')))
315 if (strcmp(
name,
"Nbands") == 0)
319 sprintf(param,
"Lambda(%d)",
i + 1);
320 if (strcmp(
name, param) == 0) {
322 iwave[
i] = (int32_t) roundf(fwave[
i]);
327 sprintf(param,
"F0(%d)",
i + 1);
328 sprintf(wparam,
"F0(%d)", iwave[
i]);
329 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
333 sprintf(param,
"Tau_r(%d)",
i + 1);
334 sprintf(wparam,
"Tau_r(%d)", iwave[
i]);
335 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
339 sprintf(param,
"k_oz(%d)",
i + 1);
340 sprintf(wparam,
"k_oz(%d)", iwave[
i]);
341 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
345 sprintf(param,
"t_co2(%d)",
i + 1);
346 sprintf(wparam,
"t_co2(%d)", iwave[
i]);
347 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
351 sprintf(param,
"k_no2(%d)",
i + 1);
352 sprintf(wparam,
"k_no2(%d)", iwave[
i]);
353 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
358 sprintf(param,
"a_h2o(%d)",
i + 1);
359 sprintf(wparam,
"a_h2o(%d)", iwave[
i]);
360 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
364 sprintf(param,
"b_h2o(%d)",
i + 1);
365 sprintf(wparam,
"b_h2o(%d)", iwave[
i]);
366 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
370 sprintf(param,
"c_h2o(%d)",
i + 1);
371 sprintf(wparam,
"c_h2o(%d)", iwave[
i]);
372 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
376 sprintf(param,
"d_h2o(%d)",
i + 1);
377 sprintf(wparam,
"d_h2o(%d)", iwave[
i]);
378 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
382 sprintf(param,
"e_h2o(%d)",
i + 1);
383 sprintf(wparam,
"e_h2o(%d)", iwave[
i]);
384 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
388 sprintf(param,
"f_h2o(%d)",
i + 1);
389 sprintf(wparam,
"f_h2o(%d)", iwave[
i]);
390 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
394 sprintf(param,
"g_h2o(%d)",
i + 1);
395 sprintf(wparam,
"g_h2o(%d)", iwave[
i]);
396 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
400 sprintf(param,
"awhite(%d)",
i + 1);
401 sprintf(wparam,
"awhite(%d)", iwave[
i]);
402 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
406 sprintf(param,
"aw(%d)",
i + 1);
407 sprintf(wparam,
"aw(%d)", iwave[
i]);
408 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
412 sprintf(param,
"bbw(%d)",
i + 1);
413 sprintf(wparam,
"bbw(%d)", iwave[
i]);
414 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
418 sprintf(param,
"wed(%d)",
i + 1);
419 sprintf(wparam,
"wed(%d)", iwave[
i]);
420 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
424 sprintf(param,
"waph(%d)",
i + 1);
425 sprintf(wparam,
"waph(%d)", iwave[
i]);
426 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
431 sprintf(param,
"ooblw01(%d)",
i + 1);
432 sprintf(wparam,
"ooblw01(%d)", iwave[
i]);
433 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
437 sprintf(param,
"ooblw02(%d)",
i + 1);
438 sprintf(wparam,
"ooblw02(%d)", iwave[
i]);
439 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
443 sprintf(param,
"ooblw03(%d)",
i + 1);
444 sprintf(wparam,
"ooblw03(%d)", iwave[
i]);
445 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
450 sprintf(param,
"oobwv01(%d)",
i + 1);
451 sprintf(wparam,
"oobwv01(%d)", iwave[
i]);
452 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
456 sprintf(param,
"oobwv02(%d)",
i + 1);
457 sprintf(wparam,
"oobwv02(%d)", iwave[
i]);
458 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
462 sprintf(param,
"oobwv03(%d)",
i + 1);
463 sprintf(wparam,
"oobwv03(%d)", iwave[
i]);
464 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
468 sprintf(param,
"oobwv04(%d)",
i + 1);
469 sprintf(wparam,
"oobwv04(%d)", iwave[
i]);
470 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
474 sprintf(param,
"oobwv05(%d)",
i + 1);
475 sprintf(wparam,
"oobwv05(%d)", iwave[
i]);
476 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
480 sprintf(param,
"oobwv06(%d)",
i + 1);
481 sprintf(wparam,
"oobwv06(%d)", iwave[
i]);
482 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
486 sprintf(param,
"oobwv07(%d)",
i + 1);
487 sprintf(wparam,
"oobwv07(%d)", iwave[
i]);
488 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
492 sprintf(param,
"oobwv08(%d)",
i + 1);
493 sprintf(wparam,
"oobwv08(%d)", iwave[
i]);
494 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
498 sprintf(param,
"oobwv09(%d)",
i + 1);
499 sprintf(wparam,
"oobwv09(%d)", iwave[
i]);
500 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
504 sprintf(param,
"oobwv10(%d)",
i + 1);
505 sprintf(wparam,
"oobwv10(%d)", iwave[
i]);
506 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
510 sprintf(param,
"oobwv11(%d)",
i + 1);
511 sprintf(wparam,
"oobwv11(%d)", iwave[
i]);
512 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
516 sprintf(param,
"oobwv12(%d)",
i + 1);
517 sprintf(wparam,
"oobwv12(%d)", iwave[
i]);
518 if (strcmp(
name, param) == 0 || strcmp(
name, wparam) == 0) {
549 printf(
" %3s %5s %8s %8s %8s %8s %8s %8s %8s %8s\n",
"Bnd",
"Lam",
550 "Fo",
"Tau_r",
"k_oz",
"k_no2",
"t_co2",
"awhite",
"aw",
554 " %3d %8.3f %8.3f %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e\n",
555 i, fwave[
i], Fo[
i], Tau_r[
i], k_oz[
i], k_no2[
i],
556 t_co2[
i], awhite[
i], aw[
i], bbw[
i]);
560 printf(
" %3s %5s\n",
"Bnd",
"Lam");
561 for (
i = 0;
i < nbandsir;
i++)
572 if (strcmp(pname,
"Nbands") == 0)
574 else if (strcmp(pname,
"NbandsIR") == 0)
575 *pval = (
void *) &nbandsir;
576 else if (strcmp(pname,
"NbandsVIS") == 0)
577 *pval = (
void *) &nbandsvis;
578 else if (strcmp(pname,
"Bindx") == 0)
579 *pval = (
void *)
bindx;
580 else if (strcmp(pname,
"fwave") == 0)
581 *pval = (
void *) fwave;
582 else if (strcmp(pname,
"iwave") == 0)
583 *pval = (
void *) iwave;
584 else if (strcmp(pname,
"Lambda") == 0)
585 *pval = (
void *) iwave;
586 else if (strcmp(pname,
"Fobar") == 0)
588 else if (strcmp(pname,
"Tau_r") == 0)
589 *pval = (
void *) Tau_r;
590 else if (strcmp(pname,
"k_oz") == 0)
591 *pval = (
void *) k_oz;
592 else if (strcmp(pname,
"t_co2") == 0)
593 *pval = (
void *) t_co2;
594 else if (strcmp(pname,
"k_no2") == 0)
595 *pval = (
void *) k_no2;
597 else if (strcmp(pname,
"a_h2o") == 0)
598 *pval = (
void *) a_h2o;
599 else if (strcmp(pname,
"b_h2o") == 0)
600 *pval = (
void *) b_h2o;
601 else if (strcmp(pname,
"c_h2o") == 0)
602 *pval = (
void *) c_h2o;
603 else if (strcmp(pname,
"d_h2o") == 0)
604 *pval = (
void *) d_h2o;
605 else if (strcmp(pname,
"e_h2o") == 0)
606 *pval = (
void *) e_h2o;
607 else if (strcmp(pname,
"f_h2o") == 0)
608 *pval = (
void *) f_h2o;
609 else if (strcmp(pname,
"g_h2o") == 0)
610 *pval = (
void *) g_h2o;
612 else if (strcmp(pname,
"awhite") == 0)
613 *pval = (
void *) awhite;
615 else if (strcmp(pname,
"aw") == 0)
617 else if (strcmp(pname,
"bbw") == 0)
618 *pval = (
void *) bbw;
620 else if (strcmp(pname,
"wed") == 0)
621 *pval = (
void *) wed;
622 else if (strcmp(pname,
"waph") == 0)
623 *pval = (
void *) waph;
625 else if (strcmp(pname,
"ooblw01") == 0)
626 *pval = (
void *) ooblw01;
627 else if (strcmp(pname,
"ooblw02") == 0)
628 *pval = (
void *) ooblw02;
629 else if (strcmp(pname,
"ooblw03") == 0)
630 *pval = (
void *) ooblw03;
632 else if (strcmp(pname,
"oobwv01") == 0)
633 *pval = (
void *) oobwv01;
634 else if (strcmp(pname,
"oobwv02") == 0)
635 *pval = (
void *) oobwv02;
636 else if (strcmp(pname,
"oobwv03") == 0)
637 *pval = (
void *) oobwv03;
638 else if (strcmp(pname,
"oobwv04") == 0)
639 *pval = (
void *) oobwv04;
640 else if (strcmp(pname,
"oobwv05") == 0)
641 *pval = (
void *) oobwv05;
642 else if (strcmp(pname,
"oobwv06") == 0)
643 *pval = (
void *) oobwv06;
644 else if (strcmp(pname,
"oobwv07") == 0)
645 *pval = (
void *) oobwv07;
646 else if (strcmp(pname,
"oobwv08") == 0)
647 *pval = (
void *) oobwv08;
648 else if (strcmp(pname,
"oobwv09") == 0)
649 *pval = (
void *) oobwv09;
650 else if (strcmp(pname,
"oobwv10") == 0)
651 *pval = (
void *) oobwv10;
652 else if (strcmp(pname,
"oobwv11") == 0)
653 *pval = (
void *) oobwv11;
654 else if (strcmp(pname,
"oobwv12") == 0)
655 *pval = (
void *) oobwv12;
664 if (strcmp(pname,
"NbandsIR") == 0)
666 else if (strcmp(pname,
"NbandsVIS") == 0)
const char * sensorId2SensorDir(int sensorId)
void parseline(char *line, char *name, char *value)
int sensorId2SubsensorId(int sensorId)
char filename[FILENAME_MAX]
int32_t rdsensorinfo(int32_t sensorID, int32_t evalmask, const char *pname, void **pval)
const char * sensorId2SensorName(int sensorId)
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)
const char * subsensorId2SubsensorDir(int subsensorId)
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 sensorID[MAXNFILES]
#define SENSOR_INFO_FILENAME