예제 #1
0
def three_fields_corner_plot():
    survey = 'CCAT-p'
    lines = ['6-5', '5-4', '4-3']
    
    b = 3
    bandwidth = 60
    kmax = 1
    
    zobs = 0.88
    nuemit = np.array([CO_data.CO_lines[l] for l in lines])
    nuobs = nuemit / (1.+zobs)

    Vsurv = CO_data.calc_Vsurv(nuobs[0], nuemit[0], bandwidth, CO_data.survey_area[survey], cosmo)
    
    Blist, Nlist = CO_data.gen_Blist_Nlist(3, bandwidth, kmax, zobs, lines, survey, cosmo)

    tf = threefield(zobs, Blist, Nlist, kmax, Vsurv, cosmo)
    labels = [r'$B_{6-5}\,[\,\text{Jy}/\text{str}\,]$', r'$B_{5-4}\,[\,\text{Jy}/\text{str}\,]$', 
              r'$B_{4-3}\,[\,\text{Jy}/\text{str}\,]$']
    fig, ax, _ = corner_plot(zobs, Blist, Nlist, cosmo, 1.75, tf=tf, labels=labels, printtext=False)
    fig.tight_layout()
    fig.savefig('CO_tf.pdf')
예제 #2
0
def intensity_power_spectrum(z,
                             b,
                             I,
                             cosmo,
                             kmin=1E-3,
                             kmax=1,
                             nk=256,
                             nmu=256,
                             distort=False,
                             ztarget=None,
                             returnk=False,
                             angle_averaged=False):
    klist = np.logspace(np.log10(kmin), np.log10(kmax), nk)
    mulist = np.linspace(-1, 1, nmu)

    if distort:
        assert ztarget is not None, "Must specify ztarget to distort!"
        apar, aperp = alpha_factors(ztarget, z, cosmo)
    else:
        apar, aperp = None, None

    # generate distorted k, mu - if applicable
    # otherwise kdist, mudist = k, mu
    k, mu = gen_k_meshgrid(klist, mulist)
    kdist, mudist = gen_k_meshgrid(klist,
                                   mulist,
                                   distort=distort,
                                   apar=apar,
                                   aperp=aperp)

    Pden = cosmo.matterPowerSpectrum(kdist, z)

    B = b * I

    # compute prefactor from kaiser effect
    beta_z = fomega(z, cosmo) / b
    kaiser = np.add(1., np.multiply(beta_z, np.square(mudist)))
    kaiser = np.square(kaiser)

    # compute prefactor from fingerofgod effect
    sp2 = sigmap2(z, b, cosmo)
    x2 = sp2 * (kdist * cosmo.h)**2 * mu**2
    fingerofgod = 1. / (1. + x2)

    # compute shot noise
    SFR, phi, alpha = CO_data._find_nearest_smit_(z, CO_data.smit_unlog_table)
    shot = I**2 * (2. + alpha) / (phi * gamma(2. + alpha))
    shot *= CO_data.smit_h3

    # put all the pieces together
    Pintensity = np.multiply(
        np.multiply(np.multiply(B**2, kaiser), fingerofgod), Pden)
    Pintensity = np.add(Pintensity, shot)

    # add in prefactor if distorted
    if distort:
        Pintensity = np.divide(Pintensity, apar * aperp**2)

    # angle average, if necessary
    if angle_averaged:
        k, Pintensity = _angle_average_ps_(k, mu, Pintensity)

    # return
    if returnk:
        if angle_averaged:
            return k, Pintensity
        else:
            return k, mu, Pintensity
    else:
        return Pintensity
