Example #1
0
File: csed.py Project: viogp/shark
def main(model_dir, outdir, redshift_table, subvols, obsdir):

    # Loop over redshift and subvolumes
    plt = common.load_matplotlib()
    fields = {'galaxies': ('mstars_disk', 'mstars_bulge', 'mvir_hosthalo',
                           'mvir_subhalo', 'type', 'mean_stellar_age', 
                           'sfr_disk', 'sfr_burst', 'id_galaxy')}

    z = (0, 0.25, 0.5, 1, 1.5, 2.0, 3.0, 4.0, 6.0)
    snapshots = redshift_table[z]

    # Create histogram
    for index, snapshot in enumerate(snapshots):

        hdf5_data = common.read_data(model_dir, snapshot, fields, subvols)
        #sfh, delta_t, LBT = common.read_sfh(model_dir, snapshot, sfh_fields, subvols)
        seds, ids, nbands = common.read_photometry_data(model_dir, snapshot, subvols)
        
        if(index == 0):
            CSED = np.zeros(shape = (len(z), 5, nbands))

        prepare_data(hdf5_data, seds, ids, CSED, nbands, index)

        h0, volh = hdf5_data[0], hdf5_data[1]
        if(volh > 0.):
            CSED[index,:]   = CSED[index,:] / volh * pow(h0,3.0)

    # Take logs
    plot_csed(plt, outdir, obsdir, h0, CSED, nbands)
Example #2
0
def main(model_dir, output_dir, redshift_table, subvols, obs_dir):

    plt = common.load_matplotlib()
    fields = {
        'galaxies':
        ('type', 'mstars_disk', 'mstars_bulge', 'rstar_disk', 'm_bh',
         'matom_disk', 'mmol_disk', 'mgas_disk', 'matom_bulge', 'mmol_bulge',
         'mgas_bulge', 'mvir_hosthalo')
    }
    hdf5_data = common.read_data(model_dir, redshift_table[0], fields, subvols)

    (mgas_relation, mgas_relation_cen, mgas_relation_sat, mh2_gals, mh1_gals,
     mgas_gals, mh2_relation, mh1_relation, mhr_relation, mhr_relation_cen,
     mhr_relation_sat, mgas_relation_ltg, mh2_relation_ltg, mh1_relation_ltg,
     mgas_relation_etg, mh2_relation_etg, mh1_relation_etg,
     mgas_ms_relation_ltg, mh2_ms_relation_ltg, mh1_ms_relation_ltg,
     mgas_ms_relation_etg, mh2_ms_relation_etg, mh1_ms_relation_etg,
     mh1_relation_satellites_halos) = prepare_data(hdf5_data)

    plot_cold_gas_fraction(plt, output_dir, obs_dir, mgas_relation,
                           mgas_relation_cen, mgas_relation_sat)
    plot_HI_stacking(plt, output_dir, obs_dir, mh1_relation_satellites_halos)

    plot_molecular_gas_fraction(
        plt, output_dir, obs_dir, mgas_gals, mgas_relation, mh1_gals,
        mh1_relation, mh2_gals, mh2_relation, mgas_relation_ltg,
        mh2_relation_ltg, mh1_relation_ltg, mgas_relation_etg,
        mh2_relation_etg, mh1_relation_etg, mgas_ms_relation_ltg,
        mh2_ms_relation_ltg, mh1_ms_relation_ltg, mgas_ms_relation_etg,
        mh2_ms_relation_etg, mh1_ms_relation_etg)

    plot_h1h2_gas_fraction(plt, output_dir, mhr_relation, mhr_relation_cen,
                           mhr_relation_sat)
