Skip to content

Commit 12a90b7

Browse files
authored
Merge pull request #1 from aquatiko/axisType
Function wcs_to_celestial_frame
2 parents 06254c7 + 932d0d7 commit 12a90b7

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
wcs_to_celestial_frame(wcs::WCSTransform)
3+
4+
Returns the reference frame of a WCSTransform.
5+
The reference frame supported in Julia are FK5, ICRS and Galactic.
6+
"""
7+
function wcs_to_celestial_frame(wcs::WCSTransform)
8+
radesys = wcs.radesys
9+
10+
xcoord = wcs.ctype[1][1:4]
11+
ycoord = wcs.ctype[2][1:4]
12+
13+
if radesys == ""
14+
if xcoord == "GLON" && ycoord == "GLAT"
15+
radesys = "Gal"
16+
elseif xcoord == "TLON" && ycoord == "TLAT"
17+
radesys = "ITRS"
18+
end
19+
end
20+
21+
return radesys
22+
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+
using Reproject: wcs_to_celestial_frame
2+
@testset "wcs to celestial frame" begin
3+
wcs1 = WCSTransform(2;
4+
ctype = ["RA---AIR", "DEC--AIR"],
5+
)
6+
wcs2 = WCSTransform(2;
7+
ctype = ["RA---AIR", "DEC--AIR"],
8+
equinox = 1888.67
9+
)
10+
wcs3 = WCSTransform(2;
11+
ctype = ["RA---AIR", "DEC--AIR"],
12+
equinox = 2000
13+
)
14+
wcs4 = WCSTransform(2;
15+
ctype = ["GLON--", "GLAT--"],
16+
)
17+
wcs5 = WCSTransform(2;
18+
ctype = ["TLON", "TLAT"],
19+
)
20+
wcs6 = WCSTransform(2;
21+
ctype = ["RA---AIR", "DEC--AIR"],
22+
radesys = "UNK"
23+
)
24+
25+
@test wcs_to_celestial_frame(wcs1) == "ICRS"
26+
@test wcs_to_celestial_frame(wcs2) == "FK4"
27+
@test wcs_to_celestial_frame(wcs3) == "FK5"
28+
@test wcs_to_celestial_frame(wcs4) == "Gal"
29+
@test wcs_to_celestial_frame(wcs5) == "ITRS"
30+
@test wcs_to_celestial_frame(wcs6) == "UNK"
31+
end

0 commit comments

Comments
 (0)