-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreduce_301.cl
executable file
·199 lines (157 loc) · 4.98 KB
/
reduce_301.cl
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#
# Ver 2.0, 13nov05
#
# Changes: 1) proceduro to U filter now
# 2) polrap.pout parameter is changed as "00" by the script
# 3) New reporting message in terminal
# 4) swap.tol parameter defined by reduce_301 now
#
procedure reduce_301
string pre = "s" {prompt="Preffix of corresponding dark images"}
string suf = "1" {prompt="Suffix of corresponding flat images (excluding the last 0 character)"}
bool trim = yes {prompt="Trim the images?"}
bool texpcor = yes {prompt="Check the *real* integration time?"}
real tol = 2. {prompt="Exptime error tolerance (%)"}
bool headcor = no {prompt="Reset exptime values in headers?"}
string zeroadr = "" {prompt="TEMP for bias. If none, bias is not used"}
string trimsec = "301s" {prompt="Trim data section"}
string texpimg = "uu.u bb.b vv.v rr.r ii.i" {prompt="Real images exptimes (*00.0* to use header value)"}
struct *flist1
struct *flist2
# ABOUT texpimg parameter:
# Is necessary the five values (UBVRI), even that just one header value be wrong. Example: texpimg must be "00.0 bb.b 00.0 00.0 00.0", case only B value be wrong.
begin
string temp1, temp2, item
string image, lixo, darkpath, filter[5], verbose
real texp, darktime
int i, n
# Dummy variable to fix a bug:
string dark
verbose = mktemp("verb")
filter[1]="u"
filter[2]="b"
filter[3]="v"
filter[4]="r"
filter[5]="i"
# Set routines parameters (if texpcor == yes, ccdrap_301.exptime is changed inside of loop)
ccdrap_301.trim = trim
ccdrap_301.trimsec = trimsec
ccdrap_301.exptime = 0.
polrap.pout = "00"
swap.tcheck = texpcor
swap.tol = tol
#!rm -f verb* &> /dev/null
print ("CAUTION: It is necessary some previous running of calib_301 on calib images!\n")
#sleep 1
# Loop on the filters directories
for(i = 1; i < 6; i=i+1) {
if(! access(filter[i]))
next
chdir(filter[i])
# para que serve essa linha abaixo?
imdel(images="p*.fits", verify=no, >& "dev$null")
# Obtaining exptime of images
texp = 0.
if(headcor) {
item = substr(texpimg,1+(i-1)*5,5+(i-1)*5)
lixo = fscan(item,texp)
}
# Register number of waveplates
temp2 = mktemp("templist")
files("p*", > temp2)
flist2 = temp2
n = 0
while(fscan(flist2, item) != EOF)
n = n+1
delete(temp2, ver-, >& "dev$null")
# Case headcor == no or current parameter from texpimg equals zero
if(texp == 0) {
chdir(item)
temp2 = mktemp("templist")
files("p*", > temp2)
flist2 = temp2
lixo = fscan(flist2, image)
delete(temp2, ver-, >& "dev$null")
swap(image, tcheck=no)
temp2 = mktemp("tempexp")
hselect(images=image//".fits", fields="EXPTIME", expr=yes, > temp2)
flist2 = temp2
lixo = fscan(flist2, texp)
delete(temp2, ver-, >& "dev$null")
imdel(images=image//".fits", verify=no, >& "dev$null")
chdir("..")
}
# Set parameters
ccdrap_301.fw = n
ccdrap_301.darkcor = no
ccdrap_301.flatcor = no
ccdrap_301.dark = ""
ccdrap_301.flat = ""
if(texpcor)
ccdrap_301.exptime = texp
# Run ccdrap_301 and polrap
ccdrap_301(version=".1")
if(n<=16)
polrap(n=n)
if(n>8)
polrap(n=8)
if(n>16)
polrap(n=16)
# Procedure to .2 version
if(access("../../dark")) {
temp2 = mktemp("../dark_base")
files("../../dark/"//pre//"*.fits", > temp2)
flist2 = temp2
# Loop on the dark images to find what to substract of corrent images
while(fscan(flist2, darkpath) != EOF){
temp1= mktemp("darktemp")
hselect(images=darkpath, fields="DARKTIME", expr=yes, > temp1)
flist1 = temp1
lixo = fscan(flist1, darktime)
delete(temp1, ver-, >& "dev$null")
if(texp == darktime) {
ccdrap_301.darkcor = yes
ccdrap_301.dark = "../"//darkpath
break
}
}
}
print("FILTER "//filter[i]//": identified exptime: "//texp//"s", >> "../"//verbose)
if(ccdrap_301.darkcor)
print("FILTER "//filter[i]//": dark image used: "//darkpath, >> "../"//verbose)
else
print("FILTER "//filter[i]//": **WARNING**: dark not used because it was not found for "//texp//"s.\n Caution: Dark headers can be wrong in case of no previous running of calib_301.", >> "../"//verbose)
if(access("../../flat/f"//filter[i]//suf//"avg.fits")) {
ccdrap_301.flatcor = yes
ccdrap_301.flat="../../../flat/f"//filter[i]//suf//"avg.fits"
print("FILTER "//filter[i]//": flat image used: "//ccdrap_301.flat, >> "../"//verbose)
}
else
print("FILTER "//filter[i]//": **WARNING**: flat image not found.", >> "../"//verbose)
print("", >> "../"//verbose)
print("")
# sleep 3
# Run ccdrap_301 and polrap
if(ccdrap_301.flatcor || ccdrap_301.darkcor) {
if(zeroadr=="" || zeroadr==" " || zeroadr==" ")
ccdrap_301(version=".2")
else
ccdrap_301(version=".2",zerocor=yes,zero=zeroadr)
if(n<=16)
polrap(n=n)
if(n>8)
polrap(n=8)
if(n>16)
polrap(n=16)
}
delete(temp2, ver-, >& "dev$null")
chdir("..")
}
if(access(verbose)){
print("\n================")
cat(verbose)
delete(verbose, ver-, >& "dev$null")
}
flist1 = ""
flist2 = ""
end