Example #3
0
def main(modeldir, outdir, redshift_table, subvols, obsdir):

    plt = common.load_matplotlib()
    fields = {
        'global':
        ('redshifts', 'm_hi', 'm_h2', 'mcold', 'mcold_metals', 'mhot_halo',
         'mejected_halo', 'mstars', 'mstars_bursts_mergers',
         'mstars_bursts_diskinstabilities', 'm_bh', 'sfr_quiescent',
         'sfr_burst', 'm_dm', 'mcold_halo', 'number_major_mergers',
         'number_minor_mergers', 'number_disk_instabilities', 'smbh_maximum')
    }

    # Read data from each subvolume at a time and add it up
    # rather than appending it all together
    for idx, subvol in enumerate(subvols):
        subvol_data = common.read_data(modeldir, redshift_table[0], fields,
                                       [subvol])
        max_bhs_subvol = subvol_data[20].copy()
        if idx == 0:
            hdf5_data = subvol_data
            max_smbh = max_bhs_subvol
        else:
            max_smbh = np.maximum(max_smbh, max_bhs_subvol)
            for subvol_datum, hdf5_datum in zip(subvol_data[3:],
                                                hdf5_data[3:]):
                hdf5_datum += subvol_datum
                #select the most massive black hole from the last list item

    # Also make sure that the total volume takes into account the number of subvolumes read
    hdf5_data[1] = hdf5_data[1] * len(subvols)

    h0, redshifts = hdf5_data[0], hdf5_data[2]

    #for z, m in zip(redshifts, max_smbh):
    #    print z,m/h0

    (mstar_plot, mcold_plot, mhot_plot, meje_plot, mstar_dm_plot,
     mcold_dm_plot, mhot_dm_plot, meje_dm_plot, mbar_dm_plot, sfr, sfrd, sfrb,
     mstarden, mstarbden_mergers, mstarbden_diskins, sfre, sfreH2, mhrat,
     mHI_plot, mH2_plot, mH2den, mdustden, omegaHI, mdustden_mol, mcoldden,
     mhotden, mejeden, history_interactions,
     mDMden) = prepare_data(hdf5_data, redshifts)

    plot_mass_densities(plt, outdir, obsdir, h0, redshifts, mstar_plot,
                        mcold_plot, mhot_plot, meje_plot, mstarden, mcoldden,
                        mhotden, mejeden)
    plot_baryon_fractions(plt, outdir, redshifts, mstar_dm_plot, mcold_dm_plot,
                          mhot_dm_plot, meje_dm_plot, mbar_dm_plot)
    plot_cosmic_sfr(plt, outdir, obsdir, redshifts, h0, sfr, sfrd, sfrb,
                    history_interactions, mDMden)
    plot_stellar_mass_cosmic_density(plt, outdir, obsdir, redshifts, h0,
                                     mstarden, mstarbden_mergers,
                                     mstarbden_diskins)
    plot_sft_efficiency(plt, outdir, redshifts, sfre, sfreH2, mhrat)
    plot_mass_cosmic_density(plt, outdir, redshifts, mcold_plot, mHI_plot,
                             mH2_plot)
    plot_omega_h2(plt, outdir, obsdir, redshifts, h0, mH2den)
    plot_cosmic_dust(plt, outdir, obsdir, redshifts, h0, mdustden,
                     mdustden_mol)
    plot_omega_HI(plt, outdir, obsdir, redshifts, h0, omegaHI)
Example #4
0
def main(modeldir, outdir, redshift_table, subvols):

    plt = common.load_matplotlib()
    fields = {'galaxies': ('type', 'vvir_hosthalo', 'cooling_rate')}
    hdf5_data = common.read_data(modeldir, redshift_table[0], fields, subvols, include_h0_volh=False)
    med_tvir = prepare_data(hdf5_data)

    plot_cooling_rate(plt, outdir, med_tvir)
