Skip to content. | Skip to navigation

Personal tools

extract_cc_spectrum.c

#include <stdio.h>
#include <stdlib.h>
#include "airs_cc_rad_typ.h"
#include "airs_cc_rad_struct.h"


/*
* Note: this struct is about 30 MBytes. 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 airs_cc_rad_gran_t airs_cc_rad_gran;

int main(int argc, char * argv[]) {
int chan; /* 0-based channel index */
int track; /* 1-based index along track */
int xtrack;/* 1-based index across-track */
char * file_name = 0;

if (argc != 4) {
fprintf(stderr, "%s extracts a single spectrum 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 > 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);
}
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);
}
file_name = argv[3];

airs_cc_rad_rdr(file_name, &airs_cc_rad_gran);

/*
* Each FOV has Qual_CC_Rad, giving qualitative quality info
* on the cloud-clearing for that scene. 0 is great, 1 is OK, 2 is bad.
*/
if ( 2 == airs_cc_rad_gran.Qual_CC_Rad[track-1][xtrack-1])
printf("WARNING, Qual_CC_Rad for this profile is 2 => DO NOT USE\n\n");
else if ( 1 == airs_cc_rad_gran.Qual_CC_Rad[track-1][xtrack-1])
printf("Warning, Qual_CC_Rad for this profile is 1 => Use With Caution\n\n");

printf("#\tFrequency\tRadiance\n");
printf("#\t(cm**-1)\t(milliWatts/m**2/cm**-1/steradian)\n");
printf("#\t\t\t(-9999 flags bad value)\n");
for (chan = 0; chan < AIRS_CC_RAD_CHANNEL; chan++) {
printf("\t%7.3f\t\t", airs_cc_rad_gran.nominal_freq[chan]);
/*
* channel should not be used because ExcludedChans indicates
* known radiometric problems. ExcludedChans echos information in
* field AB_State of the Channel Properties File
*/
if ( (airs_cc_rad_gran.ExcludedChans[chan] > 2)

/*
* channel should not be used because CalChanSummary indicates
* a transient problem with high noise
*/
|| (airs_cc_rad_gran.CalChanSummary[chan] & 8)

/*
* channel should not be used because CalChanSummary indicates
* a problem was encountered in calculating calibration coefficients
*/
/* 32 (bit 5) indicates gain anamoly, 64 (bit 6) for offset anamoly */
|| (airs_cc_rad_gran.CalChanSummary[chan] & (32 + 64))

/* channel has "popped". (transient change in zero-level in this scan) */
|| (airs_cc_rad_gran.CalFlag[track-1][chan] & 16))

/* something is wrong -- put out flag value -9999.0 */
printf("%.5e\n", -9999.0);
else
printf("%.5e\n", airs_cc_rad_gran.radiances[track-1][xtrack-1][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