-
Notifications
You must be signed in to change notification settings - Fork 5
/
lnacoude.py
78 lines (65 loc) · 1.94 KB
/
lnacoude.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
#!/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
import lnacoudetasks as coude
# regular expression of files (e.g bias_00*.fits, flat-2000jan01_?.*)
zerore = str(raw_input('\nEnter regex for zero level images: '))
flatre = str(raw_input('Enter regex for science flat images: '))
scire = str(raw_input('Enter regex for science images: '))
calre = str(raw_input('Enter regex for calibration images: '))
fcalre = str(raw_input('Enter regex for calibration flat images: '))
# list of files that match that regular expression
zerolist = glob.glob(zerore)
flatlist = glob.glob(flatre)
scilist = glob.glob(scire)
callist = glob.glob(calre)
fcallist = glob.glob(fcalre)
print 'creating a proc/ dir to store processed data'
if not os.path.isdir('proc'):
os.mkdir('proc')
allfiles = zerolist + flatlist + scilist + callist + fcallist
for file in allfiles:
shutil.copy(file, 'proc/')
os.chdir('proc')
print 'openning a ds9 window if not already openned...'
ds9.ds9()
# combine bias images
print 'Combining Bias images...'
coude.masterbias(zerore)
for zerofile in zerolist:
os.remove(zerofile)
# check output bias image
coude.checkfile('Zero')
# combine flat images
print 'Combining flat images ...'
coude.masterflat(flatre)
for flatfile in flatlist:
os.remove(flatfile)
# check output
coude.checkfile('Flat')
coude.masterflat(fcalre, output = 'cFlat')
for fcalfile in fcallist:
os.remove(fcalfile)
coude.checkfile('cFlat')
# response
# coude.subzero('Flat')
coude.flatresponse('Flat')
coude.flatresponse('cFlat', 'ncFlat')
# check output
coude.checkfile('nFlat')
coude.checkfile('ncFlat')
# correct
coude.correctimages(scire, flat='nFlat')
coude.correctimages(calre, flat='ncFlat')
# extract
coude.runapall(scire)
coude.runapall(calre)
print '--- DONE ---'