Пример #1
0
def demoBk(): 
    '''
    '''
    kmax = 0.5
    kf = 2.*np.pi/2600.
    # read in Bk 
    bisp = pickle.load(open(os.path.join(UT.dat_dir(), 'egBk.p'), 'rb'))
    i_k, j_k, l_k, bk = bisp['i_k1'], bisp['i_k2'], bisp['i_k3'], bisp['b123'] 
    
    klim = ((i_k*kf <= kmax) & (j_k*kf <= kmax) & (l_k*kf <= kmax))
    i_k, j_k, l_k = i_k[klim], j_k[klim], l_k[klim]
    ijl = UT.ijl_order(i_k, j_k, l_k, typ='GM') # order of triangles 
    
    for itri in range(1500): 
        fig = plt.figure(figsize=(15,4.8))
        sub = fig.add_subplot(111)
        sub.plot(range(1500), bk[klim][ijl][:1500], c='k', lw=0.5)
        sub.scatter(range(1500), bk[klim][ijl][:1500], c='k', s=2)
        sub.scatter(itri, bk[klim][ijl][itri], c='C1', s=30, zorder=10) 

        itri_i, itri_j, itri_l = i_k[ijl][itri], j_k[ijl][itri], l_k[ijl][itri]
        trixy = np.zeros((3,2))
        trixy[0,:] = np.array([1400, 2e10])
        trixy[1,:] = np.array([1400 - 3.33*itri_i, 2e10]) 
        theta23 = np.arccos(-0.5*(itri_l**2 - itri_i**2 - itri_j**2)/itri_i/itri_j)[0]
        trixy[2,:] = np.array([1400-3.33*itri_j[0]*np.cos(theta23), 
            10**(10.301 - 0.022*itri_j[0]*np.sin(theta23))])
        tri = plt.Polygon(trixy, fill=None, edgecolor='k')
        fig.gca().add_patch(tri)
        
        sub.text(0.5*(trixy[0,0]+trixy[1,0]), 0.5*(trixy[0,1]+trixy[1,1]), '$k_3$', 
                fontsize=8, ha='center', va='bottom') 
        sub.text(0.5*(trixy[0,0]+trixy[2,0]), 0.5*(trixy[0,1]+trixy[2,1]), '$k_2$', 
                fontsize=8, ha='left', va='top') 
        sub.text(0.5*(trixy[1,0]+trixy[2,0]), 0.5*(trixy[1,1]+trixy[2,1]), '$k_1$', 
                fontsize=8, ha='right', va='top') 

        sub.set_xlabel('triangle configurations', fontsize=25)
        sub.set_xlim([0, 1500])
        sub.set_ylabel(r'$B(k_1, k_2, k_3)$', fontsize=25)
        sub.set_yscale('log') 
        sub.set_ylim([1e7, 3e10])
        fig.savefig(os.path.join(UT.dat_dir(), 'demo', 'demoBk%i.png' % itri), bbox_inches='tight')
        plt.close() 
    return None 
