@@ -735,6 +735,30 @@ def test_prepare_alm_mmax(self):
735
735
self .assertEqual (ainfo_out .mmax , ainfo_in .mmax )
736
736
self .assertEqual (ainfo_out .nelem , ainfo_in .nelem )
737
737
738
+
739
+ def test_lens_alms (self ):
740
+ # We generate phi alms and convert them to kappa and back
741
+ lmax = 100
742
+ ps = np .zeros (lmax + 1 )
743
+ ls = np .arange (lmax + 1 )
744
+ ps [ls >= 2 ] = 1. / ls [ls >= 2 ]
745
+ phi_alm = curvedsky .rand_alm (ps ,lmax = lmax )
746
+ kappa_alm = lensing .phi_to_kappa (phi_alm )
747
+ phi_alm2 = lensing .kappa_to_phi (kappa_alm )
748
+ np .testing .assert_array_almost_equal (phi_alm , phi_alm2 )
749
+
750
+ def test_downgrade (self ):
751
+ shape ,wcs = enmap .geometry (pos = (0 ,0 ),shape = (100 ,100 ),res = 0.01 )
752
+ imap = enmap .ones (shape ,wcs )
753
+ for dfact in [None ,1 ]:
754
+ omap = enmap .downgrade (imap ,dfact )
755
+ np .testing .assert_equal (imap ,omap )
756
+
757
+ dfact = 2
758
+ omap = enmap .downgrade (imap ,dfact ,op = np .sum )
759
+ np .testing .assert_equal (omap ,np .ones (enmap .scale_geometry (shape ,wcs ,1. / dfact )[0 ])* 4 )
760
+
761
+
738
762
def test_almxfl (self ):
739
763
# We try to filter alms of shape (nalms,) and (ncomp,nalms) with
740
764
# a filter of shape (nells,)
@@ -901,43 +925,44 @@ def test_alm2map_healpix_roundtrip(self):
901
925
alm_out = curvedsky .map2alm_healpix (omap , spin = spin , ainfo = ainfo , niter = niter )
902
926
np .testing .assert_array_almost_equal (alm_out , alm )
903
927
904
- # Disabled for now because the version of ducc currently on pypi
905
- # has an adjointness bug. It's fixed in the ducc git repo.
906
- #def test_adjointness(self):
907
- # # This tests if alm2map_adjoint is the adjoint of alm2map,
908
- # # and if map2alm_adjoint is the adjoint of map2alm.
909
- # # (This doesn't test if they're correct, just that they're
910
- # # consistent with each other). This test is a bit slow, taking
911
- # # 5 s or so. It would be much faster if we dropped the ncomp=3 case.
912
- # for dtype in [np.float32, np.float64]:
913
- # for ncomp in [1,3]:
914
- # # Define our geometries
915
- # geos = []
916
- # res = 30*utils.degree
917
- # shape, wcs = enmap.fullsky_geometry(res=res, variant="fejer1")
918
- # geos.append(("fullsky_fejer1", shape, wcs))
919
-
920
- # shape, wcs = enmap.fullsky_geometry(res=res, variant="cc")
921
- # geos.append(("fullsky_cc", shape, wcs))
922
- # lmax = shape[-2]-2
923
-
924
- # shape, wcs = enmap.Geometry(shape, wcs)[3:-3,3:-3]
925
- # geos.append(("patch_cc", shape, wcs))
926
-
927
- # wcs = wcs.deepcopy()
928
- # wcs.wcs.crpix += 0.123
929
- # geos.append(("patch_gen_cyl", shape, wcs))
930
-
931
- # shape, wcs = enmap.geometry(np.array([[-45,45],[45,-45]])*utils.degree, res=res, proj="tan")
932
- # geos.append(("patch_tan", shape, wcs))
933
-
934
- # for gi, (name, shape, wcs) in enumerate(geos):
935
- # mat1 = alm_bash(curvedsky.alm2map, shape, wcs, ncomp, lmax, dtype)
936
- # mat2 = map_bash(curvedsky.alm2map_adjoint, shape, wcs, ncomp, lmax, dtype)
937
- # np.testing.assert_array_almost_equal(mat1, mat2)
938
- # mat1 = map_bash(curvedsky.map2alm, shape, wcs, ncomp, lmax, dtype)
939
- # mat2 = alm_bash(curvedsky.map2alm_adjoint, shape, wcs, ncomp, lmax, dtype)
940
- # np.testing.assert_array_almost_equal(mat1, mat2)
928
+ # MM: Re-enabled 09/17/2024
929
+ # --Disabled for now because the version of ducc currently on pypi
930
+ # has an adjointness bug. It's fixed in the ducc git repo.--
931
+ def test_adjointness (self ):
932
+ # This tests if alm2map_adjoint is the adjoint of alm2map,
933
+ # and if map2alm_adjoint is the adjoint of map2alm.
934
+ # (This doesn't test if they're correct, just that they're
935
+ # consistent with each other). This test is a bit slow, taking
936
+ # 5 s or so. It would be much faster if we dropped the ncomp=3 case.
937
+ for dtype in [np .float32 , np .float64 ]:
938
+ for ncomp in [1 ,3 ]:
939
+ # Define our geometries
940
+ geos = []
941
+ res = 30 * utils .degree
942
+ shape , wcs = enmap .fullsky_geometry (res = res , variant = "fejer1" )
943
+ geos .append (("fullsky_fejer1" , shape , wcs ))
944
+
945
+ shape , wcs = enmap .fullsky_geometry (res = res , variant = "cc" )
946
+ geos .append (("fullsky_cc" , shape , wcs ))
947
+ lmax = shape [- 2 ]- 2
948
+
949
+ shape , wcs = enmap .Geometry (shape , wcs )[3 :- 3 ,3 :- 3 ]
950
+ geos .append (("patch_cc" , shape , wcs ))
951
+
952
+ wcs = wcs .deepcopy ()
953
+ wcs .wcs .crpix += 0.123
954
+ geos .append (("patch_gen_cyl" , shape , wcs ))
955
+
956
+ shape , wcs = enmap .geometry (np .array ([[- 45 ,45 ],[45 ,- 45 ]])* utils .degree , res = res , proj = "tan" )
957
+ geos .append (("patch_tan" , shape , wcs ))
958
+
959
+ for gi , (name , shape , wcs ) in enumerate (geos ):
960
+ mat1 = alm_bash (curvedsky .alm2map , shape , wcs , ncomp , lmax , dtype )
961
+ mat2 = map_bash (curvedsky .alm2map_adjoint , shape , wcs , ncomp , lmax , dtype )
962
+ np .testing .assert_array_almost_equal (mat1 , mat2 )
963
+ mat1 = map_bash (curvedsky .map2alm , shape , wcs , ncomp , lmax , dtype )
964
+ mat2 = alm_bash (curvedsky .map2alm_adjoint , shape , wcs , ncomp , lmax , dtype )
965
+ np .testing .assert_array_almost_equal (mat1 , mat2 )
941
966
942
967
943
968
#def test_sharp_alm2map_der1(self):
0 commit comments