-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathquality_tag.class
executable file
·431 lines (407 loc) · 13.1 KB
/
quality_tag.class
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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
!! -- Written by Zhi-Yu Zhang : pmozhang@gmail.com
!! Aim: qualify CLASS spectra by hand, from level 9 to level 1
!! Allan factor is how much the spectra follows the Allan deviation when smoothing
!! Rrms factor is the ratio between measured noise and the theoretical noise calculated using Tsys
!! --usage: @quality_tag xxxx
!! xxxx is the file name. e.g., test1234.apex or FTS108e.30m
!! Here all spectra are from the aimed target and the aimed spectra
!! i.e., without calibrator spectra. find all spectra; see line 54
!! 1). set two pairs of windows first
!! for weak lines, you can set them to be all 0
!! 2). tag the line qualities from 9 (lowest) to 1 (highest)
!! 3). loop to the end of the spectral list, tag all spectra
!! 4). After tagging, load the file by
!! file in xxxx.tagqua
!! find ! you can not find spectra with quality 9
!! find /quality 3 ! (all spectra better/equal than 3)
!! find /quality 9 ! (all spectra better/equal than 9)
!! to-do: set mod x range ?
!! an automated version?
!! integrate with spectral analysis tools?
set align v c
clear
!--------------- definition -----------
define character inFileName*128
define integer qua
define real out[20] err[20] winmin1 winmax1 winmin2 winmax2 sigma1 sigma2
! -------------------------------------
set weight equal
set align velocity intersect
set bad and
set scan * *
set telescope *
set source *
set range * * * *
set offset * *
set line *
set number * *
set nomatch
set var gau wri
set plot h
set for l
on error next
!------sub-procedure showing the obs/theoretical ratio of the noise
begin procedure rms
analyse\draw text 20 14 "Rrms(Tsys): "
analyse\draw text 23.5 14 'nint(sigma/(Tsys*1.4/sqrt(abs(freq_step*1e6*time)))*100)/100'
analyse\draw window
end procedure rms
!----------------------------------------------------
let inFileName &1
file in 'inFileName'
sic copy 'inFileName' 'inFileName'.tagqua
sic wait 1
file both 'inFileName'.tagqua
find
list
if found.GT.1 then
ave /res
pl !-- plot averaged spectra for setting windows
say "Setting windows, please input parameters "
say "Please input two windows one by one in sequence. "
say "Please input window No.1"
let winmin1 &2
let winmax1 &3
say "please input window No.2"
let winmin2 &4
let winmax2 &5
set win winmin1 winmax1 winmin2 winmax2 /no
get f
pl
bas
base /pl
@rms
let sigma1 'sigma'
sm
sm
sm
sm
bas
let sigma2 'sigma'
analyse\draw text 20 13 "R_Allan "
analyse\draw text 23 13 'nint(sigma2/sigma1*100)/100*4'
get
for /while 1.EQ.1
say " "
say " =================================================="
say " Press 1-9 to set quality then press K to confirm "
say " n -> next; p-> previous; q-> quit; s -> smooth "
say " =================================================="
say " "
pen /col 0
!---------------------------------------------------------
! plotting the GUI buttons
!---------------------------------------------------------
greg\set box 2.1 3.9 0 2
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1
g\draw tex 1 1 1 /box 0
!------------------
greg\set box 4.1 5.9 0 2
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1
g\draw tex 1 1 2 /box 0
!------------------
greg\set box 6.1 7.9 0 2
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1
g\draw tex 1 1 3 /box 0
!------------------
greg\set box 8.1 9.9 0 2
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1
g\draw tex 1 1 4 /box 0
!------------------
greg\set box 10.1 11.9 0 2
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1
g\draw tex 1 1 5 /box 0
!------------------
greg\set box 12.1 13.9 0 2
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1
g\draw tex 1 1 6 /box 0
!------------------
greg\set box 14.1 15.9 0 2
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1
g\draw tex 1 1 7 /box 0
!------------------
greg\set box 16.1 17.9 0 2
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1
g\draw tex 1 1 8 /box 0
!------------------
greg\set box 18.1 19.9 0 2
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1
g\draw tex 1 1 9 /box 0
!------------------
greg\set box 20.1 21.9 0 2
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1
g\draw tex 1 1 next /box 0
!------------------
greg\set box 22.1 23.9 0 2
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1
g\draw tex 1 1 pre /box 0
!------------------
greg\set box 24.1 25.9 0 2
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1
g\draw tex 1 1 FFT /box 0
!------------------
greg\set box 20 26 15 17
g\box n n n /fill 20
pen /wei 2 /col 0
set char 2
g\draw tex 3 1 QUIT /box 0
set char 0.6
!------------------
greg\set box 10 16 15 17
g\box n n n /fill 20
pen /wei 2 /col 0
set char 2
g\draw tex 3 1 OK /box 0
set char 0.6
!------------------
pen /def
greg\set box 6 9 15 17
g\box n n n /fill 20
pen /wei 2 /col 0
set char 1.8
g\draw tex 1.2 1 SM /box 0
set char 0.6
!------------------
pen /def
greg1\draw relocate
!---------------------------------------------------------
!---------------------------------------------------------
! tag quality
!---------------------------------------------------------
if (abs(phy_curs[1]-3).LT.1.AND.abs(phy_curs[2]-1).LT.1).OR.(cursor_code.eq."1") then
tag 1
let qua 1
set box d
pl
base /pl
set char 4
g\draw tex 1.5 11.5 "1"
set char 0.6
exam quality
@rms
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (abs(phy_curs[1]-5).LT.1.AND.abs(phy_curs[2]-1).LT.1).OR.(cursor_code.eq."2") then
tag 2
let qua 2
exam quality
set box d
pl
base /pl
set char 4
g\draw tex 1.5 11.5 "2"
set char 0.6
@rms
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (abs(phy_curs[1]-7).LT.1.AND.abs(phy_curs[2]-1).LT.1).OR.(cursor_code.eq."3") then
tag 3
let qua 3
exam quality
set box d
pl
base /pl
set char 4
g\draw tex 1.5 11.5 "3"
set char 0.6
@rms
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (abs(phy_curs[1]-9).LT.1.AND.abs(phy_curs[2]-1).LT.1).OR.(cursor_code.eq."4") then
tag 4
let qua 4
exam quality
set box d
pl
base /pl
set char 4
g\draw tex 1.5 11.5 "4"
set char 0.6
@rms
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (abs(phy_curs[1]-11).LT.1.AND.abs(phy_curs[2]-1).LT.1).OR.(cursor_code.eq."5") then
tag 5
let qua 5
exam quality
set box d
pl
base /pl
set char 4
g\draw tex 1.5 11.5 "5"
set char 0.6
@rms
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (abs(phy_curs[1]-13).LT.1.AND.abs(phy_curs[2]-1).LT.1).OR.(cursor_code.eq."6") then
tag 6
let qua 6
exam quality
set box d
pl
base /pl
set char 4
g\draw tex 1.5 11.5 "6"
set char 0.6
@rms
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (abs(phy_curs[1]-15).LT.1.AND.abs(phy_curs[2]-1).LT.1).OR.(cursor_code.eq."7") then
tag 7
let qua 7
exam quality
set box d
pl
base /pl
set char 4
g\draw tex 1.5 11.5 "7"
set char 0.6
@rms
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (abs(phy_curs[1]-17).LT.1.AND.abs(phy_curs[2]-1).LT.1).OR.(cursor_code.eq."8") then
tag 8
let qua 8
exam quality
set box d
pl
base /pl
set char 4
g\draw tex 1.5 11.5 "8"
set char 0.6
@rms
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (abs(phy_curs[1]-19).LT.1.AND.abs(phy_curs[2]-1).LT.1).OR.(cursor_code.eq."9") then
tag 9
let qua 9
exam quality
set box d
pl
base /pl
set char 4
g\draw tex 1.5 11.5 "9"
set char 0.6
@rms
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!get n
if (abs(phy_curs[1]-21).LT.1.AND.abs(phy_curs[2]-1).LT.1).OR.(cursor_code.eq."N") then
get n
set box d
base
pl
base /pl
@rms
bas
let sigma1 'sigma'
sm
sm
sm
sm
bas
let sigma2 'sigma'
analyse\draw text 20 13 "Allan "
analyse\draw text 23 13 'nint(sigma2/sigma1*100)/100*4'
get
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!get p
if (abs(phy_curs[1]-23).LT.1.AND.abs(phy_curs[2]-1).LT.1).OR.(cursor_code.eq."P") then
get p
set box d
base
pl
base /pl
@rms
bas
let sigma1 'sigma'
sm
sm
sm
sm
bas
let sigma2 'sigma'
analyse\draw text 20 13 "Allan "
analyse\draw text 23 13 'nint(sigma2/sigma1*100)/100*4'
get
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!FFT
if abs(phy_curs[1]-25).LT.1.AND.abs(phy_curs[2]-1).LT.1 then
set box d
base
fft
analyse\draw text 20 13 "Allan "
analyse\draw text 23 13 'nint(sigma2/sigma1*100)/100*4'
draw
pause
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (abs(phy_curs[1]-13).LT.3.AND.abs(phy_curs[2]-16).LT.1).OR.(cursor_code.eq."K") then
get
tag qua
write
get next
set box d
base
pl
base /pl
@rms
bas
let sigma1 'sigma'
sm
sm
sm
sm
bas
let sigma2 'sigma'
analyse\draw text 20 13 "Allan "
analyse\draw text 23 13 'nint(sigma2/sigma1*100)/100*4'
get
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (abs(phy_curs[1]-23).LT.3.AND.abs(phy_curs[2]-16).LT.1).OR.(cursor_code.eq."Q") then
break
base
set box d
pl
base /pl
@rms
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!SMOOTHING
if (abs(phy_curs[1]-7.5).LT.3.AND.abs(phy_curs[2]-16).LT.1).OR.(cursor_code.eq."S") then
sm
set box d
pl
base /pl
@rms
analyse\draw text 20 13 "Allan "
analyse\draw text 23 13 'nint(sigma2/sigma1*100)/100*4'
endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
next
set box d
endif