예제 #3
0
def plot_CII_ps(z=7, name='CIIps_z7.pdf'):

    kmin = 0.01
    kmax = 10

    l = 'CII'
    lint = ['3-2', '4-3', '5-4', '6-5']
    # lint = ['2-1', '3-2', '4-3', '5-4', '6-5', '7-6', '8-7', '9-8', '10-9', '11-10', '12-11', '13-12']

    nue = CO_data.CO_lines_LT16[l]
    L0 = CO_data.CO_L0[l]
    Il = CO_data.avg_int(L0,
                         z,
                         CO_data.smit_unlog_table,
                         nue,
                         cosmo,
                         smooth=False)
    bl = 3

    k, Pi = mf.intensity_power_spectrum(z,
                                        bl,
                                        Il,
                                        cosmo,
                                        kmin=kmin,
                                        kmax=kmax,
                                        returnk=True,
                                        angle_averaged=True)

    del2 = k**3 * Pi / (2. * np.pi**2)

    fig, ax = plt.subplots(1, 1)

    ax.plot(k, del2, c=tb_c[-1], label=r'CII')

    del2int = np.zeros(np.shape(del2))
    del2int_dist = np.zeros(np.shape(del2))
    ICOtot = 0
    for li in lint:
        nue_i = CO_data.CO_lines_LT16[li]
        L0 = CO_data.CO_L0[li]
        zint = (nue_i / nue) * (1 + z)
        zint -= 1

        if zint > 0:

            Ii = CO_data.avg_int(L0,
                                 zint,
                                 CO_data.smit_unlog_table,
                                 nue_i,
                                 cosmo,
                                 smooth=False)
            print(li, zint, Ii, Ii / Il)
            ICOtot += Ii
            bi = 2
            k, Pi = mf.intensity_power_spectrum(zint,
                                                bi,
                                                Ii,
                                                cosmo,
                                                kmin=kmin,
                                                kmax=kmax,
                                                returnk=True,
                                                angle_averaged=True,
                                                distort=False,
                                                ztarget=z)

            k, Pidist = mf.intensity_power_spectrum(zint,
                                                    bi,
                                                    Ii,
                                                    cosmo,
                                                    kmin=kmin,
                                                    kmax=kmax,
                                                    returnk=True,
                                                    angle_averaged=True,
                                                    distort=True,
                                                    ztarget=z)

            del2 = k**3 * Pi / (2. * np.pi**2)
            del2_dist = k**3 * Pidist / (2. * np.pi**2)

            del2int += del2
            del2int_dist += del2_dist

    print('ICO tot:', ICOtot)
    ax.plot(k, del2int, c=tb_c[2], label='CO interlopers')
    ax.plot(k, del2int_dist, c=tb_c[0], label='CO interlopers, distorted')

    # now plot values from LT16
    LT16_target = np.genfromtxt('LT16_fig3/delta_mon_quad_target_z7.dat')
    LT16_COnodist = np.genfromtxt(
        'LT16_fig3/delta_mon_quad_int_nodist_all.dat')
    LT16_COdist = np.genfromtxt('LT16_fig3/delta_mon_quad_int_all.dat')

    s = 0.5
    ax.scatter(LT16_target[:, 0], LT16_target[:, 1], c='k', s=s)
    ax.scatter(LT16_COnodist[:, 0], LT16_COnodist[:, 1], c='r', s=s)
    ax.scatter(LT16_COdist[:, 0], LT16_COdist[:, 1], c='b', s=s)

    ax.set_xscale('log')
    ax.set_yscale('log')

    ax.set_xlabel(r'$k\,[\,h/\text{Mpc}\,]$')
    ax.set_ylabel(r'$\Delta^2 (k)\,[\,\text{Jy}^2/\text{str}^2\,]$')

    ax.set_xlim([0.01, 10])
    ax.set_ylim([10, 1E8])

    ax.legend()
    ax.set_title('z=' + str(z))

    fig.tight_layout()
    fig.savefig(name)