Example #5
0
def main(modeldir, outdir, redshift_table, subvols, obsdir):

    z = [0, 0.5, 1.0, 2.0, 3.0, 4.0]
    snapshots = redshift_table[z]

    plt = common.load_matplotlib()

    mainseqsf = np.zeros(shape=(len(z), 3, len(xmf)))
    sigmamainseqsf = np.zeros(shape=(len(z), 7, len(xmf)))

    passive_fractions = np.zeros(shape=(len(z), 3, len(xmf2)))
    passive_fractions_cens_sats = np.zeros(shape=(len(z), 2, len(xmflr),
                                                  len(xmf2)))

    hist_ssfr = np.zeros(shape=(len(z), len(ssfrbins)))

    fields = {
        'galaxies':
        ('sfr_disk', 'sfr_burst', 'mstars_disk', 'mstars_bulge', 'rstar_disk',
         'm_bh', 'matom_disk', 'mmol_disk', 'mgas_disk', 'matom_bulge',
         'mmol_bulge', 'mgas_bulge', 'mgas_metals_disk', 'mgas_metals_bulge',
         'mstars_metals_disk', 'mstars_metals_bulge', 'type', 'mvir_hosthalo',
         'rstar_bulge')
    }

    for index, snapshot in enumerate(snapshots):
        hdf5_data = common.read_data(modeldir, snapshot, fields, subvols)
        (mass, slope, offset) = prepare_data(hdf5_data, index, z[index],
                                             mainseqsf, passive_fractions,
                                             hist_ssfr, sigmamainseqsf,
                                             passive_fractions_cens_sats)

        h0 = hdf5_data[0]
        if index == 0:
            (sfr_disk, sfr_burst, mdisk, mbulge) = hdf5_data[2:6]
            sfr_seq = np.zeros(shape=(2, len(mdisk)))
            ind = np.where((sfr_disk + sfr_burst > 0) & (mdisk + mbulge > 0))
            sfr_seq[0, ind] = mass[ind]
            sfr_seq[1, ind] = np.log10(
                (sfr_disk[ind] + sfr_burst[ind]) / h0 / GyrToYr)
            slope_ms_z0 = slope
            offset_ms_z0 = offset
            #print 'scatter MS'
            #for m,a,b,c,d,e,f,g in zip(xmf[:], sigmamainseqsf[index,0,:], sigmamainseqsf[index,1,:], sigmamainseqsf[index,2,:], sigmamainseqsf[index,3,:], sigmamainseqsf[index,4,:], sigmamainseqsf[index,5,:], sigmamainseqsf[index,6,:]):
            #    print m,a,b,c,d,e,f,g

            #print 'passive fractions centrals'
            #for m,a,b,c,d,e,f in zip(xmf2[:], passive_fractions_cens_sats[0,0,0,:], passive_fractions_cens_sats[0,0,1,:], passive_fractions_cens_sats[0,0,2,:], passive_fractions_cens_sats[0,0,3,:], passive_fractions_cens_sats[0,0,4,:], passive_fractions_cens_sats[0,0,5,:],):
            #    print m,a,b,c,d,e,f
            #print 'passive fractions satellites'
            #for m,a,b,c,d,e,f in zip(xmf2[:], passive_fractions_cens_sats[0,1,0,:], passive_fractions_cens_sats[0,1,1,:], passive_fractions_cens_sats[0,1,2,:], passive_fractions_cens_sats[0,1,3,:], passive_fractions_cens_sats[0,1,4,:], passive_fractions_cens_sats[0,1,5,:],):
            #    print m,a,b,c,d,e,f

    # This should be the same in all HDF5 files
    plot_sfr_mstars_z0(plt, outdir, obsdir, h0, sfr_seq, mainseqsf,
                       sigmamainseqsf, slope_ms_z0, offset_ms_z0)
    plot_passive_fraction(plt, outdir, obsdir, passive_fractions, hist_ssfr,
                          passive_fractions_cens_sats)
Example #6
0
def main(modeldir, outdir, redshift_table, subvols, obsdir):

    plt = common.load_matplotlib()
    fields = {
        'galaxies':
        ('mstars_disk', 'mstars_bulge', 'mstars_burst_mergers',
         'mstars_burst_diskinstabilities', 'mstars_bulge_mergers_assembly',
         'mstars_bulge_diskins_assembly', 'm_bh', 'rstar_disk', 'rstar_bulge',
         'type', 'specific_angular_momentum_disk_star',
         'specific_angular_momentum_bulge_star',
         'specific_angular_momentum_disk_gas',
         'specific_angular_momentum_bulge_gas',
         'specific_angular_momentum_disk_gas_atom',
         'specific_angular_momentum_disk_gas_mol', 'lambda_subhalo',
         'mvir_subhalo', 'mgas_disk', 'mgas_bulge', 'matom_disk', 'mmol_disk',
         'matom_bulge', 'mmol_bulge', 'bh_accretion_rate_hh',
         'bh_accretion_rate_sb')
    }

    # Loop over redshift and subvolumes
    rcomb = np.zeros(shape=(len(zlist), 3, len(xmf)))
    disk_size = np.zeros(shape=(len(zlist), 3, len(xmf)))
    bulge_size = np.zeros(shape=(len(zlist), 3, len(xmf)))
    bulge_size_mergers = np.zeros(shape=(len(zlist), 3, len(xmf)))
    bulge_size_diskins = np.zeros(shape=(len(zlist), 3, len(xmf)))

    BH = np.zeros(shape=(len(zlist), 3, len(xmf)))
    disk_size_sat = np.zeros(shape=(len(zlist), 3, len(xmf)))
    disk_size_cen = np.zeros(shape=(len(zlist), 3, len(xmf)))
    BT_fractions = np.zeros(shape=(len(zlist), len(xmf)))
    BT_fractions_nodiskins = np.zeros(shape=(len(zlist), len(xmf)))
    BT_fractions_centrals = np.zeros(shape=(len(zlist), len(xmf)))
    BT_fractions_satellites = np.zeros(shape=(len(zlist), len(xmf)))
    disk_vel = np.zeros(shape=(len(zlist), 3, len(xmf)))
    bulge_vel = np.zeros(shape=(len(zlist), 3, len(xmf)))
    baryonic_TF = np.zeros(shape=(len(zlist), 3, len(xv)))

    for index, snapshot in enumerate(redshift_table[zlist]):
        hdf5_data = common.read_data(modeldir, snapshot, fields, subvols)
        prepare_data(hdf5_data, index, rcomb, disk_size, bulge_size,
                     bulge_size_mergers, bulge_size_diskins, BH, disk_size_sat,
                     disk_size_cen, BT_fractions, BT_fractions_nodiskins,
                     bulge_vel, disk_vel, BT_fractions_centrals,
                     BT_fractions_satellites, baryonic_TF)

    plot_sizes(plt, outdir, obsdir, disk_size_cen, disk_size_sat, bulge_size,
               bulge_size_mergers, bulge_size_diskins)
    plot_velocities(plt, outdir, disk_vel, bulge_vel, baryonic_TF)
    plot_sizes_combined(plt, outdir, rcomb)
    plot_bulge_BH(plt, outdir, obsdir, BH)
    plot_bt_fractions(plt, outdir, obsdir, BT_fractions,
                      BT_fractions_nodiskins, BT_fractions_centrals,
                      BT_fractions_satellites)
