|
| 1 | +using Reproject: parse_input_data, parse_output_projection |
| 2 | +@testset "input parser" begin |
| 3 | + fname = tempname() * ".fits" |
| 4 | + f = FITS(fname, "w") |
| 5 | + inhdr = FITSHeader(["FLTKEY", "INTKEY", "BOOLKEY", "STRKEY", "COMMENT", |
| 6 | + "HISTORY"], |
| 7 | + [1.0, 1, true, "string value", nothing, nothing], |
| 8 | + ["floating point keyword", |
| 9 | + "", |
| 10 | + "boolean keyword", |
| 11 | + "string value", |
| 12 | + "this is a comment", |
| 13 | + "this is a history"]) |
| 14 | + |
| 15 | + indata = reshape(Float32[1:100;], 5, 20) |
| 16 | + write(f, indata; header=inhdr) |
| 17 | + |
| 18 | + @testset "ImageHDU type" begin |
| 19 | + result = parse_input_data(f[1]) |
| 20 | + @test result[1] isa Array |
| 21 | + @test result[2] isa WCSTransform |
| 22 | + end |
| 23 | + |
| 24 | + @testset "Single HDU FITS file" begin |
| 25 | + result = parse_input_data(f, 1) |
| 26 | + @test result[1] isa Array |
| 27 | + @test result[2] isa WCSTransform |
| 28 | + end |
| 29 | + close(f) |
| 30 | + |
| 31 | + @testset "String filename input" begin |
| 32 | + result = parse_input_data(fname, 1) |
| 33 | + @test result[1] isa Array |
| 34 | + @test result[2] isa WCSTransform |
| 35 | + end |
| 36 | + |
| 37 | + f = FITS(fname, "w") |
| 38 | + write(f, indata; header=inhdr) |
| 39 | + write(f, indata; header=inhdr) |
| 40 | + |
| 41 | + @testset "Multiple HDU FITS file" begin |
| 42 | + result = parse_input_data(f, 2) |
| 43 | + @test result[1] isa Array |
| 44 | + @test result[2] isa WCSTransform |
| 45 | + |
| 46 | + close(f) |
| 47 | + result = parse_input_data(fname, 1) |
| 48 | + @test result[1] isa Array |
| 49 | + @test result[2] isa WCSTransform |
| 50 | + end |
| 51 | +end |
| 52 | + |
| 53 | +@testset "output parser" begin |
| 54 | + fname = tempname() * ".fits" |
| 55 | + f = FITS(fname, "w") |
| 56 | + inhdr = FITSHeader(["FLTKEY", "INTKEY", "BOOLKEY", "STRKEY", "COMMENT", |
| 57 | + "HISTORY"], |
| 58 | + [1.0, 1, true, "string value", nothing, nothing], |
| 59 | + ["floating point keyword", |
| 60 | + "", |
| 61 | + "boolean keyword", |
| 62 | + "string value", |
| 63 | + "this is a comment", |
| 64 | + "this is a history"]) |
| 65 | + |
| 66 | + indata = reshape(Float32[1:100;], 5, 20) |
| 67 | + write(f, indata; header=inhdr) |
| 68 | + |
| 69 | + @testset "ImageHDU type" begin |
| 70 | + result = parse_output_projection(f[1], (12,12)) |
| 71 | + @test result[1] isa WCSTransform |
| 72 | + @test result[2] isa Tuple |
| 73 | + @test_throws DomainError parse_output_projection(f[1], ()) |
| 74 | + end |
| 75 | + close(f) |
| 76 | + |
| 77 | + @testset "String filename" begin |
| 78 | + result = parse_output_projection(fname, 1) |
| 79 | + @test result[1] isa WCSTransform |
| 80 | + @test result[2] isa Tuple |
| 81 | + end |
| 82 | + |
| 83 | + wcs = WCSTransform(2; |
| 84 | + cdelt = [-0.066667, 0.066667], |
| 85 | + ctype = ["RA---AIR", "DEC--AIR"], |
| 86 | + crpix = [-234.75, 8.3393], |
| 87 | + crval = [0., -90], |
| 88 | + pv = [(2, 1, 45.0)]) |
| 89 | + |
| 90 | + @testset "WCSTransform input" begin |
| 91 | + result = parse_output_projection(wcs, (12,12)) |
| 92 | + @test result[1] isa WCSTransform |
| 93 | + @test result[2] isa Tuple |
| 94 | + @test_throws DomainError parse_output_projection(wcs, ()) |
| 95 | + end |
| 96 | +end |
| 97 | + |
0 commit comments