-
Notifications
You must be signed in to change notification settings - Fork 5
/
makeflat.py
62 lines (50 loc) · 1.53 KB
/
makeflat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
#
# A script to reduce data from the Coude Spectrograph from the 1.6m telescope
# of the Observatorio do Pico dos Dias - Brazil
#
# Load Python standard modules
import glob
import os
import shutil
# Load third-party modules
import ds9
from pyraf import iraf
print 'Loading IRAF packages ...'
iraf.imred()
iraf.ccdred()
print 'unlearning previous settings...'
iraf.ccdred.unlearn()
iraf.ccdred.ccdproc.unlearn()
iraf.ccdred.combine.unlearn()
iraf.ccdred.flatcombine.unlearn()
# regular expression of files (e.g bias_00*.fits, flat-2000jan01_?.*)
flatre = str(raw_input('Enter regular expression for flat images: '))
# list of files that match that regular expression
flatlist = glob.glob(flatre)
flatin = ', '.join(flatlist)
print 'creating a flat_files/ dir to store original data'
if not os.path.isdir('flat_files'):
os.mkdir('flat_files')
allfiles = flatlist
for file in allfiles:
shutil.copy(file, 'flat_files/')
# combine flat images
print 'Combining flat images ...'
iraf.ccdred.flatcombine.ccdtype = ''
iraf.ccdred.flatcombine.process = 'no'
iraf.ccdred.flatcombine.reject = 'ccdclip'
iraf.ccdred.flatcombine.rdnoise = 'rdnoise'
iraf.ccdred.flatcombine.gain = 'gain'
iraf.ccdred.flatcombine.output = 'Flat'
iraf.ccdred.flatcombine(input=flatin)
for file in flatlist:
os.remove(file)
print 'openning a ds9 window if not already openned...'
ds9.ds9()
# check output flat image
print 'Check output file:'
iraf.imstatistics('Flat')
print ' Running "imexamine" task..'
iraf.imexamine('Flat', 1)
print '--- DONE ---'