예제 #4
0
def plot_all_SN(survey, lines, zbounds=[0, 10], nz=1000):

    freq_range = CO_data.survey_freq_range[survey]

    b = 3
    bandwidth = 60
    kmax = 1

    # Vsurv = CO_data.calc_Vsurv(nuobs[0], nuemit[0], bandwidth, CO_data.survey_area[survey], cosmo)
    
    # Blist, Nlist = CO_data.gen_Blist_Nlist(3, bandwidth, kmax, zobs, lines, survey, cosmo)

    zextent_list = []
    for l in lines:
        nuemit = CO_data.CO_lines[l]
        zextent = (nuemit - freq_range)/freq_range
        zextent_list.append(np.flip(zextent))
    zextent_list = np.array(zextent_list)
    print(zextent_list)

    zlist = np.linspace(zbounds[0], zbounds[1], nz)
    lines_obs_list = []
    tf_bool_list = []

    for z in zlist:
        bool1 = z > zextent_list[:,0]
        bool2 = z < zextent_list[:,1]

        keys = np.where(np.logical_and(bool1, bool2))[0]

        lines_obs = [ lines[k] for k in keys ]

        lines_obs_list.append(lines_obs)

        if len(lines_obs) >= 3:
            tf_bool_list.append(True)
        else:
            tf_bool_list.append(False)

    mf_keys = np.where(tf_bool_list)[0]

    # first generate the S/N Cramer-Rao bound for the auto-spectrum
    # this is done at every redshift for each line that is in band

    SN_auto_list = []
    SN_mf_list = []
    for z, lines_at_z, mfbool in zip(zlist, lines_obs_list, tf_bool_list):
        SN = np.zeros(np.shape(lines))
        SN_mf = np.zeros(np.shape(lines))
        
        nuemit = CO_data.CO_lines[l]
        nuobs = nuemit / (1.+z)
        
        Vsurv = CO_data.calc_Vsurv(nuobs, nuemit, bandwidth, CO_data.survey_area[survey], cosmo)
        
        Blist, Nlist = CO_data.gen_Blist_Nlist(3, bandwidth, kmax, z, lines_at_z, survey, cosmo)

        mf = multifield(z, Blist, Nlist, kmax, Vsurv, cosmo)
        Vk = _Vk_(mf.klist, mf.Pklist, Vsurv)

        for i,l in enumerate(lines_at_z):
            for key, lp in enumerate(lines):
                if l == lp:
                    SN[key] = Blist[i]**2 * Vk / Nlist[i]

        if mfbool:
            cov = np.linalg.inv(mf.fmat)
            noise = np.sqrt(np.diag(cov))
            sn = Blist / noise

            for i,l in enumerate(lines_at_z):
                for key, lp in enumerate(lines):
                    if l == lp:
                        SN_mf[key] = sn[i]

        SN_auto_list.append(SN)
        SN_mf_list.append(SN_mf)

    SN_auto_list = np.array(SN_auto_list)
    SN_mf_list = np.array(SN_mf_list)

    for i,l in enumerate(lines):
        plt.plot(zlist, SN_auto_list[:,i], ls='dashed', c=tb_c[i])
        plt.plot(zlist, SN_mf_list[:,i], label=l, c=tb_c[i])

    # now generate the S/N Cramer-Rao bound for the auto-spectrum
    # done at redshifts where we have >= 3 fields

    plt.xlabel(r'$z$')
    plt.ylabel(r'$\text{S}/\text{N}(B)$')
    plt.yscale('log')

    plt.xlim(zbounds)

    plt.legend(frameon=False, title=r'$B$')
    plt.show()

    return zlist, SN_auto_list
예제 #5
0
def plot_intensity_vs_z():

    c1 = Color(tb_c[7])
    c2 = Color(tb_c[0])
    c3 = Color(tb_c[7])

    clist1 = list(c3.range_to(c2, 10))
    clist2 = list(c2.range_to(c1, 4))
    clist2 = clist2[1:]

    clist = np.append(clist1, clist2)
    clist = [c.get_hex() for c in clist]
    clist.append(tb_c[-1])

    lslist = [
        'dashed', 'dashed', 'dashed', 'dashed', 'dashed', 'dashed', 'dashed',
        'dashed', 'dashed', None, None, None, None, None
    ]

    xlist = [
        2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 1.75, 1.25, 1.5, 1.5, 8
    ]

    lines = [
        '13-12', '12-11', '11-10', '10-9', '9-8', '8-7', '7-6', '6-5', '5-4',
        '4-3', '3-2', '2-1', '1-0', 'CII'
    ]

    zlist = np.linspace(0, 10, 100)
    sigma = 1
    stable = CO_data.smit_unlog_table

    avg_int_list = {}

    for l in lines:
        nuemit = CO_data.CO_lines[l]
        L0 = CO_data.CO_L0[l]
        avg_int_list[l] = CO_data.avg_int(L0,
                                          zlist,
                                          stable,
                                          nuemit,
                                          cosmo,
                                          smooth=True,
                                          sigma=sigma)

    fig, ax = plt.subplots(1, 1, figsize=(7, 7))
    for l, c, ls in zip(lines, clist, lslist):
        ax.plot(zlist, avg_int_list[l], label=l, c=c, ls=ls)

    labelLines(ax.get_lines(),
               zorder=2.5,
               bbox={
                   'pad': 0,
                   'facecolor': 'white',
                   'edgecolor': 'white'
               },
               xvals=xlist,
               fontsize=7.5)

    ax.set_yscale('log')

    ax.set_xlabel(r'$z$')
    ax.set_ylabel(r'$\left< I \right> \,[\,\text{Jy}/\text{str}\,]$')

    fig.savefig('intensity_vs_z.pdf')