Example #7
0
def main(model_dir, outdir, redshift_table, subvols, obsdir):

    # Loop over redshift and subvolumes
    plt = common.load_matplotlib()
    fields = {
        'galaxies':
        ('mstars_disk', 'mstars_bulge', 'mvir_hosthalo', 'mvir_subhalo',
         'type', 'mean_stellar_age', 'sfr_disk', 'sfr_burst', 'id_galaxy')
    }

    sfh_fields = {
        'bulges_diskins': ('star_formation_rate_histories'),
        'bulges_mergers': ('star_formation_rate_histories'),
        'disks': ('star_formation_rate_histories')
    }

    z = (0, 2)  #0.5, 1, 1.5, 2, 3)
    snapshots = redshift_table[z]

    # Create histogram
    for index, snapshot in enumerate(snapshots):

        hdf5_data = common.read_data(model_dir, snapshot, fields, subvols)
        sfh, delta_t, LBT = common.read_sfh(model_dir, snapshot, sfh_fields,
                                            subvols)
        seds, ids, nbands = common.read_photometry_data(
            model_dir, snapshot, subvols)

        (SEDs_dust, SEDs_nodust, total_sfh, sb_sfh, disk_sfh,
         gal_props) = prepare_data(hdf5_data, sfh, seds, ids, index, nbands)

        h0, volh = hdf5_data[0], hdf5_data[1]
        if (index == 0):
            SEDs_nodust_z0 = SEDs_nodust
            SEDs_dust_z0 = SEDs_dust
            total_sfh_z0 = total_sfh
            gal_props_z0 = gal_props
            LBT_z0 = LBT
            plot_individual_seds(plt, outdir, obsdir, h0, SEDs_dust_z0,
                                 SEDs_nodust, total_sfh_z0, gal_props_z0,
                                 LBT_z0)

        if (index == 1):
            SEDs_dust_z2 = SEDs_dust
            total_sfh_z2 = total_sfh
            disk_sfh_z2 = disk_sfh
            sb_sfh_z2 = sb_sfh
            gal_props_z2 = gal_props
            LBT_z2 = LBT
            plot_individual_seds_z2(plt, outdir, obsdir, h0, SEDs_dust_z2,
                                    total_sfh_z2, disk_sfh_z2, sb_sfh_z2,
                                    gal_props_z2, LBT_z2)
