From 89b9cdaa4acd3b91b50025113f4ff05b71368299 Mon Sep 17 00:00:00 2001 From: xzackli Date: Sat, 16 Dec 2023 11:11:08 -0800 Subject: [PATCH] add tests for Fejer1 and CC --- src/enmap.jl | 2 +- src/projections/car_proj.jl | 21 +++++++++++++++------ test/data/cc.fits | Bin 0 -> 8640 bytes test/data/fejer1.fits | Bin 0 -> 8640 bytes test/data_gen/gen_sht_test_data.py | 11 ++++++++++- test/runtests.jl | 2 +- test/test_io.jl | 21 +++++++++++++++++++++ 7 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 test/data/cc.fits create mode 100644 test/data/fejer1.fits diff --git a/src/enmap.jl b/src/enmap.jl index e344a4d..8162ccf 100644 --- a/src/enmap.jl +++ b/src/enmap.jl @@ -217,7 +217,7 @@ function read_map(path::String; hdu::Int=1, sel=(), wcs::Union{WCSTransform,Noth @assert wcs0.ctype[1] == "RA---CAR" @assert wcs0.ctype[2] == "DEC--CAR" if isfejer1(wcs0) - wcs = convert(Fejer1{Float64}, wcs0) + wcs = convert(CarFejer1{Float64}, wcs0) elseif isclenshawcurtis(wcs0) wcs = convert(CarClenshawCurtis{Float64}, wcs0) else diff --git a/src/projections/car_proj.jl b/src/projections/car_proj.jl index d588af7..59ad825 100644 --- a/src/projections/car_proj.jl +++ b/src/projections/car_proj.jl @@ -38,20 +38,29 @@ function Base.convert(::Type{CarFejer1{T}}, w0::WCSTransform) where T end function isfejer1(w0::WCSTransform) - cdelt, crpix, crval = getcdelt(w0), getcrpix(w0), getcrval(w0) + Δα, Δδ = getcdelt(w0) + skyloc = pix2sky(ones(Int, w0.naxis), w0, ones(w0.naxis)) # get first pixel + δ = rad2deg(skyloc[2]) # reference DEC is an integer number of pixels from each pole minus half a pixel - half_from_pole = 90 - cdelt[2]/2 + half_from_pole = 90 - Δδ/2 npix1, npix2 = (half_from_pole - δ) / Δδ, (-half_from_pole - δ) / Δδ - return isapprox(δ + npix1 * Δδ, 90.0) && isapprox(δ + npix2 * Δδ, -90.0) + return isapprox(npix1, round(npix1)) && isapprox(npix2, round(npix2)) end -function isclenshawcurtis(w0::WCSTransform, tol=1e-6) - Δδ, j, δ = map(x->x[2], (getcdelt(w0), getcrpix(w0), getcrval(w0))) +function isclenshawcurtis(w0::WCSTransform) + Δα, Δδ = getcdelt(w0) + skyloc = pix2sky(ones(Int, w0.naxis), w0, ones(w0.naxis)) # get first pixel + δ = rad2deg(skyloc[2]) # reference DEC is an integer number of pixels from each pole npix1, npix2 = (90 - δ) / Δδ, (-90 - δ) / Δδ - return isapprox(δ + npix1 * Δδ, 90.0) && isapprox(δ + npix2 * Δδ, -90.0) + return isapprox(npix1, round(npix1)) && isapprox(npix2, round(npix2)) end +isclenshawcurtis(::CarClenshawCurtis) = true +isclenshawcurtis(x) = false +isfejer1(::CarFejer1) = true +isfejer1(x) = false + function Base.convert(::Type{WCSTransform}, w0::AbstractCARWCS) return WCSTransform(2; ctype = ["RA---CAR", "DEC--CAR"], diff --git a/test/data/cc.fits b/test/data/cc.fits new file mode 100644 index 0000000000000000000000000000000000000000..2ae642fae4d4f50f7be0109bb511d6985cc0a9d7 GIT binary patch literal 8640 zcmeH}e{fXQ6~`}ONfro@YO9+MSBElSTMBCBhp|;u3R*ELC=II(ib@~|s36LUpi#&V2;oQQyZ3v*jILHY{j0&feChWEeKI(Ib|89{&qoVsYC(yuQSWb@U9Wm>Rau}` z*339pxuPmiT~|?4UH5sBexFRevC-@OxlY&$6kKv1pE0FRm=-i+Hd)ME&EB<24)0m z1J&gLIlHE!I@s^_P%rBD9h-A$&VNzQlRvpM+Wn2@dcW`oX5K9GKEJ<;>hjuv{f>ju z7yR;_=IMH0cYoiu-t~nAxW8=sMzZ@q3jKMEyuP|3Sf`g?zem{b7OVZT-d8#I{5sFm z_00YKkLs09E6O*|FT0pVj~<;z#rdNt}7$s*{>J?M&s}0z%x3*?h zpgd^*TF!m3JY5g>=gH5DQqL18uhfgqp7Wn->6&@PH_+s0?^ntRX1#prec*9Ld$;H7 zMSZ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