-
Notifications
You must be signed in to change notification settings - Fork 5
/
makezero.py
61 lines (48 loc) · 1.46 KB
/
makezero.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
#!/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.zerocombine.unlearn()
# regular expression of files (e.g bias_00*.fits, flat-2000jan01_?.*)
zerore = str(raw_input('\nEnter regular expression for zero level images: '))
# list of files that match that regular expression
zerolist = glob.glob(zerore)
zeroin = ', '.join(zerolist)
print '\ncreating a zero_files/ dir to store original data'
if not os.path.isdir('zero_files'):
os.mkdir('zero_files')
allfiles = zerolist
for file in allfiles:
shutil.copy(file, 'zero_files/')
# combine bias images
print 'Combining zero level images...'
iraf.ccdred.zerocombine.ccdtype = ''
iraf.ccdred.zerocombine.reject = 'ccdclip'
iraf.ccdred.zerocombine.rdnoise = 'rdnoise'
iraf.ccdred.zerocombine.gain = 'gain'
iraf.ccdred.zerocombine(input=zeroin)
for zero in zerolist:
os.remove(zero)
print 'openning a ds9 window if not already openned...'
ds9.ds9()
# check output image
print 'Check output file:'
iraf.imstatistics('Zero')
print ' Running "imexamine" task..'
iraf.imexamine('Zero', 1)
print '--- DONE ---'