From b1c28ff0dedbfd9f180c559142bf8f5283e9efa4 Mon Sep 17 00:00:00 2001 From: Pey Lian Lim Date: Mon, 10 Jul 2017 15:46:19 -0400 Subject: [PATCH] Update SINKCORR keyword and HISTORY when done --- pkg/acs/calacs/acsccd/doccd.c | 5 + pkg/acs/calacs/lib/acshist.c | 186 +++++++++++++++++++--------------- 2 files changed, 111 insertions(+), 80 deletions(-) diff --git a/pkg/acs/calacs/acsccd/doccd.c b/pkg/acs/calacs/acsccd/doccd.c index 88b279f18..e70e38cf2 100644 --- a/pkg/acs/calacs/acsccd/doccd.c +++ b/pkg/acs/calacs/acsccd/doccd.c @@ -69,6 +69,7 @@ int DoCCD (ACSInfo *acs_info) { int doNoise (ACSInfo *, SingleGroup *, int *); int noiseHistory (Hdr *); int SinkDetect (ACSInfo *, SingleGroup *); + int sinkHistory(ACSInfo *, Hdr *); int GetACSGrp (ACSInfo *, Hdr *); int OmitStep (int); int PutKeyFlt (Hdr *, char *, float, char *); @@ -438,6 +439,10 @@ int DoCCD (ACSInfo *acs_info) { if (acs_info->printtime) TimeStamp("SINKCORR complete", acs_info->rootname); } + + if (!OmitStep(acs[0].sinkcorr)) + if (sinkHistory(&acs[0], x[0].globalhdr)) + return (status); /************************************************************************/ /* Write this imset to the output file. The diff --git a/pkg/acs/calacs/lib/acshist.c b/pkg/acs/calacs/lib/acshist.c index 58f0e03e7..6cd34f9bc 100644 --- a/pkg/acs/calacs/lib/acshist.c +++ b/pkg/acs/calacs/lib/acshist.c @@ -13,10 +13,10 @@ "complete" or "skipped"), the value of the pedigree keyword, and the value of the descrip keyword. The calibration switch (e.g. FLATCORR) in the header will be updated from PERFORM to either COMPLETE or SKIPPED. - + Note that since this info is written to the primary header, these routines should only be called for EXTVER = 1. - + Warren Hack, 1998 June 10: Initial ACS version. Warren Hack, 2000 Sept 12: @@ -25,78 +25,80 @@ Added history reporting on overscan table. Pey Lian Lim, 2012 Dec 12: Added support for CTE corrected post-flash. - + Pey Lian Lim, 2017 Jul 10: + Added support for SINK pixel flagging. + */ int atodHistory (ACSInfo *acs, Hdr *phdr) { - + extern int status; - + int logit; /* true if we should log file name */ int OmitStep (int); int TabHistory (RefTab *, Hdr *); int UpdateSwitch (char *, int, Hdr *, int *); - + if (OmitStep (acs->atodcorr)) /* nothing to do */ return (status); - + if (UpdateSwitch ("ATODCORR", acs->atodcorr, phdr, &logit)) return (status); - + /* Write history records for the A-to-D table. */ if (logit) { if (TabHistory (&acs->atod, phdr)) return (status); } - + return (status); } int pcteHistory (ACSInfo *acs, Hdr *phdr) { - + extern int status; - + int logit; /* true if we should log file name */ int OmitStep (int); int TabHistory (RefTab *, Hdr *); int UpdateSwitch (char *, int, Hdr *, int *); - + if (OmitStep (acs->pctecorr)) /* nothing to do */ return (status); - + if (UpdateSwitch ("PCTECORR", acs->pctecorr, phdr, &logit)) return (status); - + /* Write history records for the PCTE table. */ if (logit) { if (TabHistory (&acs->pcte, phdr)) return (status); } - + return (status); } int biasHistory (ACSInfo *acs, Hdr *phdr) { - + extern int status; - + int logit; /* true if we should log file name */ int OmitStep (int); int ImgHistory (RefImage *, Hdr *); int UpdateSwitch (char *, int, Hdr *, int *); - + if (OmitStep (acs->biascorr)) return (status); - + if (UpdateSwitch ("BIASCORR", acs->biascorr, phdr, &logit)) return (status); - + /* Write history records for the bias image. */ if (logit) { if (ImgHistory (&acs->bias, phdr)) return (status); } - + return (status); } @@ -108,7 +110,7 @@ int flashHistory (ACSInfo *acs, Hdr *phdr) { int OmitStep (int); int ImgHistory (RefImage *, Hdr *); int UpdateSwitch (char *, int, Hdr *, int *); - + if (OmitStep (acs->flashcorr)) return (status); @@ -129,15 +131,15 @@ int flashHistory (ACSInfo *acs, Hdr *phdr) { } int blevHistory (ACSInfo *acs, Hdr *phdr, int done, int driftcorr) { - + extern int status; int OmitStep (int); int PutKeyStr (Hdr *, char *, char *, char *); int TabHistory (RefTab *, Hdr *); - + if (OmitStep (acs->blevcorr)) return (status); - + if (PutKeyStr (phdr, "BLEVCORR", "COMPLETE", "")) return (status); if (done) { @@ -149,7 +151,7 @@ int blevHistory (ACSInfo *acs, Hdr *phdr, int done, int driftcorr) { } if (hstio_err()) return (status = HEADER_PROBLEM); - + if (driftcorr) { addHistoryKw (phdr, "BLEVCORR includes correction for drift along lines."); @@ -160,39 +162,63 @@ int blevHistory (ACSInfo *acs, Hdr *phdr, int done, int driftcorr) { addHistoryKw (phdr, " Overscan region table: "); if (TabHistory (&acs->oscn, phdr)) return (status); - + if (hstio_err()) return (status = HEADER_PROBLEM); - + return (status); } +int sinkHistory (ACSInfo *acs, Hdr *phdr) { + + extern int status; + + int logit; /* true if we should log file name */ + int OmitStep (int); + int ImgHistory (RefImage *, Hdr *); + int UpdateSwitch (char *, int, Hdr *, int *); + + if (OmitStep (acs->sinkcorr)) + return (status); + + if (UpdateSwitch ("SINKCORR", acs->sinkcorr, phdr, &logit)) + return (status); + + /* Write history records for the bias image. */ + if (logit) { + if (ImgHistory (&acs->sink, phdr)) + return (status); + } + + return (status); +} + /* Info about CCD parameters table (no specific calibration step). */ int CCDHistory (ACSInfo *acs, Hdr *phdr) { - + extern int status; int TabHistory (RefTab *, Hdr *); - + addHistoryKw (phdr, "CCD parameters table: "); if (TabHistory (&acs->ccdpar, phdr)) return (status); - + return (status); } int dqiHistory (ACSInfo *acs, Hdr *phdr) { - + extern int status; int logit; /* true if we should log file name */ int flag; int OmitStep (int); int TabHistory (RefTab *, Hdr *); int UpdateSwitch (char *, int, Hdr *, int *); - + if (OmitStep (acs->dqicorr)) return (status); - + if (acs->bpix.exists == EXISTS_YES) { if (acs->bpix.goodPedigree == GOOD_PEDIGREE) flag = PERFORM; @@ -203,52 +229,52 @@ int dqiHistory (ACSInfo *acs, Hdr *phdr) { } else { flag = PERFORM; } - + if (UpdateSwitch ("DQICORR", flag, phdr, &logit)) return (status); - + if (logit) { if (acs->detector != MAMA_DETECTOR) { addHistoryKw (phdr, " values checked for saturation"); } - + if (acs->bpix.exists == EXISTS_YES) { addHistoryKw (phdr, " DQ array initialized ..."); if (TabHistory (&acs->bpix, phdr)) return (status); } } - + return (status); } /* There are no reference images for assigning initial error values. */ int noiseHistory (Hdr *phdr) { - + extern int status; - + addHistoryKw (phdr, "Uncertainty array initialized."); if (hstio_err()) return (status = HEADER_PROBLEM); - + return (status); } int darkHistory (ACSInfo *acs, Hdr *phdr) { - + extern int status; int logit; /* true if we should log file name */ int OmitStep (int); int ImgHistory (RefImage *, Hdr *); int UpdateSwitch (char *, int, Hdr *, int *); - + if (OmitStep (acs->darkcorr)) return (status); - + if (UpdateSwitch ("DARKCORR", acs->darkcorr, phdr, &logit)) return (status); - + if (logit && acs->pctecorr == PERFORM) { if (ImgHistory (&acs->darkcte, phdr)) return (status); @@ -256,39 +282,39 @@ int darkHistory (ACSInfo *acs, Hdr *phdr) { if (ImgHistory (&acs->dark, phdr)) return (status); } - + return (status); } int flatHistory (ACSInfo *acs, Hdr *phdr) { - + extern int status; - + int logit; /* true if we should log file name */ int OmitStep (int); int ImgHistory (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); @@ -300,83 +326,83 @@ int flatHistory (ACSInfo *acs, Hdr *phdr) { return (status); } } - + return (status); } int nonlinHistory (ACSInfo *acs, Hdr *phdr) { - + extern int status; int logglin, loglfl; /* true if we should log file name */ int OmitStep (int); int TabHistory (RefTab *, Hdr *); int UpdateSwitch (char *, int, Hdr *, int *); - + /* Flags to record whether GLINCORR and LFLGCORR was performed */ logglin = 0; loglfl = 0; - + if (!OmitStep (acs->glincorr)) if (UpdateSwitch ("GLINCORR", acs->glincorr, phdr, &logglin)) return (status); - + if (!OmitStep (acs->lflgcorr)) if (UpdateSwitch ("LFLGCORR", acs->lflgcorr, phdr, &loglfl)) return (status); - - /* If either was performed, then record in History comments + + /* If either was performed, then record in History comments WJH 27 July 1999 */ if (logglin || loglfl) if (TabHistory (&acs->mlin, phdr)) return (status); - + return (status); } int shadHistory (ACSInfo *acs, Hdr *phdr) { - + extern int status; int logit; /* true if we should log file name */ int OmitStep (int); int ImgHistory (RefImage *, Hdr *); int UpdateSwitch (char *, int, Hdr *, int *); - + if (OmitStep (acs->shadcorr)) return (status); - + if (UpdateSwitch ("SHADCORR", acs->shadcorr, phdr, &logit)) return (status); - + if (logit) { if (ImgHistory (&acs->shad, phdr)) return (status); } - + return (status); } /* Photometry. */ int photHistory (ACSInfo *acs, Hdr *phdr) { - + extern int status; int logit; /* true if we should log file name */ int OmitStep (int); int TabHistory (RefTab *, Hdr *); int UpdateSwitch (char *, int, Hdr *, int *); - + if (OmitStep (acs->photcorr)) return (status); - + if (UpdateSwitch ("PHOTCORR", acs->photcorr, phdr, &logit)) return (status); - + if (logit) { if (TabHistory (&acs->phot, phdr)) return (status); } - + return (status); } @@ -385,24 +411,24 @@ int photHistory (ACSInfo *acs, Hdr *phdr) { */ int UpdateSwitch (char *calSwitch, int flag, Hdr *phdr, int *logit) { - + /* arguments: char *calSwitch i: name of calibration switch int flag i: value of calibration switch Hdr *phdr o: primary header int *logit o: true if we should log reference file names */ - + extern int status; - + char *history; int PutKeyStr (Hdr *, char *, char *, char *); - + if ((history = (char *) calloc (ACS_LINE+1, sizeof (char))) == NULL) return (status = OUT_OF_MEMORY); - + strcpy (history, calSwitch); - + *logit = 0; if (flag == PERFORM) { if (PutKeyStr (phdr, calSwitch, "COMPLETE", "")) @@ -429,8 +455,8 @@ int UpdateSwitch (char *calSwitch, int flag, Hdr *phdr, int *logit) { return (status = HEADER_PROBLEM); *logit = 1; } - + free (history); - + return (status); }