Пример #2
0
def AEM_rzspace():
    ''' comparison between real and redshift space 
    '''
    f_b123 = lambda sim, rsd: os.path.join(
        UT.dat_dir(), sim,
        'pySpec.B123.halo.mlim1e13.Ngrid360.Nmax40.Ncut3.step3.pyfftw%s.dat' %
        ['', '.rsd'][rsd])
    Lbox_aem = 1050.
    kf_aem = 2. * np.pi / Lbox_aem

    fig = plt.figure(figsize=(10, 5))
    sub = fig.add_subplot(111)
    i_k, j_k, l_k, p0k1, p0k2, p0k3, b123, q123, counts, _ = np.loadtxt(
        f_b123('aemulus', False), skiprows=1, unpack=True, usecols=range(10))
    i_k, j_k, l_k, p0k1, p0k2, p0k3, b123_s, q123_s, counts, _ = np.loadtxt(
        f_b123('aemulus', True), skiprows=1, unpack=True, usecols=range(10))
    klim = ((i_k * kf_aem <= 0.3) & (j_k * kf_aem <= 0.3) &
            (l_k * kf_aem <= 0.3))
    ijl = UT.ijl_order(i_k[klim], j_k[klim], l_k[klim],
                       typ='GM')  # order of triangles

    sub.scatter(range(np.sum(klim)),
                b123[klim][ijl],
                c='k',
                s=5,
                label='real-space')
    sub.plot(range(np.sum(klim)), b123[klim][ijl], c='k')
    sub.scatter(range(np.sum(klim)),
                b123_s[klim][ijl],
                c='C1',
                s=5,
                label='z-space')
    sub.plot(range(np.sum(klim)), b123_s[klim][ijl], c='C1')
    print(b123_s[klim][ijl] / b123[klim][ijl]).flatten()
    sub.legend(loc='upper right', markerscale=4, handletextpad=0., fontsize=20)
    sub.set_ylabel('$B(k_1, k_2, k_3)$', fontsize=25)
    sub.set_yscale('log')
    sub.set_xlabel(r'$k_1 \le k_2 \le k_3$ triangle indices', fontsize=25)
    sub.set_xlim([0, np.sum(klim)])
    fig.savefig(''.join([UT.dat_dir(), 'qpm/B123_aemulus_rzspace.png']),
                bbox_inches='tight')

    fig = plt.figure(figsize=(10, 5))
    sub = fig.add_subplot(111)
    sub.scatter(range(np.sum(klim)),
                q123[klim][ijl],
                c='k',
                s=2,
                label='real-space')
    sub.plot(range(np.sum(klim)), q123[klim][ijl], c='k', lw=1)
    sub.scatter(range(np.sum(klim)),
                q123_s[klim][ijl],
                c='C1',
                s=2,
                label='redshift-space')
    sub.plot(range(np.sum(klim)), q123_s[klim][ijl], c='C1', lw=1)
    sub.legend(loc='lower right',
               handletextpad=0.2,
               markerscale=10,
               fontsize=20)
    sub.set_ylabel('$Q(k_1, k_2, k_3)$', fontsize=25)
    sub.set_xlabel('$k_1 > k_2 > k_3$ triangle indices', fontsize=25)
    sub.set_xlim([0, np.sum(klim)])
    sub.set_ylim([0., 1.])
    fig.savefig(''.join([UT.dat_dir(), 'qpm/Q123_aemulus_rzspace.png']),
                bbox_inches='tight')
    return None
