Пример #1
0
def plot_vel_width_sims(sims, snap, log=False):
    """Plot velocity widths for a series of simulations"""
    vel_data.plot_prochaska_2008_data()
    for sss in sims:
        #Make abs. plot
        hspec = get_hspec(sss, snap)
        hspec.plot_vel_width("Si", 2, color=colors[sss], ls=lss[sss])
    outstr = "cosmo_vel_width_z"+str(snap)
    if log:
        ax = plt.gca()
        ax.set_yscale('log')
        plt.ylim(5e-2,10)
        outstr+="_log"
    else:
        plt.ylim(1e-2,2)
    hspec = get_hspec(5, snap, box=10)
    hspec.label=labels["S"]
    hspec.plot_vel_width("Si", 2, color=colors["S"], ls="--")
    hspec.plot_vw_errors("Si", 2, samples=100,cumulative=False, color=colors2["S"])
    plt.xlabel(r"$v_\mathrm{90}$ (km s$^{-1}$)")
#     plt.ylabel("Spectra per log interval")
    plt.xlim(10,1000)
    plt.xticks([10, 100, 1000],["10","100","1000"])
    plt.legend(loc=2,ncol=3)
    save_figure(path.join(outdir,outstr))
    plt.clf()
Пример #2
0
def do_length_split(cat, subdir):
    """Check the effect of the quasar redshift."""
    #Check z_qso split
    oldcond = cat.condition
    high_z = (0.2, 0.4, 0.6, 0.8, 2)
    low_z = (0., 0.2, 0.4, 0.6, 0.8)
    z_diff = cat.z_max() - cat.z_min()
    for (high_z_qso, z_qso_split) in zip(high_z, low_z):
        cat.condition = (z_diff < high_z_qso) * (z_diff > z_qso_split)
        cat.plot_omega_dla(label=str(high_z_qso) + " > zQSO > " +
                           str(z_qso_split))
    plt.ylim(ymin=0)
    plt.legend(loc=0)
    save_figure(path.join(subdir, "omega_gp_zdiff"))
    plt.clf()

    for (high_z_qso, z_qso_split) in zip(high_z, low_z):
        cat.condition = (z_diff < high_z_qso) * (z_diff > z_qso_split)
        cat.plot_line_density(label=str(high_z_qso) + " > zQSO > " +
                              str(z_qso_split))
    plt.ylim(ymin=0, ymax=0.1)
    plt.legend(loc=0)
    save_figure(path.join(subdir, "dndx_gp_zdiff"))
    plt.clf()
    cat.condition = oldcond
Пример #3
0
def plot_SivsHI(mets=0.05):
    """
        Plot the SiII fraction as a function of density, for some metallicity.
        Mets is an array, metallicity as a fraction of solar.
    """
    if np.size(mets) == 1:
        mets = np.array([mets,])
    tab = cc.CloudyTable(3)

    #The hydrogen density in atoms/cm^3
    dens = np.logspace(-5,2,100)

    #Roughly mean DLA metallicity

    tabHI = cg.RahmatiRT(3, 0.71)

    tempHI = 1e4*np.ones_like(dens)
    fracHI = tabHI.neutral_fraction(dens,tempHI)
    plt.semilogx(dens, fracHI, color="red",ls="--")

    ls = [":","-","-."]
    for met in mets:
        metSi = tab.get_solar("Si")*met*np.ones_like(dens)
        fracSi = tab.ion("Si",2,metSi,dens)
        plt.semilogx(dens, fracSi, color="green",ls=ls.pop())

    plt.xlabel(r"$\rho_\mathrm{H}\; (\mathrm{amu}/\mathrm{cm}^3$)")
    plt.ylabel(r"$\mathrm{m}_\mathrm{SiII} / \mathrm{m}_\mathrm{Si}$")
    plt.show()
    save_figure(path.join(outdir,"Si_fracs"))
Пример #4
0
def plot_halo_stellar_mass():
    """Plot a histogram of nearby halos"""
    for sim in (1, 7, 9):  #xrange(8):
        halo = myname.get_name(sim, True)
        hms = []
        sms = []
        sfrs = []
        zz = []
        for snap in (1, 3, 5):
            ahalo = dp.PrettyBox(halo, snap, nslice=10, label=labels[sim])
            (hm, sm, sfr) = ahalo.get_avg_stellar_mass()
            hms.append(hm)
            sms.append(sm)
            sfrs.append(sfr)
            zz.append(redshifts[snap])
        plt.figure(1)
        plt.semilogy(zz, hms, color=colors[sim], ls="-", label=labels[sim])
        plt.semilogy(zz, sms, color=colors[sim], ls="--", label=labels[sim])
        plt.figure(2)
        plt.semilogy(zz, sfrs, color=colors[sim], ls="--", label=labels[sim])
    plt.figure(1)
    plt.legend(loc=1)
    save_figure(path.join(outdir, "halos/avg_smhm_z" + str(snap)))
    plt.figure(2)
    plt.legend(loc=1)
    save_figure(path.join(outdir, "halos/avg_sfr_z" + str(snap)))
    plt.clf()
Пример #5
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()
Пример #6
0
def save_plot(elem, ion, suffix, ss_corr=True):
    """Helper function to save a nicely named file"""
    filename = elem + str(ion) + "_" + suffix
    if ss_corr:
        save_figure(path.join(outdir, filename + "_photo_atten"))
    else:
        save_figure(path.join(outdir, filename + "_no_atten"))
