Beispiel #1
0
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);
}
Beispiel #2
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);

}
Beispiel #3
0
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);
}
Beispiel #4
0
int GetGlobalInfo (AsnInfo *asn) {

    /* Arguments:
     **	asn	io: association info structure
     */
    extern int status;
    Hdr phdr;               /* primary header */

    char detector[SZ_FITS_REC+1];

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

    if (asn->debug) {
        trlmessage ("GetGlobalInfo: Ready to open primary header... ");
    } 

    if (asn->debug) {
        sprintf(MsgText, "GetGlobalInfo: asn_table is %s",asn->asn_table);
        trlmessage (MsgText);
    }

    /* Read primary header of ASN file into phdr. */
    if (LoadHdr (asn->asn_table, &phdr)) {
        sprintf (MsgText, "Could not load header from table %s",
                asn->asn_table);
        trlerror (MsgText);
        return (status);
    }
    if (asn->debug) {
        trlmessage ("GetGlobalInfo: Read in header from Image");
    }	

    /* Get the observing mode keyword values from header */
    asn->instr[0] = '\0';
    if (GetKeyStr (&phdr, "INSTRUME", 0, "", asn->instr, SZ_FITS_REC)) {
        trlkwerr ("INSTRUME", asn->asn_table);
        return (status = KEYWORD_MISSING);
    }

    asn->detector = 0;
    detector[0]   = '\0';
    if (GetKeyStr (&phdr, "DETECTOR", 0, "", detector, SZ_FITS_REC)) {
        trlkwerr ("DETECTOR", asn->asn_table);
        return (status = KEYWORD_MISSING);
    }

    /* Convert detector string to usable value */
    if (strncmp (detector, "UVIS", 4) == 0) {
        asn->detector = CCD_DETECTOR;
    } else if (strncmp (detector, "IR", 2) == 0) {
        asn->detector = IR_DETECTOR;
    } else {
        asn->detector = UNKNOWN_DETECTOR;
        return (status = HEADER_PROBLEM);
    }

    checkGlobalInfo(asn);

    /* You can NOT create a summed image with only 1 input */
    if (asn->process == SINGLE) {
        asn->rptcorr = OMIT;
    }

    /* If we are not processing an entire association, then
     ** we will not have the inputs necessary for a DTHCORR. */
    /*	if (dthcorr == PERFORM) { */
    if (asn->process == SINGLE) {
        asn->dthcorr = DUMMY;
    }
    /*	} */

    /* Otherwise, leave asn->dthcorr as set by reading ASN table itself */

    /* Close the ASN table's primary header here. */
    freeHdr (&phdr);



    if (asn->debug) {
        trlmessage ("GetGlobalInfo: Detector and Instrument determined");
    }	

    /* Successful return */
    return (status);
}