/***************************************************************** * * * FILE: fire_ci2_his_read.c test : 1.0 Date: 120895 * AUTHOR: C Paul Kozoriz, Langley DAAC * * * PURPOSE/DESCRIPTION: * * This program is designed to read the FIRE ASTEX CI2 HIS * * data granules. Each file contains a set of records that * * represent data from a single channel. Each record contains * * a header followed by a block of up to 2050 4-byte floating * * point data values. * * * * INVOCATION: * * fire_ci2_his_read (if Makefile.fci2 is used to compile program) * * * * OPTIONS: (entered on command line) * * * * -f Changes the output format. Values are expressed * * or as floating point numbers instead of in scientific * * -float notation. * * * * PROGRAM LOGIC: * * request input file name * * request output file name * * if output file exists * * request operator action: * * 1)exit pgm 2)append 3)overwite * * endif * * open input and output working files * * * * request search options * * request range of records * * * * do until (end-of-file) or current record >= end record * * read input file * * write output information * * enddo * * close working files * * program completion message * * * * * * TUNABLE PARAMETERS: * *1) BSIZE the maximum record size, expressed as real*4 values * *2) Header offsets are defined explicitly herein beginning with * * "F_Record_Number" ending with "Maximum_Delay". * * * * * * INTERNALROUTINES: * * * * messages and prompts: * * Program_Complete_Msg - prints completion msg to screen * Operator_Record_Select_Prompt - prompts operator to enter * starting and ending record numbers. * Operator_Warning_Message - prints menu w/short option list * & prompts operator action to exit/append/overwrite file * Operator_Select_Menu - prints Output option selection menu * Operator_Help_Select - prints help for Output Select Menu * Operator_Help_Action - prints help for Action Menu * * * functions: * Init_Value_Set - initializes max/min data array with values * read from first record. * Find_Value_Set - calls Max/Min functions to determine * maximum and minimum values for spectral data. * * * output formatting: * Print_MaxMins - prints array and indices of max/min values * Print_Data - prints blocks of arrayed data and indices * Print_Hdr_Title - prints title line for header report * Print_Data_Title - prints title line for spectral data report * Print_Header_Extract - prints selected header elements * Print_Title_Line - prints title w/general project legend. * *****************************************************************/ #ifdef IRIX #include #include #define _IEEE_switch #endif #ifdef HPUX #define _HPUX_SOURCE #define _IEEE_switch #endif #ifndef _IEEE_switch #include #include #endif #include #include #include #include #include #include /* operating parameters */ #define MAXLINE 132 #define BSIZE 2150 /* max record size, real*4 values */ #define REC_SIZE (BSIZE*4) /* max record size, bytes */ /* bit flags for options selected */ #define RECORD_HEADER_TEXT 1 #define SPECTRAL_DATA 2 #define RECORD_HEADER_DATA 4 #define HDR_MAX_AND_MINS 8 #define DATA_MAX_AND_MINS 16 #define MAX_OPTIONS 6 #define TRUE 1 #define FALSE 0 /* ****************************************************************** * FIRE ASTEX Cirrus-2 High-resolution Interferometer Sounder * Header offsets for C program source (FORTRAN index - 1) * ******************************************************************/ /* BEGIN HEADER DEFINITIONS ******************************************/ #define F_Record_Number (1-1) #define F_Channel_Number (2-1) #define Mirror_Position (3-1) #define Scan_direction (4-1) #define No_Recs_Bad_Mir_Align (5-1) /* no.recs w/bad mirror align */ #define Buffer_Overflow (6-1) /* flag */ #define Unknown_Records (7-1) /* number of unknown records */ #define IFGM_Points (8-1) /* number of ifgm points */ #define Beginning_Record_number (9-1) #define ZPD_Rec_no_raw_data (10-1) #define F_Time (11-1) /* (UTC, seconds) */ #define Hot_Blackbody_Temp (12-1) /* degrees Centigrade */ #define Cold_Blackbody_Temp (13-1) /* degrees Centigrade */ #define DC_Level_Ch_1 (14-1) #define DC_Level_Ch_2 (15-1) #define DC_Level_Ch_3 (16-1) #define F_Year (17-1) /* (tens & units digits) */ #define F_Month (18-1) #define F_Day (19-1) #define IFGM_0_ZPD (20-1) #define IFGM_Burst_Noise (21-1) #define Std_Dev_of_Phase (22-1) #define F_Time_beginng (23-1) /* (HHMMSS) */ #define F_Time_current (24-1) /* (HHMMSS) */ #define IFGM_Short (25-1) /* (<0 = bad) */ #define Data_Conversion_Type (26-1) #define ZPD_word_number (27-1) /* (in ifgm) */ #define Time_correction (28-1) /* (seconds) */ #define Apodization (29-1) /* (0=none) */ #define No_IFGM_FFT_Points_Used (30-1) #define Number_valid_points (31-1) /* in each spectrum */ #define Calibration_Rec_1 (32-1) #define Wavenumber_interval (33-1) /*(reciprocal centimeters) */ #define Minimum_wavenumber (34-1) /*(reciprocal centimeters) */ #define Maximum_wavenumber (35-1) /*(reciprocal centimeters) */ #define Number_words_record (36-1) /* 32-bit word length */ #define Number_words_header (37-1) #define Spectral_Resolution (38-1) #define Flag_bad_rec_count (39-1) #define Number_of_records_in_file (40-1) #define HBB_CalPt_1_Avgtemp (41-1) #define CBB_CalPt_1_Avgtemp (42-1) #define HBB_CalPt_2_Avgtemp (43-1) #define CBB_CalPt_2_Avgtemp (44-1) #define CalPt_1_RecNum (45-1) #define CalPt_2_RecNum (46-1) #define No_IFGM_Records (47-1) #define QC_Flag (48-1) /* (0=ok, PLOVR) */ #define Missing_Channel (49-1) /* (-1, CHKSET) */ #define Laser_Wavenumber (50-1) #define Aircraft_latitude (51-1) /*(+ = N) */ #define Aircraft_longitude (52-1) /*(+ = E) */ #define Aircraft_altitude (53-1) /*(feet) */ #define Aircraft_heading (54-1) /*(degrees CW from north) */ #define HBB_CorrCoef_1_Temp (55-1) #define HBB_CorrCoef_2_Temp (56-1) #define HBB_CorrCoef_3_Temp (57-1) #define CBB_CorrCoef_1_Temp (58-1) #define CBB_CorrCoef_2_Temp (59-1) #define CBB_CorrCoef_3_Temp (60-1) #define AvgTemp_Beamsplitter (61-1) #define AvgTemp_Laser (62-1) #define AvgTemp_AP_Stop (63-1) #define AvgTemp_SCAM_Encl (64-1) #define AvgTemp_Recorder_Dr (65-1) #define AvgTemp_Power_Supply (66-1) #define AvgTemp_Bomem_Ps (67-1) #define AvgTemp_Pod_Air (68-1) #define AvgTemp_Dewar_Window (69-1) #define AvgTemp_Optics_Mir (70-1) #define AvgTemp_Optics_Bench (71-1) #define AvgTemp_BB_Heatsink (72-1) #define AvgPres_Atmospheric (73-1) #define AvgDC_1_Level (74-1) #define AvgDC_2_Level (75-1) #define AvgDC_3_Level (76-1) #define AvgTemp_1_Dewar (77-1) /* degrees (K) */ #define AvgTemp_2_Dewar (78-1) /* degrees (K) */ #define HBB_Bad_Temps (79-1) #define CBB_Bad_Temps (80-1) #define F1_sec_AVDIRS (81-1) /* "File 1" seconds(AVDIRS) */ #define F2_sec_AVDIRS (82-1) /* "File 2" seconds(AVDIRS) */ #define F1_hms_AVDIRS (83-1) /* "File 1" hhmmss(AVDIRS) */ #define F2_hms_AVDIRS (84-1) /* "File 2" hhmmss(AVDIRS) */ #define AvgSP_Mean (85-1) /* (COADDHIS) */ #define AvgSP_SD (86-1) /* (COADDHIS) */ #define Lower_Wavenumber (87-1) /* (COADDHIS) */ #define Upper_Wavenumber (88-1) /* (COADDHIS) */ #define AC_Heading_start (89-1) /* A/C hdg., start(COADDHIS) */ #define AC_Heading_end (90-1) /* A/C hdg., end(COADDHIS) */ #define HBB_AvgTemp_1 (91-1) /* Avg. HBB temp.#1,(HISAC3) */ #define HBB_SD_Temp_1 (92-1) /* S.D. HBB temp.#1,(HISAC3) */ #define CBB_AvgTemp_1 (93-1) /* Avg. CBB temp.#1,(HISAC3) */ #define CBB_SD_Temp_1 (94-1) /* S.D. CBB temp.#1,(HISAC3) */ #define HBB_AvgTemp_2 (95-1) /* Avg. HBB temp.#2,(HISAC3) */ #define HBB_SD_Temp_2 (96-1) /* S.D. HBB temp.#2,(HISAC3) */ #define CBB_AvgTemp_2 (97-1) /*XXXAvg. CBB temp.#2,(HISAC3) */ #define CBB_SD_Temp_2 (98-1) /* S.D. CBB temp.#2,(HISAC3) */ #define Std_Dev (99-1) /* Std Dev.(ph.-ref.,HISAC2 */ #define Maximum_Delay (100-1) /* HISAC1 */ /* END HEADER DEFINITIONS ******************************************/ #define FIRST_HDR_ENTRY F_Record_Number #define MAX_HEADER_ENTRIES (Maximum_Delay+1) /* ****************************************************************** * -->local functions defined in this program * ******************************************************************/ void Program_Complete_Msg (); void Operator_Record_Select_Prompt (); void Operator_Warning_Message (); void Operator_Select_Menu (); void Operator_Help_Select (); void Operator_Help_Action (); void Init_Value_Set (); void Find_Value_Set (); void Print_MaxMins (); void Print_Data (); void Print_Hdr_Title (); void Print_Data_Title (); void Print_Header_Extract (); void Print_Title_Line (); void Print_Banner (); /* Global Variables */ int DBG=FALSE; /* program debug flag 0=disable */ int Float_Option=FALSE; /* floating point format option */ #ifdef PROTO main(int argc, char **argv) #else main(argc, argv) int argc; char **argv; #endif { static char rcsid[]="@(#)$Id: fire_ci2_his_read.c,v 1.1 1996/03/11 21:55:33 cpk Exp $"; FILE *inf, *outf; /* input and output file pointers */ int in_file_handle; /* integer file descriptor for status call */ float fbuf[(BSIZE+1)]; /* raw input data buffer */ float Min_Value_Set[(BSIZE+1)]; /* minimum value fl pt. array */ float Max_Value_Set[(BSIZE+1)]; /* maximum value fl pt. array */ char *spinner={"/-|-\\|"}; /* eye-catcher - program "busy" */ char inname[MAXLINE], /* input file name */ outname[MAXLINE]; /* output file name */ char out_control[MAXLINE]; /* temp buffer used for option select */ char scratch[MAXLINE]; /* temp gen.purpose char string buffer */ int elem_read_in; /* no. of raw data bytes read (fread) */ int out_flags=0; /* search option semaphore flag word */ int start_rec=0,end_rec=0,num_recs; /* record number buffers */ int curr_rec=0; /* record number buffers */ int i,j,status,done; /* loop counters, misc program control */ int strlen_inname = 1; /* number of chars read in */ /* #ifdef HPUX extern struct stat file_status; #else */ struct stat file_status; /* #endif */ /* ************************************************** * --> default to display results in scientific notation; * check for request for floating point format * **************************************************/ if ( argc > 1 ) { for ( i=1 ; i < argc ; i++ ) { strcpy( scratch, *(argv+i) ); /* fetch command line string */ /* and translate to lower case */ for ( j=0; j < strlen(scratch) ; j++ ) *(scratch+j)=tolower(*(scratch+j)); if(( strcmp( scratch, "-f" )== 0 ) || ( strcmp( scratch, "-float" )== 0 )) { Float_Option=TRUE; /* enable floating point format */ } } } /* ************************************************** * --> Prompt operator for name of fire ci2 data granule * **************************************************/ while( strlen_inname == 1 ) { Print_Banner (); printf("Enter FIRE CI2 HIS data file name: "); gets(inname); strlen_inname = strlen(inname); if( strlen_inname == 1 && tolower(inname[0]) == 'x' ) { Program_Complete_Msg (); exit(0); } } /* ************************************************** * --> Open the data granule file - read only * **************************************************/ if ((inf=fopen(inname,"r")) == NULL) { printf("error opening file %s\n",inname); exit(1); } /* ************************************************** * --> Open output report file - write * **************************************************/ printf("Enter Output file name ( \"-\" defaults to screen, \"x\" to exit) :\t"); gets(outname); /* ************************************************** * --> Set default to stdout if response was "-" or * **************************************************/ if (outname[0] == '-' || strlen(outname) == 0 ) { outf = stdout; } else if( tolower(outname[0]) == 'x' && strlen(outname) == 1 ) { Program_Complete_Msg (); exit(0); } else { if (access(outname,2) == 0) { /* ************************************************** * --> let operator know Output file exists * **************************************************/ Operator_Warning_Message (outname); printf("\n Please enter number of action to take (1-3): "); done = FALSE; /* ************************************************** * --> Output file exists - force operator to make decision * **************************************************/ while ( !done ) { scanf("%s",out_control); switch (out_control[0]) { case 'x': /* exit program */ case 'X': /* ditto */ case '1': Program_Complete_Msg (); exit(0); break; case '2': /* open for append */ if ((outf = fopen(outname,"a")) == NULL) { printf("EXITING - FATAL ERROR opening file %s\n",outname); exit(1); } done=TRUE; break; case '3': /* overwrite file */ if ((outf = fopen(outname,"w")) == NULL) { printf("EXITING - FATAL ERROR opening file %s\n",outname); exit(1); } done=TRUE; break; case '4': /* change name of file - not yet implemented */ break; case 'm': /* redisplay menu */ case 'M': /* ditto */ Operator_Warning_Message (outname); printf("\n Please enter number of action to take (1-3): "); break; case 'h': /* help */ case 'H': /* ditto */ Operator_Help_Action (); printf("\n Please enter number of action to take (1-3): "); break; default : /* duh */ printf( "\tyour selection, \"%c\" is not supported\n\n",out_control[0]); printf("\tValid selections are:\n\ \t 1 through %3 inclusive...selects and enables action\n\ \t h...help\n\ \t m...redisplay menu\n\ \t x...exit program\n",MAX_OPTIONS); printf("\n Please enter number of action to take (1-3): "); } /* end switch */ } /* end while */ } /* end access == 0 test */ else { if ((outf = fopen(outname,"w")) == NULL) { printf("EXITING - FATAL ERROR opening file %s\n",outname); exit(1); } } } /* ************************************************** * --> Prompt operator to select format * **************************************************/ Operator_Select_Menu (); printf("\n Please enter number of desired selection \ (1-%-d) <0 = CONTINUE>: ",MAX_OPTIONS); done = FALSE; while ( !done ) { scanf("%s",out_control); switch (out_control[0]) { case '0' : /* user finished selecting options */ if( out_flags != 0 ) done = TRUE; break; case '1' : /* Record Header - extract with text (#31) */ out_flags = out_flags | RECORD_HEADER_TEXT; break; case '2' : /* Record header data */ out_flags = out_flags | RECORD_HEADER_DATA; break; case '3' : /* Spectral data values */ out_flags = out_flags | SPECTRAL_DATA; break; case '4' : /* Record Header and Spectral data values */ out_flags = out_flags | RECORD_HEADER_DATA | SPECTRAL_DATA; break; case '5' : /* Record Header MAX and MIN values */ out_flags = out_flags | HDR_MAX_AND_MINS; break; case '6' : /* Spectral data MAX and MIN values */ out_flags = out_flags | DATA_MAX_AND_MINS; break; case 'm' : /* redisplay menu */ case 'M' : /* ditto */ Operator_Select_Menu (); printf("\n Please enter number of desired selection \ (1-%-d) <0 = CONTINUE>: ",MAX_OPTIONS); break; case 'h' : /* help */ case 'H' : /* ditto */ Operator_Help_Select (); printf("\n Please enter number of desired selection \ (1-%-d) <0 = CONTINUE>: ",MAX_OPTIONS); break; case 'x' : /* exit program */ case 'X' : /* ditto */ Program_Complete_Msg (); exit(0); break; default : /* duh */ printf( "\tyour selection, \"%c\" is not supported\n\n",out_control[0]); printf("\tValid selections are:\n\ \t 1 through %-d inclusive...selects and enables option\n\ \t 0...option select sequence complete\n\ \t h...help\n\ \t m...redisplay menu\n\ \t x...exit program\n",MAX_OPTIONS); printf("\n Please enter number of desired selection \ (1-%-d) <0 = CONTINUE>: ",MAX_OPTIONS); break; } /* end switch */ } /* end while */ /* ************************************************** * --> Setup for file status call; get file descriptor * **************************************************/ in_file_handle = fileno(inf); /* ************************************************** * --> Retrieve file attributes * **************************************************/ status = fstat(in_file_handle,&file_status); if (status == -1) { printf( "ERROR DETECTED - can't get status of input file %s \n - error = %d\n", inname,errno); exit(1); } /* ************************************************** * --> calculate the number of records based on record size * **************************************************/ num_recs = ((int)file_status.st_size/REC_SIZE); /* --> check for an integral number of record blocks... */ if( ((float)num_recs - ( (float)file_status.st_size/(float)REC_SIZE )) ) { printf("\n\nWARNING\n"); printf( "WARNING - granule %s record size may have changed or file may be damaged.\n", inname ); printf("WARNING\n"); fprintf(outf, "\n\nWARNING ****************************************************************\n"); fprintf(outf, "!! WARNING !! granule %s record size may have changed or file may be damaged.\n", inname ); fprintf(outf, "WARNING ****************************************************************\n\n"); } if ( DBG ) { printf(">>DBG: file_status.st_size = %d\n", (int)file_status.st_size ); printf(">>DBG: file_status.st_blksize = %d\n", (int)file_status.st_blksize ); printf(">>DBG: file_status.st_blocks = %d\n", (int)file_status.st_blocks ); printf(">>DBG:num_recs(file_status.st_size) = %d(%d)\n", num_recs,file_status.st_size); fflush(stdout); } /* ************************************************** * --> Prompt operator to select starting and ending record #'s * **************************************************/ Operator_Record_Select_Prompt ( num_recs ); while (end_rec == 0) { printf (" Please enter starting record number (-1 or %d >= number >= 1): ", num_recs); scanf("%s",out_control); if( tolower(out_control[0]) == 'x' && strlen(out_control) == 1 ) exit(0); start_rec=atoi(out_control); if ((start_rec > 0 ) && (start_rec <= num_recs)) { while ((end_rec < start_rec) || (end_rec > num_recs)) { printf( " enter last record to examine ( %d >= number >= %d): ", num_recs, start_rec); scanf("%s",out_control); if( tolower(out_control[0]) == 'x' && strlen(out_control) == 1 ) exit(0); end_rec=atoi(out_control); } } else { if (start_rec == -1) { start_rec = 1; end_rec = num_recs; } } } /* ****************************************************************** * --> start reading data record loop * ******************************************************************/ printf("\n"); curr_rec = start_rec; while ((feof(inf) == 0) && (curr_rec <= end_rec)) { printf(" %c\r",spinner[(curr_rec%7)] ); fflush(stdout); if (curr_rec > end_rec) break; /* ****************************************************************** * --> position on record number & read file record (header included) * ******************************************************************/ if ((fseek(inf,(long)((curr_rec - 1) * REC_SIZE),SEEK_SET)) != 0) { printf("seek to record %d of file %s failed -- exiting \n", curr_rec,inname); exit(1); } /* ****************************************************************** * --> start reading BSIZE records of 32 bit floating point data * ******************************************************************/ if ((elem_read_in=fread((void *)fbuf,sizeof(float),BSIZE,inf)) == NULL) { if (feof(inf) != 0) { printf ("*** END OF FILE DETECTED ***\n"); Program_Complete_Msg (); } else fprintf(outf, "FATAL ERROR - read failed on read attempt of RECORD #%d\n",curr_rec); exit(1); } /* ****************************************************************** * --> Print Title & Init value array - first pass only * ******************************************************************/ if( curr_rec == start_rec ) { if( (int ) *(fbuf+Number_of_records_in_file) != num_recs ) { fprintf(outf, "ERROR - embedded record count does not match physical file size. %d :: %d\n", (int ) *(fbuf+Number_of_records_in_file), num_recs ); exit(1); } Init_Value_Set ( fbuf, Min_Value_Set, Max_Value_Set ); Print_Title_Line ( outf, inname ); } /* ****************************************************************** * --> print out Cirrus-2 record header extract with text * ******************************************************************/ if ((out_flags & RECORD_HEADER_TEXT ) == RECORD_HEADER_TEXT ) { Print_Header_Extract ( outf, curr_rec, fbuf ); } /* ****************************************************************** * --> print out Cirrus-2 record header data values (floating point) * ******************************************************************/ if ((out_flags & RECORD_HEADER_DATA ) == RECORD_HEADER_DATA ) { Print_Hdr_Title ( outf, curr_rec, fbuf ); Print_Data ( outf, fbuf, 0, (int) *(fbuf+Number_words_header)); } /* ****************************************************************** * --> print out Cirrus-2 "Number_valid_points" spectral data values * ******************************************************************/ if ((out_flags & SPECTRAL_DATA ) == SPECTRAL_DATA ) { Print_Data_Title ( outf, curr_rec, fbuf ); Print_Data ( outf, fbuf, (int ) *(fbuf+Number_words_header), (int ) *(fbuf+Number_valid_points) ) ; } if( (out_flags & HDR_MAX_AND_MINS ) == HDR_MAX_AND_MINS || (out_flags & DATA_MAX_AND_MINS ) == DATA_MAX_AND_MINS ) { Find_Value_Set ( fbuf, Min_Value_Set, Max_Value_Set ); } /* ****************************************************************** * --> increment CI-2 record number * ******************************************************************/ curr_rec++; } /* end of while not EOF */ if ((out_flags & HDR_MAX_AND_MINS ) == HDR_MAX_AND_MINS ) { Print_MaxMins ( outf, inname, Min_Value_Set, Max_Value_Set, 0, (int ) *(fbuf+Number_words_header), "HEADER" ); } if ((out_flags & DATA_MAX_AND_MINS ) == DATA_MAX_AND_MINS ) { i= (int ) *(fbuf+Number_words_header); Print_MaxMins ( outf, inname, Min_Value_Set, Max_Value_Set, (int ) *(fbuf+Number_words_header), (int ) *(fbuf+Number_valid_points), "SPECTRAL DATA" ); } Program_Complete_Msg (); } /* ****************************************************************** * --> Print_Banner - "mission statement" * ******************************************************************/ void Print_Banner () { printf("\n \ =========================================================================\n\n"); printf("\t\tFirst ISCCP Regional Experiment - Cirrus2\n"); printf("\t\t (FIRE CI2 HIS)\n\n"); printf(" \ This utility was specifically designed to provide access to FIRE CI2 HIS\n"); printf(" \ spectral data granules. A granule is composed of a set of records, each\n"); printf(" \ of which contains a 100 word header followed by a 2050 word data block.\n"); printf(" \ Words are represented in 32-bit IEEE floating point format.\n\n"); printf(" \ Data granules represent upwelling calibrated radiance from the High-resolution\n"); printf(" \ Interferometer Sounder (HIS) aboard the NASA ER-2 aircraft during FIRE II\n"); printf(" \ for the days 26 Nov 1991 and 5 Dec 1991. Header information in each record\n"); printf(" \ contains dynamic physical information that identify mission parameters at time\n"); printf(" of capture.\n\n"); printf(" \ Menu options during startup permit the operator to make functional selections\n"); printf(" \ varying data content, presentation and scope. For convenience, help (h) and \n"); printf(" \ exit (x) options may be invoked at any entry point in the program. In addition,\n"); printf(" \ no data translation is performed by this utility.\n"); printf("\n \ =========================================================================\n\n"); } /* ****************************************************************** * --> Program_Complete_Msg * ******************************************************************/ void Program_Complete_Msg () { fprintf(stdout, "*******************************************************************\n"); fprintf(stdout, "* *\n"); fprintf(stdout, "* program complete *\n"); fprintf(stdout, "* *\n"); fprintf(stdout, "*******************************************************************\n"); } /* ****************************************************************** * --> Operator_Help_Action * ******************************************************************/ void Operator_Help_Action () { printf("*******************************************************************\n"); printf("* *\n"); printf("* Help for Action Menu *\n"); printf("* *\n"); printf("* As a precaution, this program will not attempt to overwrite an *\n"); printf("* existing data file. If this occurs, the \"Action Menu\" permits *\n"); printf("* the operator to append or overwrite the existing data file. *\n"); printf("* *\n"); printf("* Valid Action Menu option numbers are: *\n"); printf("* 1 - stop now and exit program immediately (same as x) *\n"); printf("* 2 - append to existing file *\n"); printf("* 3 - overwrites existing file *\n"); printf("* *\n"); printf("* h - this Help screen *\n"); printf("* m - redisplay Menu *\n"); printf("* x - terminates processing & eXit program *\n"); printf("* *\n"); printf("* NOTE: *\n"); printf("* File access errors terminate processing and program exit. *\n"); printf("* *\n"); printf("*******************************************************************\n"); } /* ****************************************************************** * --> Operator_Help_Select * ******************************************************************/ void Operator_Help_Select () { printf("*******************************************************************\n"); printf("* Help for Select Output Menu *\n"); printf("* *\n"); printf("* Output Menu options permit the operator to vary output report *\n"); printf("* content. One or more options may be selected concurrently by *\n"); printf("* entering the option number, one per line. Zero (0) terminates *\n"); printf("* the option selection process, and resumes the program. *\n"); printf("* *\n"); printf("* Menu options are: *\n"); printf("* 1 Header extract - selected values are shown with description *\n"); printf("* 2 Header data - complete header shown as a block of floating *\n"); printf("* point data values and array indices. *\n"); printf("* 3 Spectral data - complete spectral data shown as a block of *\n"); printf("* floating point data values and array indices. *\n"); printf("* 4 Both header and data - selects both options 2 and 3 above *\n"); printf("* 5 header data range - min. and max. data values extracted *\n"); printf("* 6 Spectral data range - min. and max. data values extracted *\n"); printf("* *\n"); printf("* 0 (zero) completes option selection process & resumes program *\n"); printf("* h this help screen *\n"); printf("* m redisplay Menu *\n"); printf("* x terminates processing & exits program *\n"); printf("*******************************************************************"); } /* ****************************************************************** * --> Operator_Warning_Message * ******************************************************************/ void Operator_Warning_Message ( Outname ) char *Outname; { printf("*******************************************************************\n"); printf("* *\n"); printf("* WARNING - FILE EXISTS - PLEASE CHOOSE OPTION BELOW *\n"); printf("* *\n"); printf("* 1 - stop now *\n"); printf("* 2 - append to existing file %s *\n", Outname); printf("* 3 - overwrite file %s *\n", Outname); printf("* *\n"); printf("* (h - help x - exit) *\n"); printf("* *\n"); printf("*******************************************************************\n"); } /* ****************************************************************** * --> Operator_Record_Select_Prompt * ******************************************************************/ void Operator_Record_Select_Prompt ( Num_Recs ) int Num_Recs; /* total number of records in file */ { printf( "\n\n ------------- SELECT RANGE OF RECORDS -------------"); printf( "\n\n\t\t(there are %d records in this granule)\n",Num_Recs); /* "\n\n Each of the %d records in this file contains a header and a data block of\n",Num_Recs); */ /* " Cirrus 2 upwelling radiance spectral data expressed in IEEE floating point\n"); */ /* printf(" format.\n\n"); */ printf(" Please indicate START and END record numbers to extract. If you enter -1\n"); printf(" for the starting record, ALL RECORDS WILL BE EXAMINED and extracted in\n"); printf(" accordance with the previously specified criteria. \n\n"); } /* ****************************************************************** * --> Operator_Select_Menu * ******************************************************************/ void Operator_Select_Menu () { printf( "\n\n*******************************************************************\n"); printf("* *\n"); printf("* Customized Output Menu *\n"); printf("* ====================== *\n"); printf("* *\n"); printf("* 1) Record Header - extract w/description *\n"); printf("* 2) Record Header - floating point data values *\n"); printf("* 3) Spectral Radiation floating point data values *\n"); printf("* 4) Both record header and spectral data values *\n"); printf("* 5) Record header data value range (MAX/MIN) *\n"); printf("* 6) Spectral data value range (MAX/MIN) *\n"); printf("* *\n"); printf("* h brief Help menu *\n"); printf("* m redisplay this Menu *\n"); printf("* x eXits program *\n"); printf("* *\n"); printf("* enter 0 (zero) to complete menu option selection process and *\n"); printf("* continue program. *\n"); printf("* *\n"); printf("*******************************************************************\n"); } /* ****************************************************************** * --> Print_Title_Line * ******************************************************************/ void Print_Title_Line ( outfile, fname ) FILE *outfile; /* output file descriptor */ char *fname; /* output file name char string */ { fprintf(outfile,"\n \ =========================================================================\n\n"); fprintf(outfile,"\t\tFirst ISCCP Regional Experiment - Cirrus2\n"); fprintf(outfile,"\t\t (FIRE CI2 HIS)\n\n"); fprintf(outfile," \ Upwelling calibrated radiance from the High-resolution Interferometer Sounder\n"); fprintf(outfile," \ (HIS) aboard the NASA ER-2 aircraft during FIRE II for the days 26 Nov 1991\n"); fprintf(outfile," and 5 Dec 1991.\n"); fprintf(outfile,"\n\tFILE NAME: %s\n\n",fname ); fprintf(outfile," \ =========================================================================\n"); } /* ****************************************************************** * --> Print_Header_Extract * ******************************************************************/ void Print_Header_Extract ( outfile, Rec_Number, fBuf ) FILE *outfile; /* output file descriptor */ int Rec_Number; /* current record number being processed */ float *fBuf; /* raw data input buffer pointer */ { fprintf(outfile, "\n\t================= Header Record %-d Extract =================\n", Rec_Number); fprintf(outfile,"\t\t===== CI2 Selected Header Values =====\n\n", (int) *(fBuf+Number_words_header) ); fprintf(outfile,"\t%-d\t\t= NUMBER WORDS IN THIS RECORD\n", (int ) *(fBuf+Number_words_record) ); fprintf(outfile,"\t%-d\t\t= NUMBER VALID POINTS IN EACH SPECTRUM \n", (int ) *(fBuf+Number_valid_points) ); fprintf(outfile,"\t%-d\t\t= NUMBER OF WORDS IN THIS HEADER\n", (int ) *(fBuf+Number_words_header) ); fprintf(outfile,"\t%-d\t\t= RECORD NUMBER\n", (int ) *(fBuf+F_Record_Number) ); fprintf(outfile,"\t%-d\t\t= CHANNEL NUMBER\n", (int ) *(fBuf+F_Channel_Number) ); fprintf(outfile,"\t%f\t= Interval (reciprocal cm.)\n", *(fBuf+Wavenumber_interval) ); fprintf(outfile,"\t%f\t= Minimum value (reciprocal cm.)\n", *(fBuf+Minimum_wavenumber) ); fprintf(outfile,"\t%f\t= Maximum value (reciprocal cm.)\n", *(fBuf+Maximum_wavenumber) ); fprintf(outfile,"\t%-d\t\t= Number of points in each spectrum\n", (int ) *(fBuf+Number_valid_points) ); fprintf(outfile,"\t%f\t= DATA START TIME(UT)\n", *(fBuf+F_Time_beginng) ); fprintf(outfile,"\t%f\t= DATA END TIME(UT)\n", *(fBuf+F_Time_current) ); fprintf(outfile,"\t%-d\t\t= CIS2 SORTIE JULIAN_MONTH(UT)\n", (int ) *(fBuf+F_Month) ); fprintf(outfile,"\t%-d\t\t= CIS2 SORTIE JULIAN_DAY(UT)\n", (int ) *(fBuf+F_Day) ); fprintf(outfile,"\t%-d\t\t= CIS2 SORTIE JULIAN_YEAR(UT)\n", (int ) *(fBuf+F_Year) ); fprintf(outfile,"\t%f\t= AIRCRAFT LATITUDE\n", *(fBuf+Aircraft_latitude) ); fprintf(outfile,"\t%f\t= AIRCRAFT LONGITUDE\n", *(fBuf+Aircraft_longitude) ); fprintf(outfile,"\t%f\t= AIRCRAFT ALTITUDE\n", *(fBuf+Aircraft_altitude) ); fprintf(outfile,"\t%f\t= AIRCRAFT HEADING\n", *(fBuf+Aircraft_heading) ); fprintf(outfile,"\n"); } /* ****************************************************************** * --> Print_Hdr_Title * ******************************************************************/ void Print_Hdr_Title ( outfile, Rec_Number, fBuf ) FILE *outfile; /* output file descriptor */ int Rec_Number; /* current record number being processed */ float *fBuf; /* raw data input buffer pointer */ { fprintf(outfile, "\n\t\t============ HEADER DATA - RECORD %-d ===========",Rec_Number); fprintf(outfile,"\n\t\t ===== %-d CI2 Raw Header Data Values =====\n\n", (int) *(fBuf+Number_words_header) ); } /* ****************************************************************** * --> Print_Data_Title * ******************************************************************/ void Print_Data_Title ( outfile, Rec_Number, fBuf ) FILE *outfile; /* output file descriptor */ int Rec_Number; /* current record number being processed */ float *fBuf; /* raw data input buffer pointer */ { fprintf(outfile, "\n\t\t============ SPECTRAL DATA - RECORD %-d ===========\n",Rec_Number); fprintf(outfile,"\n\t\t ===== %-d CI2 Spectral Data Values =====\n\n", (int) *(fBuf+Number_valid_points) ); fprintf(outfile,"\nindex\t\t CHANNEL %-d \n\n", (int) *(fBuf+F_Channel_Number) ); } /* ****************************************************************** * --> Print_Data - print floating point values scientific or float format * ******************************************************************/ void Print_Data ( outfile, fBuf, iStart, iNentries ) FILE *outfile; /* output file descriptor */ float *fBuf; /* raw data input buffer pointer */ int iStart; /* starting array element (1 displaced) */ int iNentries; /* number of elements to be displayed */ { int j; for ( j = iStart ; j < (iStart+iNentries) ; j+=5 ) { if( Float_Option ) { fprintf(outfile,"[%3d]\t%13.4f%13.4f%13.4f%13.4f%13.4f\n", (j+1),*(fBuf+j),*(fBuf+j+1),*(fBuf+j+2),*(fBuf+j+3),*(fBuf+j+4)); } else { fprintf(outfile,"[%3d]\t%13.4E%13.4E%13.4E%13.4E%13.4E\n", (j+1),*(fBuf+j),*(fBuf+j+1),*(fBuf+j+2),*(fBuf+j+3),*(fBuf+j+4)); } } fprintf(outfile,"\n"); } /* ****************************************************************** * --> Init Max/Min Value Data Array * ******************************************************************/ void Init_Value_Set ( fBuf, fMin_Values, fMax_Values ) float *fBuf; /* raw data input buffer pointer */ float *fMin_Values; /* accum array of maximum float pt values */ float *fMax_Values; /* accum array of maximum float pt values */ { int i; for( i = FIRST_HDR_ENTRY; i < BSIZE ; i++ ) { *(fMin_Values+i) = (float ) *(fBuf + i); /* initialize seed */ *(fMax_Values+i) = (float ) *(fBuf + i); /* initialize seed */ } } /* ****************************************************************** * --> Find All Max/Min Values - compare current buffer w/stored values * and update stored min/max values accordingly. * ******************************************************************/ void Find_Value_Set ( fBuf, fMin_Values, fMax_Values ) float *fBuf; /* raw data input buffer pointer */ float *fMin_Values; /* accum array of maximum float pt values */ float *fMax_Values; /* accum array of maximum float pt values */ { int i; for( i = FIRST_HDR_ENTRY; i < BSIZE ; i++ ) { if ( *(fBuf+i) < *(fMin_Values+i) ) *(fMin_Values+i) = *(fBuf+i); if ( *(fBuf+i) > *(fMax_Values+i) ) *(fMax_Values+i) = *(fBuf+i); } } /* ****************************************************************** * --> Print out data Value Ranges - MIN::MAXs * ******************************************************************/ void Print_MaxMins ( outfile, fname, fMin_Values, fMax_Values, iIndex, iNum_Values, sType ) FILE *outfile; /* output file descriptor */ char *fname; /* output file name char string */ float *fMin_Values; /* accum array of maximum float pt values */ float *fMax_Values; /* accum array of maximum float pt values */ int iIndex; /* starting offset (zero displaced) */ int iNum_Values; /* number of values to print */ char *sType; /* data identification string */ { int i,j; /* fprintf(outfile, */ /* "\n\n =========================================================================\n"); */ fprintf(outfile, "\n\t============== MIN and MAX %s VALUES =============\n",sType ); /* fprintf(outfile,"\n\tFILE NAME: %s\n",fname ); */ fprintf(outfile, " =========================================================================\n\n"); for( i = iIndex; i < (iNum_Values+iIndex) ; i+=2 ) { if( i%40 == 0 && i == 0 ) { fprintf(outfile, " [INDEX] MAXIMUM :: MINIMUM [INDEX] MAXIMUM :: MINIMUM\n"); fprintf(outfile, " ---------------------::-------------- ---------------------::--------------\n"); } for ( j=i ; j < i+2 ; j++ ) { if( *(fMin_Values+j) == *(fMax_Values+j) ) { fprintf(outfile,"[%4d] %13.4f :: *UNCHANGED* ", j+1, *(fMin_Values+j) ); } else { fprintf(outfile,"[%4d] %13.4f :: %13.4f ", j+1, *(fMax_Values+j), *(fMin_Values+j) ); } } fprintf(outfile,"\n"); } }