Пример #7
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_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()
Пример #9
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
Пример #10
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()
Пример #11
0
def plot_halo_stellar_mass():
    """Plot a histogram of nearby halos"""
    for sim in (1,7,9):   #xrange(8):
        halo = myname.get_name(sim, True)
        hms = []
        sms = []
        sfrs = []
        zz = []
        for snap in (1,3,5):
            ahalo = dp.PrettyBox(halo, snap, nslice=10, label=labels[sim])
            (hm, sm, sfr) = ahalo.get_avg_stellar_mass()
            hms.append(hm)
            sms.append(sm)
            sfrs.append(sfr)
            zz.append(redshifts[snap])
        plt.figure(1)
        plt.semilogy(zz, hms, color=colors[sim], ls="-", label=labels[sim])
        plt.semilogy(zz, sms, color=colors[sim], ls="--", label=labels[sim])
        plt.figure(2)
        plt.semilogy(zz, sfrs, color=colors[sim], ls="--", label=labels[sim])
    plt.figure(1)
    plt.legend(loc=1)
    save_figure(path.join(outdir, "halos/avg_smhm_z"+str(snap)))
    plt.figure(2)
    plt.legend(loc=1)
    save_figure(path.join(outdir, "halos/avg_sfr_z"+str(snap)))
    plt.clf()
Пример #12
0
def do_snr_check(cat, subdir):
    """Check effect of removing spectra with a low SNR."""
    first_snr = cat.snr_thresh
    cat.set_snr(-2)
    cat.plot_omega_dla(zmax=5, label="All GP")
    cat.set_snr(2)
    cat.plot_omega_dla(zmax=5, label="SNR > 2")
    cat.set_snr(4)
    cat.plot_omega_dla(zmax=5, label="SNR > 4")
    #     cat.set_snr(8)
    #     cat.plot_omega_dla(zmax=5,label="SNR > 8")
    plt.legend(loc=0)
    save_figure(path.join(subdir, "omega_gp_snr"))
    plt.clf()

    cat.set_snr(-2)
    cat.plot_line_density(zmax=5, label="All GP")
    cat.set_snr(2)
    cat.plot_line_density(zmax=5, label="SNR > 2")
    cat.set_snr(4)
    cat.plot_line_density(zmax=5, label="SNR > 4")
    #     cat.set_snr(8)
    #     cat.plot_line_density(zmax=5, label="SNR > 8")
    plt.legend(loc=0)
    save_figure(path.join(subdir, "dndx_gp_snr"))
    plt.clf()
    cat.set_snr(first_snr)
Пример #13
0
def plot_den(sim, snap, num, subdir="", voff = 0, box=10, elem="Si", ion=2):
    """Plot density"""
    hspec = get_hspec(sim, snap, snr=20., box=box)
    #Adjust the default plot parameters, which do not scale well in a gridspec.
    matplotlib.rc('xtick', labelsize=10)
    matplotlib.rc('ytick', labelsize=10)
    matplotlib.rc('axes', labelsize=10)
    matplotlib.rc('font', size=8)
    matplotlib.rc('lines', linewidth=1.5)
    gs = gridspec.GridSpec(9,2)
    ax3 = plt.subplot(gs[0:4,0])
    plt.sca(ax3)
    xoff = hspec.plot_spectrum(elem,ion,-1,num, flux=False)
    xlim = plt.xlim()
    ax3.xaxis.set_label_position('top')
    ax3.xaxis.tick_top()
    voff += xoff
    ax2 = plt.subplot(gs[5:,0])
    plt.sca(ax2)
    dxlim = hspec.plot_density(elem,ion, num)
    plt.ylabel(r"n$_\mathrm{"+elem+"II}$ (cm$^{-3}$)")
    plt.ylim(ymin=1e-9)
    ax1 = plt.subplot(gs[4,0])
    plt.sca(ax1)
    xscale = dxlim*hspec.velfac/xlim[1]
    hspec.plot_den_to_tau(elem, ion, num, thresh = 1e-9, xlim=200,voff=voff, xscale=xscale)
    ax1.axes.get_xaxis().set_visible(False)
    plt.xlabel("")
    plt.xlim(xlim)
    sdir = path.join(outdir,"spectra/"+subdir)
    if not path.exists(sdir):
        os.mkdir(sdir)
    save_figure(path.join(sdir,str(num)+"_cosmo"+str(sim)+"_"+elem+"_colden"))
    plt.clf()
    matplotlib.rc_file_defaults()
def plot_agn_rel_cddf(snap):
    """Load and make a plot of the difference between both simulations with and without AGN"""
    basen = myname.get_name(0)
    base = dp.PrettyBox(basen, snap, nslice=10)
    cddf_base = base.column_density_function()
    basen = myname.get_name(4)
    other = dp.PrettyBox(basen, snap, nslice=10)
    cddf = other.column_density_function()
    plt.semilogx(cddf_base[0],
                 cddf[1] / cddf_base[1],
                 color=colors[0],
                 ls=lss[0])
    basen = myname.get_name(1)
    base = dp.PrettyBox(basen, snap, nslice=10)
    cddf_base = base.column_density_function()
    basen = myname.get_name(2)
    other = dp.PrettyBox(basen, snap, nslice=10)
    cddf = other.column_density_function()
    plt.semilogx(cddf_base[0],
                 cddf[1] / cddf_base[1],
                 color=colors[1],
                 ls=lss[1])
    plt.ylim(0.8, 1.5)
    plt.xlim(1e17, 1e22)
    save_figure(path.join(outdir, "cosmo_rel_agn_cddf_z" + str(snap)))
    plt.clf()
