-
Notifications
You must be signed in to change notification settings - Fork 0
/
align.cl
303 lines (251 loc) · 9.89 KB
/
align.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
################################################################################
#
# ===========================================================
# PROCEDURE TO PERFORM IMALIGN
# ===========================================================
#
# To run properly this procedure must be executed inside the package:
# 'noao.digiphot.daophot'
#
# by Gabriel Perren 2009
#
################################################################################
procedure align ()
struct *list {mode="h"}
struct *listm {mode="h"}
struct *listk {mode="h"}
begin
struct name, name2, namem, namek
string var[50], var2[50], frame
int i, j, k, m, o, p, q, x
real thresh
bool auxi, auxi2
# ------------------------------------------------------------------------------------
# Control 0
# ------------------------------------------------------------------------------------
if (! defpac ("daophot")) {
print ('')
print (' This script must be loaded inside the package noao/digiphot/daophot')
bye()
}
else { # Do nothing
}
# ------------------------------------------------------------------------------------
# Control 0
# ------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------
# Structure to create a single file for each cluster, containing the name of the frame
# files that correspond to the same cluster
# ------------------------------------------------------------------------------------
files ('*.fit', > 'frames')
list = "frames"
j=0
for (i=1; fscan(list, name) != EOF; i=i+1) {
j = j+1 # This int stores the amount of cluster files in the folder
var[i] = name
k = strlen(name)
if (substr (name, k-3, k) == ".fit") {
name2 = substr (name, 1, 4)
print (' Name: '//name2)
}
else {
print (' Wrong image name')
bye()
}
var2[i] = name2 # This variables (var2[1], var2[2], etc.) hold the names of
} # all the star frames, without the ".fit" extension and the
# filter and time exposition information.
m=1
while (m<=j) {
k=1
while (k<=j) {
print (var2[m], >> 'tempm')
print (var2[k], >> 'tempk')
listm = "tempm"
listk = "tempk"
while (fscan (listm, namem) != EOF)
while (fscan (listk, namek) != EOF)
if (namem == namek) { # This 'while' structure separates the frames of a single cluster
print (var[k], >> 'cluster_'//var2[m]) # into a unique file for each cluster
}
del ('tempm')
del ('tempk')
k=k+1
}
m=m+1
}
files ('cluster_*', > 'clusters')
list = "clusters"
j=0
for (i=1; fscan(list, name) != EOF; i=i+1) {
j=j+1
k = strlen(name)
name2 = substr (name, k-3, k)
var[i] = name2
}
m=1
while (m<=j) {
o=1
list = ('cluster_'//var[m])
while (fscan(list, name) != EOF) {
o=o+1
}
# This 'while' cleans the otput file from the previous
o=sqrt(o) # 'while' so that the names of the frames are not repited
fields.mode = 'hl'
fields.files = ('cluster_'//var[m])
fields.fields = "1-1"
fields.lines = '1-'//o
fields >> ('cluster.'//var[m])
del ('cluster_'//var[m])
m=m+1
}
del ('frames')
# ------------------------------------------------------------------------------------
# Structure to create a single file for each cluster, containing the name of the frame
# files that correspond to the same cluster
# ------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------
# Daofind on a cluster's frame in the cluster's file
# ------------------------------------------------------------------------------------
list = "clusters"
j=0
for (i=1; fscan(list, name) != EOF; i=i+1) {
j=j+1
k = strlen(name) # This 'for' stores the unique names of each cluster
name2 = substr (name, k-3, k) # in the var[i] variables (this name is a FOUR lettered word)
var[i] = name2
m=1
while (m<=j) {
print ('')
print (var[m]//' Frames')
print ('')
list = ('cluster.'//var[m])
while (fscan(list, name) != EOF) {
print (name)
}
print ('')
print (' Input the name of the frame you want to display')
print (' and run Daofind on (whitout the .fit extension)')
print (' This will be the "reference" image')
print ('')
auxi=no
while (auxi==no) { # This 'while' checks that the input image name is right.
scan (frame)
print (frame, > 'temp')
list = "temp"
while (fscan (list, name) != EOF)
del ('temp')
q=0
x=0
list = ('cluster.'//var[m])
while (fscan(list, name2) != EOF) {
x=x+1
k = strlen(name2)
name2 = substr (name2, 1, k-7)
if (name==name2) {
q=q+0
}
else {
q=q+1
}
}
if (q==x) {
print ('')
print (' Image name does not match any name stored in the cluster.'//var[m]//' file')
print (' Input image name again')
print ('')
}
else {
auxi=yes
}
}
print (frame, > 'frame.'//var[m]) # File used by the next script: 'align2'
}
print ('')
print (' Input threshold value (a high threshold finds only the brighter stars)')
scan (thresh)
findpars.threshold = thresh
auxi = no
while (auxi == no) {
daofind.verif = no
daofind.verb = no
daofind.interactive = no
daofind ((frame), "default")
display ((frame), 1)
tvmark.interactive = no
tvmark.mark = 'point'
tvmark.font = "raster"
tvmark.color = 204
tvmark.number = no
tvmark.label = no
tvmark (1, (frame // '.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.mark = 'point'
tvmark.font = "raster"
tvmark.color = 204
tvmark.number = yes
tvmark.label = no
tvmark (1, (frame // '.coo.1'))
print ('')
print ( 'Add or delete stars with the cursor')
print ('')
print (' Perform new Daofind search with different "threshold"? (y/n)')
print ('')
scan (auxi2)
if (auxi2==no) {
auxi = yes
centerpars.calgorithm = "centroid"
phot.mode = "hl"
#phot.image = frame//'.fit'
#phot.coords = frame//'.coo.1'
#phot.output = "default"
phot.skyfile = ""
phot.centerpars = ""
phot.interactive = no
phot.radplots = no
phot.icommands = ""
phot.gcommands = ""
phot (frame//'.fit', frame//'.coo.1', "default")
del (frame//'.coo.1')
txdump.textfiles = frame//'.fit.mag.1'
txdump.fields = "XCENTER,YCENTER"
txdump.expr = 'MAG[1]!=INDEF'
txdump.headers = yes
txdump.parameters = yes
txdump.mode = "hl"
txdump > frame//'.coo.1'
del (frame//'.fit.mag.1')
}
else {
auxi = no
del (frame// '.coo.1')
print ('')
print (' Actual threshold = ' //thresh)
print (' Input new threshold value')
print ('')
print (' (A higher threshold means LESS stars)')
print ('')
scan (thresh)
findpars.threshold = thresh
}
}
m=m+1
}
# ------------------------------------------------------------------------------------
# Daofind on a cluster's frame in the cluster's file
# ------------------------------------------------------------------------------------
print (' ')
print (' ----------------------------------------------------- ')
print (' Script "align" finished correctly. ')
print (' Move on to the "align2" script ')
print ('')
print (' Remember this last script must be executed inside the package:')
print ('')
print (' images/immatch ')
print (' ----------------------------------------------------- ')
end