Пример #1
0
def plot_all_rho(simlist):
    """Make the rho_HI plot with labels etc"""
    #Cosmo0
    for i in simlist:   #xrange(8):
        (zzz,dndx,omegadla) = get_rhohi_dndx(i)
        plt.figure(1)
        plt.plot(zzz,dndx, 'o', color=colors[i], ls=lss[i], label=labels[i])
        plt.figure(2)
        plt.plot(zzz,omegadla, 'o', color=colors[i], ls=lss[i],label=labels[i])
    plt.figure(1)
    plt.xlabel("z")
    plt.ylabel(r"$dN / dX$")
    dla_data.dndx_not()
    dla_data.dndx_pro()
    plt.xlim(2,4)
    plt.ylim(0,0.13)
    plt.legend(loc=4, ncol=3)
    tight_layout_wrapper()
    save_figure(path.join(outdir,"cosmo_dndx"))
    plt.clf()

    plt.figure(2)
    plt.xlabel("z")
    plt.ylabel(r"$10^3 \Omega_\mathrm{DLA}$")
    dla_data.omegahi_not()
#     dla_data.omegahi_pro()
    plt.xlim(2,4)
    plt.ylim(0,2.)
    plt.legend(loc=4, ncol=3)
    tight_layout_wrapper()
    save_figure(path.join(outdir,"cosmo_rhohi"))
    plt.clf()
def plot_halos(sim, hh):
    """Plot the halo closest in mass and position in the given sim to the halo of the given number in sim 7."""
    ahalo = dp.PrettyHalo(myname.get_name(sim), 3, 20000)
    ahalo7 = dp.PrettyHalo(myname.get_name(7), 3, 20000)
    (mass, cofm, radii) = _load_halo(ahalo, 30)
    (mass7, cofm7, _) = _load_halo(ahalo7, 30)
    dist = np.sum((cofm7[hh] - cofm)**2, axis=1)
    nn = np.where(dist == np.min(dist))
    rhh = hh
    hh = np.ravel(nn)[0]
    print "Requested: ", rhh, "Got: ", hh, " dist:", np.sqrt(
        dist[nn]), " r-mass:", mass[hh] / mass7[rhh], "ormass: ", mass7[rhh]
    plt.title(r"Central Halo: $" +
              dp.pr_num(ahalo.sub_mass[hh] / 0.72 / 1e11) +
              r"\times 10^{11} M_\odot$")
    ahalo.plot_pretty_halo(hh)
    #Backwards because someone is a fortran programmer
    circle = plt.Circle((0, 0), radii[hh], color="black", fill=False)
    ax = plt.gca()
    ax.add_artist(circle)
    #     plot_rvir(ahalo.sub_cofm[hh], cofm, radii,ahalo.sub_radii[hh])
    dp.tight_layout_wrapper()
    save_figure(path.join(outdir, "pretty_" + str(sim) + "_halo_" + str(rhh)))
    plt.clf()
    ahalo.plot_pretty_cut_halo(hh)
    circle = plt.Circle((0, 0), radii[hh], color="black", fill=False)
    ax = plt.gca()
    ax.add_artist(circle)
    #     plot_rvir(ahalo.sub_cofm[hh], cofm, radii,ahalo.sub_radii[hh]/)
    plt.title(labels[sim] + " at z=3")
    dp.tight_layout_wrapper()
    save_figure(
        path.join(outdir, "pretty_cut_" + str(sim) + "_halo_" + str(rhh)))
    plt.clf()
    del ahalo
def plot_dndx_breakdown(sim):
    """Make the rho_HI plot with labels etc"""
    halo = myname.get_name(sim, True, 25)
    snaps = {4: 1, 3.5: 2, 3: 3, 2.5: 4, 2: 5}
    fractions = []
    zzz = []
    omegadla = []
    for zzzz in (4, 3.5, 3, 2.5, 2):
        ahalo = dp.PrettyBox(halo, snaps[zzzz], nslice=10)
        (massbins, fracs) = ahalo.get_omega_hi_mass_breakdown(False)
        fractions.append(fracs)
        zzz.append(zzzz)
        omegadla.append(ahalo.line_density())
    fractions = np.array(fractions)
    for i in xrange(np.size(fractions[0, :]) - 2):
        plt.plot(zzz,
                 fractions[:, i + 1],
                 color=colors[i],
                 ls=lss[i],
                 label=dp.pr_num(np.log10(massbins[i])) + " - " +
                 dp.pr_num(np.log10(massbins[i + 1])))
    plt.plot(zzz, fractions[:, -1], color=colors[6], ls=lss[6], label="Field")
    plt.plot(zzz, omegadla, color=colors[sim], ls=lss[sim], label="Total")
    plt.xlabel("z")
    plt.ylabel(r"$dN/dX$")
    dla_data.dndx_not()
    dla_data.dndx_pro()
    plt.xlim(2, 4)
    plt.ylim(0, 0.15)
    plt.legend(loc=1, ncol=2)
    tight_layout_wrapper()
    save_figure(path.join(outdir, "cosmo_dndx_break" + str(sim)))
    plt.clf()