Пример #15
0
def plot_cum_f_peak_sims(sims, snap):
    """Plot f_peak for a series of simulations"""
    (_, cfmm) = vel_data.plot_cum_stat_data(True, None)
    norm = cfmm[-1]
    for sss in sims:
        #Make abs. plot
        hspec = get_hspec(sss, snap)
        hspec.plot_cum_f_peak("Si",
                              2,
                              norm=norm,
                              color=colors[sss],
                              ls=lss[sss])
    hspec = get_hspec(5, snap, box=10)
    hspec.label = labels["S"]
    hspec.plot_cum_f_peak("Si", 2, norm=norm, color=colors["S"], ls="--")
    hspec.plot_f_peak_errors("Si",
                             2,
                             samples=norm,
                             cumulative=True,
                             color=colors2["S"])
    outstr = "cosmo_cum_f_peak_z" + str(snap)
    plt.ylim(0, norm + 1)
    plt.ylabel("Cumulative Distribution")
    plt.xlim(0, 1)
    plt.legend(loc=4, ncol=2)
    save_figure(path.join(outdir, outstr))
    plt.clf()
Пример #16
0
def save_plot(elem, ion, suffix, ss_corr=True):
    """Helper function to save a nicely named file"""
    filename = elem+str(ion)+"_"+suffix
    if ss_corr:
        save_figure(path.join(outdir,filename+"_photo_atten"))
    else:
        save_figure(path.join(outdir,filename+"_no_atten"))
Пример #17
0
def do_qso_split(cat, subdir):
    """Check the effect of the quasar redshift."""
    #Check z_qso split
    oldcond = cat.condition
    high_z = (2.5, 3.0, 3.5, 5.0)
    low_z = (2.0, 2.5, 3.0, 3.5)
    for (high_z_qso, z_qso_split) in zip(high_z, low_z):
        cat.condition = (cat.z_max() < high_z_qso) * (cat.z_max() >
                                                      z_qso_split)
        cat.plot_omega_dla(label="$" + str(high_z_qso) +
                           " > z_\mathrm{QSO} > " + str(z_qso_split) + "$")
    plt.ylim(ymin=0)
    plt.legend(loc=0)
    save_figure(path.join(subdir, "omega_gp_zqso" + str(cat.lowzcut)))
    plt.clf()

    for (high_z_qso, z_qso_split) in zip(high_z, low_z):
        cat.condition = (cat.z_max() < high_z_qso) * (cat.z_max() >
                                                      z_qso_split)
        cat.plot_line_density(label="$" + str(high_z_qso) +
                              " > z_\mathrm{QSO} > " + str(z_qso_split) + "$")
    plt.ylim(ymin=0, ymax=0.15)
    plt.legend(loc=0)
    save_figure(path.join(subdir, "dndx_gp_zqso" + str(cat.lowzcut)))
    plt.clf()
    cat.condition = oldcond
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
Пример #19
0
def plot_eq_width(sims, snap):
    """Plot velocity widths for a series of simulations"""
    for sss in sims:
        #Make abs. plot
        hspec = get_hspec(sss, snap)
        hspec.plot_eq_width("Si", 2, 1526, color=colors[sss], ls=lss[sss])
    hspec = get_hspec(7, snap)
    outstr = "cosmo_eq_width_z" + str(snap)
    if snap == 5:
        nv_table = 7
    else:
        nv_table = 9
    (center, _) = vel_data.plot_si1526_eqw(zrange[snap], nv_table=nv_table)
    hspec = get_hspec(5, snap, box=10)
    hspec.label = labels["S"]
    hspec.plot_eq_width("Si", 2, 1526, color=colors["S"], ls="--")
    hspec.plot_eq_width_errors("Si",
                               2,
                               1526,
                               100,
                               color=colors2["S"],
                               nv_table=nv_table,
                               min_width=center[0])
    plt.xlabel(r"log $(W_\mathrm{1526} / \AA )$")
    plt.ylim(0, 3)
    plt.legend(loc=2, ncol=3)
    plt.text(-1.3, 2, "z=" + str(zzz[snap]), size=22)
    save_figure(path.join(outdir, outstr))
    plt.clf()
Пример #20
0
def plot_vel_width_sims(sims, snap, log=False):
    """Plot velocity widths for a series of simulations"""
    vel_data.plot_prochaska_2008_data()
    for sss in sims:
        #Make abs. plot
        hspec = get_hspec(sss, snap)
        hspec.plot_vel_width("Si", 2, color=colors[sss], ls=lss[sss])
    outstr = "cosmo_vel_width_z" + str(snap)
    if log:
        ax = plt.gca()
        ax.set_yscale('log')
        plt.ylim(5e-2, 10)
        outstr += "_log"
    else:
        plt.ylim(1e-2, 2)
    hspec = get_hspec(5, snap, box=10)
    hspec.label = labels["S"]
    hspec.plot_vel_width("Si", 2, color=colors["S"], ls="--")
    hspec.plot_vw_errors("Si",
                         2,
                         samples=100,
                         cumulative=False,
                         color=colors2["S"])
    plt.xlabel(r"$v_\mathrm{90}$ (km s$^{-1}$)")
    #     plt.ylabel("Spectra per log interval")
    plt.xlim(10, 1000)
    plt.xticks([10, 100, 1000], ["10", "100", "1000"])
    plt.legend(loc=2, ncol=3)
    save_figure(path.join(outdir, outstr))
    plt.clf()
Пример #21
0
def plot_cum_vel_width_sims(sims, snap):
    """Plot velocity widths for a series of simulations"""
    (_, cvels) = vel_data.plot_cum_vw_data(None)
    norm = cvels[-1]
    for sss in sims:
        #Make abs. plot
        hspec = get_hspec(sss, snap)
        hspec.plot_cum_vel_width("Si",
                                 2,
                                 norm=norm,
                                 color=colors[sss],
                                 ls=lss[sss])
    hspec = get_hspec(5, snap, box=10)
    hspec.label = labels["S"]
    hspec.plot_cum_vel_width("Si", 2, norm=norm, color=colors["S"], ls="--")
    hspec.plot_vw_errors("Si",
                         2,
                         samples=norm,
                         cumulative=True,
                         color=colors2["S"])
    outstr = "cosmo_cum_vel_width_z" + str(snap)
    plt.ylim(0, norm + 1)
    #     plt.ylabel("Total Spectra")
    plt.xlabel(r"$v_\mathrm{90}$ (km s$^{-1}$)")
    plt.xlim(9, 1000)
    plt.xticks([10, 100, 1000], ["10", "100", "1000"])
    plt.legend(loc=4, ncol=2)
    save_figure(path.join(outdir, outstr))
    plt.clf()
