-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctio.cl
339 lines (288 loc) · 10.9 KB
/
ctio.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
procedure ctio ()
struct *flist {mode="h"}
struct *flist2 {mode="h"}
struct *file_var {mode="h"}
begin
struct name, line3
real line, boxsize, bigbox, niterate, tolerance
real line2
real ut
real filter
bool check, imalign, doalign
string reference
int k, m
if (! defpac ("daophot")) {
print ('')
print (' This script must be loaded inside the package \'noao.digiphot.daophot\'')
bye()
}
astutil
rename.files = '*.fits'
rename.newname = 'fit'
rename.field = 'extn'
rename
files ("*.fit", >> 'list')
setairmass.equinox = 'equinox'
setairmass.st = 'LST'
setairmass.ut = 'time-obs'
setairmass.date = 'date-obs'
setairmass.update = yes
setairmass ('*.fit')
hedit (images="*.fit", fields="GAIN", value=1.44, add=no, addonly=yes, delete=no, verify=no, update=yes)
hedit (images="*.fit", fields="RDNOISE", value=7., add=no, addonly=yes, delete=no, verify=no, update=yes)
flist = 'list'
while (fscan (flist,name) != EOF) {
print ('')
print (' Editing '//name//' file...')
print ('')
hselect.mode = "hl"
hselect.images = name
hselect.fields = "FILTER"
hselect.expr = yes
hselect > "tempctio"
flist2 = 'tempctio'
while (fscan (flist2,line) != EOF)
del ("tempctio")
filter = line
if (filter == 2) {
hedit (images=(name), fields="FILTERS", value="B", add=yes, addonly=no, delete=no, verify=no, update=yes)
}
else {
if (filter == 3) {
hedit (images=(name), fields="FILTERS", value="V", add=no, addonly=yes, delete=no, verify=no, update=yes)
}
else {
if (filter == 5) {
hedit (images=(name), fields="FILTERS", value="I", add=no, addonly=yes, delete=no, verify=no, update=yes)
}
else {
if (filter == 6) {
hedit (images=(name), fields="FILTERS", value="U", add=no, addonly=yes, delete=no, verify=no, update=yes)
}
else {
print ('ERROR IN NAME OF FILE: '//name)
print ('Filter value found: '//filter)
print ('Closing...')
bye()
}
}
}
}
hselect.mode = "hl"
hselect.images = name
hselect.fields = "TIME-OBS"
hselect.expr = yes
hselect > "tempctio"
flist2 = 'tempctio'
while (fscan (flist2,line2) != EOF)
del ("tempctio")
ut = line2
hedit (images=(name), fields="UT", value=(ut), add=no, addonly=yes, delete=no, verify=no, update=yes)
}
print ('')
print (' Trim images (this will trim ALL frames to')
print (' the section: [26:4052,26:4052])? (y/n)')
print (' default = no')
check = no
scan (check)
if (check) {
imcopy.input = '*.fit[26:4052,26:4052]'
imcopy.output = '*.fit'
imcopy.verbose = yes
imcopy
}
print ('')
print (' Trimming done')
print ('')
print (' Perform transposing? (y/n)')
print (' default = no')
check = no
scan (check)
if (check) {
print ('')
print (' First transposing (this could take a while)...')
imtranspose (input="*.fit[-*,*]", output="*.fit")
print ('')
print (' Second transposing (this could take a while)...')
imtranspose (input="*.fit[-*,*]", output="*.fit")
daophot
}
print ('')
print (' Perform align? (y/n)')
print (' default = yes')
check = yes
scan (check)
if (check) {
findpars.threshold = 500000
imalign = yes
while (imalign) {
flist = 'list'
while (fscan (flist,name) != EOF) {
print (name)
k = strlen(name)
if (substr (name, k-3, k) == ".fit") {
name = substr (name, 1, k-4)
print (name//'.fits', >> 'listfits')
}
}
print ('')
print (' Input the \'reference\' image')
scan (reference)
print (' ')
print (' ----------------------------------------------------- ')
print (' Display task: ')
print (' Original Image: ' // reference )
print (' ----------------------------------------------------- ')
display ((reference), 1)
print (' ')
print (' ----------------------------------------------------- ')
print (' Daofind task: ')
print (' Search for stars ')
print (' ----------------------------------------------------- ')
daofind.verif = no
daofind.verb = no
daofind ((reference), "default")
print (' ')
print (' ----------------------------------------------------- ')
print (' Tvmark ')
print (' - circle = detected star ')
print (' ----------------------------------------------------- ')
print ('')
file_var = (reference // '.coo.'// 1)
m=0
while (fscan (file_var,line3) != EOF) {
m = m + 1
}
print ('')
print (' Number of stars marked: '//(m-41))
print ('')
print (' We set a really high threshold (500000) so that NO stars are')
print (' marked and the user selects the stars by hand.')
print ('')
print (' Continue: press \'y\' or \'n\' key (you will enter the interactive \'tvmark\')')
check = yes
scan (check)
tvmark.interactive = no
tvmark.outimage = ""
tvmark.mark = 'circle'
tvmark.font = "raster"
tvmark.txsize = 2
tvmark.radii = 10
tvmark.color = 204
tvmark.number = yes
tvmark.label = no
tvmark (1, (reference // '.coo.'// 1))
# The first tvmark marks the stars in the image, found by 'daofind'
# The second one (below this), performs the 'interactive' tvmark.
# If I try to make the first tvmark 'interactive', then
# it doesn't mark the stars, this way the found star are marked
tvmark.interactive = yes
tvmark.outimage = ""
tvmark.mark = 'circle'
tvmark.font = "raster"
tvmark.txsize = 2
tvmark.radii = 10
tvmark.color = 204
tvmark.number = yes
tvmark.label = no
tvmark (1, (reference // '.coo.'// 1))
print ('')
print (' Were stars correctly marked (else delete')
print (' "*.coo.1" file and repeat)? (y/n)')
print ('')
print (' default = yes')
check = yes
scan (check)
if (check == no) {
delete (reference // '.coo.'// 1)
imalign = yes
}
else {
imalign = no
unlearn phot
unlearn centerpars
unlearn fitskypars
unlearn photpars
phot.interactive = no
phot.radplots = no
phot.update = yes
phot.verbose = no
phot.mode = 'hl'
phot.verify = no
phot (reference, "default", "default")
txdump.mode = 'hl'
txdump.textfile = (reference//'.mag.1')
txdump.headers = no
txdump.fields = 'XCENTER,YCENTER'
txdump.expr = 'MAG[1]!=INDEF'
txdump > referimalign
}
}
doalign = yes
while (doalign) {
print ('')
print (' Input \'imalign\' parameter values:')
print ('')
boxsize = 7
print (' Actual boxsize value = '//boxsize//' Input new value:')
scan (boxsize)
bigbox = 11
print (' Actual bigbox value = '//bigbox//' Input new value:')
scan (bigbox)
niterate = 8
print (' Actual niterate value = '//niterate//' Input new value:')
scan (niterate)
tolerance = 10
print (' Actual tolerance value = '//tolerance//' Input new value:')
scan (tolerance)
print ('')
print (' Performing \'imalign\'...')
imalign.input = '@list'
imalign.referenc = reference
imalign.coords = 'referimalign'
imalign.output = '@listfits'
imalign.boxsize = boxsize
imalign.bigbox = bigbox
imalign.negative = no
imalign.niterate = niterate
imalign.tolerance = tolerance
imalign.maxshift = INDEF
imalign.shiftimages = yes
imalign.interp_type = "nearest"
imalign.boundary_typ = "nearest"
imalign.trimimages = yes
imalign.verbose = yes
imalign.mode = "hl"
imalign
delete ('@list')
print ('')
print (' Displaying shifted images')
print ('')
m=1
flist = ('listfits')
while (fscan(flist, name) != EOF) {
display (name, m)
m=m+1
}
print ('')
print (' Were the images shifted correctly (else input new parameters and re-do)? (y/n)')
print (' default = yes')
check=yes
scan (check)
if (check) {
doalign = no
}
rename.files = '*.fits'
rename.newname = 'fit'
rename.field = 'extn'
rename
}
delete ('listfits')
delete ('referimalign')
delete (reference//'.coo.1')
delete (reference//'.mag.1')
}
delete ('list')
print ('')
print (' Done!')
end