-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsltwcalib2d.py
executable file
·91 lines (75 loc) · 2.78 KB
/
sltwcalib2d.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env python
import re
import os
import glob
from pyraf import iraf
def identify():
iraf.twodspec()
iraf.longslit()
iraf.identify(images='Lamp.fits', section='middle column',
database='database', coordlist='linelists$idhenear.dat',
nsum=10, match=-3.0, maxfeatures=50, zwidth=100.0,
ftype='emission', fwidth=20.0, cradius=7.0, threshold=0.0,
minsep=2.0, function='chebyshev', order=6, sample='*',
niterate=0, low_reject=3.0, high_reject=3.0, grow=0.0,
autowrite='no')
def reidentify():
iraf.twodspec()
iraf.longslit()
iraf.reidentify(reference='Lamp', images='Lamp', interactive='no',
section='column', newaps='yes', override='yes', refit='yes',
trace='no', step=10, nsum=10, shift=0.0, search=0.0,
nlost=5, cradius=7.0, threshold=0.0, addfeatures='no',
coordlist='linelists$idhenear.dat', match=-3.0,
maxfeatures=50, minsep=2.0, database='database')
def fitcoords():
iraf.twodspec()
iraf.longslit()
iraf.fitcoords(images='Lamp', fitname='Lamp', interactive='yes',
combine='no', database='database', deletions='deletions.db',
function='chebyshev', xorder=6, yorder=6)
def transform(lst):
f = open(lst)
l = f.readlines()
f.close()
namelst = ['ftbo' + i for i in l]
outputlst = ['wftbo' + i for i in l]
# namelst = [i.split('.')[0] + 'otbf.fits' for i in l]
# outputlst = [i.split('.')[0] + 'otbfw.fits' for i in l]
f = open("temp1.txt", 'w')
for i in namelst:
f.write(i + '\n')
f.close()
f = open("temp2.txt", 'w')
for i in outputlst:
f.write(i + '\n')
f.close()
iraf.twodspec()
iraf.longslit(dispaxis=2)
# for i in namelst:
# print '#' * 30, i, '===>', i.split('.')[0] + 'w.fits'
# iraf.transform(input = i, output = i.split('.')[0] + 'w.fits',
# minput = '', moutput = '', fitnames = 'LampLamp',
# database = 'database', interptype = 'spline3',
# flux = 'yes')
iraf.transform(input='@temp1.txt', output='@temp2.txt',
minput='', moutput='', fitnames='LampLamp',
database='database', interptype='spline3',
flux='yes')
def clear():
print 'remove wftbo*.fits'
filelst = glob.glob('*.fits')
filelst = [i for i in filelst if re.match(
r'^wftboYF.+\.fits', i) is not None]
for name in filelst:
print 'remove ' + name
os.remove(name)
def main():
clear()
corhalogenlst = 'cor_halogen.lst'
identify()
reidentify()
fitcoords()
transform(corhalogenlst)
if __name__ == "__main__":
main()