Ejemplo n.º 1
0
def plot_position_scatter(MS_table, pos_key1='x', pos_key2='y'):
    check_for_pos_key(pos_key1)
    check_for_pos_key(pos_key2)
    pos1 = m2.get_col_halo_table(MS_table, pos_key1)
    pos2 = m2.get_col_halo_table(MS_table, pos_key2)
    plt.plot(pos1, pos2, '*', markersize=.96)
    plt.xlabel('{0} [Mpc / h]'.format(pos_key1))
    plt.ylabel('{0} [Mpc / h]'.format(pos_key2))
Ejemplo n.º 2
0
def plot_position_scatter(MS_table, pos_key1 = 'x', pos_key2 = 'y'):
    check_for_pos_key(pos_key1)
    check_for_pos_key(pos_key2)
    pos1 = m2.get_col_halo_table(MS_table, pos_key1)
    pos2 = m2.get_col_halo_table(MS_table, pos_key2)
    plt.plot(pos1, pos2, '*', markersize = .96)
    plt.xlabel('{0} [Mpc / h]'.format(pos_key1))
    plt.ylabel('{0} [Mpc / h]'.format(pos_key2))
Ejemplo n.º 3
0
def plot_mass_histogram(MS_table, mass_key = 'fof_np', no_h = True, MS2 = False, bins = 50, color = 'k', label = ''):
    check_for_mass_key(mass_key)
    mass = np.array(m2.get_col_halo_table(MS_table, mass_key))
    if MS2 == False:
        mass_conv = 8.6E8
    else:
        mass_conv = 6.885E6
    if no_h:
        mass_conv /= cosmo['h']
    mass = np.log10(mass * mass_conv)
    hist_ret = plt.hist(mass, bins, color = color, label = label)
    return hist_ret
Ejemplo n.º 4
0
def plot_mass_histogram(MS_table,
                        mass_key='fof_np',
                        no_h=True,
                        MS2=False,
                        bins=50,
                        color='k',
                        label=''):
    check_for_mass_key(mass_key)
    mass = np.array(m2.get_col_halo_table(MS_table, mass_key))
    if MS2 == False:
        mass_conv = 8.6E8
    else:
        mass_conv = 6.885E6
    if no_h:
        mass_conv /= cosmo['h']
    mass = np.log10(mass * mass_conv)
    hist_ret = plt.hist(mass, bins, color=color, label=label)
    return hist_ret
Ejemplo n.º 5
0
                        MS2=False,
                        bins=50,
                        color='k',
                        label=''):
    check_for_mass_key(mass_key)
    mass = np.array(m2.get_col_halo_table(MS_table, mass_key))
    if MS2 == False:
        mass_conv = 8.6E8
    else:
        mass_conv = 6.885E6
    if no_h:
        mass_conv /= cosmo['h']
    mass = np.log10(mass * mass_conv)
    hist_ret = plt.hist(mass, bins, color=color, label=label)
    return hist_ret


if __name__ == '__main__':
    a = m2.read_halo_table_ascii(
        "/Volumes/DATA/Millennium Data/MillenniumII/snap6.txt",
        "0,1,2,3,4,5,6,7,8,9,x,x,x,x,x,15,16,17,x,x,20")
    plot_mass_histogram(a,
                        mass_key='fof_np',
                        no_h=True,
                        MS2=True,
                        color='k',
                        label='no_h')
    plot_mass_histogram(a, mass_key='fof_np', no_h=False, MS2=True, color='r')
    plt.rc('text', usetex=True)
    plt.xlabel('Mass (M$_\\odot$)')
    plt.show()
Ejemplo n.º 6
0
##function plots Millennium or MillenniumII structures 
def plot_position_scatter(MS_table, pos_key1 = 'x', pos_key2 = 'y'):
    check_for_pos_key(pos_key1)
    check_for_pos_key(pos_key2)
    pos1 = m2.get_col_halo_table(MS_table, pos_key1)
    pos2 = m2.get_col_halo_table(MS_table, pos_key2)
    plt.plot(pos1, pos2, '*', markersize = .96)
    plt.xlabel('{0} [Mpc / h]'.format(pos_key1))
    plt.ylabel('{0} [Mpc / h]'.format(pos_key2))
    
def plot_mass_histogram(MS_table, mass_key = 'fof_np', no_h = True, MS2 = False, bins = 50, color = 'k', label = ''):
    check_for_mass_key(mass_key)
    mass = np.array(m2.get_col_halo_table(MS_table, mass_key))
    if MS2 == False:
        mass_conv = 8.6E8
    else:
        mass_conv = 6.885E6
    if no_h:
        mass_conv /= cosmo['h']
    mass = np.log10(mass * mass_conv)
    hist_ret = plt.hist(mass, bins, color = color, label = label)
    return hist_ret
    
if __name__ == '__main__':
    a = m2.read_halo_table_ascii("/Volumes/DATA/Millennium Data/MillenniumII/snap6.txt", "0,1,2,3,4,5,6,7,8,9,x,x,x,x,x,15,16,17,x,x,20")
    plot_mass_histogram(a, mass_key = 'fof_np', no_h = True, MS2 = True, color = 'k', label = 'no_h')
    plot_mass_histogram(a, mass_key = 'fof_np', no_h = False, MS2 = True, color = 'r')
    plt.rc('text', usetex = True)
    plt.xlabel('Mass (M$_\\odot$)')
    plt.show()


