Skip to content. | Skip to navigation

 Try out the New GES DISC site
Personal tools

extract_hsb.c

#include <stdio.h>
#include <stdlib.h>
#include "hsb_bt_typ.h"
#include "hsb_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 hsb_bt_gran_t hsb_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, 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];

hsb_bt_rdr(file_name, &hsb_bt_gran);

/*
* Each HSB scan 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 != hsb_bt_gran.state[track]) {
printf("Warning, HSB state for this profile is %s, not PROCESS\n",
hsb_bt_gran.state[track] == 1 ? "SPECIAL" :
hsb_bt_gran.state[track] == 2 ? "ERRONEOUS" :
hsb_bt_gran.state[track] == 3 ? "MISSING" :
"UNKNOWN");
}

printf("# HSB Brightness Temperatures (Kelvins)\n");
printf("# Channels 1-5\n");
printf("# (-9999 flags bad value)\n");
printf("# Channel 1 is always -9999. It was not implemented, but\n");
printf("# is kept to make HSB channel numbering equivalent to AMSU-B\n");
for (chan = 0; chan < HSB_BT_CHANNEL; chan++) {
printf("%8.2f\n", hsb_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