diff --git a/ctegen2/ctehelpers.c b/ctegen2/ctehelpers.c index 8421df9b1..bdec615da 100644 --- a/ctegen2/ctehelpers.c +++ b/ctegen2/ctehelpers.c @@ -38,8 +38,8 @@ void initCTEParamsFast(CTEParamsFast * pars, const unsigned _nTraps, pars->isSubarray = False; pars->chip = 0; pars->refAndIamgeBinsIdenticle = True; - pars->rowOffset = 0; //from begining of chip - pars->columnOffset = 0; //from begining of chip + pars->rowOffset = 0; //from begining of chip (for WFC3 this includes overscan, for ACS this does not, i.e. it has already been trimmed) + pars->columnOffset = 0; //from begining of chip (for WFC3 this includes overscan, for ACS this does not, i.e. it has already been trimmed) pars->imageRowsStart = 0; pars->imageRowsEnd = 0; pars->postscanWidth = 0; diff --git a/pkg/acs/calacs/acscte/dopcte-gen2.c b/pkg/acs/calacs/acscte/dopcte-gen2.c index 2c9f70a47..719ab9fd6 100644 --- a/pkg/acs/calacs/acscte/dopcte-gen2.c +++ b/pkg/acs/calacs/acscte/dopcte-gen2.c @@ -22,8 +22,8 @@ int get_amp_array_size_acs_cte(const ACSInfo *acs, SingleGroup *amp, int *xsize, int *ysize, int *xbeg, int *xend, int *ybeg, int *yend); -static int extractAmp(SingleGroup * amp, const SingleGroup * image, const unsigned ampID); -static int insertAmp(SingleGroup * amp, const SingleGroup * image, const unsigned ampID); +static int extractAmp(SingleGroup * amp, const SingleGroup * image, const unsigned ampID, CTEParamsFast * ctePars); +static int insertAmp(SingleGroup * amp, const SingleGroup * image, const unsigned ampID, CTEParamsFast * ctePars); static int alignAmpData(FloatTwoDArray * amp, const unsigned ampID); static int alignAmp(SingleGroup * amp, const unsigned ampID); @@ -103,9 +103,15 @@ int doPCTEGen2 (ACSInfo *acs, CTEParamsFast * ctePars, SingleGroup * chipImage) nColumns = amp_xsize; ctePars->nRows = nRows; ctePars->nColumns = nColumns; - ctePars->columnOffset = 0;//amp_xbeg;//acs->offsetx; - ctePars->rowOffset = 0;//amp_ybeg;//acs->offsety; - ctePars->razColumnOffset = nthAmp*nColumns; + ctePars->columnOffset = amp_xbeg; + ctePars->rowOffset = amp_ybeg; + // razColumnOffset is used to align the image with the column scaling (SCLBYCOL) in the PCTETAB. + // The SCLBYCOL array is 8192 cols wide which is 2048*4 and therefore does NOT include the physical + // overscan columns (24 for ACS WFC) like this array does for calwf3. + // The raz format is all 4 amps side by side in CDAB order. + ctePars->razColumnOffset = ctePars->columnOffset; + if (ampID == AMP_A || ampID == AMP_B) + ctePars->razColumnOffset += ACS_WFC_N_COLUMNS_PER_CHIP_EXCL_OVERSCAN; //This is used for the final output SingleGroup ampImage; @@ -119,7 +125,7 @@ int doPCTEGen2 (ACSInfo *acs, CTEParamsFast * ctePars, SingleGroup * chipImage) // read data from the SingleGroup into an array containing data from // just one amp - if ((status = extractAmp(&Image, chipImage, ampID))) + if ((status = extractAmp(&Image, chipImage, ampID, ctePars))) { freeOnExit(&ptrReg); return (status); @@ -251,7 +257,7 @@ int doPCTEGen2 (ACSInfo *acs, CTEParamsFast * ctePars, SingleGroup * chipImage) return (status); } - if ((status = insertAmp(chipImage, &Image, ampID))) + if ((status = insertAmp(chipImage, &Image, ampID, ctePars))) { freeOnExit(&ptrReg); return (status); @@ -269,7 +275,7 @@ int doPCTEGen2 (ACSInfo *acs, CTEParamsFast * ctePars, SingleGroup * chipImage) return (status); } -static int extractAmp(SingleGroup * amp, const SingleGroup * image, const unsigned ampID) +static int extractAmp(SingleGroup * amp, const SingleGroup * image, const unsigned ampID, CTEParamsFast * ctePars) { extern int status; @@ -279,24 +285,23 @@ static int extractAmp(SingleGroup * amp, const SingleGroup * image, const unsig //WARNING - assumes row major storage assert(amp->sci.data.storageOrder == ROWMAJOR && image->sci.data.storageOrder == ROWMAJOR); - const unsigned nRows = amp->sci.data.ny; - const unsigned nColumns = amp->sci.data.nx; - - unsigned rowSkipLength = image->sci.data.nx; - unsigned offset = 0; - if (ampID == AMP_B || ampID == AMP_D) - offset = nColumns; - else if (ampID != AMP_A && ampID != AMP_C) + if (ampID != AMP_A && ampID != AMP_B && ampID != AMP_C && ampID != AMP_D) { trlerror("Amp number not recognized, must be 0-3."); return (status = ERROR_RETURN); } + const unsigned nRows = amp->sci.data.ny; + const unsigned nColumns = amp->sci.data.nx; + + unsigned rowSkipLength = image->sci.data.nx; + unsigned offset = ctePars->columnOffset; + copyOffsetSingleGroup(amp, image, nRows, nColumns, 0, offset, nColumns, rowSkipLength); return status; } -static int insertAmp(SingleGroup * image, const SingleGroup * amp, const unsigned ampID) +static int insertAmp(SingleGroup * image, const SingleGroup * amp, const unsigned ampID, CTEParamsFast * ctePars) { extern int status; @@ -306,19 +311,18 @@ static int insertAmp(SingleGroup * image, const SingleGroup * amp, const unsigne //WARNING - assumes row major storage assert(amp->sci.data.storageOrder == ROWMAJOR && image->sci.data.storageOrder == ROWMAJOR); - const unsigned nRows = amp->sci.data.ny; - const unsigned nColumns = amp->sci.data.nx; - - unsigned rowSkipLength = image->sci.data.nx; - unsigned offset = 0; - if (ampID == AMP_B || ampID == AMP_D) - offset = nColumns; - else if (ampID != AMP_A && ampID != AMP_C) + if (ampID != AMP_A && ampID != AMP_B && ampID != AMP_C && ampID != AMP_D) { trlerror("Amp number not recognized, must be 0-3."); return (status = ERROR_RETURN); } + const unsigned nRows = amp->sci.data.ny; + const unsigned nColumns = amp->sci.data.nx; + + unsigned rowSkipLength = image->sci.data.nx; + unsigned offset = ctePars->columnOffset; + copyOffsetSingleGroup(image, amp, nRows, nColumns, offset, 0, rowSkipLength, nColumns); return status; } diff --git a/pkg/acs/calacs/include/acs.h b/pkg/acs/calacs/include/acs.h index a2fdcfa46..89bb1c40e 100644 --- a/pkg/acs/calacs/include/acs.h +++ b/pkg/acs/calacs/include/acs.h @@ -13,6 +13,9 @@ # define ACS_FITS_REC 82 # define SZ_STRKWVAL 68 +#define ACS_WFC_N_COLUMNS_PER_CHIP_INCL_OVERSCAN 4144 +#define ACS_WFC_N_COLUMNS_PER_CHIP_EXCL_OVERSCAN 4096 + /* Macros for dusing GetKey/PutKey functions.... */ # define USE_DEFAULT 1 /* Use default if keyword is missing */ # define NO_DEFAULT 0 /* missing keyword is fatal error */