Пример #22
0
def test_tescari_halos(sim, snap):
    """Plot velocity width for spectra through the center of halos, like in Tescari 2009"""
    halo = myname.get_name(sim, box=10)
    hspec = ps.VWPlotSpectra(snap, halo, savefile="halo_spectra_2.hdf5",cdir=path.expanduser("~/codes/cloudy_tables/ion_out_no_atten/"))
    hspec.plot_vel_width("Si", 2, color="red")
    vel_data.plot_prochaska_2008_data()
    save_figure(path.join(outdir,"cosmo_tescari_halos"))
    plt.clf()
Пример #23
0
def plot_covering_frac(sim, snap, ff=True):
    """Load a simulation and plot its cddf"""
    halo = myname.get_name(sim, ff)
    ahalo = dp.PrettyBox(halo, snap, nslice=10)
    ahalo.plot_sigma_DLA()
    del ahalo
    save_figure(path.join(outdir, "cosmo"+str(sim)+"_covering_z"+str(snap)))
    plt.clf()
Пример #24
0
def plot_UVB_effect():
    """Load a simulation and plot its cddf"""
    for i in (0,5,7):
        halo = myname.get_name(i, True)
        ahalo = dp.PrettyBox(halo, 3, nslice=10)
        ahalo.plot_column_density(color=colors[i], ls=lss[i],moment=True)
    dla_data.column_density_data(moment=True)
    save_figure(path.join(outdir, "cosmo_UVB_3"))
    plt.clf()
def plot_UVB_effect():
    """Load a simulation and plot its cddf"""
    for i in (0, 5, 7):
        halo = myname.get_name(i, True)
        ahalo = dp.PrettyBox(halo, 3, nslice=10)
        ahalo.plot_column_density(color=colors[i], ls=lss[i], moment=True)
    dla_data.column_density_data(moment=True)
    save_figure(path.join(outdir, "cosmo_UVB_3"))
    plt.clf()
def plot_covering_frac(sim, snap, ff=True):
    """Load a simulation and plot its cddf"""
    halo = myname.get_name(sim, ff)
    ahalo = dp.PrettyBox(halo, snap, nslice=10)
    ahalo.plot_sigma_DLA()
    del ahalo
    save_figure(
        path.join(outdir, "cosmo" + str(sim) + "_covering_z" + str(snap)))
    plt.clf()
Пример #27
0
def mass_hist(name, ahalos):
    """Plot a histogram of halo masses"""
    for ahalo in ahalos:
        ahalo.plot_mass_hist()
    plt.xlabel(r"Halo mass ($M_\odot$)")
    plt.ylabel(r"PDF")
    plt.ylim(0, 1.5)
    plt.legend()
    save_figure(path.join(outdir,name+"_CIV_mass_hist"))
    plt.clf()
Пример #28
0
def CIV_eq_ratio(name, ahalos):
    """Carbon IV equivalent width ratio"""
    for ahalo in ahalos:
        ahalo.plot_eq_width_ratio()
    plt.xlabel("r perp (kpc)")
    plt.ylabel(r"$\eta_\mathrm{pair} / \eta_\mathrm{DLA}$")
    plt.ylim(0, 1.5)
    plt.legend()
    save_figure(path.join(outdir,name+"_CIV_eq_ratio"))
    plt.clf()
Пример #29
0
def collis_dist(name, ahalos):
    """Plot the collisional ionisation fractions"""
    for ahalo in ahalos:
        ahalo.plot_collisional_fraction()
    plt.xlabel("r perp (kpc)")
    plt.ylabel(r"Collisional ionisation fraction")
    plt.ylim(0, 1.5)
    plt.legend()
    save_figure(path.join(outdir,name+"_CIV_collisional"))
    plt.clf()
Пример #30
0
def C_ionic_eq_width(name, ahalo):
    """Plot eq. width distribution"""
    ahalo.plot_eq_width(elem="C", ion=4, line=1548,color="grey",label="C-IV")
    ahalo.plot_eq_width(elem="C", ion=-1, line=1548, color="pink", label="C-ALL")
    plt.xlabel("r perp (kpc)")
    plt.ylabel(r"EW(CIV 1548)")
    CGM_w = np.loadtxt("CGMofDLAs_avgWCIV.dat")
    plt.errorbar(CGM_w[:,0], CGM_w[:,1], yerr = CGM_w[:,2], xerr=[CGM_w[:,0]-[0,7,100,200],[7,100,200,275]-CGM_w[:,0]], fmt='o',ecolor="black")
    save_figure(path.join(outdir,name+"_CIV_eq_width"))
    plt.clf()
Пример #31
0
def plot_metallicity(sims, snap):
    """Plot metallicity, vel width, their correlation and the extra statistics"""
    out = "cosmo_metallicity_z" + str(snap)
    for sim in sims:
        hspec = get_hspec(sim, snap)
        hspec.plot_metallicity(color=colors[sim], ls=lss[sim])
    vel_data.plot_alpha_metal_data(zrange[snap])
    plt.legend(loc=2, ncol=3)
    plt.ylim(0, 2)
    save_figure(path.join(outdir, out))
    plt.clf()