Пример #4
0
def plot_H2_effect(sim, snap):
    """Load a simulation and plot its cddf"""
    halo = myname.get_name(sim, True)
    savefile = "boxhi_grid_noH2.hdf5"
    ahalo = dp.PrettyBox(halo, snap, nslice=10, savefile=savefile, label=r"No $H_2$")
    ahalo.plot_column_density(color="blue", ls="--", moment=True)
    savefile = "boxhi_grid_H2.hdf5"
    ahalo2 = dp.PrettyBox(halo, snap, nslice=10, savefile=savefile, label=r"$H_2$")
    ahalo2.plot_column_density(color="red",moment=True)
#     savefile = path.join(halo,"snapdir_"+str(snap).rjust(3,'0'),"boxhi_grid_H2-old.hdf5")
#     ahalo2 = dp.PrettyBox(halo, snap, nslice=10, savefile=savefile)
#     ahalo2.plot_column_density(color="green",moment=True)
    dla_data.column_density_data(moment=True)
#     dla_data.noterdaeme_12_data(path.join(path.dirname(__file__),"../dla_data"), moment=True)
    plt.legend(loc=3)
    plt.xlim(1e20,2e22)
    plt.ylim(1e-5,0.1)
#     plt.title("CDDF for "+labels[sim]+" at z="+str(redshifts[snap]))
    save_figure(path.join(outdir, "cosmo"+str(sim)+"_H2_"+str(snap)))
    plt.clf()
    cddf_base = ahalo.column_density_function()
    cddf = ahalo2.column_density_function()
    plt.semilogx(cddf_base[0], np.log10(cddf[1]/cddf_base[1]), color=colors[sim], ls=lss[sim])
    plt.ylim(-0.5,0.5)
    tight_layout_wrapper()
    ax = plt.gca()
    ylab = ax.set_ylabel(r"$N_\mathrm{HI} f(N)$")
    save_figure(path.join(outdir, "cosmo_rel"+str(sim)+"_H2_"+str(snap)))
    plt.clf()
Пример #5
0
def plot_halos(sim,hh):
    """Plot the halo closest in mass and position in the given sim to the halo of the given number in sim 7."""
    ahalo = dp.PrettyHalo(myname.get_name(sim),3,20000)
    ahalo7 = dp.PrettyHalo(myname.get_name(7),3,20000)
    (mass, cofm, radii) = _load_halo(ahalo, 30)
    (mass7, cofm7, _) = _load_halo(ahalo7, 30)
    dist = np.sum((cofm7[hh] - cofm)**2, axis=1)
    nn = np.where( dist == np.min(dist))
    rhh = hh
    hh = np.ravel(nn)[0]
    print "Requested: ",rhh,"Got: ",hh," dist:",np.sqrt(dist[nn])," r-mass:",mass[hh]/mass7[rhh], "ormass: ",mass7[rhh]
    plt.title(r"Central Halo: $"+dp.pr_num(ahalo.sub_mass[hh]/0.72/1e11)+r"\times 10^{11} M_\odot$")
    ahalo.plot_pretty_halo(hh)
    #Backwards because someone is a fortran programmer
    circle=plt.Circle((0,0),radii[hh],color="black",fill=False)
    ax = plt.gca()
    ax.add_artist(circle)
#     plot_rvir(ahalo.sub_cofm[hh], cofm, radii,ahalo.sub_radii[hh])
    dp.tight_layout_wrapper()
    save_figure(path.join(outdir,"pretty_"+str(sim)+"_halo_"+str(rhh)))
    plt.clf()
    ahalo.plot_pretty_cut_halo(hh)
    circle=plt.Circle((0,0),radii[hh],color="black",fill=False)
    ax = plt.gca()
    ax.add_artist(circle)
#     plot_rvir(ahalo.sub_cofm[hh], cofm, radii,ahalo.sub_radii[hh]/)
    plt.title(labels[sim]+" at z=3")
    dp.tight_layout_wrapper()
    save_figure(path.join(outdir,"pretty_cut_"+str(sim)+"_halo_"+str(rhh)))
    plt.clf()
    del ahalo
