/****** PROGRAM PCDECLSP.C This program reads in a compressed FITS image, decompresses it and writes it out as a legitimate FITS byte stream. It reads and writes the FITS records as streams of 2880 bytes. NOTE: The FITS header and associated data are assumed to be in SEPARATE files. If no file name is specified on the command line, the program will prompt for one. If only one name is given on the command line, it is assumed to be the input file, and the output file will be given the same file name except that the extension will be set to '$$$'. If two names are given on the command line, the first is taken as the input file, the second as the output file. The data file is assumed to have the extension .IMQ, but this can be changed by specifying a third file name on the command line. EXAMPLES: >pcdeclsp - asks for header file name, reads data from *.IMQ, makes *.$$$ as output >pcdeclsp lspn0094.hdr - reads data from LSPN0094.IMQ, makes LSPN0094.$$$ as output >pcdeclsp lspn0094.hdr d:lspn0094.fit - reads data from LSPN0094.IMQ, makes LSPN0094.FIT on drive D: >pcdeclsp lspn0094.hdr d:lspn0094.fit lspn0094.dat - reads data from LSPN0094.DAT, makes LSPN0094.FIT on drive D: Version 1.0 written 1/90 by A. Warnock ST Systems Corp. NASA/Goddard Space Flight Center Code 681 Greenbelt, MD 20771 (301)286-3965 SPAN - STARS::WARNOCK 6168::WARNOCK Internet - warnock@stars.gsfc.nasa.gov warnock@[128.183.84.7] Version 1.1, 3/90 by AW3 - saves correct input buffer length in do_data to fix a bug in carrying a new 16-bit value from the end of one input buffer to the beginning of the next. Written for Turbo C v2.0 from Borland Int'l. Will compile and link under the tiny model to generate a .COM file. See MAKEFILE for details. The string routines strsetsz and strsrep are from the CXL library, version 5.1. The templates are given below. For non-PC systems, these routines will have to be written from scratch. The CXL library is available for PC-based compilers on fine bulletin boards everywhere. For more information on CXL, contact Mike Smedley P. O. Box 33603 San Antonio, TX 78265-3603 **** Templates char *strsetsz( char *str, int newsize) ; Adjusts the length of str, either by truncation or padding with blanks. char *strsrep( char *str, char *search, char *replace) ; Searches for, and replaces one string within another. Case sensitive. *****/ #include #include #include #include "cxlstr.h" #define NULL 0 #define TRUE 'T' #define FALSE 'F' #define FITS_SIZE 2880 #define TEXT_SIZE 80 FILE *do_infile( int argc, char *argv[], char *linebfr); FILE *do_datafile( int argc, char *argv[], char *linebfr); FILE *do_outfile( int argc, char *argv[], char *linebfr); void header( FILE *infile); void xtension( FILE *infile, FILE *outfile, long *file_len); void do_data( FILE *infile, FILE *outfile, long *file_len); void decomp( char *inptr, long int *bytlen, short int *ipixel, short int outbfr[], long int *offset); /* Global declarations */ char inbfr[3000], /* input buffer */ _end[TEXT_SIZE + 1]; /* end-of-header string */ main(int argc, char *argv[]) { FILE *infile, /* Input file */ *outfile; /* Output file */ char linebfr[TEXT_SIZE + 1], /* holds the command line */ tempbfr[TEXT_SIZE + 1]; /* scratch buffer */ long file_len; /* data length from FITS header */ /* Get the file names and open the INPUT and OUTPUT files. */ infile = do_infile( argc, argv, linebfr); strcpy( tempbfr, linebfr ); outfile = do_outfile( argc, argv, linebfr); /* Initialize some string stuff first */ strcpy( _end, "END" ); strsetsz( _end, TEXT_SIZE) ; inbfr[ FITS_SIZE ] = NULL; /* Process the primary header */ header( infile ); /* Process the extension header and write the output header */ xtension( infile, outfile, &file_len); /* Decompress the data stream and write the output file */ fclose( infile ); infile = do_datafile( argc, argv, tempbfr); do_data( infile, outfile, &file_len); /* Clean up after ourselves */ fclose( infile ); fclose( outfile ); printf( "\nAll Done!\n" ); }