예제 #1
0
int GetAsnName (char *filename, char *asn_name) {

    extern int status;
    IODescPtr im;           /* descriptor for an image */
    Hdr phdr;               /* primary header */

    /* Function definitions */
    int GetKeyStr (Hdr *, char *, int, char *, char *, int);

    /* Read primary header of ASN file into hdr. */
    initHdr (&phdr);
    im = openInputImage (filename, "", 0);
    if (hstio_err())
        return (status = OPEN_FAILED);

    getHeader (im, &phdr);          /* get primary header */
    if (hstio_err())
        return (status = OPEN_FAILED);

    closeImage (im);

    asn_name[0] = '\0';
    if (GetKeyStr (&phdr, "ASN_TAB", 0, "", asn_name, SZ_FITS_REC)) {
        trlkwerr ("ASN_TAB", asn_name);
        return (status = KEYWORD_MISSING);
    }

    /* Close the file's primary header. */
    freeHdr (&phdr);

    /* Successful return */
    return (status);

}
예제 #2
0
파일: wf3info.c 프로젝트: jhunkeler/hstcal
int CheckDetector (char *image, int detector, char *keyword, int *badtype) {

	extern int status;

	FitsKw key;		/* location of keyword in header */
	IODescPtr im;		/* descriptor for primary header unit */
	Hdr phdr;		/* primary header */

	char keyval[SZ_FITS_REC+1];

	keyval[0] = '\0';
	initHdr (&phdr);

	/* Open the primary header of the reference file. */
	im = openInputImage (image, "", 0);
	getHeader (im, &phdr);
	if (hstio_err())
	    return (status = HEADER_PROBLEM);

	/* Get the DETECTOR keyword. */
	key = findKw (&phdr, keyword);
	if (key == NotFound) {
	    trlkwerr (keyword, image);
	    return (status = KEYWORD_MISSING);
	} else {
	    getStringKw (key, keyval, SZ_FITS_REC);
	    if (hstio_err()) {
		trlkwerr (keyword, image);
		return (status = KEYWORD_MISSING);
	    }
	}

	/* Does the ref file DETECTOR value match the science image? */
	if (detector == IR_DETECTOR) {
	    if (strncmp (keyval, "IR", strlen(keyval)) != 0) {
		sprintf (MsgText, "%s %s='%s' does not match science data",
			 image, keyword, keyval);
		trlerror (MsgText);
		(*badtype)++;
	    }
	} else {
	    if (strncmp (keyval, "UVIS", strlen(keyval)) != 0) {
		sprintf (MsgText, "%s %s='%s' does not match science data",
			 image, keyword, keyval);
		trlerror (MsgText);
		(*badtype)++;
	    }
	}

	/* Close the reference file. */
	closeImage (im);
	freeHdr (&phdr);

	return (status);
}
예제 #3
0
파일: wf3info.c 프로젝트: jhunkeler/hstcal
int CheckGain (char *image, float gain, char *keyword, int *badtype) {

	extern int status;

	FitsKw key;		/* location of keyword in header */
	IODescPtr im;   /* descriptor for primary header unit */
	Hdr phdr;		/* primary header */

	float keyval;

	initHdr (&phdr);

	/* Open the primary header of the reference file. */
	im = openInputImage (image, "", 0);
	getHeader (im, &phdr);
	if (hstio_err())
	    return (status = HEADER_PROBLEM);

	/* Get the CCDGAIN keyword. */
	key = findKw (&phdr, keyword);
	if (key == NotFound) {
	    trlkwerr (keyword, image);
	    return (status = KEYWORD_MISSING);
	} else {
	    keyval = getFloatKw (key);
	    if (hstio_err()) {
		trlkwerr (keyword, image);
		return (status = KEYWORD_MISSING);
	    }
	}

	/* Does the ref file CCDGAIN value match the science image? */
	/* A value of -1 is considered to be OK */
	if ((keyval != -1) && (gain != keyval)) {
	    sprintf (MsgText, "%s %s=%g does not match science data",
		     image, keyword, keyval);
	    trlerror (MsgText);
	    (*badtype)++;
	}

	/* Close the reference file. */
	closeImage (im);
	freeHdr (&phdr);

	return (status);
}
예제 #4
0
파일: loadhead.c 프로젝트: jhunkeler/hstcal
int LoadHdr (char *input, Hdr *phdr) {

	extern int status;
	
	IODescPtr im;		/* descriptor for input image */
   	
	sprintf(MsgText, "Trying to open %s...",input);
	trlmessage (MsgText);

	/* Open input image in order to read its primary header. */
	im = openInputImage (input, "", 0);				

	if (hstio_err()) {
		trlopenerr (input);
	    return (status = OPEN_FAILED);
	}
		
    initHdr (phdr);	

	/* get primary header */
	if (getHeader (im, phdr) )
		status = HEADER_PROBLEM;	
	if (hstio_err() || status) {
		trlreaderr (input);
		closeImage (im);
		freeHdr (phdr);
	    return (status = OPEN_FAILED);
	}
	
	closeImage (im);
    
	sprintf(MsgText, "Read in Primary header from %s...",input);
	trlmessage (MsgText);

	return (status);
}	
예제 #5
0
파일: acssum.c 프로젝트: jhunkeler/hstcal
int AcsSum (char *input, char *output, char *mtype, int printtime, int verbose)
{

    extern int status;

    IRAFPointer tpin;

    AcsSumInfo acs;
    IODescPtr im;        /* descriptor for input image */
    Hdr phdr;        /* primary header for input image */
    int nimgs;
    int i;
    char acs_input[CHAR_FNAME_LENGTH];

    int          FileExists (char *);
    void         TimeStamp (char *, char *);
    void         PrBegin (char *);
    void         PrEnd (char *);
    void         PrFileName (char *, char *);
    void         PrHdrInfo (char *, char *, char *, char *);
    int          MkName (char *, char *, char *, char *, char *, int);
    void         WhichError (int);
    void         InitSumTrl (char *input, char *output);
    void         FindAsnRoot (char *, char *);
    int          mkNewSpt (char *, char *, char *);

    /* Determine input and output trailer files, then initialize
        output file by combining inputs into output file */
    InitSumTrl (input, output);

    PrBegin ("ACSSUM");
    nimgs = 0;

    if (printtime)
        TimeStamp ("ACSSUM started", "");

    /* open the input file template */
    tpin = c_imtopen (input);

    nimgs = c_imtlen(tpin);

    /* Initialize structure containing acssum information. */
    AcsInit (&acs,nimgs);

    /* Copy command-line arguments into acs. */
    for (i = 0; i < nimgs; i++) {
        c_imtgetim (tpin, acs.input[i], CHAR_FNAME_LENGTH);
        PrFileName ("input", acs.input[i]);
    }

    /* close file template */
    c_imtclose (tpin);

    strcpy (acs.output, output);
    acs.printtime = printtime;
    acs.verbose = verbose;

    PrFileName ("output", acs.output);
    FindAsnRoot (output, acs.rootname);

    initHdr (&phdr);

    /* Check whether the output file already exists. */
    if (FileExists (acs.output)) {
        FreeAcsInput (acs.input, nimgs);
        return (status);
    }
    strcpy(acs_input,acs.input[0]);

    /* Open input image in order to read its primary header. */
    im = openInputImage (acs_input, "", 0);

    if (hstio_err()) {
        FreeAcsInput (acs.input, nimgs);
        return (status = OPEN_FAILED);
    }

    getHeader (im, &phdr);        /* get primary header */
    if (hstio_err()) {
        FreeAcsInput (acs.input, nimgs);
        return (status = OPEN_FAILED);
    }
    closeImage (im);

    /* Get keyword values from primary header. */
    if (GetSumKeyInfo (&acs, &phdr)) {
        FreeAcsInput (acs.input, nimgs);
        return (status);
    }
    freeHdr (&phdr);

    /* Print information about this image. */
    PrHdrInfo (acs.aperture, acs.filter1, acs.filter2, acs.det);

    if (acs.printtime)
        TimeStamp ("Begin processing", acs.rootname);

    /* Sum all imsets. */
    if (SumGrps (&acs,mtype)){
        FreeAcsInput (acs.input, nimgs);
        return (status);
    }

    /* create new SPT file for output product */
    if (mkNewSpt (input, mtype, output)) {
        return(status);
    }

    /* Done... */
    trlmessage ("\n");
    PrEnd ("ACSSUM");

    if (acs.printtime)
        TimeStamp ("ACSSUM completed", acs.rootname);

    /* Write out temp trailer file to final file */
    WriteTrlFile ();

    FreeAcsInput (acs.input, nimgs);
    return (status);
}
예제 #6
0
int ImgPedigree (RefImage *ref) {

	FitsKw key;		/* location of keyword in header */
	IODescPtr im;		/* descriptor for primary header unit */
	Hdr phdr;		/* primary header */

	initHdr (&phdr);
	ref->goodPedigree = GOOD_PEDIGREE;	/* initial value */

	if (!GotFileName (ref->name)) {
	    ref->exists = EXISTS_NO;
	    return (0);
	}

	/* Open the primary header of the reference file. */
	im = openInputImage (ref->name, "", 0);
	if (hstio_err()) {
	    ref->exists = EXISTS_NO;
	    clear_hstioerr();
	    return (0);
	}
	ref->exists = EXISTS_YES;
	getHeader (im, &phdr);
	if (hstio_err())
	    return (HEADER_PROBLEM);

	/* Get pedigree and descrip.  If either or both are missing,
	   that's not an error in this case.
	*/
	key = findKw (&phdr, "PEDIGREE");
	if (key == NotFound) {
	    ref->pedigree[0] = '\0';
	} else {
	    getStringKw (key, ref->pedigree, STIS_FITS_REC);
	    if (hstio_err()) {
		printf ("ERROR    Trying to get PEDIGREE.\n");
		return (HEADER_PROBLEM);
	    }
	}

	key = findKw (&phdr, "DESCRIP");
	if (key == NotFound) {
	    ref->descrip[0] = '\0';
	} else {
	    getStringKw (key, ref->descrip, STIS_FITS_REC);
	    if (hstio_err()) {
		printf ("ERROR    Trying to get DESCRIP.\n");
		return (HEADER_PROBLEM);
	    }
	}

	/* Is this a dummy reference file? */
	if (strncmp (ref->pedigree, "DUMMY", 5) == 0)
	    ref->goodPedigree = DUMMY_PEDIGREE;	/* dummy, so pedigree is bad */
	else
	    ref->goodPedigree = GOOD_PEDIGREE;		/* pedigree is good */

	/* Done with this image for the time being. */
	closeImage (im);
	freeHdr (&phdr);

	return (0);
}
예제 #7
0
/*
Description:
------------
If using the exposure time, the scaling factors are normalized to ratios 
relative to the max exposure. 

    Date            Author      Description
    ----            ------      -----------
    24-Sep-1998     W.J. Hack   Initial Version
    18-Mar-1999     W.J. Hack   Revised to read EXPTIMEs from Primary headers
                                using image-template list directly
    20-Oct-1999     W.J. Hack   Revised to compute number of good input images
                                and insure they are less than MAX_FILES.
    14-Apr-2000     W.J. Hack   Revised to also return final EXPEND appropriate
                                for output CR-combined product
    14-Mar-2002     W.J. Hack   Added computation of cumulative DARKTIME
    4-Apr-2002      W.J. Hack   added initialization of 'totd'
   24-Apr-2002      W.J. Hack   removed darktime altogether, find initial EXPSTART
*/
int cr_scaling (char *expname, IRAFPointer tpin, float efac[], int *nimgs, double *expend, double *expstart)
{
    extern int status;

    Hdr         prihdr;
    int         nzero, k;
    char        fdata[CHAR_FNAME_LENGTH + 1];
    IODescPtr   ip;
    int         numimgs;        /* How many good input images are there? */

    double     end, keyend, keystart, start;

    int         GetKeyFlt (Hdr *, char *, int, float, float *);
    int         GetKeyDbl (Hdr *, char *, int, double, double *);
    /* -------------------------------- begin ---------------------------------- */

    /* Rewind the image template pointer */
    c_imtrew(tpin);

    *nimgs = c_imtlen(tpin);
    end = 0.0;
    keyend = 0.0;
    start = 1e+10;
    keystart = 0.0;

    
    /* Check to make sure there are not too many images to work with... */
    if (*nimgs > MAX_FILES) {
        trlerror("There are too many input images to combine. "); 
        return(status = NOTHING_TO_DO);
    }

    /* if the parameter scaling is null, all images have equal weight. 
        If no keyword name is given for the exposure time, assume equal
        weights of 1 for all images.
    */
    if (expname[0] == '\0') {
        return (status);
    }

    /* Use exposure time as scaling factor */
    nzero = 0;	
     
    /* loop all input files counting how many usable inputs there are */
    numimgs = 0;
    for (k = 0; k < *nimgs; ++k) {

        /* read the next input image name in the template list */
        c_imtgetim (tpin, fdata, CHAR_FNAME_LENGTH);

        /* open the primary header */
        ip = openInputImage (fdata, "", 0);
        if (hstio_err()) {
            sprintf (MsgText, "Cannot open data file '%s'", fdata);
            trlerror (MsgText);
            return (status = OPEN_FAILED);
        }

        initHdr (&prihdr);

        /* read in primary header from image */
        getHeader (ip, &prihdr);

        if (GetKeyFlt (&prihdr, expname, USE_DEFAULT, 0., &efac[k]) != 0) {
            sprintf (MsgText, "cannot read '%s' from the primary header of '%s'", expname, fdata);
            trlerror (MsgText);
            freeHdr (&prihdr);
            return(status = KEYWORD_MISSING);
        }
        
        if (efac[k] < 0.) {
            sprintf (MsgText, "exposure time of file '%s' is negative", fdata);
            trlerror (MsgText);
            freeHdr (&prihdr);
            return(status = INVALID_VALUE);
        }
        if (efac[k] == 0.) {
            nzero++;
        }
        
        numimgs++;
        if (GetKeyDbl (&prihdr, "EXPEND", USE_DEFAULT, 0., &keyend) != 0) {
            sprintf (MsgText, "cannot read 'EXPEND' from the primary header of '%s'", fdata);
            trlerror (MsgText);
            freeHdr (&prihdr);
            return(status = KEYWORD_MISSING);
        }
        if (GetKeyDbl (&prihdr, "EXPSTART", USE_DEFAULT, 0., &keystart) != 0) {
            sprintf (MsgText, "cannot read 'EXPSTART' from the primary header of '%s'", fdata);
            trlerror (MsgText);
            freeHdr (&prihdr);
            return(status = KEYWORD_MISSING);
        }
        
        end = (keyend > end) ? keyend: end;
        start = (keystart < start) ? keystart : start;
        closeImage (ip);
        freeHdr (&prihdr);
    }
    
    if (nzero > 0 && nzero < *nimgs) {
        trlwarn ("Some (but not all) input imsets have zero exposure time.");
        trlwarn ("Final product will be compromised!");
        
        /* This type of error will need to be handled differently in order
            to allow pipeline processing of this type of dataset. 
        return (status = INVALID_VALUE);
        */
    }
    
    /* Only return the number of valid input images,
        initial EXPSTART and final EXPEND value
    */
    *nimgs = numimgs;
    *expend = end;
    *expstart = start;
    
    return (status);
}
예제 #8
0
int GetCCDInfo (WF3Info *wf3, CCD_Switch *sci_sw, RefFileInfo *sciref) {

/* arguments:
WF3Info *wf3          i: calibration flags and other info
CCD_Switch *sci_sw    o: all calibration switches (0 or 1) for science file
RefFileInfo *sciref  io: list of keyword,filename pairs for science file
*/

	extern int status;

	IODescPtr im;		/* descriptor for an image */
	Hdr phdr;		/* primary header */
	int nextend;		/* number of FITS extensions in rawfile */

	int GetKeyInt (Hdr *, char *, int, int, int *);
	int GetKeyFlt (Hdr *, char *, int, float, float *);
	int GetCCDSws (CCD_Switch *, Hdr *);
	int GetCCDRef (WF3Info *, CCD_Switch *, Hdr *, RefFileInfo *);
	
	/* Open input raw data file. */
	initHdr (&phdr);
	im = openInputImage (wf3->rawfile, "", 0);
	if (hstio_err()) {
	    sprintf (MsgText, "Member \"%s\" is not present", wf3->rawfile);
	    trlerror (MsgText);
        freeHdr(&phdr);
	    return (status = OPEN_FAILED);
	}

	/* Read primary header into pdhr. */
	getHeader (im, &phdr);
	if (hstio_err()) {
	    sprintf (MsgText, "Could not open PRIMARY header for \"%s\" ",
		     wf3->rawfile);
	    trlmessage (MsgText);
        closeImage(im);
        freeHdr(&phdr);
	    return (status = OPEN_FAILED);
	}
	closeImage (im);
	
	/* Get generic parameters: */

	/* Find out how many extensions there are in this file. */
	if (GetKeyInt (&phdr, "NEXTEND", USE_DEFAULT, EXT_PER_GROUP, &nextend)){
        freeHdr(&phdr);
        closeImage(im);
	    return (status = KEYWORD_MISSING);
    }
        
	wf3->nchips = nextend / EXT_PER_GROUP;

	/* Get binning and gain info.  We really only need this for the CCD. */
	if (GetKeyInt (&phdr, "BINAXIS1", USE_DEFAULT, 1, &wf3->scibin[0])) {
        closeImage(im);
        freeHdr(&phdr);
	    return (status = KEYWORD_MISSING);
    }
	if (GetKeyInt (&phdr, "BINAXIS2", USE_DEFAULT, 1, &wf3->scibin[1])){
        closeImage(im);
        freeHdr(&phdr);
	    return (status = KEYWORD_MISSING);
    }
	if (GetKeyFlt (&phdr, "CCDGAIN",  USE_DEFAULT, 1.5, &wf3->scigain)){
        closeImage(im);
        freeHdr(&phdr);
	    return (status = KEYWORD_MISSING);
    }
    
	wf3->samebin = 1;	/* default */

	/* Get calibration switches, and check that reference files exist. */
	if (GetCCDSws (sci_sw, &phdr))
	    return (status = KEYWORD_MISSING);
	if (GetCCDRef (wf3, sci_sw, &phdr, sciref))
	    return (status = CAL_FILE_MISSING);

	freeHdr (&phdr);
	return (status);
}
예제 #9
0
int CalStis11 (char *inwav, char *insci, char *output,
		int printtime, int verbose) {

	int status;

	StisInfo11 wavecal, scidata;	/* calibration switches, etc. */

	IODescPtr imWav;	/* descriptor for input wavecal */
	IODescPtr imSci;	/* descriptor for input science file */
	Hdr phdrWav;		/* primary header for input wavecal */
	Hdr phdrSci;		/* primary header for input science file */
	int subscicorr;		/* PERFORM if CCD and sclamp is HITM1 or 2 */

	int GetKeyInfo11 (StisInfo11 *, Hdr *);
	int SubSci (StisInfo11 *, StisInfo11 *);

	PrBegin (11);

	if (printtime)
	    TimeStamp ("CALSTIS-11 started", "");

	/* Initialize structure containing calstis information. */
	StisInit11 (&wavecal, &scidata);

	/* Copy command-line arguments into wavecal & scidata. */
	strcpy (wavecal.input, inwav);
	strcpy (scidata.input, insci);
	strcpy (wavecal.output, output);
	wavecal.printtime = printtime;
	scidata.printtime = printtime;
	wavecal.verbose = verbose;
	scidata.verbose = verbose;

	PrFileName ("wavecal", wavecal.input);
	PrFileName ("science", scidata.input);
	PrFileName ("output", wavecal.output);

	initHdr (&phdrWav);
	initHdr (&phdrSci);

	/* Check whether the output file already exists. */
	if ((status = FileExists (wavecal.output)))
	    return (status);

	/* Read primary header of input wavecal. */
	imWav = openInputImage (wavecal.input, "", 0);
	if (hstio_err())
	    return (OPEN_FAILED);
	getHeader (imWav, &phdrWav);
	if (hstio_err())
	    return (OPEN_FAILED);
	closeImage (imWav);

	/* Get keyword values from wavecal primary header. */
	if ((status = GetKeyInfo11 (&wavecal, &phdrWav)))
	    return (status);

	freeHdr (&phdrWav);

	/* Print information about the input wavecal. */
	PrHdrInfo (wavecal.obsmode, wavecal.aperture,
		wavecal.opt_elem, wavecal.det);

	/* Do we need to subtract the science image from the wavecal? */
	subscicorr = PERFORM;			/* initial value */
	if (wavecal.detector != CCD_DETECTOR) {
	    subscicorr = OMIT;
	    printf ("Warning  Detector is %s\n", wavecal.det);
	}
	if (strcmp (wavecal.sclamp, "HITM1") != 0 &&
		   strcmp (wavecal.sclamp, "HITM2") != 0) {
	    subscicorr = OMIT;
	    printf ("Warning  Wavecal SCLAMP is `%s', not HITM1 or HITM2\n",
			wavecal.sclamp);
	}
	if (wavecal.texpstrt >= EXT_SHUTTER_CLOSED) {
	    subscicorr = OMIT;
	    printf (
	"Warning  TEXPSTRT=%.2f implies external shutter is closed.\n",
		wavecal.texpstrt);
	}

	if (subscicorr != PERFORM) {
	    printf (
	"Warning  Science data will not be subtracted from wavecal.\n");
	    return (NOTHING_TO_DO);
	}

	/* Read primary header of input science file. */
	imSci = openInputImage (scidata.input, "", 0);
	if (hstio_err())
	    return (OPEN_FAILED);
	getHeader (imSci, &phdrSci);
	if (hstio_err())
	    return (OPEN_FAILED);
	closeImage (imSci);

	if (wavecal.printtime)
	    TimeStamp ("Begin processing", wavecal.rootname);

	/* Get keyword values from science file primary header. */
	if ((status = GetKeyInfo11 (&scidata, &phdrSci)))
	    return (status);

	freeHdr (&phdrSci);

	/* Detector, central wavelength, grating, and aperture must be
	   the same in the wavecal and science file.
	*/
	if (wavecal.detector != scidata.detector ||
	    wavecal.cenwave != scidata.cenwave ||
	    strcmp (wavecal.opt_elem, scidata.opt_elem) != 0 ||
	    strcmp (wavecal.aperture, scidata.aperture) != 0) {

	    printf ("Warning  Wavecal and science file do not match; \\\n");
	    printf ("Warning  the science file will not be subtracted.\n");
	    return (NOTHING_TO_DO);
	}

	/* Subtract the science image from the wavecal. */
	if ((status = SubSci (&wavecal, &scidata)))
	    return (status);

	printf ("\n");
	PrEnd (11);

	if (wavecal.printtime)
	    TimeStamp ("CALSTIS-11 completed", wavecal.rootname);

	return (0);
}
예제 #10
0
static int FluxToNet (StisInfo6 *sts, IntensArray *inta, int sporder) {

	/* This is used to store information from the fflux file in a
           form suitable for the reference file input routines.
        */
	StisInfo6 fsts;
	ApInfo slit;
	PhotInfo phot;

	IODescPtr im;
	Hdr phdr;
	double photfactor, throughput, response, dispersion;
	double atodgain, readnoise;
	float correction;
	int i, dispc, helc, status;
	int abs_starti, thr_starti;
	int dummy;

	void FreePhot6 (PhotInfo *);
	void FreeThroughput6 (ApInfo *);
	int GetAbsPhot6 (StisInfo6 *, int, PhotInfo *, int, int *);
	int GetApDes6 (StisInfo6 *, ApInfo *);
	int GetApThr6 (StisInfo6 *, ApInfo *);
	int Get_KeyD (Hdr *, char *, int, double, double *);
	int Get_KeyS (Hdr *, char *, int, char *, char *, int);
	int GetSwitch (Hdr *, char *, int *);
	double interp1d (double, double *, double *, int, int *);
	void StisInit6 (StisInfo6 *);

	photfactor = H_PLANCK * C_LIGHT / HST_AREA;

	/* Initialize local data structures. */
	StisInit6 (&fsts);
        InitRefTab (&fsts.phottab);
        InitRefTab (&fsts.apertab);
        InitRefTab (&fsts.apdestab);
	slit.allocated  = 0;
	slit.gac_allocated  = 0;
	phot.allocated  = 0;
	phot.pcorr      = NULL;

	/* Handling the primary header here is not efficient. But keeps
           this new code manageable since everything new is added at a
           single point. In the future we may move this to outside the
           main loop and pass the necessary values as part of the sts
           structure.
        */
	initHdr (&phdr);
	im = openInputImage (sts->pxtab.name, "", 0);
	if (hstio_err())
	    return (OPEN_FAILED);
	getHeader (im, &phdr);
	if (hstio_err())
	    return (OPEN_FAILED);
	closeImage (im);

	/* Abort if both helcorr and dispcorr weren't performed.
           The criterion is: if a keyword is set to either COMPLETE
           or PERFORM, we assume that the operation was performed.
           This is because UpdHdrSwitch in Do1Dx only updates the
           keywords to COMPLETE if they are set to PERFORM in the
           input file.  (note:  UpdHdrSwitch is no longer used)
        */
	if ((status = GetSwitch (&phdr, "DISPCORR", &dispc)))
	    return (status);
	if ((status = GetSwitch (&phdr, "HELCORR", &helc)))
	    return (status);
	if (!((dispc == PERFORM || dispc == COMPLETE) &&
              (helc  == PERFORM || helc  == COMPLETE))) {
	    printf ("ERROR    No DISPCORR/HELCORR in fflux file.\n");
	    return (ERROR_RETURN);
	}

	/* Read header keywords. */
	if ((status = Get_KeyD (&phdr, "READNSE", 1, 0., &readnoise)))
	    return (status);
	if ((status = Get_KeyD (&phdr, "ATODGAIN", 1, 1., &atodgain)))
	    return (status);
	if ((status = Get_KeyS (&phdr, "PHOTTAB", FATAL, "",
                                fsts.phottab.name, STIS_LINE)))
	    return (status);
	if ((status = Get_KeyS (&phdr, "APDESTAB", FATAL, "",
                                fsts.apdestab.name, STIS_LINE)))
	    return (status);
	if ((status = Get_KeyS (&phdr, "APERTAB", FATAL, "",
                                fsts.apertab.name, STIS_LINE)))
	    return (status);

	/* Copy stuff from primary data structure into local one. */
	fsts.x1d_o    = sts->x1d_o;
	fsts.dispcorr = sts->dispcorr;
	fsts.fluxcorr = sts->fluxcorr;
	fsts.pctcorr  = sts->pctcorr;
	fsts.cenwave  = sts->cenwave;
	strcpy (fsts.opt_elem, sts->opt_elem);
	strcpy (fsts.aperture, sts->aperture);

	/* Read the required reference info. */
	dummy = 0;
	if ((status = GetAbsPhot6 (&fsts, sporder, &phot, 0, &dummy)))
	    return (status);
	if ((status = GetApDes6 (&fsts, &slit)))
	    return (status);
        if ((status = GetApThr6 (&fsts, &slit)))
	    return (status);

	abs_starti = 1;				/* initial values */
	thr_starti = 1;

	/* Loop over flux array. */
	for (i = 0;  i < inta->nelem;  i++) {
	    response   = interp1d (inta->wave[i], phot.wl, phot.thru,
                                   phot.nelem, &abs_starti);
	    throughput = interp1d (inta->wave[i], slit.wl, slit.thr,
                                   slit.nelem, &thr_starti);
	    if (i > 0)
	        dispersion = inta->wave[i] - inta->wave[i-1];
	    else
	        dispersion = inta->wave[1] - inta->wave[0];

	    /* This check is provisional; final version awaits IS's words. */
	    if (response   <= 0.0 ||
	        dispersion <= 0.0 ||
	        throughput <= 0.0) {
	        printf ("ERROR    Error in fflux file contents.\n");
	        return (ERROR_RETURN);
	    }

	    correction = (float) (photfactor / (response * throughput *
                         inta->wave[i] * dispersion * atodgain *
                         CM_PER_ANGSTROM));

	    inta->intens[i] = inta->intens[i] / correction;
	}

	FreeThroughput6 (&slit);
	FreePhot6 (&phot);

	freeHdr (&phdr);
	return STIS_OK;
}