Skip to content

Commit 40d1358

Browse files
aquatikogiordano
authored andcommitted
data matrix and WCSTransform tuple type parser (#7)
1 parent 4dfde45 commit 40d1358

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/core.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Reprojects image data to a new projection using interpolation.
55
66
# Arguments
77
- `input_data`: Image data which is being reprojected.
8-
It can be an ImageHDU, FITS object or name of a FITS file.
8+
It can be an ImageHDU, FITS object, name of a FITS file or a tuple of image matrix and WCSTransform.
99
- `output_projection`: Frame in which data is reprojected.
1010
Frame can be taken from WCSTransform object, ImageHDU, FITS or name of FITS file.
1111
- `shape_out`: Shape of image after reprojection.
@@ -17,7 +17,7 @@ Reprojects image data to a new projection using interpolation.
1717
- `hud_out:` Used to specify HDU number when giving output projection as FITS or name of FITS file.
1818
"""
1919
function reproject(input_data, output_projection; shape_out = nothing, order::Int = 1, hdu_in::Int = 1, hdu_out::Int = 1)
20-
if input_data isa ImageHDU
20+
if input_data isa ImageHDU || input_data isa Tuple{AbstractArray, WCSTransform}
2121
array_in, wcs_out = parse_input_data(input_data)
2222
else
2323
array_in, wcs_out = parse_input_data(input_data, hdu_in)

src/parsers.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""
22
parse_input_data(input_data::ImageHDU)
3+
parse_input_data(input_data::Tuple{AbstractArray, WCSTransform})
34
parse_input_data(input_data::String, hdu_in)
45
parse_input_data(input_data::FITS, hdu_in)
56
@@ -14,6 +15,10 @@ function parse_input_data(input_data::ImageHDU)
1415
return read(input_data), WCS.from_header(read_header(input_data, String))[1]
1516
end
1617

18+
function parse_input_data(input_data::Tuple{AbstractArray, WCSTransform})
19+
return input_data[1], input_data[2]
20+
end
21+
1722
function parse_input_data(input_data::String, hdu_in)
1823
return parse_input_data(FITS(input_data), hdu_in)
1924
end

test/parsers.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ using Reproject: parse_input_data, parse_output_projection
2121
@test result[2] isa WCSTransform
2222
end
2323

24+
@testset "data matrix and WCSTransform tuple" begin
25+
wcs = WCSTransform(2;
26+
cdelt = [-0.066667, 0.066667],
27+
ctype = ["RA---AIR", "DEC--AIR"],
28+
crpix = [-234.75, 8.3393],
29+
crval = [0., -90],
30+
pv = [(2, 1, 45.0)])
31+
result = parse_input_data((indata, wcs))
32+
@test result[1] isa Array
33+
@test result[2] isa WCSTransform
34+
end
35+
2436
@testset "Single HDU FITS file" begin
2537
result = parse_input_data(f, 1)
2638
@test result[1] isa Array

0 commit comments

Comments
 (0)