Пример #3
0
def QPM_AEM(rsd=False):
    str_rsd = ''
    if rsd: str_rsd = '.rsd'
    f_pell = lambda sim: ''.join([
        UT.dat_dir(), sim, '/pySpec.Plk.halo.mlim1e13.Ngrid360', str_rsd,
        '.dat'
    ])
    f_pnkt = lambda sim: ''.join([
        UT.dat_dir(), sim, '/pySpec.Plk.halo.mlim1e13.Ngrid360.nbodykit',
        str_rsd, '.dat'
    ])
    f_b123 = lambda sim: ''.join([
        UT.dat_dir(), sim,
        '/pySpec.B123.halo.mlim1e13.Ngrid360.Nmax40.Ncut3.step3.pyfftw',
        str_rsd, '.dat'
    ])

    Lbox_qpm = 1050.
    Lbox_aem = 1050.
    kf_qpm = 2. * np.pi / Lbox_qpm
    kf_aem = 2. * np.pi / Lbox_aem

    fig = plt.figure(figsize=(5, 5))
    sub = fig.add_subplot(111)
    k, p0k = np.loadtxt(f_pell('aemulus'),
                        unpack=True,
                        skiprows=1,
                        usecols=[0, 1])
    klim = (k < 0.3)
    sub.plot(k[klim], p0k[klim], c='k', lw=1, label='Aemulus')
    k, p0k = np.loadtxt(f_pnkt('aemulus'),
                        unpack=True,
                        skiprows=1,
                        usecols=[0, 1])
    klim = (k < 0.3)
    sub.plot(k[klim], p0k[klim], c='k', ls='--', lw=1)
    k, p0k = np.loadtxt(f_pell('qpm'), unpack=True, skiprows=1, usecols=[0, 1])
    klim = (k < 0.3)
    sub.plot(k[klim], p0k[klim], c='C1', lw=1, label='QPM')
    k, p0k = np.loadtxt(f_pnkt('qpm'), unpack=True, skiprows=1, usecols=[0, 1])
    klim = (k < 0.3)
    sub.plot(k[klim], p0k[klim], c='C1', ls='--', lw=1)
    sub.legend(loc='upper right', fontsize=20)
    sub.set_ylabel('$P_0(k)$', fontsize=25)
    sub.set_yscale('log')
    sub.set_xlabel('$k$', fontsize=25)
    sub.set_xlim([8e-3, 0.5])
    sub.set_xscale('log')
    fig.savefig(''.join([UT.dat_dir(), 'qpm/p0k_qpm_aemulus', str_rsd,
                         '.png']),
                bbox_inches='tight')

    fig = plt.figure(figsize=(10, 5))
    sub = fig.add_subplot(111)
    i_k, j_k, l_k, p0k1, p0k2, p0k3, b123, q123, counts, b123_sn = np.loadtxt(
        f_b123('aemulus'), skiprows=1, unpack=True, usecols=range(10))
    klim = ((i_k * kf_aem <= 0.22) & (i_k * kf_aem >= 0.03) &
            (j_k * kf_aem <= 0.22) & (j_k * kf_aem >= 0.03) &
            (l_k * kf_aem <= 0.22) & (l_k * kf_aem >= 0.03))
    i_k, j_k, l_k = i_k[klim], j_k[klim], l_k[klim]

    ijl = UT.ijl_order(i_k, j_k, l_k, typ='GM')  # order of triangles

    sub.scatter(range(np.sum(klim)),
                b123[klim][ijl],
                c='k',
                s=5,
                label='Aemulus')
    sub.plot(range(np.sum(klim)), b123[klim][ijl], c='k')

    i_k, j_k, l_k, p0k1, p0k2, p0k3, b123, q123, counts, b123_sn = np.loadtxt(
        f_b123('qpm'), skiprows=1, unpack=True, usecols=range(10))
    klim = ((i_k * kf_qpm <= 0.22) & (i_k * kf_qpm >= 0.03) &
            (j_k * kf_qpm <= 0.22) & (j_k * kf_qpm >= 0.03) &
            (l_k * kf_qpm <= 0.22) & (l_k * kf_qpm >= 0.03))
    i_k, j_k, l_k, = i_k[klim], j_k[klim], l_k[klim]

    ijl = UT.ijl_order(i_k, j_k, l_k, typ='GM')  # order of triangles
    sub.scatter(range(np.sum(klim)), b123[klim][ijl], c='C1', s=5, label='QPM')
    sub.plot(range(np.sum(klim)), b123[klim][ijl], c='C1')
    sub.legend(loc='upper right', markerscale=4, handletextpad=0., fontsize=20)
    sub.set_ylabel('$B(k_1, k_2, k_3)$', fontsize=25)
    sub.set_yscale('log')
    sub.set_ylim([1e8, 6e9])
    sub.set_xlabel(r'$k_1 \le k_2 \le k_3$ triangle indices', fontsize=25)
    sub.set_xlim([0, np.sum(klim)])
    fig.savefig(''.join(
        [UT.dat_dir(), 'qpm/B123_qpm_aemulus', str_rsd, '.png']),
                bbox_inches='tight')

    fig = plt.figure(figsize=(10, 5))
    sub = fig.add_subplot(111)
    i_k, j_k, l_k, p0k1, p0k2, p0k3, b123, q123, counts, b123_sn = np.loadtxt(
        f_b123('aemulus'), skiprows=1, unpack=True, usecols=range(10))
    sub.scatter(range(len(q123)), q123, c='k', s=2, label='Aemulus')
    i_k, j_k, l_k, p0k1, p0k2, p0k3, b123, q123, counts, b123_sn = np.loadtxt(
        f_b123('qpm'), skiprows=1, unpack=True, usecols=range(10))
    sub.scatter(range(len(q123)), q123, c='C1', s=2, label='QPM')
    sub.legend(loc='upper right', fontsize=20)
    sub.set_ylabel('$Q(k_1, k_2, k_3)$', fontsize=25)
    sub.set_xlabel('$k_1 > k_2 > k_3$ triangle indices', fontsize=25)
    sub.set_xlim([0, len(q123)])
    sub.set_ylim([0., 1.])
    fig.savefig(''.join(
        [UT.dat_dir(), 'qpm/Q123_qpm_aemulus', str_rsd, '.png']),
                bbox_inches='tight')
    return None