import MillenniumII as ml
import os
from subprocess import check_output
from IO import readfile
import matplotlib.pyplot as plt
import numpy as np

if __name__ == '__main__':
    home = '{0}/'.format(os.environ['HOME'])
    direc = '{0}/Projects/age-clustering/plots/'.format(home)
    ifilearr = ['sig_massloss.txt', 'no_sig_massloss.txt']
    for ifile in ifilearr: 
        data = ml.read_halo_table_ascii('{0}{1}'.format(direc, ifile), 'x,x,x,x,x,x,x,7,8,9,x,x,x,x,x,x,x,x,x,x,x,x,x,x')
        x = np.array(ml.get_col_halo_table(data,'x'))
        y = np.array(ml.get_col_halo_table(data, 'y'))
        z = np.array(ml.get_col_halo_table(data, 'z'))
        out_halo_name = '{0}halo_{1}'.format(direc, ifile)
        ml.write_halo_table_ascii(out_halo_name, data, fmt = '0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20')
        xiauto_file = '{0}xi_{1}'.format(direc, ifile)
        #check_output(['2pt-autocorrelation', out_halo_name, xiauto_file])
        #xi_auto = readfile(xiauto_file, 3, ',', 2)
        plt.plot(x, y, '+', markersize = 0.9, label = ifile)
        plt.show()
        #plt.loglog(xi_auto[0],xi_auto[1], label = ifile)
    #plt.legend()
    #plt.show()
    #haloid, subhaloid, treeid, descendantid, lastprogenitorid, snapnum, sub_np, x, y, z, firsthaloinfofgroupid, radii, fofid, fof_np, firstsubhaloid, max_tree_mass, max_tree_mass_snap, min_mass_root_max, min_mass_root_max_snap, assem_gao, assem_jp, form_gao, form_jp, merg
    #check_output(['2pt-crosscorrelation', out_halo_name, halos_filename, xi_cross_filename])
Ejemplo n.º 8
0
import numpy as np
import MillenniumII as m2
import os
import Correlation_Func as cf
import Standard_Plots as sp
    
if __name__ == '__main__':
    curr = '{0}/'.format(os.getcwd())
    filen = 'Mstar_cat_snap31-MS2.txt'
    xi_m_m_filen = 'xi_m_m_31.txt'
    h = 0.73
    mass_conv = 6.9E6 / h #Converts to Solar Masses 
    #Read in xi_m_m
    xi_m_m_corr = cf.read_corr_file(xi_m_m_filen)
    #Read in sample
    sample = m2.read_halo_table_ascii('{0}{1}'.format(curr, filen), '7,8,9,17')
    print 'Plotting position scatter plot of sample file: {0}'.format(filen)
    sp.plot_position_scatter(sample, 'x', 'y')
    plt.show()
    print np.median(np.array(m2.get_col_halo_table(sample, 'fof_np')) * mass_conv)
    sample_auto_corr = cf.calc_auto_corr(sample, MS2 = True)
    #sample_cross_corr = calc_cross_corr(sample)
    plt.loglog(sample_auto_corr['data'].r, sample_auto_corr['data'].cf, label = 'sample')
    plt.loglog(xi_m_m_corr['data'].r, xi_m_m_corr['data'].cf, label = '$\\xi_{mm}$')
    print sample_auto_corr['data'].cf
    print xi_m_m_corr['data'].cf
    plt.plot(sample_auto_corr['data'].r, np.sqrt(sample_auto_corr['data'].cf / xi_m_m_corr['data'].cf))
    plt.legend()
    plt.rc('text', usetex = True)
    plt.xlabel('r [Mpc / h]')
    plt.ylabel('$\\xi(r)$')
Ejemplo n.º 9
0
import numpy as np
import MillenniumII as m2
import os
import Correlation_Func as cf
import Standard_Plots as sp

if __name__ == '__main__':
    curr = '{0}/'.format(os.getcwd())
    filen = 'Mstar_cat_snap31-MS2.txt'
    xi_m_m_filen = 'xi_m_m_31.txt'
    h = 0.73
    mass_conv = 6.9E6 / h  #Converts to Solar Masses
    #Read in xi_m_m
    xi_m_m_corr = cf.read_corr_file(xi_m_m_filen)
    #Read in sample
    sample = m2.read_halo_table_ascii('{0}{1}'.format(curr, filen), '7,8,9,17')
    print 'Plotting position scatter plot of sample file: {0}'.format(filen)
    sp.plot_position_scatter(sample, 'x', 'y')
    plt.show()
    print np.median(
        np.array(m2.get_col_halo_table(sample, 'fof_np')) * mass_conv)
    sample_auto_corr = cf.calc_auto_corr(sample, MS2=True)
    #sample_cross_corr = calc_cross_corr(sample)
    plt.loglog(sample_auto_corr['data'].r,
               sample_auto_corr['data'].cf,
               label='sample')
    plt.loglog(xi_m_m_corr['data'].r,
               xi_m_m_corr['data'].cf,
               label='$\\xi_{mm}$')
    print sample_auto_corr['data'].cf
    print xi_m_m_corr['data'].cf