def main(modeldir, outdir, redshift_table, subvols, obsdir):

    plt = common.load_matplotlib()
    fields = {
        'galaxies':
        ('mstars_disk', 'mstars_bulge', 'mstars_burst_mergers',
         'mstars_burst_diskinstabilities', 'mstars_bulge_mergers_assembly',
         'mstars_bulge_diskins_assembly', 'm_bh', 'rstar_disk', 'rstar_bulge',
         'type', 'specific_angular_momentum_disk_star',
         'specific_angular_momentum_bulge_star',
         'specific_angular_momentum_disk_gas',
         'specific_angular_momentum_bulge_gas',
         'specific_angular_momentum_disk_gas_atom',
         'specific_angular_momentum_disk_gas_mol', 'lambda_subhalo',
         'mvir_subhalo', 'mvir_hosthalo', 'matom_disk', 'mmol_disk',
         'mgas_disk', 'matom_bulge', 'mmol_bulge', 'mgas_bulge', 'sfr_disk',
         'sfr_burst', 'vvir_hosthalo', 'rgas_disk', 'rgas_bulge')
    }

    # Loop over redshift and subvolumes

    sam_vs_sam_halo_disk = np.zeros(shape=(len(zlist), 3, len(xlf), 2))
    sam_vs_sam_halo_gal = np.zeros(shape=(len(zlist), 3, len(xlf), 2))
    sam_vs_sam_halo_disk_gas = np.zeros(shape=(len(zlist), 3, len(xlf), 2))
    sam_vs_sam_halo_bar = np.zeros(shape=(len(zlist), 3, len(xlf), 2))

    m_vs_m_halo_disk = np.zeros(shape=(len(zlist), 3, len(xmf), 2))
    m_vs_m_halo_gal = np.zeros(shape=(len(zlist), 3, len(xmf), 2))
    m_vs_m_halo_disk_gas = np.zeros(shape=(len(zlist), 3, len(xmf), 2))
    m_vs_m_halo_bar = np.zeros(shape=(len(zlist), 3, len(xmf), 2))

    r_vs_r_halo_disk = np.zeros(shape=(len(zlist), 3, len(xlf), 2))
    r_vs_r_halo_gal = np.zeros(shape=(len(zlist), 3, len(xlf), 2))
    r_vs_r_halo_disk_gas = np.zeros(shape=(len(zlist), 3, len(xlf), 2))
    r_vs_r_halo_bar = np.zeros(shape=(len(zlist), 3, len(xlf), 2))

    for index, snapshot in enumerate(redshift_table[zlist]):
        hdf5_data = common.read_data(modeldir, snapshot, fields, subvols)
        (lh, lj, lm, bt, ms, ssfr) = prepare_data(
            hdf5_data, index, sam_vs_sam_halo_disk, sam_vs_sam_halo_gal,
            sam_vs_sam_halo_disk_gas, sam_vs_sam_halo_bar, m_vs_m_halo_disk,
            m_vs_m_halo_gal, m_vs_m_halo_disk_gas, m_vs_m_halo_bar,
            r_vs_r_halo_disk, r_vs_r_halo_gal, r_vs_r_halo_disk_gas,
            r_vs_r_halo_bar)

    plot_specific_am_ratio(plt, outdir, obsdir, sam_vs_sam_halo_disk,
                           sam_vs_sam_halo_gal, sam_vs_sam_halo_disk_gas,
                           sam_vs_sam_halo_bar, m_vs_m_halo_disk,
                           m_vs_m_halo_gal, m_vs_m_halo_disk_gas,
                           m_vs_m_halo_bar, r_vs_r_halo_disk, r_vs_r_halo_gal,
                           r_vs_r_halo_disk_gas, r_vs_r_halo_bar)
Example #9
0
def main(model_dir, output_dir, redshift_table, subvols, obs_dir):

    plt = common.load_matplotlib()
    fields = {'galaxies': ('type', 'mstars_disk', 'mstars_bulge',
                           'rstar_disk', 'm_bh', 'matom_disk', 'mmol_disk', 'mgas_disk',
                           'matom_bulge', 'mmol_bulge', 'mgas_bulge', 'mvir_hosthalo',
                           'id_halo_tree', 'mhot', 'position_x', 'position_y', 'position_z', 
                           'velocity_x', 'velocity_y', 'velocity_z', 'vvir_hosthalo')}
    hdf5_data = common.read_data(model_dir, redshift_table[0], fields, subvols)

    (mHI_halos_stacking, sats_vproj, sats_rproj, sats_type) = prepare_data(hdf5_data)

    plot_HI_gas_fraction_groups(plt, output_dir, obs_dir, mHI_halos_stacking)
    plot_caustic_halos(plt, output_dir, sats_vproj, sats_rproj, sats_type)