Пример #32
0
def plot_metallicity(sims, snap):
    """Plot metallicity, vel width, their correlation and the extra statistics"""
    out = "cosmo_metallicity_z"+str(snap)
    for sim in sims:
        hspec = get_hspec(sim, snap)
        hspec.plot_metallicity(color=colors[sim], ls=lss[sim])
    vel_data.plot_alpha_metal_data(zrange[snap])
    plt.legend(loc=2,ncol=3)
    plt.ylim(0,2)
    save_figure(path.join(outdir,out))
    plt.clf()
Пример #33
0
def rel_c_colden(ahalo):
    """Column density for different carbon ions"""
    ahalo.plot_colden_ratio(color="grey",elem="C",ion=4,ion2=-1, label="CIV")
    ahalo.plot_colden_ratio(color="pink",elem="C",ion=2, ion2=-1, label="CII")
    ahalo.plot_colden_ratio(color="green",elem="C",ion=3, ion2=-1, label="CIII")
    ahalo.plot_colden_ratio(color="blue",elem="C",ion=5, ion2=-1, label="CV")
    #(center, mean_plot_arr6) = ahalo.plot_colden_ratio(color="yellow",elem="C",ion=6, ion2=-1, label="CVI")
    #(center, mean_plot_arr7) = ahalo.plot_colden_ratio(color="red",elem="C",ion=7, ion2=-1, label="CVII")
    #plt.plot(center, mean_plot_arr2+mean_plot_arr3+mean_plot_arr4+mean_plot_arr5+mean_plot_arr6+mean_plot_arr7, color="black")
    plt.legend(loc='upper center', ncol=2)
    save_figure(path.join(outdir,"ion_C_colden_ratio"))
    plt.clf()
Пример #34
0
def do_check_p_thresh(cat, subdir):
    """Check the effect of very unlikely samples"""
    cat.p_thresh_sample = 1e-4
    cat.plot_line_density(zmax=5, label=r"$p_\mathrm{sample} = 10^{-4}$")
    cat.p_thresh_sample = 1e-2
    cat.plot_line_density(zmax=5, label=r"$p_\mathrm{sample} = 10^{-2}$")
    cat.p_thresh_sample = 1e-4
    cat.p_thresh_spec = 0.1
    cat.plot_line_density(zmax=5, label=r"$p_\mathrm{spec} = 10^{-1}$")
    plt.legend(loc=0)
    save_figure(path.join(subdir, "dndx_p_thresh"))
    plt.clf()
Пример #35
0
def C_ionic_coverfrac(name, ahalo):
    """Plot covering fraction"""
    ahalo.plot_covering_fraction(elem="C", ion=4, line=1548,color="grey",label="C-IV")
    ahalo.plot_covering_fraction(elem="C", ion=-1, line=1548, color="pink", label="C-ALL")
    plt.xlabel("r perp (kpc)")
    plt.ylabel(r"$F(W_{1548} > 0.2 \AA)$")
    CGM_c = np.loadtxt("CGMofDLAs_CfCIV.dat")
    plt.errorbar(CGM_c[:,0], CGM_c[:,2], yerr = [CGM_c[:,2]-CGM_c[:,1],CGM_c[:,3]-CGM_c[:,2]], fmt='o', xerr=[CGM_c[:,0]-[7,100,200],[100,200,275]-CGM_c[:,0]],ecolor="black")
    plt.ylim(0,1.0)
    plt.legend()
    save_figure(path.join(outdir,name+"_CIV_coverfrac"))
    plt.clf()
Пример #36
0
def HI_coverfrac(name, ahalos):
    """CIV covering fraction"""
    for ahalo in ahalos:
        ahalo.plot_covering_fraction_colden(elem="H", ion=1)
    plt.xlabel("r perp (kpc)")
    plt.ylabel(r"$F(LLS)$")
    CGM_c = np.loadtxt("CGMofDLAs_Cfothick.dat")
    plt.errorbar(CGM_c[:,0], CGM_c[:,2], yerr = [CGM_c[:,2]-CGM_c[:,1],CGM_c[:,3]-CGM_c[:,2]], fmt='o', xerr=[CGM_c[:,0]-[7,50,117.5,200],[50,117.5,200,275]-CGM_c[:,0]],ecolor="black")
    plt.ylim(0,1.0)
    plt.legend()
    save_figure(path.join(outdir,name+"_LLS_coverfrac"))
    plt.clf()
Пример #37
0
def test_tescari_halos(sim, snap):
    """Plot velocity width for spectra through the center of halos, like in Tescari 2009"""
    halo = myname.get_name(sim, box=10)
    hspec = ps.VWPlotSpectra(
        snap,
        halo,
        savefile="halo_spectra_2.hdf5",
        cdir=path.expanduser("~/codes/cloudy_tables/ion_out_no_atten/"))
    hspec.plot_vel_width("Si", 2, color="red")
    vel_data.plot_prochaska_2008_data()
    save_figure(path.join(outdir, "cosmo_tescari_halos"))
    plt.clf()
Пример #38
0
def plot_vel_widths_metal():
    """Plot some velocity width data at a particular redshift"""
    #Load sims
    colorss = {1: "blue", 4: "purple", 3: "orange", 5: "red"}
    for sim in (1, 4, 5):
        halo = "modified_128_a" + str(sim) + "_b1"
        hspec0 = ps.VWPlotSpectra(25, base + halo)
        #Make abs. plot
        hspec0.plot_vel_width("Si", 2, color=colorss[sim], ls="-")
    vel_data.plot_prochaska_2008_data()
    save_figure(path.join(outdir, "cosmo_velw_metal_load"))
    plt.clf()
