Description
Makes mask, intercept, and slope images for an affine detector response from a set of sky flats taken at two different exposure times. Note that using images made from only different numbers of coadds will not work: the two sets must have diferent exposure (integration) times. Each set of images is stacked and averaged. Pixel values outside of a threshold (usually 1.5 standard deviations from the mean) are removed from the masks, and the two masks are combined by multiplication ('and'-ing). The slope is computed as (av2 - av1) / (exposure2 - exposure1), and the intercept as av1 - slope * exposure1 where the mask is 1. An affine response is calculated for each pixel. Often, the intercept values are negative.
Usage
makeflats.py command-file
The command file is a text file of the paths of images to stack, the output file to write, and flags controlling modes, printout, and graphics (see examples below). The outputs are other FITS files.
Examples
The following file will make mask, intercept, and slope frames for 7/24/07:
# sample makeflats.py command file # comment out or remove any undesired flags # set files to stack (one per line) files1 = '''072407/raw/im0141.a.fits 072407/raw/im0142.a.fits 072407/raw/im0143.a.fits 072407/raw/im0144.a.fits 072407/raw/im0145.a.fits 072407/raw/im0146.a.fits 072407/raw/im0147.a.fits 072407/raw/im0148.a.fits 072407/raw/im0149.a.fits 072407/raw/im0150.a.fits''' # set exposure time 1 exposure1 = 0.25 files2 = '''072407/raw/im0161.a.fits 072407/raw/im0162.a.fits 072407/raw/im0163.a.fits 072407/raw/im0164.a.fits 072407/raw/im0165.a.fits 072407/raw/im0166.a.fits 072407/raw/im0167.a.fits 072407/raw/im0168.a.fits 072407/raw/im0169.a.fits 072407/raw/im0170.a.fits''' # set exposure time 2 exposure2 = 1.00 # set stacking mode, mask threshold, printout, graphics flags mode = 0 # 0 = average, 1 = median thresh = 1.5 printout = True graphics = True # set output files to write maskOutput = '072407/intermediates/mask.fits' interceptOutput = '072407/intermediates/intercept.fits' slopeOutput = '072407/intermediates/slope.fits'
The output using the above is:
> makeflats.py 072407/intermediates/makeflats.txt reading 072407/raw/im0141.a.fits reading 072407/raw/im0142.a.fits reading 072407/raw/im0143.a.fits reading 072407/raw/im0144.a.fits reading 072407/raw/im0145.a.fits reading 072407/raw/im0146.a.fits reading 072407/raw/im0147.a.fits reading 072407/raw/im0148.a.fits reading 072407/raw/im0149.a.fits reading 072407/raw/im0150.a.fits stack is (10, 512, 512) av is (512, 512), mean = 105.377964401, std = 83.702736997 reading 072407/raw/im0161.a.fits reading 072407/raw/im0162.a.fits reading 072407/raw/im0163.a.fits reading 072407/raw/im0164.a.fits reading 072407/raw/im0165.a.fits reading 072407/raw/im0166.a.fits reading 072407/raw/im0167.a.fits reading 072407/raw/im0168.a.fits reading 072407/raw/im0169.a.fits reading 072407/raw/im0170.a.fits stack is (10, 512, 512) av is (512, 512), mean = 1218.91552734, std = 274.226981714 mask1 is (512, 512), thresh = 1.5 stds, mask1 has 699 zeros mask2 is (512, 512), thresh = 1.5 stds, mask2 has 9828 zeros mask is (512, 512), mask has 10225 zeros exposure1 = 0.25, exposure2 = 1.0 masked slope is (512, 512), mean = 1466.56517331 masked intercept is (512, 512), mean = -261.7508686 writing 072407/intermediates/mask.fits writing 072407/intermediates/intercept.fits writing 072407/intermediates/slope.fits

The following command file makes flats for the first set of sky images on 9/08/07:
# sample makeflats.py command file # comment out or remove any undesired flags # set files to stack (one per line) files1 = '''090807/raw/im0442.a.fits 090807/raw/im0443.a.fits 090807/raw/im0444.a.fits 090807/raw/im0445.a.fits 090807/raw/im0446.a.fits 090807/raw/im0447.a.fits 090807/raw/im0448.a.fits 090807/raw/im0449.a.fits 090807/raw/im0450.a.fits 090807/raw/im0451.a.fits''' # set exposure time 1 exposure1 = 0.25 files2 = '''090807/raw/im0422.a.fits 090807/raw/im0423.a.fits 090807/raw/im0424.a.fits 090807/raw/im0425.a.fits 090807/raw/im0426.a.fits 090807/raw/im0427.a.fits 090807/raw/im0428.a.fits 090807/raw/im0429.a.fits 090807/raw/im0430.a.fits 090807/raw/im0431.a.fits''' # set exposure time 2 exposure2 = 1.00 # set stacking mode, mask threshold, printout, graphics flags mode = 0 # 0 = average, 1 = median thresh = 1.5 printout = True graphics = True # set output files to write maskOutput = '090807/intermediates/mask.fits' interceptOutput = '090807/intermediates/intercept.fits' slopeOutput = '090807/intermediates/slope.fits'
The output using the above is:
> makeflats.py 090807/intermediates/makeflats.txt reading 090807/raw/im0442.a.fits reading 090807/raw/im0443.a.fits reading 090807/raw/im0444.a.fits reading 090807/raw/im0445.a.fits reading 090807/raw/im0446.a.fits reading 090807/raw/im0447.a.fits reading 090807/raw/im0448.a.fits reading 090807/raw/im0449.a.fits reading 090807/raw/im0450.a.fits reading 090807/raw/im0451.a.fits stack is (10, 512, 512) av is (512, 512), mean = 623.193564224, std = 135.693910642 reading 090807/raw/im0422.a.fits reading 090807/raw/im0423.a.fits reading 090807/raw/im0424.a.fits reading 090807/raw/im0425.a.fits reading 090807/raw/im0426.a.fits reading 090807/raw/im0427.a.fits reading 090807/raw/im0428.a.fits reading 090807/raw/im0429.a.fits reading 090807/raw/im0430.a.fits reading 090807/raw/im0431.a.fits stack is (10, 512, 512) av is (512, 512), mean = 9963.93652344, std = 1793.29954274 mask1 is (512, 512), thresh = 1.5 stds, mask1 has 10501 zeros mask2 is (512, 512), thresh = 1.5 stds, mask2 has 10747 zeros mask is (512, 512), mask has 10989 zeros exposure1 = 0.25, exposure2 = 1.0 masked slope is (512, 512), mean = 12326.3934883 masked intercept is (512, 512), mean = -2463.95463313 writing 090807/intermediates/mask.fits writing 090807/intermediates/intercept.fits writing 090807/intermediates/slope.fits

©Sky Coyote 2007