-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_subtile_radec.pro
61 lines (38 loc) · 1.34 KB
/
get_subtile_radec.pro
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
; extract subtile ra and dec from one line of Zooniverse
; classification CSV output
function get_subtile_radec, line
pos = strpos(line, 'subtile center')
if (pos EQ -1) then return, -1 ; sometimes this happens ...
;print, pos
pos_equ_sign_ra = strpos(line, '=', pos)
pos_dec = strpos(line, 'dec', pos)
ra_string = strmid(line, pos_equ_sign_ra + 1, pos_dec-pos_equ_sign_ra-1)
ra_string = strtrim(ra_string, 2) ; get rid of any whitespace
pos_equ_sign_dec = strpos(line, '=', pos_dec)
pos_quote_end_dec = strpos(line, '"', pos_equ_sign_dec)
; print, ra_string
dec_string = $
strmid(line, pos_equ_sign_dec+1, pos_quote_end_dec-pos_equ_sign_dec-1)
dec_string = strtrim(dec_string, 2)
outstr = {ra : double(ra_string), dec: double(dec_string)}
return, outstr
end
pro _test_subtile_center
lines = djs_readlines('line.txt')
line = lines[0]
outstr = get_subtile_radec(line)
help, outstr,/st
end
pro _test_many_subtile_center, outstr
lines = djs_readlines('lines.txt')
outstr = replicate({ra: 0.0d, dec: 0.0d}, n_elements(lines))
ct = 0L
for i=0L, n_elements(lines)-1 do begin
str = get_subtile_radec(lines[i])
if (i MOD 500) EQ 0 then print, i, ' ', size(str, /type)
if (size(str, /type) NE 8) then continue
outstr[ct] = str
ct += 1
endfor
outstr = outstr[0:(ct-1)]
end