From 96ef189e6ebb987b698b53591ef94b42d795ab95 Mon Sep 17 00:00:00 2001 From: Michele De La Pena Date: Tue, 7 May 2024 11:54:42 -0400 Subject: [PATCH] Added the constraint the serial CTE correction only applies to post-SM4 data. --- pkg/acs/Dates | 3 +- pkg/acs/History | 3 +- pkg/acs/Updates | 2 +- pkg/acs/lib/acscte/docte.c | 163 ++++++++++++++++++++----------------- 4 files changed, 92 insertions(+), 79 deletions(-) diff --git a/pkg/acs/Dates b/pkg/acs/Dates index 0f17ebd8..2b41c748 100644 --- a/pkg/acs/Dates +++ b/pkg/acs/Dates @@ -1,10 +1,11 @@ - 14-Sep-2023 CALACS 10.4.0 Implementation of the "Parallel and Serial CTE correction". This + 07-May-2024 CALACS 10.4.0 Implementation of the "Parallel and Serial CTE correction". This version of the CTE correction (Version 3) is based upon the algorithm of Version 2, but includes the additional correction for the serial direction which is amp-dependent. Previous generations of CTE correction are no longer supported, and obsolete code has been removed. Note the PCTETAB has changed substantially to accommodate the amp-dependent serial corrections. + The serial CTE correction only applies to post-SM4 data. 08-Feb-2022 CALACS 10.3.5 Update to the cosmic ray rejection algorithm as to the way the output ERR extension is computed for the CRJ file. The output ERR is now propagated from the usable input ERR extensions diff --git a/pkg/acs/History b/pkg/acs/History index 4ef0f61c..2decba27 100644 --- a/pkg/acs/History +++ b/pkg/acs/History @@ -1,4 +1,4 @@ -### 14-Sep-2023 - MDD - Version 10.4.0 +### 07-May-2024 - MDD - Version 10.4.0 Implementation of the "Parallel and Serial CTE correction". This version of the CTE correction (Version 3) is based upon the algorithm of Version 2, but includes the additional correction @@ -6,6 +6,7 @@ generations of CTE correction are no longer supported, and obsolete code has been removed. Note the PCTETAB has changed substantially to accommodate the amp-dependent serial corrections. + The serial CTE correction only applies to post-SM4 data. ### 08-Feb-2022 - MDD - Version 10.3.5 Update to the cosmic ray rejection algorithm as to the way diff --git a/pkg/acs/Updates b/pkg/acs/Updates index a2316a2e..feece989 100644 --- a/pkg/acs/Updates +++ b/pkg/acs/Updates @@ -1,4 +1,4 @@ -Update for version 10.4.0 - 14-Sep-2023 (MDD) +Update for version 10.4.0 - 07-May-2024 (MDD) pkg/acs/calacs/Dates pkg/acs/calacs/History pkg/acs/calacs/Updates diff --git a/pkg/acs/lib/acscte/docte.c b/pkg/acs/lib/acscte/docte.c index 469ec0cc..716c397d 100644 --- a/pkg/acs/lib/acscte/docte.c +++ b/pkg/acs/lib/acscte/docte.c @@ -295,11 +295,11 @@ int DoCTE (ACSInfo *acs_info, const bool forwardModelOnly) { cteParallelPars.scale_frac = (acs->expstart - cteParallelPars.cte_date0) / (cteParallelPars.cte_date1 - cteParallelPars.cte_date0); /* - This routine writes information to the HISTORY portion of the output + This routine writes information to the HISTORY portion of the output primary header which includes KEYWORD values read from the PCTETAB. Some of the KEYWORDs have different values for their use in the application of the parallel and serial CTE corrections. Further, the serial CTE is - amp-dependent so the KEYWORDs are documented for each amp. + amp-dependent so the KEYWORDs are documented for each amp. Write the parallel HISTORY information here. */ @@ -360,82 +360,89 @@ int DoCTE (ACSInfo *acs_info, const bool forwardModelOnly) { sprintf(MsgText, "(docte) amploc: %s ampID: %i amplocInCalib: %s ampIDInCalib: %i", amploc, ampID, amplocInCalib, ampIDInCalib); trlmessage(MsgText); - startOfSetInCalib = SET_TO_PROCESS[ampIDInCalib]; - strcpy(corrType, "serial"); - //sprintf(MsgText,"(pctecorr) Collecting data for Correction Type: %s \n", startOfSetInCalib, corrType); - // MDD Remove msg on final - sprintf(MsgText,"(pctecorr) StartOfSet: %d. Collecting data for Correction Type: %s \n", startOfSetInCalib, corrType); - trlmessage(MsgText); - /* - Loop to control the application of the CTE corrections - the serial - (Extensions 5-8 [A], 9-12 [B], 13-16 [C], 17-20 [D]) correction for each - Amp will be done first, then the parallel (Extensions 1-4) correction will - be done. The "Extensions" refer to the set of extensions in the calibration - reference file pertaining to a particular amp correction. - - As noted at the top of this file, the typical order of processing is - Chip 2 (Amps C and D) and then Chip 1 (Amps A and B). + Only perform the serial CTE correction for post-SM4 data */ - if (!skipLoadPrimary) { - initCTEParamsFast(&ctePars, TRAPS, 0, 0, nScaleTableColumns, acs_info->nThreads); + if (acs_info->expstart >= SM4MJD) { + + startOfSetInCalib = SET_TO_PROCESS[ampIDInCalib]; + strcpy(corrType, "serial"); + //sprintf(MsgText,"(pctecorr) Collecting data for Correction Type: %s \n", startOfSetInCalib, corrType); + // MDD Remove msg on final + sprintf(MsgText,"(pctecorr) StartOfSet: %d. Collecting data for Correction Type: %s \n", startOfSetInCalib, corrType); + trlmessage(MsgText); + + /* + Loop to control the application of the CTE corrections - the serial + (Extensions 5-8 [A], 9-12 [B], 13-16 [C], 17-20 [D]) correction for each + Amp will be done first, then the parallel (Extensions 1-4) correction will + be done. The "Extensions" refer to the set of extensions in the calibration + reference file pertaining to a particular amp correction. + + As noted at the top of this file, the typical order of processing is + Chip 2 (Amps C and D) and then Chip 1 (Amps A and B). + */ + + if (!skipLoadPrimary) { + initCTEParamsFast(&ctePars, TRAPS, 0, 0, nScaleTableColumns, acs_info->nThreads); + + ctePars.refAndIamgeBinsIdenticle = True; + ctePars.verbose = acs->verbose = 0 ? False : True; + if ((status = allocateCTEParamsFast(&ctePars))) + { + freeOnExit(&ptrReg); + freeOnExit(&ptrParallelReg); + return (status); + } + } - ctePars.refAndIamgeBinsIdenticle = True; - ctePars.verbose = acs->verbose = 0 ? False : True; - if ((status = allocateCTEParamsFast(&ctePars))) + if ((status = loadPCTETAB(cteTabFilename, &ctePars, startOfSetInCalib, skipLoadPrimary))) { freeOnExit(&ptrReg); freeOnExit(&ptrParallelReg); return (status); } - } - - if ((status = loadPCTETAB(cteTabFilename, &ctePars, startOfSetInCalib, skipLoadPrimary))) - { - freeOnExit(&ptrReg); - freeOnExit(&ptrParallelReg); - return (status); - } - skipLoadPrimary = True; + skipLoadPrimary = True; - if ((status = getCTEParsFromImageHeader(&x[0], &ctePars))) - { - freeOnExit(&ptrReg); - freeOnExit(&ptrParallelReg); - return (status); - } - - ctePars.scale_frac = (acs->expstart - ctePars.cte_date0) / (ctePars.cte_date1 - ctePars.cte_date0); - - /* - Write the amp-dependent serial HISTORY information here. - */ - char amp_corrType[20] = "serial - Amp "; - char s_amp[5]; - strncpy(s_amp, ccdamp + nthAmp, 1); - s_amp[1] = '\0'; - strcat(amp_corrType, s_amp); - amp_corrType[19] = '\0'; - if ((status = populateImageFileWithCTEKeywordValues(&x[0], &ctePars, amp_corrType))) - { - freeOnExit(&ptrReg); - freeOnExit(&ptrParallelReg); - return (status); - } + if ((status = getCTEParsFromImageHeader(&x[0], &ctePars))) + { + freeOnExit(&ptrReg); + freeOnExit(&ptrParallelReg); + return (status); + } - sprintf(MsgText, "(pctecorr) IGNORING read noise level PCTERNOI from PCTETAB: %f. Using amp dependent values from CCDTAB instead", ctePars.rn_amp); - trlwarn(MsgText); - sprintf(MsgText, "(pctecorr) Readout simulation forward modeling iterations PCTENFOR: %i", - ctePars.n_forward); - trlmessage(MsgText); - sprintf(MsgText, "(pctecorr) Number of iterations used in the parallel transfer PCTENPAR: %i", - ctePars.n_par); - trlmessage(MsgText); - sprintf(MsgText, "(pctecorr) CTE_FRAC: %f", ctePars.scale_frac); - trlmessage(MsgText); + ctePars.scale_frac = (acs->expstart - ctePars.cte_date0) / (ctePars.cte_date1 - ctePars.cte_date0); + + /* + Write the amp-dependent serial HISTORY information here. + */ + char amp_corrType[20] = "serial - Amp "; + char s_amp[5]; + strncpy(s_amp, ccdamp + nthAmp, 1); + s_amp[1] = '\0'; + strcat(amp_corrType, s_amp); + amp_corrType[19] = '\0'; + if ((status = populateImageFileWithCTEKeywordValues(&x[0], &ctePars, amp_corrType))) + { + freeOnExit(&ptrReg); + freeOnExit(&ptrParallelReg); + return (status); + } - sprintf(MsgText, "(pctecorr) The %s CTE processing parameters have been read.", corrType); - trlmessage(MsgText); + sprintf(MsgText, "(pctecorr) IGNORING read noise level PCTERNOI from PCTETAB: %f. Using amp dependent values from CCDTAB instead", ctePars.rn_amp); + trlwarn(MsgText); + sprintf(MsgText, "(pctecorr) Readout simulation forward modeling iterations PCTENFOR: %i", + ctePars.n_forward); + trlmessage(MsgText); + sprintf(MsgText, "(pctecorr) Number of iterations used in the parallel transfer PCTENPAR: %i", + ctePars.n_par); + trlmessage(MsgText); + sprintf(MsgText, "(pctecorr) CTE_FRAC: %f", ctePars.scale_frac); + trlmessage(MsgText); + + sprintf(MsgText, "(pctecorr) The %s CTE processing parameters have been read.", corrType); + trlmessage(MsgText); + } // End if block for collecting and reporting serial CTE correction /* The number of acs_info->nimsets represents the number of chips to process for the @@ -446,14 +453,17 @@ int DoCTE (ACSInfo *acs_info, const bool forwardModelOnly) { clock_t begin = (double)clock(); - /* Serial correction */ - strcpy(corrType, "serial"); - if ((status = doPCTEGen2(&acs[i], &ctePars, &x[i], forwardModelOnly, corrType, &ccdamp, nthAmp, amploc, ampID))) - { - freeOnExit(&ptrReg); - freeOnExit(&ptrParallelReg); - return status; - } + /* Perform the serial CTE correction for only post-SM4 data */ + if (acs_info->expstart >= SM4MJD) { + /* Serial correction */ + strcpy(corrType, "serial"); + if ((status = doPCTEGen2(&acs[i], &ctePars, &x[i], forwardModelOnly, corrType, &ccdamp, nthAmp, amploc, ampID))) + { + freeOnExit(&ptrReg); + freeOnExit(&ptrParallelReg); + return status; + } + } // End short if block for applying serial CTE correction /* Parallel correction */ strcpy(corrType, "parallel"); @@ -471,7 +481,8 @@ int DoCTE (ACSInfo *acs_info, const bool forwardModelOnly) { } } - freeOnExit(&ptrReg); + if (acs_info->expstart >= SM4MJD) + freeOnExit(&ptrReg); freeOnExit(&ptrParallelReg); PrSwitch("pctecorr", COMPLETE);