Example #10
0
def main(modeldir, outdir, redshift_table, subvols, obsdir):

    plt = common.load_matplotlib()
    fields = {'galaxies': ('mstars_disk', 'mstars_bulge', 'mstars_burst_mergers', 'mstars_burst_diskinstabilities',
                           'mstars_bulge_mergers_assembly', 'mstars_bulge_diskins_assembly', 'm_bh', 'rstar_disk', 'rstar_bulge', 'type', 
                           'specific_angular_momentum_disk_star', 'specific_angular_momentum_bulge_star',
                           'specific_angular_momentum_disk_gas', 'specific_angular_momentum_bulge_gas',
                           'specific_angular_momentum_disk_gas_atom', 'specific_angular_momentum_disk_gas_mol',
                           'lambda_subhalo', 'mvir_subhalo', 'mvir_hosthalo', 'matom_disk', 'mmol_disk', 'mgas_disk',
                           'matom_bulge', 'mmol_bulge', 'mgas_bulge','sfr_disk', 'sfr_burst','vmax_subhalo')}

    # Loop over redshift and subvolumes
    sam_stars_disk    = np.zeros(shape = (len(zlist), 3, len(xmf),2))
    sam_gas_disk_atom = np.zeros(shape = (len(zlist), 3, len(xmf),2))
    sam_gas_disk_mol  = np.zeros(shape = (len(zlist), 3, len(xmf),2))
    sam_bar           = np.zeros(shape = (len(zlist), 3, len(xmf),2))
    sam_halo          = np.zeros(shape = (len(zlist), 3, len(xmf), 2))
    sam_stars         = np.zeros(shape = (len(zlist), 3, len(xmf), 2))

    sam_ratio_halo_disk  = np.zeros(shape = (len(zlist), 3, len(xmfh), 2))
    sam_ratio_halo_gal   = np.zeros(shape = (len(zlist), 3, len(xmfh), 2))
    sam_ratio_halo_disk_gas = np.zeros(shape = (len(zlist), 3, len(xmfh), 2))
    vmax_halo_gal        = np.zeros(shape = (len(zlist), 3, len(xmfh), 2)) 

    sam_vs_sam_halo_disk  = np.zeros(shape = (len(zlist), 3, len(xlf), 2))
    sam_vs_sam_halo_gal   = np.zeros(shape = (len(zlist), 3, len(xlf), 2))
    sam_vs_sam_halo_disk_gas = np.zeros(shape = (len(zlist), 3, len(xlf), 2))

    disk_size_sat = np.zeros(shape = (len(zlist), 3, len(xmf)))
    disk_size_cen = np.zeros(shape = (len(zlist), 3, len(xmf))) 
    bulge_size    = np.zeros(shape = (len(zlist), 3, len(xmf)))

    for index, snapshot in enumerate(redshift_table[zlist]):
        hdf5_data = common.read_data(modeldir, snapshot, fields, subvols)
        (lh, lj, lm, bt, ms, ssfr)  = prepare_data(hdf5_data, index, sam_stars_disk, sam_gas_disk_atom, sam_gas_disk_mol, sam_halo, sam_ratio_halo_disk, 
                     sam_ratio_halo_gal, sam_ratio_halo_disk_gas, disk_size_sat, disk_size_cen, bulge_size, sam_vs_sam_halo_disk, sam_vs_sam_halo_gal,
                     sam_vs_sam_halo_disk_gas, sam_bar, sam_stars, vmax_halo_gal)
        if(index  == 0):
		lambdaH = lh
		lambda_jiang = lj
		lambda_mass  = lm
                BT_ratio = bt
	        stellar_mass = ms
                ssfr_z0 = ssfr

    plot_specific_am(plt, outdir, obsdir, sam_stars_disk, sam_gas_disk_atom, sam_gas_disk_mol, sam_halo, sam_bar, sam_stars)
    plot_specific_am_ratio(plt, outdir, obsdir, sam_ratio_halo_disk, sam_ratio_halo_gal, sam_ratio_halo_disk_gas, 
                           sam_vs_sam_halo_disk, sam_vs_sam_halo_gal, sam_vs_sam_halo_disk_gas)
    plot_lambda(plt, outdir, obsdir, lambdaH, lambda_jiang, lambda_mass, BT_ratio, stellar_mass, ssfr_z0)
    plot_sizes(plt, outdir, obsdir, disk_size_cen, disk_size_sat, bulge_size, vmax_halo_gal)
Example #11
0
def main():

    model_dir = '/fred/oz009/clagos/vr-testing-outputs/hydro/'
    output_dir = '/fred/oz009/clagos/vr-testing-outputs/Plots/hydro/'
    obs_dir = '/home/clagos/scm/analysis/VR'
    subvols = [0,1,2]
    snap = [28, 19, 15]
    vol = 25.0**3.0 #Mpc
    vol_eagle = 25.0**3.0

    name_file = 'fourth-try-6dfofsubhalos'#:'third-try'

    plt = common.load_matplotlib()
    fields = ['Mass_BN98','Mass_FOF','Mass_200crit','Mass_200mean','Mass_tot','R_200crit','R_200mean','hostHaloID','ID','Vmax','Rmax','Xcmbp','Ycmbp','Zcmbp','cNFW','lambda_B','npart']

    # Create histogram
    hist = np.zeros(shape = (2,len(snap),len(mbins)))
    histsh = np.zeros(shape = (len(snap),len(mbins)))
    histvmax = np.zeros(shape = (2,len(snap),len(vbins)))

    R200med = np.zeros(shape = (2,len(snap),3,len(mbins)))
    rvmaxmed = np.zeros(shape = (2,len(snap),3,len(vbins)))
    cmed = np.zeros(shape = (2,len(snap),3,len(mbins)))
    lambdamed = np.zeros(shape = (2,len(snap),3,len(mbins)))

    for j in range(0,len(snap)):
        hdf5_data = common.read_data(model_dir, fields, snap[j], subvols, name_file)
        prepare_data(hdf5_data, j, hist, histsh, R200med, rvmaxmed, histvmax, cmed, lambdamed)

    # Take logs
    ind = np.where(hist > 0.)
    hist[ind] = np.log10(hist[ind]/vol/dm)

    ind = np.where(histsh > 0.)
    histsh[ind] = np.log10(histsh[ind]/vol/dm)

    ind = np.where(histvmax > 0.)
    histvmax[ind] = np.log10(histvmax[ind]/vol/dm)

    plot_halomf_z(plt, output_dir+name_file+'/', obs_dir, snap, vol_eagle, hist, histsh)
    plot_r200_z(plt, output_dir+name_file+'/', R200med, snap)
    plot_rivmax_vmax_z(plt, output_dir+name_file+'/', rvmaxmed, histvmax, snap, vol_eagle)
    plot_con_lambda(plt, output_dir+name_file+'/', cmed, lambdamed, snap)