Пример #6
0
def plot_dndx_breakdown(sim):
    """Make the rho_HI plot with labels etc"""
    halo = myname.get_name(sim, True, 25)
    snaps = {4:1, 3.5:2, 3:3, 2.5:4, 2:5}
    fractions=[]
    zzz = []
    omegadla = []
    for zzzz in (4, 3.5, 3, 2.5, 2):
        ahalo = dp.PrettyBox(halo, snaps[zzzz], nslice=10)
        (massbins, fracs) = ahalo.get_omega_hi_mass_breakdown(False)
        fractions.append(fracs)
        zzz.append(zzzz)
        omegadla.append(ahalo.line_density())
    fractions = np.array(fractions)
    for i in xrange(np.size(fractions[0,:])-2):
        plt.plot(zzz,fractions[:,i+1], color=colors[i], ls=lss[i], label=dp.pr_num(np.log10(massbins[i]))+" - "+dp.pr_num(np.log10(massbins[i+1])))
    plt.plot(zzz,fractions[:,-1], color=colors[6], ls=lss[6], label="Field")
    plt.plot(zzz,omegadla, color=colors[sim], ls=lss[sim], label="Total")
    plt.xlabel("z")
    plt.ylabel(r"$dN/dX$")
    dla_data.dndx_not()
    dla_data.dndx_pro()
    plt.xlim(2,4)
    plt.ylim(0,0.15)
    plt.legend(loc=1, ncol=2)
    tight_layout_wrapper()
    save_figure(path.join(outdir,"cosmo_dndx_break"+str(sim)))
    plt.clf()
Пример #7
0
def plot_rel_cddf(snap):
    """Load and make a plot of the difference between two simulations"""
    basen = myname.get_name(7)
    base = dp.PrettyBox(basen, snap, nslice=10)
    cddf_base = base.column_density_function()
    for xx in (0,4,2,1,3,9):
        halo2 = myname.get_name(xx)
        ahalo2 = dp.PrettyBox(halo2, snap, nslice=10)
        cddf = ahalo2.column_density_function()
        plt.semilogx(cddf_base[0], cddf[1]/cddf_base[1], color=colors[xx], ls=lss[xx], label=labels[xx])
    plt.legend(loc=3, ncol=2)
    plt.xlabel(r"$N_\mathrm{HI}$ (cm$^{-2}$)")
    plt.ylabel(r"$f(N)/f_\mathrm{"+labels[7]+"}(N)$")
    plt.title("CDDF relative to "+labels[7]+" at z="+str(redshifts[snap]))
    plt.ylim(-0.2,1.8)
    plt.xlim(1e17, 1e22)
    tight_layout_wrapper()
    save_figure(path.join(outdir,"cosmo_rel_cddf_z"+str(snap)))
    plt.clf()
def plot_H2_effect(sim, snap):
    """Load a simulation and plot its cddf"""
    halo = myname.get_name(sim, True)
    savefile = "boxhi_grid_noH2.hdf5"
    ahalo = dp.PrettyBox(halo,
                         snap,
                         nslice=10,
                         savefile=savefile,
                         label=r"No $H_2$")
    ahalo.plot_column_density(color="blue", ls="--", moment=True)
    savefile = "boxhi_grid_H2.hdf5"
    ahalo2 = dp.PrettyBox(halo,
                          snap,
                          nslice=10,
                          savefile=savefile,
                          label=r"$H_2$")
    ahalo2.plot_column_density(color="red", moment=True)
    #     savefile = path.join(halo,"snapdir_"+str(snap).rjust(3,'0'),"boxhi_grid_H2-old.hdf5")
    #     ahalo2 = dp.PrettyBox(halo, snap, nslice=10, savefile=savefile)
    #     ahalo2.plot_column_density(color="green",moment=True)
    dla_data.column_density_data(moment=True)
    #     dla_data.noterdaeme_12_data(path.join(path.dirname(__file__),"../dla_data"), moment=True)
    plt.legend(loc=3)
    plt.xlim(1e20, 2e22)
    plt.ylim(1e-5, 0.1)
    #     plt.title("CDDF for "+labels[sim]+" at z="+str(redshifts[snap]))
    save_figure(path.join(outdir, "cosmo" + str(sim) + "_H2_" + str(snap)))
    plt.clf()
    cddf_base = ahalo.column_density_function()
    cddf = ahalo2.column_density_function()
    plt.semilogx(cddf_base[0],
                 np.log10(cddf[1] / cddf_base[1]),
                 color=colors[sim],
                 ls=lss[sim])
    plt.ylim(-0.5, 0.5)
    tight_layout_wrapper()
    ax = plt.gca()
    ylab = ax.set_ylabel(r"$N_\mathrm{HI} f(N)$")
    save_figure(path.join(outdir, "cosmo_rel" + str(sim) + "_H2_" + str(snap)))
    plt.clf()
