int flatHistory (ACSInfo *acs, Hdr *phdr) { extern int status; int logit; /* true if we should log file name */ int OmitStep (int); int ImgHistory (const RefImage *, Hdr *); int TabHistory (RefTab *, Hdr *); int GotFileName (char *); int UpdateSwitch (char *, int, Hdr *, int *); if (OmitStep (acs->flatcorr)) return (status); if (UpdateSwitch ("FLATCORR", acs->flatcorr, phdr, &logit)) return (status); if (logit) { if (GotFileName (acs->pflt.name)) { if (ImgHistory (&acs->pflt, phdr)) /* pixel-to-pixel */ return (status); } if (GotFileName (acs->dflt.name)) { if (ImgHistory (&acs->dflt, phdr)) /* delta flat */ return (status); } if (GotFileName (acs->lflt.name)) { if (ImgHistory (&acs->lflt, phdr)) /* low-order flat */ return (status); } if (GotFileName (acs->cflt.name)) { if (ImgHistory (&acs->cflt, phdr)) /* coronographic flat */ return (status); if (TabHistory (&acs->spot, phdr)) /* spot reference table */ return (status); } } return (status); }
int flatHistory (WF3Info *wf3, Hdr *phdr) { extern int status; int logit; /* true if we should log file name */ int OmitStep (int); int ImgHistory (RefImage *, Hdr *); int GotFileName (char *); int UpdateSwitch (char *, int, Hdr *, int *); if (OmitStep (wf3->flatcorr)) return (status); if (UpdateSwitch ("FLATCORR", wf3->flatcorr, phdr, &logit)) return (status); if (logit) { if (GotFileName (wf3->pflt.name)) { if (ImgHistory (&wf3->pflt, phdr)) /* pixel-to-pixel */ return (status); } if (GotFileName (wf3->dflt.name)) { if (ImgHistory (&wf3->dflt, phdr)) /* delta flat */ return (status); } if (GotFileName (wf3->lflt.name)) { if (ImgHistory (&wf3->lflt, phdr)) /* low-order flat */ return (status); } } return (status); }
static int checkDQI (Hdr *phdr, WF3Info *wf32d, int *missing, int *nsteps) { /* arguments: Hdr *phdr i: primary header WF3Info *wf32d i: switches, file names, etc int *missing io: incremented if the table is missing int *nsteps io: incremented if this step can be performed */ extern int status; int GotFileName (char *); int GetTabRef (RefFileInfo *, Hdr *, char *, RefTab *, int *); void MissingFile (char *, char *, int *); void CheckTabType (RefTab *, char *, char *, int *); int CheckDetector (char *, int, char *, int *); if (wf32d->dqicorr == PERFORM) { if (GetTabRef (wf32d->refnames, phdr, "BPIXTAB", &wf32d->bpix, &wf32d->dqicorr)) return (status); if (wf32d->bpix.exists != EXISTS_YES) { if (wf32d->detector == IR_DETECTOR || GotFileName (wf32d->bpix.name)) { MissingFile ("BPIXTAB", wf32d->bpix.name, missing); } } else { /* Is the FILETYPE appropriate for a BPIX table? */ CheckTabType (&wf32d->bpix, "BAD PIXELS", "BPIXTAB", missing); /* Does it have the correct DETECTOR value? */ if (CheckDetector(wf32d->bpix.name, wf32d->detector, "DETECTOR", missing)) return (status); } if (wf32d->dqicorr == PERFORM) (*nsteps)++; } 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); }
static int checkFlat (Hdr *phdr, WF3Info *wf32d, int *missing, int *nsteps) { /* arguments: Hdr *phdr i: primary header WF3Info *wf32d i: switches, file names, etc int *missing io: incremented if a file is missing int *nsteps io: incremented if this step can be performed */ extern int status; int calswitch; int GetSwitch (Hdr *, char *, int *); int GotFileName (char *); int GetImageRef (RefFileInfo *, Hdr *, char *, RefImage *, int *); void MissingFile (char *, char *, int *); void CheckImgType (RefImage *, char *, char *, int *); int CheckFilter (char *, char *, char *, int *); int CheckDetector (char *, int, char *, int *); /* Are we supposed to do this step? */ if (wf32d->flatcorr == PERFORM) { if (GetSwitch (phdr, "FLATCORR", &calswitch)) return (status); if (calswitch == COMPLETE) { wf32d->flatcorr = OMIT; return (status); } /* Initial values; may be reset below. */ wf32d->pfltcorr = PERFORM; wf32d->dfltcorr = PERFORM; wf32d->lfltcorr = PERFORM; if (GetImageRef (wf32d->refnames, phdr, "PFLTFILE", &wf32d->pflt, &wf32d->pfltcorr)) return (status); if (wf32d->pflt.exists != EXISTS_YES) { if (GotFileName (wf32d->pflt.name)) { /* name specified? */ MissingFile ("PFLTFILE", wf32d->pflt.name, missing); } else { wf32d->pfltcorr = OMIT; /* name was blank or "N/A" */ } } else { /* Is the FILETYPE appropriate for a PFLT file? */ CheckImgType (&wf32d->pflt, "PIXEL-TO-PIXEL FLAT", "PFLTFILE", missing); /* Does it have the correct FILTER value? */ if (CheckFilter(wf32d->pflt.name, wf32d->filter, "FILTER", missing)) return (status); /* Does it have the correct DETECTOR value? */ if (CheckDetector(wf32d->pflt.name, wf32d->detector, "DETECTOR", missing)) return (status); } if (GetImageRef (wf32d->refnames, phdr, "DFLTFILE", &wf32d->dflt, &wf32d->dfltcorr)) return (status); if (wf32d->dflt.exists != EXISTS_YES) { if (GotFileName (wf32d->dflt.name)) { MissingFile ("DFLTFILE", wf32d->dflt.name, missing); } else { wf32d->dfltcorr = OMIT; } } else { /* Is the FILETYPE appropriate for a DFLT file? */ CheckImgType (&wf32d->dflt, "DELTA FLAT", "DFLTFILE", missing); /* Does it have the correct FILTER value? */ if (CheckFilter(wf32d->dflt.name, wf32d->filter, "FILTER", missing)) return (status); /* Does it have the correct DETECTOR value? */ if (CheckDetector(wf32d->dflt.name, wf32d->detector, "DETECTOR", missing)) return (status); } if (GetImageRef (wf32d->refnames, phdr, "LFLTFILE", &wf32d->lflt, &wf32d->lfltcorr)) return (status); if (wf32d->lflt.exists != EXISTS_YES) { if (GotFileName (wf32d->lflt.name)) { MissingFile ("LFLTFILE", wf32d->lflt.name, missing); } else { wf32d->lfltcorr = OMIT; } } else { /* Is the FILETYPE appropriate for a LFLT file? */ CheckImgType (&wf32d->lflt, "LARGE SCALE FLAT", "LFLTFILE", missing); /* Does it have the correct FILTER value? */ if (CheckFilter(wf32d->lflt.name, wf32d->filter, "FILTER", missing)) return (status); /* Does it have the correct DETECTOR value? */ if (CheckDetector(wf32d->lflt.name, wf32d->detector, "DETECTOR", missing)) return (status); } /* If any of the three parts of flat fielding is set to PERFORM, then we can do this step. If not, and if any part is DUMMY because of the reference file, reset the flat field flag to DUMMY; this will mean that all the files that were specified have pedigree=dummy. */ if (wf32d->pfltcorr == PERFORM || wf32d->dfltcorr == PERFORM || wf32d->lfltcorr == PERFORM) { (*nsteps)++; } else if (wf32d->pfltcorr == OMIT && wf32d->dfltcorr == OMIT && wf32d->lfltcorr == OMIT) { (*missing)++; trlerror ("PFLTFILE, DFLTFILE, and LFLTFILE are all blank."); } else if (wf32d->pfltcorr == DUMMY || wf32d->dfltcorr == DUMMY || wf32d->lfltcorr == DUMMY) { wf32d->flatcorr = DUMMY; } } return (status); }