Window Convolution Matrix#

Load modules.

import h5py as hp
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LogNorm
from mpl_toolkits.axes_grid1 import make_axes_locatable

from config import DATADIR

Set I/O.

NOTE: Change 'MULTIPOLE' to '000' for subfigure (a) (monopole), and '202' for subfigure (b) (quadrupole).

MULTIPOLE = '000'  # '202
FORMULA = 'reduced'
SUFFIX_TAG = "LRG_altmtl_SGC_0.4z0.6_mock0"
wcmat_file = f"wcmat_{MULTIPOLE}_{FORMULA}_{SUFFIX_TAG}.h5"
try:
    with hp.File(DATADIR / "common" / "winconv-matrices" / wcmat_file, 'r') as hf:
        wcmat = hf['wcmat'][:]
except FileNotFoundError:
    wcmat = np.loadtxt(
        DATADIR / "common" / "winconv-matrices" /
        wcmat_file.replace('.h5', '.txt')
    )
    with hp.File(DATADIR / "common" / "winconv-matrices" / wcmat_file, 'w') as hf:
        hf.create_dataset('wcmat', data=wcmat)
if MULTIPOLE == '000':
    fig, ax = plt.subplots(figsize=(4.5, 4.5), dpi=150)
elif MULTIPOLE == '202':
    fig, ax = plt.subplots(figsize=(5.5, 4.5), dpi=150)

heatmat = 1. / np.abs(wcmat)
dimr, dimc = heatmat.shape

cax = ax.matshow(
    heatmat,
    norm=LogNorm(vmin=1e-2, vmax=1e12),
    cmap="YlOrRd_r",
    rasterized=True
)

if MULTIPOLE == '000':
    divider = make_axes_locatable(ax)
    cbar_ax = divider.append_axes('top', size='5%', pad=0.45)

    cbar = fig.colorbar(cax, cax=cbar_ax, orientation='horizontal')

    cbar.ax.xaxis.set_label_position('top')
    cbar.ax.xaxis.set_ticks_position('top')
    cbar.set_label(r"$\left\vert{W}_{IJ}^{-1}\right\vert$", labelpad=10)

if MULTIPOLE == '000':
    ax.get_xaxis().set_ticks([
        dimc//8 - .5,
        3*dimc//8 - .5,
        5*dimc//8 - .5,
        7*dimc//8 - .5,
    ])
    ax.get_yaxis().set_ticks([dimr//2 - .5])

    xtick_labels = [
        r"$\mathbf{B}_{000}$",
        r"$\mathbf{B}_{110}$",
        r"$\mathbf{B}_{022}$",
        r"$\mathbf{B}_{202}$",
    ]
    ytick_labels = [
        r"$\tilde{\mathbf{B}}_{000}$",
    ]
elif MULTIPOLE == '202':
    ax.get_xaxis().set_ticks([
        dimc//10 - .5,
        3*dimc//10 - .5,
        5*dimc//10 - .5,
        7*dimc//10 - .5,
        9*dimc//10 - .5
    ])
    ax.get_yaxis().set_ticks([dimr//2 - .5])

    xtick_labels = [
        r"$\mathbf{B}_{000}$",
        r"$\mathbf{B}_{110}$",
        r"$\mathbf{B}_{220}$",
        r"$\mathbf{B}_{112}$",
        r"$\mathbf{B}_{202}$",
    ]
    ytick_labels = [
        r"$\tilde{\mathbf{B}}_{202}$",
    ]

ax.get_xaxis().set_ticklabels(xtick_labels);
ax.get_yaxis().set_ticklabels(ytick_labels);
../../_images/840caff154b3f56be49ae210346d40aa6217a4163dee3cd8801a84dc257c1093.png