Example #12
0
File: smhm.py Project: viogp/shark
def main(modeldir, outdir, redshift_table, subvols):

    plt = common.load_matplotlib()
    fields = {
        'galaxies':
        ('mstars_disk', 'mstars_bulge', 'm_bh', 'mgas_disk', 'mgas_bulge',
         'mhot', 'mreheated', 'mvir_hosthalo', 'type')
    }

    zlist = (0, 0.5, 1, 2, 3, 4)
    snapshots = redshift_table[zlist]
    massgal = np.zeros(shape=(len(zlist), 3, len(xmf)))
    massbar = np.zeros(shape=(len(zlist), 3, len(xmf)))
    massbar_inside = np.zeros(shape=(len(zlist), 3, len(xmf)))

    for idx, snapshot in enumerate(snapshots):
        hdf5_data = common.read_data(modeldir, snapshot, fields, subvols)
        prepare_data(hdf5_data, idx, massgal, massbar, massbar_inside)

    plot_SMHM_z(plt, outdir, zlist, massgal)
    plot_BMHM_z(plt, outdir, massbar, massbar_inside)
Example #13
0
def main(model_dir, outdir, redshift_table, subvols, obsdir):

    # Loop over redshift and subvolumes
    plt = common.load_matplotlib()
    fields = {
        'galaxies': ('mstars_disk', 'mstars_bulge', 'mvir_hosthalo',
                     'mvir_subhalo', 'type')
    }

    z = (0, 0.5, 1, 2)
    snapshots = redshift_table[z]

    # Create histogram
    hist = np.zeros(shape=(len(z), len(mbins)))
    histsh = np.zeros(shape=(len(z), len(mbins)))
    plotz = np.empty(shape=(len(z)), dtype=np.bool_)

    for index, snapshot in enumerate(snapshots):

        hdf5_data = common.read_data(model_dir, snapshot, fields, subvols)
        prepare_data(hdf5_data, hist, histsh, index)

        h0, volh = hdf5_data[0], hdf5_data[1]
        if (volh > 0.):
            vol = volh / pow(h0, 3.)  # In Mpc^3
            hist[index, :] = hist[index, :] / vol / dm
            histsh[index, :] = histsh[index, :] / vol / dm
            plotz[index] = True
        else:
            plotz[index] = False

    # Take logs
    ind = np.where(hist > 0.)
    hist[ind] = np.log10(hist[ind])

    ind = np.where(histsh > 0.)
    histsh[ind] = np.log10(histsh[ind])

    plot_halomf_z(plt, outdir, obsdir, z, h0, hist, histsh, plotz)
Example #14
0
def main(modeldir, outdir, redshift_table, subvols, obsdir):

    plt = common.load_matplotlib()
    fields = {
        'galaxies':
        ('type', 'mstars_disk', 'mstars_bulge', 'rstar_disk', 'm_bh',
         'matom_disk', 'mmol_disk', 'mgas_disk', 'matom_bulge', 'mmol_bulge',
         'mgas_bulge', 'mvir_hosthalo')
    }

    hdf5_data = common.read_data(modeldir, redshift_table[0], fields, subvols)

    (hist_smf, hist_smf_sat, hist_bmf, hist_bmf_sat, mHIms, mHIms_true,
     mHImhalo, mHImhalo_true, ETGsmhalo, LTGsmhalo,
     hist_himf) = prepare_data(hdf5_data)

    plot_smf_resolve(plt, outdir, obsdir, hist_smf, hist_smf_sat)
    plot_bmf_resolve(plt, outdir, obsdir, hist_bmf, hist_bmf_sat)
    plot_mHI_mstar_resolve(plt, outdir, obsdir, mHIms, mHIms_true)
    plot_mHI_mhalo_resolve(plt, outdir, obsdir, mHImhalo, mHImhalo_true)
    plot_bt_resolve(plt, outdir, obsdir, ETGsmhalo, LTGsmhalo)
    plot_bmf_resolve_baryon_components(plt, outdir, obsdir, hist_bmf, hist_smf,
                                       hist_himf)
