Skip to content

Commit

Permalink
add failing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mreineck committed May 13, 2022
1 parent b888aa6 commit 596c1df
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions test/test_mueller_convolver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ducc0
import numpy as np
import pytest
import healpy
from litebird_sim import MuellerConvolver


Expand Down Expand Up @@ -62,3 +63,55 @@ def test_trivial_mueller_matrix(fct, lkmax, ncomp):
)
ref_sig = ref_conv.interpol(ptg)[0] * fct
np.testing.assert_allclose(sig, ref_sig, atol=1e-3)


# This test case fails for reasons I don't yet understand
# We are using a polarized beam, which is observing a uniform, completely
# unpolarized sky through a rotating polarizer.
# I would expect a signal modulated with exp(i*2*alpha), but the result is
# actually constant. Any insights are welcome!

@pmp("lmax", [100])
def test_polarized(lmax):
rng = np.random.default_rng(41)

ncomp = 3
kmax = 2
nptg = 100
epsilon = 1e-4
ofactor = 1.5
nthreads = 0

# completely dark sky
slm = random_alm(lmax, lmax, ncomp, rng) * 0
# add uniform unpolarized emission
slm[0,0] = 1
# generate a Gaussian beam using healpy
blm = healpy.blm_gauss(1.*np.pi/180., lmax=lmax, pol=True)

ptg = np.empty((nptg, 3))
ptg[:, 0] = 0.5 * np.pi
ptg[:, 1] = 0.
ptg[:, 2] = 0.
alpha = rng.random(nptg) * 2 * np.pi

# Linear polarizer (see last page of https://www.brown.edu/research/labs/mittleman/sites/brown.edu.research.labs.mittleman/files/uploads/lecture17_0.pdf)
mueller = np.zeros((4,4))
mueller[:2,:2] = 1

fullconv = MuellerConvolver(
lmax,
kmax,
slm,
blm,
mueller,
single_precision=False,
epsilon=epsilon,
ofactor=ofactor,
nthreads=nthreads,
)
sig = fullconv.signal(ptg, alpha)

# I'm testing for near-constness for now, to detect that I'm not getting the
# result I expect. This has to improve once we have found the bug.
np.testing.assert_array_less(1e-4, np.max(sig)-np.min(sig))

1 comment on commit 596c1df

@ziotom78
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Martin, this kind of test will surely help a lot!

Please sign in to comment.