Пример #4
0
def fastpm_v_tng(z,
                 str_flag='',
                 mh_lim=15.,
                 Lbox=205.,
                 Nmax=40,
                 Ncut=3,
                 step=3):
    ''' make plots that compare the powerspectrum and bispectrum of 
    fastpm and illustris tng 
    '''
    dir_fpm = os.path.join(UT.dat_dir(), 'fastpm')
    f_fpm = ('halocat_FastPM_40step_N250_IC500_B2_z%.2f%s.mlim%.fe10' %
             (z, str_flag, mh_lim))
    f_tng = ('halocat_TNG300Dark_z%.2f.mlim%.fe10' % (z, mh_lim))
    print('FastPM file: %s' % f_fpm)
    print('Illustris TNG file: %s' % f_tng)

    f_pell = lambda f_halo: ('%s/pySpec.Plk.%s.Lbox%.f.Ngrid360.dat' %
                             (dir_fpm, f_halo, Lbox))
    f_pnkt = lambda f_halo: ('%s/pySpec.Plk.%s.Lbox%.f.Ngrid360.nbodykit.dat' %
                             (dir_fpm, f_halo, Lbox))
    f_b123 = lambda f_halo: (
        '%s/pySpec.Bk.%s.Lbox%.f.Ngrid360.step%i.Ncut%i.Nmax%i.dat' %
        (dir_fpm, f_halo, Lbox, step, Ncut, Nmax))

    kf = 2. * np.pi / Lbox

    # P(k) comparison
    fig = plt.figure(figsize=(5, 5))
    sub = fig.add_subplot(111)
    k, p0k = np.loadtxt(f_pell(f_fpm), unpack=True, skiprows=1, usecols=[0, 1])
    sub.plot(k, p0k, c='k', lw=1, label='FastPM')
    k, p0k_fpm = np.loadtxt(f_pnkt(f_fpm),
                            unpack=True,
                            skiprows=1,
                            usecols=[0, 1])
    sub.plot(k, p0k_fpm, c='k', ls='--', lw=1)
    k, p0k = np.loadtxt(f_pell(f_tng), unpack=True, skiprows=1, usecols=[0, 1])
    sub.plot(k, p0k, c='C1', lw=1, label='Illustris TNG')
    k, p0k_tng = np.loadtxt(f_pnkt(f_tng),
                            unpack=True,
                            skiprows=1,
                            usecols=[0, 1])
    sub.plot(k, p0k_tng, c='C1', ls='--', lw=1)
    print(p0k_fpm / p0k_tng)[k < 0.2] - 1.
    sub.legend(loc='lower left', fontsize=20)
    sub.set_ylabel('$P_0(k)$', fontsize=25)
    sub.set_yscale('log')
    sub.set_ylim([1e0, 1e4])
    sub.set_xlabel('$k$', fontsize=25)
    sub.set_xscale('log')
    sub.set_xlim([1e-2, 10.])
    fig.savefig(os.path.join(dir_fpm,
                             'p0k_fpm_tng_z%.2f%s.png' % (z, str_flag)),
                bbox_inches='tight')

    fig = plt.figure(figsize=(10, 5))
    sub = fig.add_subplot(111)
    for fh, lbl, c in zip([f_fpm, f_tng], ['FastPM', 'Illustris TNG'],
                          ['k', 'C1']):
        i_k, j_k, l_k, p0k1, p0k2, p0k3, b123, q123, counts, b123_sn = np.loadtxt(
            f_b123(fh), skiprows=1, unpack=True, usecols=range(10))
        klim = ((i_k * kf <= 1.) & (i_k * kf >= 0.01) & (j_k * kf <= 1.) &
                (j_k * kf >= 0.01) & (l_k * kf <= 1.) & (l_k * kf >= 0.01))

        i_k, j_k, l_k = i_k[klim], j_k[klim], l_k[klim]
        ijl = UT.ijl_order(i_k, j_k, l_k, typ='GM')  # order of triangles

        sub.scatter(range(np.sum(klim)), b123[klim][ijl], c=c, s=5, label=lbl)
        sub.plot(range(np.sum(klim)), b123[klim][ijl], c=c)

    sub.legend(loc='upper right', markerscale=4, handletextpad=0., fontsize=20)
    sub.set_ylabel('$B(k_1, k_2, k_3)$', fontsize=25)
    sub.set_yscale('log')
    sub.set_ylim([1e3, 5e6])
    sub.set_xlabel(r'$k_1 \le k_2 \le k_3$ triangle indices', fontsize=25)
    sub.set_xlim([0, np.sum(klim)])
    fig.savefig(os.path.join(dir_fpm,
                             'bk_fpm_tng_z%.2f%s.png' % (z, str_flag)),
                bbox_inches='tight')

    fig = plt.figure(figsize=(10, 5))
    sub = fig.add_subplot(111)
    for fh, lbl, c in zip([f_fpm, f_tng], ['FastPM', 'Illustris TNG'],
                          ['k', 'C1']):
        i_k, j_k, l_k, p0k1, p0k2, p0k3, b123, q123, counts, b123_sn = np.loadtxt(
            f_b123(fh), skiprows=1, unpack=True, usecols=range(10))
        klim = ((i_k * kf >= 0.01) & (j_k * kf >= 0.01) & (l_k * kf >= 0.01))
        i_k, j_k, l_k = i_k[klim], j_k[klim], l_k[klim]
        ijl = UT.ijl_order(i_k, j_k, l_k, typ='GM')  # order of triangles

        sub.scatter(range(np.sum(klim)), q123[klim][ijl], c=c, s=5, label=lbl)
        sub.plot(range(np.sum(klim)), q123[klim][ijl], c=c)

    sub.legend(loc='upper right', markerscale=4, handletextpad=0., fontsize=20)
    sub.set_ylabel('$Q(k_1, k_2, k_3)$', fontsize=25)
    sub.set_ylim([0., 1.])
    sub.set_xlabel(r'$k_1 \le k_2 \le k_3$ triangle indices', fontsize=25)
    sub.set_xlim([0, np.sum(klim)])
    fig.savefig(os.path.join(dir_fpm,
                             'qk_fpm_tng_z%.2f%s.png' % (z, str_flag)),
                bbox_inches='tight')
    return None
