-
Notifications
You must be signed in to change notification settings - Fork 0
/
align2.cl
263 lines (219 loc) · 8.54 KB
/
align2.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
################################################################################
#
# ===========================================================
# PROCEDURE TO PERFORM IMALIGN (2)
# ===========================================================
#
# To run properly this procedure must be executed inside the package:
# 'images.immatch'
#
# by Gabriel Perren 2009
#
################################################################################
procedure align2 ()
struct *list {mode="h"}
struct *list2 {mode="h"}
struct *list3 {mode="h"}
struct *list4 {mode="h"}
begin
int i, j, k, m, q, n
struct name, name, line
string var[50]
bool check, auxi
real boxsize, bigbox, niterate, tolerance, gain, rdnoise
# ------------------------------------------------------------------------------------
# Control 0
# ------------------------------------------------------------------------------------
print ('')
print (' This script must be loaded inside the package images/immatch')
print (' Is this package loaded? (y/n)')
check=no
scan (check)
if (check) {
}
else {
bye()
}
# ------------------------------------------------------------------------------------
# Control 0
# ------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------
# Check the existence of the file 'gain_rdnoise' previously created by the
# "casleored" script. If such file does not exist, input the values and
# the file will be created.
#
files ('*gain_rdnoise', > 'temp.grd')
list3 = 'temp.grd'
n=0
while (fscan (list3,line) != EOF) {
n = n + 1
}
if (n == 0) {
print ('')
print (' No "gain_rdnoise" file.')
print ('')
print (' Input GAIN value')
scan (gain)
print (' Input RDNOISE value')
scan (rdnoise)
print ('')
print (gain,rdnoise, > "gain_rdnoise") # This file will be used by the 'casleopsf' script later on
}
else { # The file exists, then do nothing.
}
del ('temp.grd')
# ------------------------------------------------------------------------------------
mkdir ('standard') # In this folder the standard stars sets will be stored later on
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) {
print (var[m], >> 'cluster_folders') # This file will be used by 'casleored2' script.
list = ('cluster.'//var[m])
while (fscan(list, name) != EOF) {
k = strlen(name)
name = substr (name, 1, k-3)
print ((name//'.out'), >> ('cluster.'//var[m]//'.out'))
}
m=m+1
}
mv ('cluster_folders', 'standard/')
m=1
while (m<=j) {
print ('')
print (' Input parameter values:')
print ('')
boxsize = 11
print (' Actual boxsize value = '//boxsize//' Input new value:')
scan (boxsize)
bigbox = 51
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)
auxi=no
while (auxi==no) {
print ('')
print (var[m]//' Frames')
print ('')
list = ('cluster.'//var[m])
while (fscan(list, name) != EOF) {
print (name)
}
list = ('frame.'//var[m])
while (fscan(list, name) != EOF) {
print (name)
}
print ('')
imalign.input = ('@cluster.'//var[m])
imalign.reference = (name//'.fit')
imalign.coords = (name//'.coo.1')
imalign.output = ('@cluster.'//var[m]//'.out')
imalign.boxsize = boxsize
imalign.bigbox = bigbox
imalign.negative = no
imalign.niterate = niterate
imalign.tolerance = tolerance
imalign.maxshift = INDEF
imalign.shiftimages = yes
imalign.interp_type = "linear"
imalign.boundary_typ = "nearest"
imalign.trimimages = yes
imalign.verbose = yes
imalign.mode = "hl"
imalign
print ('')
print (' Displaying shifted images')
print ('')
q=1
list = ('cluster.'//var[m]//'.out')
while (fscan(list, name) != EOF) {
display (name, q)
q=q+1
}
print ('')
print (' Were the images shifted correctly (else input new parameters and re-do)? (y/n)')
check=yes
scan (check)
if (check) {
auxi=yes
del ('cluster.'//var[m])
del ('frame.'//var[m])
del (var[m]//'*.coo.1')
print ('')
print (' Is this a standard star set: '//var[m]//' ? (y/n)')
scan (check)
if (check) {
list2 = ('cluster.'//var[m]//'.out')
while (fscan(list2, name2) != EOF) {
k = strlen(name2)
name2 = substr (name2, 1, k-4)
del (name2) # Delete original image frame
rename.mode = "hl"
rename.field = "all"
rename.mode = "hl"
rename (name2//'.out.fits', name2) # Rename .out images to original names
mv (name2, 'standard/') # Move out shifted images
}
del ('cluster.'//var[m]//'.out')
}
else {
mkdir (var[m])
list2 = ('cluster.'//var[m]//'.out')
while (fscan(list2, name2) != EOF) {
k = strlen(name2)
name2 = substr (name2, 1, k-4)
del (name2) # Delete original image frame
rename.mode = "hl"
rename.field = "all"
rename.mode = "hl"
rename (name2//'.out.fits', name2) # Rename .out images to original names
mv (name2, (var[m]//'/')) # Move out shifted images
cp ('gain_rdnoise', (var[m]//'/'))
}
del ('cluster.'//var[m]//'.out')
}
}
else {
auxi=no
list = ('cluster.'//var[m]//'.out')
while (fscan(list, name) != EOF) {
del (name//'.fits')
}
print ('')
print (' Input new parameter values:')
print ('')
print (' Actual boxsize value = '//boxsize//' Input new value:')
scan (boxsize)
print (' Actual bigbox value = '//bigbox//' Input new value:')
scan (bigbox)
print (' Actual niterate value = '//niterate//' Input new value:')
scan (niterate)
print (' Actual tolerance value = '//tolerance//' Input new value:')
scan (tolerance)
}
}
m=m+1
}
del ('clusters')
del ('gain_rdnoise')
print (' ')
print (' ----------------------------------------------------- ')
print (' Script "align2" finished correctly. ')
print (' Move on to the "casleored2" script ')
print ('')
print (' Remember this last script must be executed inside the package:')
print ('')
print (' noao/digiphot/daophot ')
print (' ----------------------------------------------------- ')
end