def plot_all_rho(simlist):
    """Make the rho_HI plot with labels etc"""
    #Cosmo0
    for i in simlist:  #xrange(8):
        (zzz, dndx, omegadla) = get_rhohi_dndx(i)
        plt.figure(1)
        plt.plot(zzz, dndx, 'o', color=colors[i], ls=lss[i], label=labels[i])
        plt.figure(2)
        plt.plot(zzz,
                 omegadla,
                 'o',
                 color=colors[i],
                 ls=lss[i],
                 label=labels[i])
    plt.figure(1)
    plt.xlabel("z")
    plt.ylabel(r"$dN / dX$")
    dla_data.dndx_not()
    dla_data.dndx_pro()
    plt.xlim(2, 4)
    plt.ylim(0, 0.13)
    plt.legend(loc=4, ncol=3)
    tight_layout_wrapper()
    save_figure(path.join(outdir, "cosmo_dndx"))
    plt.clf()

    plt.figure(2)
    plt.xlabel("z")
    plt.ylabel(r"$10^3 \Omega_\mathrm{DLA}$")
    dla_data.omegahi_not()
    #     dla_data.omegahi_pro()
    plt.xlim(2, 4)
    plt.ylim(0, 2.)
    plt.legend(loc=4, ncol=3)
    tight_layout_wrapper()
    save_figure(path.join(outdir, "cosmo_rhohi"))
    plt.clf()
def plot_rel_cddf(snap):
    """Load and make a plot of the difference between two simulations"""
    basen = myname.get_name(7)
    base = dp.PrettyBox(basen, snap, nslice=10)
    cddf_base = base.column_density_function()
    for xx in (0, 4, 2, 1, 3, 9):
        halo2 = myname.get_name(xx)
        ahalo2 = dp.PrettyBox(halo2, snap, nslice=10)
        cddf = ahalo2.column_density_function()
        plt.semilogx(cddf_base[0],
                     cddf[1] / cddf_base[1],
                     color=colors[xx],
                     ls=lss[xx],
                     label=labels[xx])
    plt.legend(loc=3, ncol=2)
    plt.xlabel(r"$N_\mathrm{HI}$ (cm$^{-2}$)")
    plt.ylabel(r"$f(N)/f_\mathrm{" + labels[7] + "}(N)$")
    plt.title("CDDF relative to " + labels[7] + " at z=" +
              str(redshifts[snap]))
    plt.ylim(-0.2, 1.8)
    plt.xlim(1e17, 1e22)
    tight_layout_wrapper()
    save_figure(path.join(outdir, "cosmo_rel_cddf_z" + str(snap)))
    plt.clf()
                plot_cddf_a_halo(ss, zz, moment=True)

        if zz == 3:
            dla_data.column_density_data(moment=True)
        if zz == 4:
            dla_data.noterdaeme_12_data(path.join(path.dirname(__file__),
                                                  "../dla_data"),
                                        moment=True)
            plt.xlim(1e20, 5e22)
            plt.ylim(ymax=0.1)
#             dla_data.zafar_data(path.join(path.dirname(__file__),"../dla_data"), moment=True)

        plt.legend(loc=3)
        ax = plt.gca()
        ylab = ax.set_ylabel(r"$N_\mathrm{HI} f(N)$")
        tight_layout_wrapper()
        save_figure(path.join(outdir, "cosmo_cddf_z" + str(zz) + "_moment"))
        plt.clf()

    for zz in (1, 3, 5):
        plot_rel_cddf(zz)
        plot_halohist(zz)
#         multi_halohist(zz)
#         plot_halohist(zz, False)

#Make a plot of the effect of AGN on the cddf.
    for ss in (2, 1):
        plot_cddf_a_halo(ss, 4, moment=True)
    for ss in (0, 4):
        plot_cddf_a_halo(ss, 4, moment=True)
    plt.legend(loc=3)
