Skip to content. | Skip to navigation

Personal tools

extract_vnir.c

#include <stdio.h>
#include <stdlib.h>
#include "vnir_rad_typ.h"
#include "vnir_rad_struct.h"


/*
* Note: this struct is large. On my system this works
* when allocated this way but not when allocated as an automatic
* local variable in main(). It could also be dynamically allocated
* with malloc().
*/
static vnir_rad_gran_t vnir_rad_gran;

int main(int argc, char * argv[]) {
int chan; /* 0-based channel index. */
int track; /* 0-based index along track */
int xtrack;/* 0-based index across-track */
int i,j; /* 0-based indices for 8x9 of pixels per FOV */
char * file_name = 0;

if (argc != 4) {
fprintf(stderr, "%s extracts a single profile from a specified input\n",
argv[0]);
fprintf(stderr, "file to stdout. It requires exactly three arguments:\n");
fprintf(stderr, " 1) scan line number [1, 135]\n");
fprintf(stderr, " 2) field-of-view number [1, 90]\n");
fprintf(stderr, " 3) file name\n\n");
exit(EXIT_FAILURE);
}
track = atoi(argv[1]);
if (track < 1 || track > 135) {
fprintf(stderr,
"Error: first argument must be scan line number [1, 135].\n");
fprintf(stderr, "got \"%s\".\n\n", argv[1]);
exit(EXIT_FAILURE);
}
track--; /* change to 0-based for internal use */

xtrack = atoi(argv[2]);
if (xtrack < 1 || xtrack > 90) {
fprintf(stderr,
"Error: first argument must be scan line number [1, 90].\n");
fprintf(stderr, "got \"%s\".\n\n", argv[2]);
exit(EXIT_FAILURE);
}
xtrack--; /* change to 0-based for internal use */

file_name = argv[3];

vnir_rad_rdr(file_name, &vnir_rad_gran);

/*
* Each V/NIR Field-of-view has a "state", indicating whether the instrument
* was in science mode when the data was collected and whether the
* data was successfully transmitted.
*/
if ( 0 != vnir_rad_gran.state[track][xtrack]) {
printf("Warning, AIRS state for this profile is %s, not PROCESS\n",
vnir_rad_gran.state[track][xtrack] == 1 ? "SPECIAL" :
vnir_rad_gran.state[track][xtrack] == 2 ? "ERRONEOUS" :
vnir_rad_gran.state[track][xtrack] == 3 ? "MISSING" :
"UNKNOWN");
}

printf("# Vis/Near IR radiance\n");
printf("# Channels 1-4\n");
printf("# (-9999 flags bad value)\n\n");
for (chan = 0; chan < VNIR_RAD_CHANNEL; chan++) {
printf("# Channel %d\n", chan + 1);
for (i = 0; i < VNIR_RAD_SUBTRACK; i++) {
for (j = 0; j < VNIR_RAD_SUBXTRACK; j++)
printf("%8.2f ", vnir_rad_gran.radiances[track][xtrack][chan][i][j]);
printf("\n");
}
printf("\n");
}

return 0;
}

Document Actions
NASA Logo - nasa.gov
NASA Privacy Policy and Important Notices
Last updated: Sep 09, 2009 02:26 PM ET
Top