Esempio n. 1
0
def test_subvol_gmf(Mr):
    """
    """
    thr = -1.0 * np.float(Mr)
    model = PrebuiltHodModelFactory("zheng07", threshold=thr, halocat="multidark", redshift=0.0)
    model.new_haloprop_func_dict = {"sim_subvol": util.mk_id_column}

    datsubvol = lambda x: util.mask_func(x, 0)
    model.populate_mock(simname="multidark", masking_function=datsubvol, enforce_PBC=False)

    # compute group richness
    # These are wrong because they assume periodicity
    # rich = richness(model.mock.compute_fof_group_ids())
    # gmf = GMF(rich)  #GMF
    # print gmf
    # print GMF(rich , counts = True)

    galaxy_sample = model.mock.galaxy_table
    x = galaxy_sample["x"]
    y = galaxy_sample["y"]
    z = galaxy_sample["z"]
    vz = galaxy_sample["vz"]

    pos = three_dim_pos_bundle(model.mock.galaxy_table, "x", "y", "z", velocity=vz, velocity_distortion_dimension="z")

    b_para, b_perp = 0.2, 0.2
    groups = FoFGroups(pos, b_perp, b_para, period=None, Lbox=200, num_threads="max")

    gids = groups.group_ids
    rich = richness(gids)
    gmf = GMF(rich)

    print gmf
    print GMF(rich, counts=True)
    return None
Esempio n. 2
0
def test_GMFbinning(Mr):
    """ Tests for the GMF binning scheme in order to make it sensible. 
    """
    gids_saved = "gids_saved.p"
    if not os.path.isfile(gids_saved):
        thr = -1.0 * np.float(Mr)
        model = PrebuiltHodModelFactory("zheng07", threshold=thr, halocat="multidark", redshift=0.0)
        model.new_haloprop_func_dict = {"sim_subvol": util.mk_id_column}

        datsubvol = lambda x: util.mask_func(x, 0)
        model.populate_mock(simname="multidark", masking_function=datsubvol, enforce_PBC=False)

        galaxy_sample = model.mock.galaxy_table
        x = galaxy_sample["x"]
        y = galaxy_sample["y"]
        z = galaxy_sample["z"]
        vz = galaxy_sample["vz"]

        pos = three_dim_pos_bundle(
            model.mock.galaxy_table, "x", "y", "z", velocity=vz, velocity_distortion_dimension="z"
        )

        b_para, b_perp = 0.2, 0.2
        groups = FoFGroups(pos, b_perp, b_para, period=None, Lbox=200, num_threads="max")

        pickle.dump(groups, open(gids_saved, "wb"))
    else:
        groups = pickle.load(open(gids_saved, "rb"))

    gids = groups.group_ids
    rich = richness(gids)
    # print "rich=" , rich
    rbins = np.logspace(np.log10(3.0), np.log10(20), 10)
    rbins = np.array([1, 2.0, 3.0, 4.0, 5.0, 6.0, 7, 9, 11, 14, 17, 20])
    gmf = GMF(rich, counts=False, bins=rbins)
    gmf_counts = GMF(rich, counts=True, bins=rbins)

    print rbins
    print gmf
    print gmf_counts
    fig = plt.figure(1)
    sub = fig.add_subplot(111)

    sub.plot(0.5 * (rbins[:-1] + rbins[1:]), gmf)

    sub.set_xscale("log")
    sub.set_yscale("log")

    plt.show()
    # print gmf
    # print GMF(rich , counts = True)
    return None
Esempio n. 3
0
def test_subvol_gmf(Mr):
    '''
    '''
    thr = -1. * np.float(Mr)
    model = PrebuiltHodModelFactory('zheng07',
                                    threshold=thr,
                                    halocat='multidark',
                                    redshift=0.)
    model.new_haloprop_func_dict = {'sim_subvol': util.mk_id_column}

    datsubvol = lambda x: util.mask_func(x, 0)
    model.populate_mock(simname='multidark',
                        masking_function=datsubvol,
                        enforce_PBC=False)

    #compute group richness
    # These are wrong because they assume periodicity
    #rich = richness(model.mock.compute_fof_group_ids())
    #gmf = GMF(rich)  #GMF
    #print gmf
    #print GMF(rich , counts = True)

    galaxy_sample = model.mock.galaxy_table
    x = galaxy_sample['x']
    y = galaxy_sample['y']
    z = galaxy_sample['z']
    vz = galaxy_sample['vz']

    pos = three_dim_pos_bundle(model.mock.galaxy_table,
                               'x',
                               'y',
                               'z',
                               velocity=vz,
                               velocity_distortion_dimension="z")

    b_para, b_perp = 0.2, 0.2
    groups = FoFGroups(pos,
                       b_perp,
                       b_para,
                       period=None,
                       Lbox=200,
                       num_threads='max')

    gids = groups.group_ids
    rich = richness(gids)
    gmf = GMF(rich)

    print gmf
    print GMF(rich, counts=True)
    return None
