@@ -15,42 +15,43 @@ function xy_to_θϕ((x,y))
1515 θ, ϕ
1616end
1717
18- function healpix_to_flat (healpix_map:: Vector{T} , proj:: ProjLambert{T} ; rot = ( 0 , 0 ,0 )) where {T}
18+ function healpix_to_flat (healpix_map:: Vector{T} , proj:: ProjLambert{T} ; rots = [(( 0 , 90 ,0 ),)] ) where {T}
1919
2020 Nside_sphere = hp. npix2nside (length (healpix_map))
21- @unpack Δx = proj
21+ @unpack Δx, Ny, Nx = proj
2222
2323 # compute projection coordinate mapping
24- xs = ys = Δx* ((- Nside÷ 2 : Nside÷ 2 - 1 ) .+ 0.5 )
24+ ys = @. Δx * ((- Nx÷ 2 : Nx÷ 2 - 1 ) + 0.5 ) # x/y switch here intentional
25+ xs = @. Δx * ((- Ny÷ 2 : Ny÷ 2 - 1 ) + 0.5 )
2526 xys = tuple .(xs,ys' )[:]
2627 θϕs = xy_to_θϕ .(xys)
2728 (θs, ϕs) = first .(θϕs), last .(θϕs)
2829
29- # rotate the pole to the equator to match Healpy's azeqview convention, in
30- # addition to applying the user rotation
31- R = hp. Rotator (( 0 , 90 , 0 ), eulertype= " ZYX" ) * hp . Rotator ( rot, eulertype = " ZYX " )
30+ # the default rots=[(0,90,0)] makes it so you get a view of the
31+ # equator, to match Helapy's azeqview convention
32+ R = prod ([ hp. Rotator (rot ... , eulertype= " ZYX" ) for rot in rots] )
3233 (θs′, ϕs′) = eachrow (R. get_inverse ()(θs, ϕs))
3334
3435 # interpolate map
35- FlatMap (reshape (hp. get_interp_val (healpix_map, θs′, ϕs′), Nside, Nside ), proj)
36+ FlatMap (reshape (hp. get_interp_val (healpix_map, θs′, ϕs′), Ny, Nx ), proj)
3637
3738end
3839
39- function healpix_pixel_centers_to_flat (f:: FlatField , Nside_sphere; rots= [(0 ,90 ,0 )], healpix_pixels= 0 : (12 * Nside_sphere^ 2 - 1 ))
40+ function healpix_pixel_centers_to_flat (f:: FlatField , Nside_sphere; rots= [(( 0 ,90 ,0 ), )], healpix_pixels= 0 : (12 * Nside_sphere^ 2 - 1 ))
4041
4142 @unpack Δx, Ny, Nx = f
4243
4344 (θs, ϕs) = hp. pix2ang (Nside_sphere, healpix_pixels)
4445
45- # rotate the pole to the equator to match Healpy's azeqview convention, in
46- # addition to applying the user rotation
47- R = prod ([hp. Rotator (rot, eulertype= " ZYX" ) for rot in rots])
46+ # the default rots=[(0,90,0)] makes it so you get a view of the
47+ # equator, to match Helapy's azeqview convention
48+ R = prod ([hp. Rotator (rot... , eulertype= " ZYX" ) for rot in rots])
4849 (θs′, ϕs′) = eachrow (R (θs, ϕs))
4950
5051 # compute projection coordinate mapping
5152 # (using Ny for xs and vice-versa intentional)
5253 xys = @. θϕ_to_xy (tuple (θs′, ϕs′))
53- xs = @. first (xys) / Δx + Ny÷ 2 + 0.5
54+ xs = @. first (xys) / Δx + Ny÷ 2 + 0.5 # x/y switch here intentional
5455 ys = @. last (xys) / Δx + Nx÷ 2 + 0.5
5556
5657 (xs, ys)
0 commit comments