Skip to content

Commit aebe7a2

Browse files
committed
wcs_to_celestial_frame added
1 parent 06254c7 commit aebe7a2

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

src/Reproject.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ module Reproject
33
using FITSIO, WCS
44

55
include("parsers.jl")
6+
include("utils.jl")
67

78
end # module

src/utils.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const UNDEFINED = 987654321.0e99 # from WCS.jl
2+
3+
"""
4+
wcs_to_celestial_frame(wcs::WCSTransform)
5+
6+
Returns the reference frame of a WCSTransform.
7+
The reference frame supported in Julia are FK5, ICRS and Galactic.
8+
"""
9+
function wcs_to_celestial_frame(wcs::WCSTransform)
10+
radesys = wcs.radesys
11+
12+
if wcs.equinox != UNDEFINED
13+
equinox = wcs.equinox
14+
else
15+
equinox = nothing
16+
end
17+
18+
xcoord = wcs.ctype[1][1:4]
19+
ycoord = wcs.ctype[2][1:4]
20+
21+
if radesys == ""
22+
if xcoord == "RA--" && ycoord == "DEC-"
23+
if equinox === nothing
24+
radesys = "ICRS"
25+
elseif equinox < 1984.0
26+
radesys = "FK4"
27+
else
28+
radesys = "FK5"
29+
end
30+
elseif xcoord == "GLON" && ycoord == "GLAT"
31+
radesys = "Gal"
32+
elseif xcoord == "TLON" && ycoord == "TLAT"
33+
radesys = "ITRS"
34+
end
35+
end
36+
37+
return radesys
38+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ rp = pyimport("reproject")
1010

1111
@testset "Reproject.jl" begin
1212
include("parsers.jl")
13+
include("utils.jl")
1314
end

test/utils.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@testset "wcs to celestial frame" begin
2+
wcs1 = WCSTransform(2;
3+
ctype = ["RA---AIR", "DEC--AIR"],
4+
)
5+
wcs2 = WCSTransform(2;
6+
ctype = ["RA---AIR", "DEC--AIR"],
7+
equinox = 1888.67
8+
)
9+
wcs3 = WCSTransform(2;
10+
ctype = ["RA---AIR", "DEC--AIR"],
11+
equinox = 2000
12+
)
13+
wcs4 = WCSTransform(2;
14+
ctype = ["GLON--", "GLAT--"],
15+
)
16+
wcs5 = WCSTransform(2;
17+
ctype = ["TLON", "TLAT"],
18+
)
19+
wcs6 = WCSTransform(2;
20+
ctype = ["RA---AIR", "DEC--AIR"],
21+
radesys = "UNK"
22+
)
23+
24+
@test wcs_to_celestial_frame(wcs1) == "ICRS"
25+
@test wcs_to_celestial_frame(wcs2) == "FK4"
26+
@test wcs_to_celestial_frame(wcs3) == "FK5"
27+
@test wcs_to_celestial_frame(wcs4) == "Gal"
28+
@test wcs_to_celestial_frame(wcs5) == "ITRS"
29+
@test wcs_to_celestial_frame(wcs6) == "UNK"
30+
end
31+

0 commit comments

Comments
 (0)