Пример #39
0
def generic_coverfrac(ionname, elem, ion, line, name, ahalos):
    """Plot covering fraction"""
    for ahalo in ahalos:
        ahalo.plot_covering_fraction(elem=elem, ion=ion, line=line)
    plt.xlabel("r perp (kpc)")
    plt.ylabel(r"$F(W_{"+str(line)+r"} > 0.2 \AA)$")
    CGM_c = np.loadtxt("CGMofDLAs_Cf"+ionname+".dat")
    plt.errorbar(CGM_c[:,0], CGM_c[:,2], yerr = [CGM_c[:,2]-CGM_c[:,1],CGM_c[:,3]-CGM_c[:,2]], fmt='o', xerr=[CGM_c[:,0]-[7,100,200],[100,200,275]-CGM_c[:,0]],ecolor="black")
    plt.ylim(0,1.0)
    plt.legend()
    save_figure(path.join(outdir,name+"_"+ionname+"_coverfrac"))
    plt.clf()
Пример #40
0
def plot_vel_widths_metal():
    """Plot some velocity width data at a particular redshift"""
    #Load sims
    colorss={1:"blue", 4:"purple", 3:"orange", 5:"red"}
    for sim in (1,4,5):
        halo = "modified_128_a"+str(sim)+"_b1"
        hspec0 = ps.VWPlotSpectra(25, base+halo)
        #Make abs. plot
        hspec0.plot_vel_width("Si", 2, color=colorss[sim], ls="-")
    vel_data.plot_prochaska_2008_data()
    save_figure(path.join(outdir,"cosmo_velw_metal_load"))
    plt.clf()
Пример #41
0
def plot_metal_ion_corr(sim, snap,species="Si",ion=2):
    """Plot metallicity from Z/H vs from a single species for computing ionisation corrections"""
    halo = myname.get_name(sim)
    hspec = ps.VWPlotSpectra(snap, halo)
    hspec.plot_metallicity(color="red", ls="-")
    hspec.plot_species_metallicity(species, ion, color="blue", ls="-")
    vel_data.plot_alpha_metal_data((3.5,2.5))
    save_figure(path.join(outdir, "cosmo_metallicity"+str(sim)+"_ion_corr"+str(snap)))
    plt.clf()
    hspec.plot_ion_corr(species, ion)
    save_figure(path.join(outdir, "cosmo_metallicity"+str(sim)+"_rel_ion_corr"+str(snap)))
    plt.clf()
Пример #42
0
def plot_covering_frac(sim, snap, ff=True):
    """Load a simulation and plot its cddf"""
    halo = "Cosmo"+str(sim)+"_V6"
    if ff:
        halo+="_512"
    ahalo = dp.PrettyBox(base+halo, snap, nslice=10)
    ahalo.plot_sigma_DLA()
    save_figure(path.join(outdir, "cosmo"+str(sim)+"_covering_z"+str(snap)))
    plt.clf()
    ahalo.plot_halo_hist()
    save_figure(path.join(outdir, "cosmo"+str(sim)+"_halohist_z"+str(snap)))
    del ahalo
    plt.clf()
Пример #43
0
def do_sample_error_check(cat, subdir):
    """Do a bunch of resamplings to check the effect of sample variance."""
    #dNdX/Omega_DLA
    cat.plot_dndx_sample_errors(z_max=5, nsample=13)
    plt.legend(loc=0)
    plt.ylim(0, 0.16)
    save_figure(path.join(subdir, "dndx_gp_resample"))
    plt.clf()
    cat.plot_omega_sample_errors(z_max=5, nsample=13)
    plt.legend(loc=0)
    plt.ylim(0, 2.5)
    save_figure(path.join(subdir, "omega_gp_resample"))
    plt.clf()
Пример #44
0
def CIV_vel_offset(name, ahalos):
    """Velocity offset of CIV from the DLAs"""
    vel_offset_rubin()
    for ahalo in ahalos:
        ahalo.plot_flux_vel_offset()
    plt.ylabel("N")
    plt.xlabel(r"$v_\mathrm{pair} - v_\mathrm{DLA}$ (km/s)")
    plt.ylim(0,4)
    plt.xlim(0,120)
    plt.yticks(np.arange(0,5),("0","1","2","3","4"))
    plt.legend()
    save_figure(path.join(outdir,name+"_CIV_vel_offset"))
    plt.clf()
Пример #45
0
def plot_breakdown(simlist):
    """Make a plot of the column density function, broken down by halo mass."""
    for sss in simlist:
        halo = myname.get_name(sss, True)
        for nn in (1,3,5):
            ahalo = dp.PrettyBox(halo, nn, nslice=10)
            ahalo.plot_colden_mass_breakdown()
            plt.xlim(20.3,22.3)
            plt.ylim(0,1.4)
            plt.legend(loc=2,ncol=2)
            save_figure(path.join(outdir,"halos/break/cosmo"+str(sss)+"_"+str(nn)+"_break"))
            plt.clf()
            del ahalo
Пример #46
0
def plot_rel_vel_width(sims, snap):
    """Plot velocity widths relative to simulation 7"""
    hspec = get_hspec(7, snap)
    (vbin, vels7) = hspec.vel_width_hist("Si", 2)
    #Make rel plot
    for sss in sims:
        hspec = get_hspec(sss, snap)
        (vbin, vel) = hspec.vel_width_hist("Si", 2)
        mm = np.min([np.size(vel), np.size(vels7)])
        plt.semilogx(vbin[:mm], vel[:mm]/vels7[:mm], color=colors[sss],ls=lss[sss])
    plt.xlim(10, 1000)
    save_figure(path.join(outdir,"cosmo_rel_vel_z"+str(snap)))
    plt.clf()
