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); }
int GetSwitch (Hdr *phdr, char *calswitch, int *flag) { /* arguments: Hdr *phdr i: primary header char *calswitch i: name of keyword (e.g. FLATCORR) int *flag o: value of switch: PERFORM, OMIT, or COMPLETE */ extern int status; FitsKw key; /* keyword location in header */ char *word; /* scratch space for header keyword value */ int streq_ic (char *, char *); /* strings equal? (case insensitive) */ key = findKw (phdr, calswitch); if (key == NotFound) { *flag = OMIT; return (status); } if ((word = (char *) calloc (CHAR_FNAME_LENGTH+1, sizeof(char))) == NULL) return (status = OUT_OF_MEMORY); getStringKw (key, word, CHAR_FNAME_LENGTH); if (hstio_err()) { free (word); sprintf (MsgText, "Error getting keyword `%s'.", calswitch); trlerror (MsgText); return (status = HEADER_PROBLEM); } if (streq_ic (word, "perform")) { *flag = PERFORM; } else if (streq_ic (word, "complete")) { *flag = COMPLETE; } else if (streq_ic (word, "skipped")) { *flag = OMIT; } else if (streq_ic (word, "omit")) { *flag = OMIT; } else { *flag = OMIT; sprintf (MsgText, "Keyword %s = %s is invalid.", calswitch, word); trlerror (MsgText); free (word); return (status = HEADER_PROBLEM); } free (word); return (status); }
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); }