-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmacrol.cl
executable file
·251 lines (172 loc) · 7.03 KB
/
macrol.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
#
# Ver. Mar05
#
procedure macrol
string file_in {prompt="pccd output file (.log) or list(@*)"}
string file_out {prompt="output file (.out)"}
string minimun="first" {enum="first|full", prompt="minimum? (first,full)"}
struct *flist,*flistvar
begin
int nl = 0
int ml = 0
int gl = 0
int tl = 0
real naper = 0
int nstar = 0
int stars = 0
real positions = 0
real apertures = 0
int nnstar = 0
real qq = 0
real uu = 0
real ss = 0
real pp = 0
real tt = 0
real st = 0
real vv = 0
real svv = 0
real sfull = 0
real ssconst = 100
real qqq = 0
real uuu = 0
real sss
real ppp = 0
real ttt = 0
real stt = 0
real aperval = 0
real aperok = 0
real qq1, uu1, ss1, pp1, tt1, st1
real nhw_used = 0
bool primin
int nfile
string outfile, lix, cadena, filein_list, vtmpfile, namev
string waveplate, tmp
struct line, line10, line12, line14, line26, linedata, lineaper
struct line11, line13
sss = ssconst
lineaper = " 0. 0. 0. 0. 0. 0. "
filein_list = file_in
# Create list of input files in a temporary file
vtmpfile = mktemp ("tmp$tmpvar")
files (filein_list, > vtmpfile)
flistvar = vtmpfile
#Elimina arquivo de saida se existe, no diretorio local
delete(file_out//".out",ver-)
# Define nome do archivo de saida (.out), no diretorio tmp$
tmp = envget("tmp")
outfile = tmp // file_out // ".out"
if (access(outfile)) delete(outfile, ver-)
# Imprime cabecario no archivo de saida
# print (" Q U SIGMA P THETA SIGMAtheor. APERTURE STAR", >> outfile)
nfile = 0
# Fazendo o "do" nos arquivos da lista de entrada
while (fscan(flistvar, namev) != EOF) {
nfile = nfile + 1
# Inicializa o puntero de lectura 'flist' ao archivo (.log)
flist = namev
print("File : ",namev)
nl = 0
nstar = 0
waveplate = "half"
# Comeca letura do archivo (.log) com 'flist'
while (fscan (flist, line) != EOF) {
# Conta o numero de linha
nl = nl + 1
# Pega os dados da linha nl
if ((waveplate == "quarter") || (waveplate == "other") || (waveplate == "v0other"))
linedata = fscan (line, vv, svv, qq, uu, ss, pp, tt, st, sfull)
else
linedata = fscan (line, qq, uu, ss, pp, tt, st)
# Elimina do calculo as linhas con dados espureos
#cadena = substr (line,1,4)
#if (cadena == " NaN" )
if ( (stridx(line,"nan") != 0) || (stridx(line,"NaN") != 0))
ss = ssconst
# lee o numero de estrelas do arquivo de entrada (.log)
if (nl == 10)
line10 = fscan (line, lix, lix, lix, lix, stars)
#lee o tipo de lamina retardadora usada
if (nl == 11)
line11 = fscan(line,lix,lix,lix,waveplate)
# lee o numero de posicoes do arquivo de entrada (.log)
if (nl == 12)
line12 = fscan (line, lix, lix, lix, lix, lix, positions)
# read the position number used from pccdgen output
if (nl == 13) {
line13 = fscan(line,lix,lix,lix,lix,lix,lix,lix,lix,lix,lix,lix,lix,lix,lix,lix,lix,lix,lix,lix,lix,nhw_used)
if (nhw_used != 0) {
if (mod(nhw_used,4) !=0) positions = int(nhw_used/4)*4 + 4
else positions = int(nhw_used/4)*4
}
}
# lee o numero de aperturas do arquivo de entrada (.log)
if (nl == 14)
line14 = fscan (line, lix, lix, lix, lix, apertures)
# lee tamanho da apertura
if (substr(line,1,9) == " APERTURE")
line26 = fscan (line, lix, lix, aperval)
if (substr(line,1,5) == " STAR")
primin = no
# Verifica letura ate o numero massimo de estrelas
if (stars > nstar) {
if (frac(positions / 4) == 0)
gl = 6 + (positions / 4)
else
gl = 7 + int(positions / 4)
ml = 1 + (apertures * gl)
tl = 28 + (nstar * ml) + (naper * gl)
# Verfica letura ate o numero massimo de aperturas
if (apertures > naper) {
# Verifica sim o numero de linha contem os dados Q, U, ,,,
# e evalua cada apertura para a estrela nstar
if (nl == tl) {
naper = naper + 1
nnstar = nstar + 1
print ("Evaluating...star ", nnstar, " of ", stars, ", aperture ", naper, " of ", apertures)
if (minimun == "first") {
if (ss > sss)
primin = yes
}
# Verifica se o SIGMA e' minimo
if (ss < sss && primin == no) {
lineaper = line
qqq = qq
uuu = uu
sss = ss
ppp = pp
ttt = tt
stt = st
aperok = aperval
}
# Verifica se termino evaluacao de aperturas para a estrela nstar
if (naper == apertures) {
# Imprime apertura dados de apertura com menor SIGMA
if ((waveplate == "quarter") || (waveplate == "other") || (waveplate == "v0other")) {
if (nstar == 0 && nfile == 1) print (" V SIGMAV Q U SIGMA P THETA SIGMAth. rms APER. STAR", >>outfile)
print (lineaper, " ", aperok, " ", nnstar,>> outfile)
}
else {
if (nstar == 0 && nfile == 1) print (" Q U SIGMA P THETA SIGMAtheor. APERTURE STAR", >> outfile)
print (lineaper, " ", aperok, " ", nnstar,>> outfile)
}
# Atualiza variaveis para prossima letura
nstar = nstar + 1
qqq = 0
uuu = 0
sss = ssconst
ppp = 0
ttt = 0
stt = 0
naper = 0
lineaper = " 0. 0. 0. 0. 0. 0. "
}
}
}
}
}
}
movefiles(outfile,".")
delete(vtmpfile, ver-)
flistvar=""
flist=""
end