Example #15
0
def main():

    model_dir = '/fred/oz009/clagos/vr-testing-outputs/hydro/'
    output_dir = '/fred/oz009/clagos/vr-testing-outputs/Plots/hydro/'
    obs_dir = '/home/clagos/scm/analysis/VR'
    subvols = [0, 1, 2]
    snap = [28, 19, 15]
    vol = 25.0**3.0  #Mpc
    vol_eagle = 25.0**3.0

    name_file = 'fourth-try-6dfofsubhalos'  #:'third-try'

    plt = common.load_matplotlib()
    fields = [
        'Aperture_mass_star_30_kpc', 'M_star', 'Aperture_mass_gas_30_kpc',
        'R_HalfMass_star', 'SFR_gas', 'Aperture_mass_30_kpc', 'M_bh',
        'Aperture_rhalfmass_star_30_kpc', 'Aperture_veldisp_star_30_kpc',
        'Zmet_gas', 'Zmet_gas_sf', 'Zmet_star', 'tage_star',
        'Aperture_SFR_gas_30_kpc',
        'Projected_aperture_1_rhalfmass_star_30_kpc',
        'Projected_aperture_2_rhalfmass_star_30_kpc',
        'Projected_aperture_3_rhalfmass_star_30_kpc', 'Zmet_gas_nsf'
    ]

    # Create histogram for mass functions
    histmtot = np.zeros(shape=(len(snap), len(mbins)))
    histm30 = np.zeros(shape=(len(snap), len(mbins)))
    histmgas = np.zeros(shape=(len(snap), len(mbins)))
    histmall = np.zeros(shape=(len(snap), len(mbins)))

    # create matrices for several scaling relations
    SFRMstar = np.zeros(shape=(len(snap), 3, len(mbins)))
    SFRMstar30 = np.zeros(shape=(len(snap), 3, len(mbins)))
    R50Mstar = np.zeros(shape=(len(snap), 3, len(mbins)))
    SigmaMstar = np.zeros(shape=(len(snap), 3, len(mbins)))
    MBHMstar = np.zeros(shape=(len(snap), 3, len(mbins)))
    R50Mstar30 = np.zeros(shape=(len(snap), 3, len(mbins)))
    R50pMstar30 = np.zeros(shape=(len(snap), 3, len(mbins)))
    SigmaMstar30 = np.zeros(shape=(len(snap), 3, len(mbins)))
    ZstarMstar = np.zeros(shape=(len(snap), 3, len(mbins)))
    AgeSMstar = np.zeros(shape=(len(snap), 3, len(mbins)))
    ZSFMstar = np.zeros(shape=(len(snap), 3, len(mbins)))
    ZNSFMstar = np.zeros(shape=(len(snap), 3, len(mbins)))

    for j in range(0, len(snap)):
        hdf5_data = common.read_data(model_dir, fields, snap[j], subvols,
                                     name_file)
        prepare_data(hdf5_data, j, histmtot, histm30, histmgas, SFRMstar,
                     R50Mstar, SigmaMstar, histmall, MBHMstar, R50Mstar30,
                     SigmaMstar30, ZstarMstar, ZSFMstar, AgeSMstar, SFRMstar30,
                     R50pMstar30, ZNSFMstar)

    # Take logs for mass functions
    ind = np.where(histmtot > 0.)
    histmtot[ind] = np.log10(histmtot[ind] / vol / dm)

    ind = np.where(histm30 > 0.)
    histm30[ind] = np.log10(histm30[ind] / vol / dm)

    ind = np.where(histmgas > 0.)
    histmgas[ind] = np.log10(histmgas[ind] / vol / dm)

    ind = np.where(histmall > 0.)
    histmall[ind] = np.log10(histmall[ind] / vol / dm)

    #mass funcion plots
    plot_mf_z(plt, output_dir + name_file + '/', snap, vol_eagle, histmtot,
              histm30, histmgas, histmall)
    #scaling relation plots
    plot_scaling_z(plt, output_dir + name_file + '/', snap, SFRMstar, R50Mstar,
                   R50Mstar30, MBHMstar, SigmaMstar30, ZstarMstar, ZSFMstar,
                   AgeSMstar, SFRMstar30, R50pMstar30, ZNSFMstar)