Пример #12
0
    plt.figure(1)

    # Load only the nHI grids
    hplots = dp.HaloHIPlots(base, snapnum, minpart=minpart)

    if len(sys.argv) < 2 or int(sys.argv[1]) == 2:
        # low-mass halo radial profile
        hplots.plot_radial_profile(minM=3e9, maxM=3.5e9, maxR=10.0)
        plt.ylim(ymax=27)
        save_figure(path.join(outdir, "radial_profile_halo_low_" + str(snapnum)))
        plt.clf()

        hplots.ahalo.plot_pretty_halo(0)
        plt.title(r"Arepo, $\mathrm{z}=" + dp.pr_num(hplots.ahalo.redshift, 1) + "$")
        dp.tight_layout_wrapper()
        save_figure(path.join(outdir, "Arepo_" + str(snapnum) + "pretty_halo"))
        plt.clf()
        # Get the right halo
        g_halo_0 = hplots.ghalo.identify_eq_halo(hplots.ahalo.sub_mass[0], hplots.ahalo.sub_cofm[0, :], maxpos=50.0)[0]
        try:
            a_shalo = np.min(np.where(hplots.ahalo.sub_mass < 1e10))
            # Get the right halo for a smaller halo
            s_mass = hplots.ahalo.sub_mass[a_shalo]
            s_pos = hplots.ahalo.sub_cofm[a_shalo, :]
            g_shalo = hplots.ghalo.identify_eq_halo(s_mass, s_pos)
            # Make sure it has a gadget counterpart
            if np.size(g_shalo) == 0:
                nosmall = 1
                for i in np.where(hplots.ahalo.sub_mass < 1e10)[0]:
                    s_mass = hplots.ahalo.sub_mass[i]
Пример #13
0
                plot_cddf_a_halo(3, 3, moment=True)
            else:
                plot_cddf_a_halo(ss, zz,moment=True)

        if zz==3 :
            dla_data.column_density_data(moment=True)
        if zz == 4:
            dla_data.noterdaeme_12_data(path.join(path.dirname(__file__),"../dla_data"), moment=True)
            plt.xlim(1e20,5e22)
            plt.ylim(ymax=0.1)
#             dla_data.zafar_data(path.join(path.dirname(__file__),"../dla_data"), moment=True)

        plt.legend(loc=3)
        ax = plt.gca()
        ylab = ax.set_ylabel(r"$N_\mathrm{HI} f(N)$")
        tight_layout_wrapper()
        save_figure(path.join(outdir,"cosmo_cddf_z"+str(zz)+"_moment"))
        plt.clf()

    for zz in (1,3,5):
        plot_rel_cddf(zz)
        plot_halohist(zz)
#         multi_halohist(zz)
#         plot_halohist(zz, False)

    #Make a plot of the effect of AGN on the cddf.
    for ss in (2,1):
        plot_cddf_a_halo(ss, 4, moment=True)
    for ss in (0,4):
        plot_cddf_a_halo(ss, 4, moment=True)
    plt.legend(loc=3)
Пример #14
0
    plt.figure(1)

    #Load only the nHI grids
    hplots=dp.HaloHIPlots(base,snapnum,minpart=minpart)

    if len(sys.argv) < 2 or int(sys.argv[1]) == 2:
        #low-mass halo radial profile
        hplots.plot_radial_profile(minM=3e9, maxM=3.5e9,maxR=10.)
        plt.ylim(ymax = 27)
        save_figure(path.join(outdir,"radial_profile_halo_low_"+str(snapnum)))
        plt.clf()

        hplots.ahalo.plot_pretty_halo(0)
        plt.title(r"Arepo, $\mathrm{z}="+dp.pr_num(hplots.ahalo.redshift,1)+"$")
        dp.tight_layout_wrapper()
        save_figure(path.join(outdir,"Arepo_"+str(snapnum)+"pretty_halo"))
        plt.clf()
        #Get the right halo
        g_halo_0 = hplots.ghalo.identify_eq_halo(hplots.ahalo.sub_mass[0],hplots.ahalo.sub_cofm[0,:],maxpos=50.)[0]
        try:
            a_shalo=np.min(np.where(hplots.ahalo.sub_mass < 1e10))
            #Get the right halo for a smaller halo
            s_mass=hplots.ahalo.sub_mass[a_shalo]
            s_pos=hplots.ahalo.sub_cofm[a_shalo,:]
            g_shalo = hplots.ghalo.identify_eq_halo(s_mass,s_pos)
            #Make sure it has a gadget counterpart
            if np.size(g_shalo) == 0:
                nosmall=1
                for i in np.where(hplots.ahalo.sub_mass < 1e10)[0]:
                    s_mass=hplots.ahalo.sub_mass[i]