예제 #6
0
def plot_intensity_vs_nu(kplot=0.7, sigma=1):

    nulist = np.linspace(170, 270, 100)

    ltarget = 'CII'
    linterlopers = [
        '13-12', '12-11', '11-10', '10-9', '9-8', '8-7', '7-6', '6-5', '5-4',
        '4-3', '3-2', '2-1', '1-0'
    ]

    nuemit_int = [CO_data.CO_lines[l] for l in linterlopers]
    L0l_list = [CO_data.CO_L0[l] for l in linterlopers]

    nuemit_target = CO_data.CO_lines[ltarget]
    zlist = (nuemit_target - nulist) / nulist

    L0target = CO_data.CO_L0[ltarget]
    Itarget = np.array([
        CO_data.avg_int(L0target,
                        z,
                        CO_data.smit_unlog_table,
                        nuemit_target,
                        cosmo,
                        smooth=False,
                        sigma=sigma) for z in zlist
    ])

    Patk_target = []
    Patk_int = {l: [] for l in linterlopers}

    for z, nu, It in zip(tqdm(zlist), nulist, Itarget):
        k, Ptarget = mf.intensity_power_spectrum(z,
                                                 3,
                                                 It,
                                                 cosmo,
                                                 returnk=True,
                                                 angle_averaged=True)

        Pk = np.interp(kplot, k, Ptarget)
        Patk_target.append(Pk)

        for l, nue, L0l in zip(linterlopers, nuemit_int, L0l_list):
            zl = (nue / nuemit_target) * (1 + z) - 1
            if zl >= 0.0:
                Itarget = CO_data.avg_int(L0l,
                                          np.array([zl]),
                                          CO_data.smit_unlog_table,
                                          nue,
                                          cosmo,
                                          smooth=True,
                                          sigma=sigma)[0]
                Pl = mf.intensity_power_spectrum(zl,
                                                 2,
                                                 It,
                                                 cosmo,
                                                 angle_averaged=True)

                Pk = np.interp(kplot, k, Pl)
                Patk_int[l].append(Pk)

            else:
                Patk_int[l].append(0)

    Patk_target = np.array(Patk_target)
    for l in linterlopers:
        Patk_int[l] = np.array(Patk_int[l])

    fig, ax = plt.subplots(1, 1)

    ax.plot(zlist,
            kplot**3 * Patk_target / (2. * np.pi**2),
            c=tb_c[0],
            label=ltarget)

    Ptot = np.zeros(np.shape(Patk_target))
    # for l in linterlopers:
    for l in ['2-1', '3-2', '4-3', '5-4', '6-5', '7-6']:
        ax.plot(zlist, kplot**3 * Patk_int[l] / (2. * np.pi**2), label=l)
        Ptot += Patk_int[l]

    print(Ptot)
    ax.plot(zlist, kplot**3 * Ptot / (2. * np.pi**2), c='k', label='int tot')
    ax.legend()

    ax.set_yscale('log')

    ax.set_xlabel(r'$z_{\text{C~\textsc{ii}}}$')
    ax.set_ylabel(r'$\Delta^2 (k)$')

    plt.show()
예제 #7
0
    'ns': 1.0
}
cosmo = cosmology.setCosmology('myCosmo', params)

survey = 'CCAT-p'
lines = ['6-5', '5-4', '4-3']

b = 3
bandwidth = 60
kmax = 1

zobs = 0.88
nuemit = np.array([CO_data.CO_lines[l] for l in lines])
nuobs = nuemit / (1. + zobs)

Blist, Nlist = CO_data.gen_Blist_Nlist(3, bandwidth, kmax, zobs, lines, survey,
                                       cosmo)

Vsurv = CO_data.calc_Vsurv(nuobs[0], nuemit[0], bandwidth,
                           CO_data.survey_area[survey], cosmo)

fig, ax, _ = corner_plot(1,
                         np.array([1, 2, 3]),
                         np.array([100, 100, 100]),
                         cosmo,
                         0.25,
                         kmax=1,
                         Vk=200000,
                         norm=True,
                         intstr=True)
fig.tight_layout()
fig.savefig('corner_Nconstant.pdf')
예제 #8
0
tb_c = [
    '#4e79a7', '#f28e2b', '#e15759', '#76b7b2', '#59a14f', '#edc948',
    '#b07aa1', '#ff9da7', '#9c755f', '#bab0ac'
]

stable = CO_data.smit_unlog_table

Jlist = np.arange(3, 13)
Jlist_label = [str(J) + '-' + str(J - 1) for J in Jlist]
freqlist = [CO_data.CO_lines_LT16[Jlabel] for Jlabel in Jlist_label]  # in GHz

ICOlist = []
ztarget = 7
nuCII = CO_data.CO_lines_LT16['CII']
L0CII = CO_data.CO_L0['CII']
ICII = CO_data.avg_int(L0CII, ztarget, stable, nuCII, cosmo)

for l, nu in zip(Jlist_label, freqlist):
    zinterloper = (nu / nuCII) * (1 + ztarget) - 1

    L0 = CO_data.CO_L0[l]
    inten = CO_data.avg_int(L0, zinterloper, stable, nu, cosmo)
    ICOlist.append(inten)

ICOlist = np.array(ICOlist)

fig, ax = plt.subplots(1, 1)

ax.scatter(Jlist, ICOlist / ICII)

ax.set_xlabel(r'$J$')