diff --git a/src/enmap.jl b/src/enmap.jl index fac6c91..7b3fdcc 100644 --- a/src/enmap.jl +++ b/src/enmap.jl @@ -54,6 +54,20 @@ function Base.convert(::Type{CarClenshawCurtis{T}}, w0::WCSTransform) where T return CarClenshawCurtis{T}(T.(getcdelt(w0)), T.(getcrpix(w0)), T.(getcrval(w0)), getunit(T, w0)) end +# this kind of WCS only has two spatial dimensions. this check should be constant-propagated +function Base.getproperty(wcs::CarClenshawCurtis, k::Symbol) + if k == :naxis + return 2 + end + return getfield(wcs, k) +end + +function Base.show(io::IO, wcs::CarClenshawCurtis{T}) where T + expr = join(["$k=$(getproperty(wcs, Symbol(k)))" + for k in ["naxis","cdelt","crval","crpix"]], ",") + print(io, "CarClenshawCurtis{$(T)}($expr)") +end + # forward all array traits to parent. based on MetaArrays Base.size(x::Enmap) = size(parent(x)) diff --git a/test/test_io.jl b/test/test_io.jl index ab78714..a3c5505 100644 --- a/test/test_io.jl +++ b/test/test_io.jl @@ -1,16 +1,16 @@ @testset "Enmap I/O" begin - imap = read_map("data/test.fits"; trim=false) - @test size(imap) == (100, 100, 3) - @test imap.wcs.naxis == 2 - @test imap.wcs.cdelt == [-1, 1] - @test imap.wcs.crval == [0.5, 0.0] - @test sum(imap) ≈ 14967.2985 - # read with sel - imap = read_map("data/test.fits", sel=(11:20,21:40,1:2); trim=false) - @test size(imap) == (10,20,2) - imap = read_map("data/test.fits", sel=(11:20,21:40,1:2); trim=true) - @test size(imap) == (10,20,2) + for trim in (true, false) + imap = read_map("data/test.fits"; trim=trim) + @test size(imap) == (100, 100, 3) + @test imap.wcs.naxis == 2 + @test collect(imap.wcs.cdelt) == [-1, 1] + @test collect(imap.wcs.crval) == [0.5, 0.0] + @test sum(imap) ≈ 14967.2985 + # read with sel + imap = read_map("data/test.fits", sel=(11:20,21:40,1:2); trim=trim) + @test size(imap) == (10,20,2) + end # todo: add tests on IAU conversion w/ and w/o sel end