1
+ """
2
+ Parse input data and returns an Array and WCS object.
3
+ """
4
+ function parse_input_data (input_data:: ImageHDU )
5
+ return read (input_data), WCS. from_header (read_header (input_data, String))[1 ]
6
+ end
7
+
8
+ function parse_input_data (input_data:: String , hdu_in = nothing )
9
+ return parse_input_data (FITS (input_data), hdu_in = hdu_in)
10
+ end
11
+
12
+ function parse_input_data (input_data:: FITS , hdu_in = nothing )
13
+ if hdu_in == nothing
14
+ if length (input_data) > 1
15
+ throw (ArgumentError (" More than one HDU is present, please specify HDU to use with ``hdu_in=`` option" ))
16
+ else
17
+ hdu_in = 1
18
+ end
19
+ end
20
+ return parse_input_data (input_data[hdu_in])
21
+ end
22
+
23
+ function parse_input_data (input_data, hdu_in = nothing )
24
+ throw (TypeError (input_data, " should be in " , Union{String, FITS, ImageHDU, Tuple{ImageHDU,FITSHeader}}))
25
+ end
26
+
27
+ # TODO : extend support for passing FITSHeader when FITSHeader to WCSTransform support is possible.
28
+
29
+
30
+ """
31
+ Parse output projection and returns a WCS object and Shape of output
32
+ """
33
+ function parse_output_projection (output_projection:: WCSTransform , shape_out = nothing )
34
+ wcs_out = output_projection
35
+ if shape_out isa nothing
36
+ throw (ArgumentError (" Need to specify shape when specifying output_projection as WCS object" ))
37
+ elseif length (shape_out) == 0
38
+ throw (DomainError (shape_out, " The shape of the output image should not be an empty tuple" ))
39
+ end
40
+
41
+ return wcs_out, shape_out
42
+ end
43
+
44
+ function parse_output_projection (output_projection:: ImageHDU , shape_out = nothing )
45
+ wcs_out = WCS. from_header (read_header (output_projection))[1 ]
46
+ if shape_out == nothing
47
+ shape_out = size (output_projection)
48
+ end
49
+ if length (shape_out) == 0
50
+ throw (DomainError (shape_out, " The shape of the output image should not be an empty tuple" ))
51
+ end
52
+ return wcs_out, shape_out
53
+ end
54
+
55
+ function parse_output_projection (output_projection:: String , hdu_number = nothing )
56
+ hdu_list = FITS (output_projection)
57
+ if hdu_number == nothing
58
+ wcs_out = WCS. from_header (read_header (hdu_list[1 ], String))
59
+ else
60
+ wcs_out = WCS. from_header (read_header (hdu_list[hdu_number], String))
61
+ end
62
+
63
+ try
64
+ shape_out = size (output_projection)
65
+ catch
66
+ throw (ArgumentError (" Given FITS file doesn't have ImageHDU" ))
67
+ end
68
+
69
+ return wcs_out, shape_out
70
+ end
71
+
72
+ function parse_output_projection (output_projection, shape_out = nothing )
73
+ throw (TypeError (output_projection, " should be in " , Union{String, WCSTransform, FITSHeader}))
74
+ end
0 commit comments