def CountsInCylinders(proj_search_radius, cylinder_half_length, period,
                      filename):
    global path
    if filename.endswith(".npy"):
        sample = np.load(os.path.join(path, filename))
        if (sample.dtype != 'float64'):
            sample = sample.astype('float64')
            cic = counts_in_cylinders(
                sample,
                sample,
                proj_search_radius=proj_search_radius,
                cylinder_half_length=cylinder_half_length,
                period=period)
            np.save(os.path.join('/home/ajana/CIC/', 'cic_' + str(filename)),
                    cic.astype('int8'))
        else:
            cic = counts_in_cylinders(
                sample,
                sample,
                proj_search_radius=proj_search_radius,
                cylinder_half_length=cylinder_half_length,
                period=period)
            np.save(os.path.join('/home/ajana/CIC/', 'cic_' + str(filename)),
                    cic.astype('int8'))

    else:
        raise TypeError("File should be in .npy format")
Esempio n. 2
0
def CountsInAnnuli(inner_radius, outer_radius, cylinder_half_length, period,
                   filename):
    global path
    if filename.endswith(".npy"):
        sample = np.load(os.path.join(path, filename))
        if (sample.dtype != 'float64'):
            sample = sample.astype('float64')
            outer = counts_in_cylinders(
                sample,
                sample,
                proj_search_radius=outer_radius,
                cylinder_half_length=cylinder_half_length,
                period=period)
            inner = counts_in_cylinders(
                sample,
                sample,
                proj_search_radius=inner_radius,
                cylinder_half_length=cylinder_half_length,
                period=period)
            #np.save(os.path.join('/mnt/data4/Abhishek/CIA/random','cia_'+str(filename)),(outer-inner).astype('int8'))
            np.save(
                os.path.join('/mnt/data4/Abhishek/fidmock/cia',
                             'cia_' + str(filename)),
                ((outer - inner).astype('int8')))
            del outer
            del inner
            del sample
        else:
            outer = counts_in_cylinders(
                sample,
                sample,
                proj_search_radius=outer_radius,
                cylinder_half_length=cylinder_half_length,
                period=period)
            inner = counts_in_cylinders(
                sample,
                sample,
                proj_search_radius=inner_radius,
                cylinder_half_length=cylinder_half_length,
                period=period)
            #np.save(os.path.join('/mnt/data4/Abhishek/CIA/random','cia_'+str(filename)),(outer-inner).astype('int8'))
            np.save(
                os.path.join('/mnt/data4/Abhishek/fidmock/cia',
                             'cia_' + str(filename)),
                ((outer - inner).astype('int8')))
            del outer
            del inner
            del sample
    else:
        raise TypeError("File should be in .npy format")
Esempio n. 3
0
def calc_all_observables(param, seed=seed):

    model.param_dict.update(dict(
        zip(param_names,
            param)))  ##update model.param_dict with pairs (param_names:params)

    try:
        model.mock.populate(seed=seed)
    except:
        model.populate_mock(halocat, seed=seed)

    gc.collect()

    output = []

    pos_gals_d = return_xyz_formatted_array(*(model.mock.galaxy_table[ax] for ax in 'xyz'), \
            velocity=model.mock.galaxy_table['vz'], velocity_distortion_dimension='z',\
                                          period=Lbox)             ##redshift space distorted
    pos_gals_d = np.array(pos_gals_d, dtype=float)

    pos_gals = return_xyz_formatted_array(*(model.mock.galaxy_table[ax]
                                            for ax in 'xyz'),
                                          period=Lbox)
    pos_gals = np.array(pos_gals, dtype=float)
    particle_masses = halocat.particle_mass
    total_num_ptcls_in_snapshot = halocat.num_ptcl_per_dim**3
    downsampling_factor = total_num_ptcls_in_snapshot / float(num_ptcls_to_use)

    vpf = void_prob_func(pos_gals_d,
                         r_vpf,
                         random_sphere_centers=vpf_centers,
                         period=Lbox)
    wprp = wp(pos_gals_d, r_wp, pi_max, period=Lbox)
    Pcic = np.bincount(counts_in_cylinders(pos_gals_d, pos_gals_d, proj_search_radius, \
            cylinder_half_length, period=Lbox), minlength=100)[1:71]/float(pos_gals_d.shape[0])
    Pcic_40 = np.add.reduceat(Pcic, sum_40)
    ggl = delta_sigma(pos_gals, ptclpos, particle_masses=particle_masses, downsampling_factor=downsampling_factor,\
                      rp_bins=rp_bins_ggl, period=Lbox)[1]/1e12

    func = np.concatenate((np.array(
        (pos_gals_d.shape[0] / float(Lbox**3), )), wprp, ggl, vpf, Pcic_40))

    output.append(func)

    # parameter set
    output.append(param)

    output.append(np.where(param - fid != 0)[0][0])

    return output
Esempio n. 4
0
def calc_all_observables(param):

    model.param_dict.update(dict(
        zip(param_names,
            param)))  ##update model.param_dict with pairs (param_names:params)

    try:
        model.mock.populate()
    except:
        model.populate_mock(halocat)

    gc.collect()

    output = []

    pos_gals_d = return_xyz_formatted_array(*(model.mock.galaxy_table[ax] for ax in 'xyz'), \
            velocity=model.mock.galaxy_table['vz'], velocity_distortion_dimension='z',\
                                          period=Lbox)             ##redshift space distorted
    pos_gals_d = np.array(pos_gals_d, dtype=float)

    vpf = void_prob_func(pos_gals_d,
                         r_vpf,
                         random_sphere_centers=vpf_centers,
                         period=Lbox)
    wprp = wp(pos_gals_d, r_wp, pi_max, period=Lbox)
    Pcic = np.bincount(counts_in_cylinders(pos_gals_d, pos_gals_d, proj_search_radius, \
            cylinder_half_length,period=Lbox), minlength=100)[1:71]/float(pos_gals_d.shape[0])

    func = np.concatenate((np.array(
        (pos_gals_d.shape[0] / float(Lbox**3), )), wprp, vpf, Pcic))

    output.append(func)

    # parameter set
    output.append(param)

    output.append(np.where(param - median_w != 0)[0][0])

    return output