Skip to content. | Skip to navigation

Personal tools

extract_amsua.c

#include <stdio.h>
#include <stdlib.h>
#include "amsua_bt_typ.h"
#include "amsua_bt_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 amsua_bt_gran_t amsua_bt_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 */
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, 45]\n");
fprintf(stderr, " 2) field-of-view number [1, 30]\n");
fprintf(stderr, " 3) file name\n\n");
exit(EXIT_FAILURE);
}
track = atoi(argv[1]);
if (track < 1 || track > 45) {
fprintf(stderr,
"Error: first argument must be scan line number [1, 45].\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 > 30) {
fprintf(stderr,
"Error: first argument must be scan line number [1, 30].\n");
fprintf(stderr, "got \"%s\".\n\n", argv[2]);
exit(EXIT_FAILURE);
}
xtrack--; /* change to 0-based for internal use */

file_name = argv[3];

amsua_bt_rdr(file_name, &amsua_bt_gran);

/*
* Each AMSU-A scan has 2 "state"s, indicating whether the AMSU-A1 and
* AMSU-A2 instruments were in science mode when the data
* was taken and whether the data was successfully transmitted.
*/
if ( 0 != amsua_bt_gran.state1[track]) {
printf("Warning, AMSU-A1 state for this profile is %s, not PROCESS\n",
amsua_bt_gran.state1[track] == 1 ? "SPECIAL" :
amsua_bt_gran.state1[track] == 2 ? "ERRONEOUS" :
amsua_bt_gran.state1[track] == 3 ? "MISSING" :
"UNKNOWN");
}
if ( 0 != amsua_bt_gran.state2[track]) {
printf("Warning, AMSU-A2 state for this profile is %s, not PROCESS\n",
amsua_bt_gran.state2[track] == 1 ? "SPECIAL" :
amsua_bt_gran.state2[track] == 2 ? "ERRONEOUS" :
amsua_bt_gran.state2[track] == 3 ? "MISSING" :
"UNKNOWN");
}

printf("# AMSU Brightness Temperatures (Kelvins)\n");
printf("# Channels 1-15\n");
printf("# (-9999 flags bad value)\n");
for (chan = 0; chan < AMSUA_BT_CHANNEL; chan++) {
printf("%8.2f\n", amsua_bt_gran.brightness_temp[track][xtrack][chan]);
}

return 0;
}

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