Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@zonca
Copy link
Member

@zonca zonca commented Jun 10, 2021

No description provided.

@zonca
Copy link
Member Author

zonca commented Jun 10, 2021

the rotate_alm comparison with Fortran had a bug, it was comparing the Fortran to Fortran instead of healpy to Fortran.

the Alms are actually quite different between healpy and Fortran:

(Pdb) orig
[0j, (31+0j), 0j, (52+0j), (52+21j), 0j, (73+0j), (73+21j), (73+42j), 0j, 0j, (41+0j), 0j, (62+0j), (62+21j), 0j, (83+0j), (83+21j), (83+42j), 0j]
(Pdb) ref
array([   0.00000000 +0.j        ,  -64.00566224 +0.j        ,
         -3.19617408 +2.0021959j ,   87.82013608 +0.j        ,
         -6.57242310+50.11280794j,    0.79259236 -0.9284526j ,
        -49.67325547 +0.j        ,  -51.28126239-61.62891293j,
         -9.32823219+79.07879935j,   -0.15720457 +0.32469296j,
          0.00000000 +0.j        ,  -85.55208091 +0.j        ,
         -3.57384286 +2.93255811j,  107.54117225 +0.j        ,
         -2.77944942+57.10153224j,    0.79421285 -1.10982745j,
        -60.71533037 +0.j        ,  -61.09151238-65.99438789j,
         -4.86354653+86.52772532j,   -0.14716538 +0.36047478j])
(Pdb) mine
array([   0.00000000 +0.j        ,  -64.00565796 +0.j        ,
          6.01334854 +5.73849263j,   87.82013608 +0.j        ,
         -6.58093829+50.1084887j ,   -3.75913914 -2.13645466j,
        -49.67325547 +0.j        ,  -51.28126266-61.62891268j,
         -8.92714885+79.1993621j ,    1.63993991 +0.47239151j,
          0.00000000 +0.j        ,  -85.55207525 +0.j        ,
          8.23166716 +6.11553975j,  107.54117225 +0.j        ,
         -2.78936165+57.09751076j,   -4.40081795 -2.03054971j,
        -60.71533037 +0.j        ,  -61.09151267-65.9943876j ,
         -4.42280461+86.63057763j,    1.80108316 +0.39800113j])
E       Mismatched elements: 14 / 20 (70%)
E       Max absolute difference: 12.227078099911715
E       Max relative difference: 1.1956782734781954
E        x: array([   0.000000 +0.j      ,  -64.005662 +0.j      ,
E                -3.196174 +2.002196j,   87.820136 +0.j      ,
E                -6.572423+50.112808j,    0.792592 -0.928453j,...
E        y: array([   0.000000 +0.j      ,  -64.005658 +0.j      ,
E                 6.013349 +5.738493j,   87.820136 +0.j      ,
E                -6.580938+50.108489j,   -3.759139 -2.136455j,...

@zonca zonca force-pushed the fix_rotate_alm_test branch from 27724ca to b665391 Compare January 15, 2022 04:44
@zonca
Copy link
Member Author

zonca commented Jan 21, 2022

@keskitalo you contributed this unit test back in #399
would you like to take a look at it?
Anyway I think it is just an issue in the test, the routines should be fine.

@keskitalo
Copy link
Contributor

keskitalo commented Jan 21, 2022

Thanks for finding the error, @zonca !

The initialization of the a_lm array in the test does indeed have an error. Instead of

for i in range(3):
    for ell in range(lmax + 1):
        for m in range(ell):
            ind = hp.Alm.getidx(lmax, ell, m)
            alm[i, ind] = (i + 1) * 10 + ell + 1j * m

It should be (changed loop ranges for both ell and m):

for i in range(3):
    for ell in range(2, lmax + 1):
        for m in range(ell + 1):
            ind = hp.Alm.getidx(lmax, ell, m)
            alm[i, ind] = (i + 1) * 10 + ell + 1j * m

Unfortunately, at least on my test system, I now see small but genuine discrepancies:

#   refererence                                              Healpy 
0  0j                                                               0j
1 (-64.0056622444+0j)                              (-64.0056622444+0j)
2 (-3.19617408364+2.00219590117j)       (-3.19617407425+2.00219591617j)
3 (87.8201360825+0j)                                (87.8201360825+0j)
4 (-6.57242309702+50.1128079361j)      (-6.5724228618+50.1128079669j)
5 (0.792592362074-0.928452597766j)  (0.792592353357-0.928452605206j)
6 (-49.6732554742+0j)                              (-49.6732554742+0j)
7 (-51.2812623888-61.6289129316j)       (-51.2812626781-61.6289126909j)
8 (-9.3282321943+79.0787993482j)       (-9.32823145193+79.0787994357j)
9 (-0.157204566965+0.3246929587j)    (-0.157204562393+0.324692960914j)
10 0j                                                              0j
11 (-85.5520809077+0j)                            (-85.5520809077+0j)
12 (-3.57384285749+2.93255811219j)    (-3.57384284372+2.93255812897j)
13 (107.541172254+0j)                                (107.541172254+0j)
14 (-2.77944941833+57.1015322415j)     (-2.77944915031+57.1015322546j)
15 (0.794212854046-1.10982745343j)    (0.794212843627-1.10982746089j)
16 (-60.7153303746+0j)                             (-60.7153303746+0j)
17 (-61.0915123767-65.9943878923j)     (-61.0915126865-65.9943876056j)
18 (-4.86354653261+86.5277253196j)   (-4.86354572031+86.5277253653j)
19 (-0.147165377786+0.360474777237j)(-0.14716537271+0.36047477931j)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants