Open scizen9 opened 3 years ago
I just wanted to see if there have been any updates on this issue. From what I can tell, the mask frame has not yet been modified to a purely boolean array in the current code. That being said, when there's a chance, this would be a great feature to have for post-reduction stacking.
Just to add to this conversation, in FlagSaturation.py
in lines 36 to 45, it looks like the flag value for saturated values is incorrectly set (assuming that the flag values above are correct). It seems to be adding 8 to the flag where it should be adding 1.
# Create flags for saturated pixels
flags = np.zeros(self.action.args.ccddata.data.shape, dtype=np.uint8)
sat = np.where(self.action.args.ccddata.data > 60000)
flags[sat] += 8
number_of_sat_pixels = np.sum(sat)
sat = np.where(self.action.args.ccddata.data == 0)
flags[sat] += 8
number_of_sat_pixels += np.sum(sat)
Definitions:
Flag values are defined as follows: 0 - normal data 1 - saturated pixel (unaltered) 2 - bad column, hot pixel (fixed) 4 - cosmic ray pixel (fixed) 8 - negative flat value (unaltered) 16 - slice edge (unaltered) 32 - low signal flat (unaltered) 64 - outside slice illuminated area (unaltered) 128 - DAR padded pixel (unaltered)
Currently the python version of the pipeline only implements a subset of these flags and it attempts to keep the flag and mask segments of the astropy CCDData object consistent. This is not actually achieved for the flags that are currently implemented. Ultimately, we don't want this behaviour anyway. The mask should be boolean (True or False, where True means apply the mask) and should be generated based on best data reduction practices from the flag image just prior to the mask being used in a primitive operation.
The issue is that the CCDData mask segment causes data to be masked if it has any value other than 0 and the current way the mask image is implemented causes any and all flagged pixels to be excluded from calculations where they might properly be included.
What we need to do:
The bit pattern used for generating a masked image from the flags is determined by science considerations. For now we can provide a default bit mask and implement a way for the user to use their own bit pattern based on their own science goals.
I recommend a default bit pattern that does not mask the fixed pixels (bad column, cosmic ray), but does mask the unaltered pixels from the table above.