Пример #47
0
def plot_vir_vsmass(sim, snap):
    """Plot mass histogram"""
    #Load from a save file only
    hspec = get_hspec(sim, snap)
    (halos, _) = hspec.find_nearest_halo()
    hspec._plot_xx_vs_mass(hspec.sub_mass[halos] + 1,
                           name="Mass",
                           color=colors[sim],
                           color2=colors2[sim],
                           log=True)
    out = "cosmo" + str(sim) + "_vir_mass_z" + str(snap)
    save_figure(path.join(outdir, out))
    plt.clf()
Пример #48
0
def do_halomass_plots(fosc):
    """Plot halo mass, distance to the halo and the relationship between eq. width and column density"""
    ahalos = {
                    4:CIVPlottingSpectra(5, myname.get_name(4, box=25), None, None, savefile="rand_civ_spectra.hdf5", spec_res=5.,label=labels[4]+" 25"),
                   9:CIVPlottingSpectra(5, myname.get_name(9, box=25), None, None, savefile="rand_civ_spectra.hdf5", spec_res=5.,label=labels[9]+" 25"),
                    7:CIVPlottingSpectra(5, myname.get_name(7, box=25), None, None, savefile="rand_civ_spectra.hdf5", spec_res=5.,label=labels[7]+" 25")}
    for (ll, ahalo) in ahalos.items():
        ahalo.plot_eqw_mass("C",4,1548,color=colors[ll])
    plt.legend(loc="upper left")
    save_figure(path.join(outdir,"civ_eqwvsmass"))
    plt.clf()
    for (ll, ahalo) in ahalos.items():
        ahalo.plot_eqw_dist("C",4,1548,color=colors[ll])
    plt.legend(loc="upper left")
    save_figure(path.join(outdir,"civ_eqwvsdist"))
    plt.clf()
    ahalos['I']=CIVPlottingSpectra(68, path.expanduser("~/data/Illustris"), None, None, savefile="rand_civ_spectra.hdf5", spec_res=5.,label=labels['I']+" 75")
    ccc = {1e12: "yellow", 1e15:"red"}
    for tag in ('I', 4, 7):
        for nmin in (1e12, 1e15):
            nminstr = str(np.round(np.log10(nmin),1))
            #for (ll, ahalo) in ahalos.iteritems():
            ahalos[tag].plot_mass_hist(elem="C",ion=4,color=ccc[nmin], ls=lss[tag],nmin=nmin, label=ahalos[tag].label+" "+nminstr)
    plt.legend(loc="upper left",ncol=1)
    save_figure(path.join(outdir,"civ_halos_hist"))
    plt.clf()
    ahalos['I'].plot_eq_width_vs_col_den("C",4,1548)
    eqw = np.linspace(-3, 0.5,50)
    plt.semilogy(eqw, linear_cog_col(10**eqw, 1548, fosc), '-',color="black")
    plt.ylim(1e12,1e16)
    plt.xlim(-2.5,0.5)
    save_figure(path.join(outdir,"civ_eqwvscolden"))
    plt.clf()
Пример #49
0
def hc_tau_par(ahalo, name="ion", ions=(2,3,4,5,-1)):
    """Plot the column densities for different CIV ions"""
    if 2 in ions:
        ahalo.plot_tau_par(color="deeppink",ls="-.",elem="C",ion=2,line=1334,label="CII")
    if 4 in ions:
        ahalo.plot_tau_par(color="grey",ls="--", elem="C",ion=4,line=1548,label="CIV")
    #ahalo.plot_colden(color="black",elem="H",ion=1,label="HI")
    plt.yscale('log')
    plt.ylabel(r"Optical Depth")
    plt.xlabel(r"Velocity from DLA (kms$^{-1}$)")
    plt.ylim(0.1, 100)
    plt.legend(loc='upper right', ncol=3)
    save_figure(path.join(outdir,name+"_C_tau_par"+ahalo.label.replace(" ","_")))
    plt.clf()
Пример #50
0
def plot_vw_break(sim, snap):
    """Plot breakdown of velocity width by halo mass"""
    hspec = get_hspec(sim, snap)
    hspec.plot_vel_width_breakdown()
    out = "cosmo" + str(sim) + "_vw_break_z" + str(snap)
    plt.legend(loc=1, ncol=3)
    plt.xlim(8, 700)
    plt.xticks((10, 40, 100, 400), ("10", "40", "100", "400"))
    save_figure(path.join(topdir, out))
    plt.clf()
    hspec.plot_f_peak_breakdown()
    out = "cosmo" + str(sim) + "_fedge_break_z" + str(snap)
    save_figure(path.join(topdir, out))
    plt.clf()
Пример #51
0
def plot_H2_effect(sim, snap):
    """Load a simulation and plot its cddf"""
    halo = "Cosmo"+str(sim)+"_V6_512"
    savefile = path.join(base+halo,"snapdir_"+str(snap).rjust(3,'0'),"boxhi_grid.hdf5")
    ahalo = dp.PrettyBox(base+halo, snap, nslice=10, savefile=savefile)
    ahalo.plot_column_density(color="blue", ls="--")
    del ahalo
    savefile = path.join(base+halo,"snapdir_"+str(snap).rjust(3,'0'),"boxhi_grid_H2.hdf5")
    ahalo = dp.PrettyBox(base+halo, snap, nslice=10, savefile=savefile)
    ahalo.plot_column_density(color="red")
    dla_data.column_density_data()
    del ahalo
    save_figure(path.join(outdir, "cosmo"+str(sim)+"_H2_"+str(snap)))
    plt.clf()
Пример #52
0
def plot_vel_widths_sims(sim):
    """Plot some velocity width data at a particular redshift"""
    #Load sims
    halo = "modified_128_a" + str(sim) + "_b1"
    hspec0 = ps.VWPlotSpectra(17, base + halo)
    hspec2 = ps.VWPlotSpectra(25, base + halo)
    hspec3 = ps.VWPlotSpectra(36, base + halo)
    #Make abs. plot
    hspec0.plot_vel_width("Si", 2, color="blue", ls="-")
    hspec2.plot_vel_width("Si", 2, color="orange", ls="--")
    hspec3.plot_vel_width("Si", 2, color="red", ls="-.")
    vel_data.plot_prochaska_2008_data()
    save_figure(path.join(outdir, "cosmo_velw_" + str(sim) + "_metal_zz"))
    plt.clf()
