Skip to content

Commit

Permalink
Bug fix to address a problem detected when processing a Tungsten flat…
Browse files Browse the repository at this point in the history
… with a high background. (#547)

Uninitialized values were used for further computation causing an eventual exception.
The problem detected by this image could happen for images with lower
backgrounds with no pixel values less than a threshold minimum (1000) so
it was important to fix for useful science data.
  • Loading branch information
mdlpstsci authored Apr 29, 2021
1 parent e0f20b7 commit fda59ea
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pkg/wfc3/calwf3/Dates
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
28-Apr-2021 - MDD - Version 3.6.1
- Bug fix to address a problem detected when processing a Tungsten flat with a high background.
Uninitialized values were used for further computation causing an eventual exception.

31-Dec-2020 - MDD - Version 3.6.0
- Implementation of a significantly upgraded CTE correction as defined/derived by J. Anderson.
The upgraded CTE algorithm is also streamlined and executes faster then the previous version.
Expand Down
4 changes: 4 additions & 0 deletions pkg/wfc3/calwf3/History
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 28-Apr-2021 - MDD - Version 3.6.1
- Bug fix to address a problem detected when processing a Tungsten flat with a high background.
Uninitialized values were used for further computation causing an eventual exception.

### 31-Dec-2020 - MDD - Version 3.6.0
- Implementation of a significantly upgraded CTE correction as defined/derived by J. Anderson.
The upgraded CTE algorithm is also streamlined and executes faster then the previous version.
Expand Down
4 changes: 4 additions & 0 deletions pkg/wfc3/calwf3/Updates
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Updates for Version 3.6.1 28-Apr-2021 - MDD
- Bug fix to address a problem detected when processing a Tungsten flat with a high background.
Uninitialized values were used for further computation causing an eventual exception.

Updates for Version 3.6.0 31-Dec-2020 - MDD
- Implementation of a significantly upgraded CTE correction as defined/derived by J. Anderson.
The upgraded CTE algorithm is also streamlined and executes faster then the previous version.
Expand Down
4 changes: 2 additions & 2 deletions pkg/wfc3/calwf3/include/wf3version.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* This string is written to the output primary header as CAL_VER. */


# define WF3_CAL_VER "3.6.0(Dec-31-2020)"
# define WF3_CAL_VER_NUM "3.6.0"
# define WF3_CAL_VER "3.6.1(Apr-28-2021)"
# define WF3_CAL_VER_NUM "3.6.1"

#endif /* INCL_WF3VERSION_H */
22 changes: 20 additions & 2 deletions pkg/wfc3/calwf3/wf3cte/wf3cte.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
M.D. De La Pena Mar-2020: Further changes to accommodate subarrays - only evaluate valid (non-zero) pixels.
Updates received from Jay Anderson. Removed deprecated routines: find_dadj, rsz2rsc, inverse_cte_blur, and raz2rsz.
Small bug found in original subarray code during testing.
M.D. De La Pena Apr-2021: Fix to address a problem detected when processing a Tungsten flat with a high
background. Uninitialized values were used for further computation causing an eventual exception.
*/

# include <time.h>
Expand Down Expand Up @@ -1549,6 +1552,11 @@ float find_raz2rnoival(float *raz_cdab, float *FLOAT_RNOIVAL, float *FLOAT_BKGDV
FLOAT_RNOIVAL[0] = 3.33;
FLOAT_BKGDVAL[0] = raz_cdab[0];

iv1 = 1;
iv2 = 999;
id1 = 1;
id2 = 999;

/*
* Distill the image variation information and background into quick histograms
*/
Expand Down Expand Up @@ -1662,17 +1670,27 @@ float find_raz2rnoival(float *raz_cdab, float *FLOAT_RNOIVAL, float *FLOAT_BKGDV
vsum = 0;

for (ih=iv1; ih<=iv2; ih++) {
nsum = nsum + vhist[ih-1];
vsum = vsum + vhist[ih-1]*(ih-501);
nsum = nsum + vhist[ih-1];
vsum = vsum + vhist[ih-1]*(ih-501);
}

if (vsum==0 || nsum==0) {
RNOIVALu = 9.75 ;
BKGDVALu = 999.9 ;
*FLOAT_RNOIVAL = RNOIVALu;
*FLOAT_BKGDVAL = BKGDVALu;
return(RNOIVALu);
}

/* For debugging purposes only
printf(" \n");
printf(" vsum: %12lld \n",vsum);
printf(" nsum: %12lld \n",nsum);
printf(" \n");
printf(" dbar: %12.2f \n",idmin/2.30*(SPREAD_FOR_HISTO));
printf(" vbar: %12.2f %12lld %12lld \n",vsum/nsum*(SPREAD_FOR_HISTO),vsum,nsum);
printf(" \n");
*/

RNOIVAL = (int)(idmin/2.30/(SPREAD_FOR_HISTO)/sqrt(1+1/8.0)*4+0.5)/4.00;
RNOIVAL = idmin/2.30/(SPREAD_FOR_HISTO)/sqrt(1+1/8.0);
Expand Down

0 comments on commit fda59ea

Please sign in to comment.