Esempio n. 4
0
def build_xi_nbar_gmf(Mr=21):
    '''
    Build "data" xi, nbar, GMF values and write to file
    '''
    model = PrebuiltHodModelFactory('zheng07', threshold = -1.0*np.float(Mr))
    model.populate_mock(halocat = halocat , enforce_PBC = False) # population mock realization
    pos = three_dim_pos_bundle(model.mock.galaxy_table, 'x', 'y', 'z')

    # write xi
    rbins = hardcoded_xi_bins()
    rmax = rbins.max()
    approx_cell1_size = [rmax, rmax, rmax]
    approx_cell2_size = approx_cell1_size
    approx_cellran_size = [rmax, rmax, rmax]
    period = np.array([Lbox , Lbox , Lbox]) 
    data_xir = tpcf(
            sample1, rbins, sample2 = sample2, 
            randoms=randoms, period = period, 
            max_sample_size=int(1e4), estimator='Landy-Szalay', 
            approx_cell1_size=approx_cell1_size, 
            approx_cellran_size=approx_cellran_size, 
            RR_precomputed = RR, 
            NR_precomputed = NR1) 
    output_file = ''.join([util.dat_dir(), 'xir.Mr', str(Mr), '.dat'])
    np.savetxt(output_file, data_xir)

    # write nbar values
    nbar = model.mock.number_density
    output_file = ''.join([util.dat_dir(), 'nbar.Mr', str(Mr), '.dat'])
    np.savetxt(output_file, [nbar])

    # write GMF
    rich = richness(model.mock.compute_fof_group_ids())
    gmf = GMF(rich)  # GMF
    output_file = ''.join([util.dat_dir(), 'gmf.Mr', str(Mr), '.dat'])
    np.savetxt(output_file, gmf)

    return None
Esempio n. 5
0
def test_GMFbinning(Mr):
    ''' Tests for the GMF binning scheme in order to make it sensible. 
    '''
    gids_saved = 'gids_saved.p'
    if not os.path.isfile(gids_saved):
        thr = -1. * np.float(Mr)
        model = PrebuiltHodModelFactory('zheng07',
                                        threshold=thr,
                                        halocat='multidark',
                                        redshift=0.)
        model.new_haloprop_func_dict = {'sim_subvol': util.mk_id_column}

        datsubvol = lambda x: util.mask_func(x, 0)
        model.populate_mock(simname='multidark',
                            masking_function=datsubvol,
                            enforce_PBC=False)

        galaxy_sample = model.mock.galaxy_table
        x = galaxy_sample['x']
        y = galaxy_sample['y']
        z = galaxy_sample['z']
        vz = galaxy_sample['vz']

        pos = three_dim_pos_bundle(model.mock.galaxy_table,
                                   'x',
                                   'y',
                                   'z',
                                   velocity=vz,
                                   velocity_distortion_dimension="z")

        b_para, b_perp = 0.2, 0.2
        groups = FoFGroups(pos,
                           b_perp,
                           b_para,
                           period=None,
                           Lbox=200,
                           num_threads='max')

        pickle.dump(groups, open(gids_saved, 'wb'))
    else:
        groups = pickle.load(open(gids_saved, 'rb'))

    gids = groups.group_ids
    rich = richness(gids)
    #print "rich=" , rich
    rbins = np.logspace(np.log10(3.), np.log10(20), 10)
    rbins = np.array([1, 2., 3., 4., 5., 6., 7, 9, 11, 14, 17, 20])
    gmf = GMF(rich, counts=False, bins=rbins)
    gmf_counts = GMF(rich, counts=True, bins=rbins)

    print rbins
    print gmf
    print gmf_counts
    fig = plt.figure(1)
    sub = fig.add_subplot(111)

    sub.plot(0.5 * (rbins[:-1] + rbins[1:]), gmf)

    sub.set_xscale('log')
    sub.set_yscale('log')

    plt.show()
    #print gmf
    #print GMF(rich , counts = True)
    return None