44
55"""
66from enum import IntEnum
7- import pytest
7+
88import numpy as np
99
1010from stcal .saturation .saturation import flag_saturated_pixels
@@ -40,7 +40,6 @@ def test_basic_saturation_flagging():
4040 assert np .all (gdq [0 , satindex :, 5 , 5 ] == DQFLAGS ["SATURATED" ])
4141
4242
43- @pytest .mark .xfail (reason = "stcal PR#321 broke this test" )
4443def test_read_pattern_saturation_flagging ():
4544 """Check that the saturation threshold varies depending on how the reads
4645 are allocated into resultants."""
@@ -76,7 +75,7 @@ def test_read_pattern_saturation_flagging():
7675 )
7776
7877 # Make sure that groups after the third get flagged
79- assert np .all (gdq [0 , 2 :, 5 , 5 ] == DQFLAGS ["SATURATED" ])
78+ assert np .all (gdq [0 , 3 :, 5 , 5 ] == DQFLAGS ["SATURATED" ])
8079
8180
8281def test_read_pattern_saturation_flagging_dnu ():
@@ -120,7 +119,7 @@ def test_read_pattern_saturation_flagging_dnu():
120119
121120def test_group2_saturation_flagging_with_bias ():
122121 """Flag group 2 saturation in frame-averaged data with significant bias.
123-
122+
124123 Saturation in frame-averaged groups may not exceed the saturation threshold
125124 until after the group where a saturating CR occurs. Special rules are used
126125 for the second group of frame-averaged data. Check that the saturation
@@ -142,35 +141,35 @@ def test_group2_saturation_flagging_with_bias():
142141 # Frame 5 in group 2 has a 40000 count CR saturating the pixel
143142 # averaged over 5 frames this only looks like a 8000 count jump in group 2
144143 # but group 3 signal saturates
145-
144+
146145 bias [5 , 5 ] = 15000
147-
146+
148147 data [0 , 0 , 5 , 5 ] = 18000
149148 data [0 , 1 , 5 , 5 ] = 31000
150149 data [0 , 2 , 5 , 5 ] = 68000
151150 data [0 , 3 , 5 , 5 ] = 73000 # Signal reaches saturation limit
152151 data [0 , 4 , 5 , 5 ] = 78000
153-
154-
152+
153+
155154 # Add another pixel with bias of 15000, but no source flux
156155 # pixel counts are 15000 > sat_thresh/5, but should not be flagged as
157156 # saturated.
158157 bias [15 , 15 ] = 15000
159-
158+
160159 data [0 , :, 15 , 15 ] = 15000
161160
162161 # Set saturation value in the saturation model
163162 satvalue = 60000
164163 sat_thresh [5 , 5 ] = satvalue
165164 sat_thresh [15 , 15 ] = satvalue
166-
165+
167166
168167 # set read_pattern to have 5 reads per group.
169168 read_pattern = [
170- [1 , 2 , 3 , 4 , 5 ],
171- [6 , 7 , 8 , 9 , 10 ],
172- [11 , 12 , 13 , 14 , 15 ],
173- [16 , 17 , 18 , 19 , 20 ],
169+ [1 , 2 , 3 , 4 , 5 ],
170+ [6 , 7 , 8 , 9 , 10 ],
171+ [11 , 12 , 13 , 14 , 15 ],
172+ [16 , 17 , 18 , 19 , 20 ],
174173 [21 , 22 , 23 , 24 , 25 ]
175174 ]
176175
0 commit comments