Skip to content

Commit

Permalink
modify test
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuke-takase committed Aug 23, 2024
1 parent ae884f5 commit c0f934d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 31 deletions.
30 changes: 10 additions & 20 deletions notebooks/diff_pointing_channel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,9 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
Expand All @@ -34,7 +25,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand All @@ -57,7 +48,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -77,7 +68,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -92,7 +83,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -128,7 +119,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -139,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -191,7 +182,7 @@
"The red line $\\Delta C_{\\ell, Ana}^{BB}$ is simulated by\n",
"\n",
"$$\n",
"\\Delta C_{\\ell, Ana}^{BB} = \\frac{1}{2} (\\langle|{}_{1}\\tilde{h}|^2\\rangle + \\langle|{}_{3}\\tilde{h}|^2\\rangle)~\\rho^2~\\ell^2~C_{\\ell}^{TT}\n",
"\\Delta C_{\\ell, Ana}^{BB} = \\frac{1}{8} (\\langle|{}_{1}\\tilde{h}|^2\\rangle + \\langle|{}_{3}\\tilde{h}|^2\\rangle)~\\rho^2~\\ell^2~C_{\\ell}^{TT}\n",
"$$\n",
"\n",
"where $\\langle|{}_{n}\\tilde{h}|^2\\rangle$ represents the entire sky average of the spin-n cross-link.\n",
Expand All @@ -201,7 +192,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -223,7 +214,6 @@
"xlink1_mean = np.mean(np.abs(total_field.get_xlink(1))**2)\n",
"xlink3_mean = np.mean(np.abs(total_field.get_xlink(3))**2)\n",
"ana = (1/8) * (xlink1_mean + xlink3_mean) * fiducial_cl[0] * rho_T[0]**2 * ell**2\n",
"#ana = (xlink1_mean + xlink3_mean) * fiducial_cl[0] * rho[0]**2 * ell**2\n",
"\n",
"plt.plot(fiducial_cl[0], label=\"input TT\")\n",
"plt.plot(fiducial_cl[2], label=\"input BB\")\n",
Expand Down
Binary file modified tests/__pycache__/test_sbm.cpython-310-pytest-8.3.2.pyc
Binary file not shown.
Binary file modified tests/reference/diff_pointing_output_map.fits
Binary file not shown.
27 changes: 16 additions & 11 deletions tests/test_sbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def test_diff_gain(self, save_output_map=False):
print(f"output_map.shape: {output_map.shape}")

if save_output_map==True:
hp.write_map("tests/reference/diff_gain_output_map.fits", output_map)
hp.write_map("tests/reference/diff_gain_output_map.fits", output_map, overwrite=True)
print("Diff gain output map saved.")
else:
reference = hp.read_map("tests/reference/diff_gain_output_map.fits", field=(0,1,2))
print(f"reference.shape: {reference.shape}")
Expand All @@ -47,20 +48,23 @@ def test_diff_pointing(self, save_output_map=False):
dQ = hp.alm2map_der1(hp.map2alm(self.input_map[1]), nside=self.nside)
dU = hp.alm2map_der1(hp.map2alm(self.input_map[2]), nside=self.nside)

eth_I = dI[2] - dI[1]*1j
eth_P = dQ[2] + dU[1] - (dQ[1] - dU[2])*1j
eth_I = dI[2] - 1j*dI[1]
eth_P = dQ[2] + dU[1] - 1j*(dQ[1] - dU[2])
o_eth_P = dQ[2] - dU[1] + 1j*(dQ[1] + dU[2])

rho = np.deg2rad(1/60)
chi = np.deg2rad(0)
print("rho: ", rho)
print("chi: ", chi)
rho_T = np.deg2rad(1/60)
chi_T = np.deg2rad(0)
rho_B = np.deg2rad(0)
chi_B = np.deg2rad(0)
zeta = rho_T * np.exp(1j*chi_T) - 1j*rho_B * np.exp(1j*chi_B)
o_zeta = rho_T * np.exp(1j*chi_T) + 1j*rho_B * np.exp(1j*chi_B) #\overline{\zeta}

spin_0_field = Field(I, spin=0)
spin_1_field = Field(-rho/2*np.exp(1j*chi)*eth_I, spin=1)
spin_0_field = Field(np.zeros(len(P)), spin=0)
spin_1_field = Field(-1.0/4.0 * (zeta*eth_I + o_zeta.conj()*o_eth_P), spin=1)
spin_m1_field = spin_1_field.conj()
spin_2_field = Field(P/2.0, spin=2)
spin_m2_field = spin_2_field.conj()
spin_3_field = Field(-rho/4*np.exp(1j*chi)*eth_P, spin=3)
spin_3_field = Field(-1.0/4.0 * o_zeta * eth_P, spin=3)
spin_m3_field = spin_3_field.conj()

signal_field = SignalFields(
Expand All @@ -77,7 +81,8 @@ def test_diff_pointing(self, save_output_map=False):
print(f"output_map.shape: {output_map.shape}")

if save_output_map==True:
hp.write_map("tests/reference/diff_pointing_output_map.fits", output_map)
hp.write_map("tests/reference/diff_pointing_output_map.fits", output_map, overwrite=True)
print("Diff gain output map saved.")
else:
reference = hp.read_map("tests/reference/diff_pointing_output_map.fits", field=(0,1,2))
print(f"reference.shape: {reference.shape}")
Expand Down

0 comments on commit c0f934d

Please sign in to comment.