Пример #5
0
def QPM_AEM(rsd=False):
    str_rsd = ''
    str_rsd_pdf = ''
    if rsd:
        str_rsd = '.rsd'
        str_rsd_pdf = '_rsd'

    f_pell = lambda sim: os.path.join(
        dir_dat, sim, 'pySpec.Plk.halo.mlim1e13.Lbox1050.Ngrid360%s.dat' %
        str_rsd)
    f_pnkt = lambda sim: os.path.join(
        dir_dat, sim,
        'pySpec.Plk.halo.mlim1e13.Lbox1050.Ngrid360.nbodykit%s.dat' % str_rsd)
    f_b123 = lambda sim: os.path.join(
        dir_dat, sim,
        'pySpec.B123.halo.mlim1e13.Lbox1050.Ngrid360.Nmax40.Ncut3.step3.pyfftw%s.dat'
        % str_rsd)

    Lbox = 1050.
    kf = 2. * np.pi / 1050

    fig = plt.figure(figsize=(5, 5))
    sub = fig.add_subplot(111)
    k, p0k = np.loadtxt(f_pell('aemulus'),
                        unpack=True,
                        skiprows=1,
                        usecols=[0, 1])
    klim = (k < 0.3)
    sub.plot(k[klim], p0k[klim], c='k', lw=1, label='Aemulus')
    k, p0k = np.loadtxt(f_pnkt('aemulus'),
                        unpack=True,
                        skiprows=1,
                        usecols=[0, 1])
    klim = (k < 0.3)
    sub.plot(k[klim], p0k[klim], c='k', ls='--', lw=1)
    k, p0k = np.loadtxt(f_pell('qpm'), unpack=True, skiprows=1, usecols=[0, 1])
    klim = (k < 0.3)
    sub.plot(k[klim], p0k[klim], c='C1', lw=1, label='QPM')
    k, p0k = np.loadtxt(f_pnkt('qpm'), unpack=True, skiprows=1, usecols=[0, 1])
    klim = (k < 0.3)
    sub.plot(k[klim], p0k[klim], c='C1', ls='--', lw=1)
    sub.legend(loc='upper right', fontsize=20)
    sub.set_ylabel('$P_0(k)$', fontsize=25)
    sub.set_yscale('log')
    sub.set_xlabel('$k$', fontsize=25)
    sub.set_xlim([8e-3, 0.5])
    sub.set_xscale('log')
    fig.savefig(os.path.join(dir_dat, 'qpm',
                             'p0k_qpm_aemulus%s.png' % str_rsd),
                bbox_inches='tight')


    i_k, j_k, l_k, _, _, _, b123_aem, q123_aem, counts_aem, _ = \
            np.loadtxt(f_b123('aemulus'), skiprows=1, unpack=True,
                    usecols=range(10))

    i_k, j_k, l_k, _, _, _, b123_qpm, q123_qpm, counts_qpm, _ = \
            np.loadtxt(f_b123('qpm'), skiprows=1, unpack=True,
                    usecols=range(10))

    fig = plt.figure(figsize=(10, 5))
    sub = fig.add_subplot(111)
    #klim = ((i_k*kf <= 0.22) & (i_k*kf >= 0.03) &
    #        (j_k*kf <= 0.22) & (j_k*kf >= 0.03) &
    #        (l_k*kf <= 0.22) & (l_k*kf >= 0.03))
    klim = ((i_k * kf <= 0.22) & (j_k * kf <= 0.22) & (l_k * kf <= 0.22))
    print('%i triangle configurations' % np.sum(klim))
    i_k, j_k, l_k = i_k[klim], j_k[klim], l_k[klim]
    b123_aem = b123_aem[klim]
    q123_aem = q123_aem[klim]
    b123_qpm = b123_qpm[klim]
    q123_qpm = q123_qpm[klim]

    counts_aem = counts_aem[klim]
    counts_qpm = counts_qpm[klim]

    ijl = UT.ijl_order(i_k, j_k, l_k, typ='GM')  # order of triangles

    sub.scatter(range(np.sum(klim)),
                b123_aem[ijl],
                c='k',
                s=5,
                label='Aemulus')
    sub.plot(range(np.sum(klim)), b123_aem[ijl], c='k')

    sub.scatter(range(np.sum(klim)), b123_qpm[ijl], c='C1', s=5, label='QPM')
    sub.plot(range(np.sum(klim)), b123_qpm[ijl], c='C1')
    sub.legend(loc='upper right', markerscale=4, handletextpad=0., fontsize=20)
    sub.set_ylabel('$B(k_1, k_2, k_3)$', fontsize=25)
    sub.set_yscale('log')
    sub.set_ylim([1e8, 1e10])
    sub.set_xlabel(r'$k_1 \le k_2 \le k_3$ triangle indices', fontsize=25)
    sub.set_xlim([0, np.sum(klim)])
    fig.savefig(os.path.join(dir_dat, 'qpm',
                             'B123_qpm_aemulus%s.png' % str_rsd),
                bbox_inches='tight')
    fig.savefig(os.path.join(dir_dat, 'qpm',
                             'B123_qpm_aemulus%s.pdf' % str_rsd_pdf),
                bbox_inches='tight')

    fig = plt.figure(figsize=(10, 5))
    sub = fig.add_subplot(111)
    sub.scatter(range(np.sum(klim)),
                q123_aem[ijl],
                c='k',
                s=2,
                label='Aemulus')
    sub.plot(range(np.sum(klim)), q123_aem[ijl], c='k')
    sub.scatter(range(np.sum(klim)), q123_qpm[ijl], c='C1', s=2, label='QPM')
    sub.plot(range(np.sum(klim)), q123_qpm[ijl], c='C1')
    sub.legend(loc='lower left', handletextpad=0., markerscale=4, fontsize=25)
    sub.set_ylabel('$Q(k_1, k_2, k_3)$', fontsize=25)
    sub.set_xlabel(r'$k_1 \le k_2 \le k_3$ triangle indices', fontsize=25)
    #sub.set_xlabel('$k_1 > k_2 > k_3$ triangle indices', fontsize=25)
    sub.set_xlim([0, np.sum(klim)])
    sub.set_ylim([0., 1.])
    fig.savefig(os.path.join(dir_dat, 'qpm',
                             'Q123_qpm_aemulus%s.png' % str_rsd),
                bbox_inches='tight')
    fig.savefig(os.path.join(dir_dat, 'qpm',
                             'Q123_qpm_aemulus%s.pdf' % str_rsd_pdf),
                bbox_inches='tight')

    # plot Q shape triangle plot
    nbin = 13
    x_bins = np.linspace(0., 1., nbin + 1)
    y_bins = np.linspace(0.5, 1., (nbin // 2) + 1)
    print(y_bins)

    fig = plt.figure(figsize=(12, 4))
    sub = fig.add_subplot(121)
    Bgrid = Plots._BorQgrid(
        l_k.astype(float) / i_k.astype(float),
        j_k.astype(float) / i_k.astype(float), q123_qpm, counts_qpm, x_bins,
        y_bins)
    bplot = plt.pcolormesh(x_bins,
                           y_bins,
                           Bgrid.T,
                           vmin=0,
                           vmax=1,
                           cmap='RdBu')

    sub.text(0.95,
             0.05,
             'QPM',
             ha='right',
             va='bottom',
             transform=sub.transAxes,
             fontsize=25)
    sub.set_ylabel('$k_2/k_1$', fontsize=25)

    sub = fig.add_subplot(122)
    Bgrid = Plots._BorQgrid(
        l_k.astype(float) / i_k.astype(float),
        j_k.astype(float) / i_k.astype(float), q123_aem, counts_aem, x_bins,
        y_bins)
    bplot = plt.pcolormesh(x_bins,
                           y_bins,
                           Bgrid.T,
                           vmin=0,
                           vmax=1,
                           cmap='RdBu')
    sub.text(0.95,
             0.05,
             'Aemulus',
             ha='right',
             va='bottom',
             transform=sub.transAxes,
             fontsize=25)

    bkgd = fig.add_subplot(111, frameon=False)
    bkgd.tick_params(labelcolor='none',
                     top=False,
                     bottom=False,
                     left=False,
                     right=False)
    bkgd.set_xlabel(r'$k_3/k_1$', labelpad=10, fontsize=25)

    cbar_ax = fig.add_axes([0.925, 0.15, 0.01, 0.7])
    cbar = fig.colorbar(bplot, cax=cbar_ax)
    cbar.set_label('$Q(k_1, k_2, k_3)$', labelpad=10, rotation=90, fontsize=20)

    fig.subplots_adjust(wspace=0.15)
    fig.savefig(os.path.join(dir_dat, 'qpm',
                             'Q123_shape_qpm_aemulus%s.png' % str_rsd),
                bbox_inches='tight')
    fig.savefig(os.path.join(dir_dat, 'qpm',
                             'Q123_shape_qpm_aemulus%s.pdf' % str_rsd_pdf),
                bbox_inches='tight')
    return None