Skip to content

Commit

Permalink
also check in science frame for saturation value
Browse files Browse the repository at this point in the history
  • Loading branch information
ivenzor committed Nov 25, 2024
1 parent 06f8ecf commit d069e88
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions exotic/exotic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1906,20 +1906,27 @@ def main():
if fitsortext == 1:
# Only do the dark correction if user selects this option
if exotic_infoDict['darks']:
# First pass: find maximum value across all dark files
# First pass: find max value across all dark files
# this value will be a proxy for the saturation value
# EXOTIC will reject a dark frame if it's too bright, i.e. its median relative to max_across_darks
max_across_darks = 0
# EXOTIC will reject a dark frame if it's too bright, i.e. its median relative to the saturation value
saturation_value = 0
for darkFile in exotic_infoDict['darks']:
darkData = fits.getdata(darkFile)
file_max = np.max(darkData)
max_across_darks = max(max_across_darks, file_max)
saturation_value = max(saturation_value, file_max)
print("saturation value:", saturation_value)
# We also check a science frame looking for the saturation value
inputfile = corruption_check(exotic_infoDict['images'])[0]
inputfileData = fits.getdata(inputfile)
file_max = np.max(inputfileData)
saturation_value = max(saturation_value, file_max)
print("saturation value:", saturation_value)
# Second pass: validate darks
darksImgList = []
for darkFile in exotic_infoDict['darks']:
darkData = fits.getdata(darkFile)
median_val = np.median(darkData)
ratio = median_val / max_across_darks # Compare dark file median to saturation value
ratio = median_val / saturation_value # Compare dark file median to saturation value
#If the median of all the pixels in the darkfile is above 80% of the saturation value, the file is likely not a valid dark file
if ratio > 0.8:
log_info(f"\nWarning: Skipping suspicious dark frame {darkFile}: median/max ratio = {ratio}\n", warn=True)
Expand Down

0 comments on commit d069e88

Please sign in to comment.