Пример #53
0
def plot_rel_vel_width(sims, snap):
    """Plot velocity widths relative to simulation 7"""
    hspec = get_hspec(7, snap)
    (vbin, vels7) = hspec.vel_width_hist("Si", 2)
    #Make rel plot
    for sss in sims:
        hspec = get_hspec(sss, snap)
        (vbin, vel) = hspec.vel_width_hist("Si", 2)
        mm = np.min([np.size(vel), np.size(vels7)])
        plt.semilogx(vbin[:mm],
                     vel[:mm] / vels7[:mm],
                     color=colors[sss],
                     ls=lss[sss])
    plt.xlim(10, 1000)
    save_figure(path.join(outdir, "cosmo_rel_vel_z" + str(snap)))
    plt.clf()
Пример #54
0
def plot_metal_ion_corr(sim, snap, species="Si", ion=2):
    """Plot metallicity from Z/H vs from a single species for computing ionisation corrections"""
    halo = myname.get_name(sim)
    hspec = ps.VWPlotSpectra(snap, halo)
    hspec.plot_metallicity(color="red", ls="-")
    hspec.plot_species_metallicity(species, ion, color="blue", ls="-")
    vel_data.plot_alpha_metal_data((3.5, 2.5))
    save_figure(
        path.join(outdir,
                  "cosmo_metallicity" + str(sim) + "_ion_corr" + str(snap)))
    plt.clf()
    hspec.plot_ion_corr(species, ion)
    save_figure(
        path.join(outdir, "cosmo_metallicity" + str(sim) + "_rel_ion_corr" +
                  str(snap)))
    plt.clf()
Пример #55
0
def plot_corr_as_points():
    """Plot the correlation as points"""
    halo = myname.get_name(7)
    hspec = ps.VWPlotSpectra(3, halo)
    vel = hspec.vel_width("Si", 2)
    met = hspec.get_metallicity()
    #Ignore objects too faint to be seen
    ind2 = np.where(met > 1e-4)
    met = met[ind2]
    vel = vel[ind2]
    plt.loglog(vel, met, 'o', color="blue")
    plt.xlim(10, 2e3)
    plt.ylabel(r"$\mathrm{Z} / \mathrm{Z}_\odot$")
    plt.xlabel(r"$v_\mathrm{90}$ (km s$^{-1}$)")
    save_figure(path.join(outdir, "cosmo_corr_as_points"))
    plt.clf()
def plot_breakdown(simlist):
    """Make a plot of the column density function, broken down by halo mass."""
    for sss in simlist:
        halo = myname.get_name(sss, True)
        for nn in (1, 3, 5):
            ahalo = dp.PrettyBox(halo, nn, nslice=10)
            ahalo.plot_colden_mass_breakdown()
            plt.xlim(20.3, 22.3)
            plt.ylim(0, 1.4)
            plt.legend(loc=2, ncol=2)
            save_figure(
                path.join(
                    outdir,
                    "halos/break/cosmo" + str(sss) + "_" + str(nn) + "_break"))
            plt.clf()
            del ahalo
Пример #57
0
def plot_v_struct(sims, snap):
    """Plot mean-median statistic for all sims on one plot"""
    #Plot extra statistics
    for sss in sims:
        halo = myname.get_name(sss, True)
        #Load from a save file only
        hspec = RotationFiltered(snap, halo, label=labels[sss], spec_res=0.1)
        hspec.get_observer_tau("Si", 2, force_recompute=True)
        hspec.plot_vel_width("Si", 2, color=colors[sss], ls=lss[sss])
    vel_data.plot_prochaska_2008_data()
    plt.legend(loc=2, ncol=3)
    plt.xlabel(r"$v_\mathrm{90}$ (km s$^{-1}$)")
    plt.xlim(2, 1000)
    plt.ylim(0, 2)
    save_figure(path.join(outdir, "cosmo_rot_z" + str(snap)))
    plt.clf()
Пример #58
0
def plot_metallicity(sim, snap):
    """Plot a spectrum"""
    halo = "modified_128_a" + str(sim) + "_b1"
    out = "cosmo" + str(sim) + "_metallicity_z" + str(snap)
    #Load from a save file only
    hspec = ps.VWPlotSpectra(snap, base + halo, None, None)
    hspec.plot_metallicity()
    vel_data.plot_alpha_metal_data(zrange[snap])
    save_figure(path.join(outdir, out))
    plt.clf()
    out = "cosmo" + str(sim) + "_correlation_z" + str(snap)
    hspec.plot_Z_vs_vel_width()
    vel_data.plot_prochaska_2008_correlation()
    save_figure(path.join(outdir, out))
    hspec.save_file()
    plt.clf()
Пример #59
0
def plot_test():
    """Test which plots the neutral fraction for a bunch of particles"""

    # plot_file(True,5)
    # save_figure.save_figure("test_cold_gas5_molec")
    # plt.clf()
    #
    # plot_file(False,5)
    # save_figure.save_figure("test_cold_gas5_no_molec")
    # plt.clf()

    plot_neut_sim(False, 1)
    plt.semilogx(np.ones(3) * 0.168, (0.0, 0.5, 1), "-")
    #     plt.xticks((0.1,0.15,0.2,0.25))
    #     plt.xlim(0.1,0.3)
    save_figure.save_figure("test_cold_gas1_no_molec")
    plt.clf()