コード例 #1
0
    def test_filenames(self):
        # Read in celr_e | halo 0 | z=0
        path = '/cosma5/data/dp004/dc-pear3/data/eagle'
        exists_dir = os.path.isdir(
            os.path.join(path, 'halo_00/data/particledata_029_z000p000'))
        exists_file = os.path.isfile(
            os.path.join(path, 'halo_00/data/particledata_029_z000p000',
                         'eagle_subfind_particles_029_z000p000.0.hdf5'))

        print(f"\n{' celr_e | halo 0 | z=0 ':-^60}")
        print(f"Data directory exists: {exists_dir}.")
        print(f"Data file exists: {exists_file}.")

        # Read in celr_b | halo 0 | z=0
        path = '/cosma5/data/dp004/dc-pear3/data/bahamas'
        exists_dir = os.path.isdir(
            os.path.join(path, 'halo_00/data/particledata_029'))
        exists_file = os.path.isfile(
            os.path.join(path, 'halo_00/data/particledata_029',
                         'eagle_subfind_particles_029.0.hdf5'))

        print(f"\n{' celr_b | halo 0 | z=0 ':-^60}")
        print(f"Data directory exists: {exists_dir}.")
        print(f"Data file exists: {exists_file}.")

        # Read in macsis | halo 0 | z=0
        path = '/cosma5/data/dp004/dc-hens1/macsis/macsis_gas'
        exists_dir = os.path.isdir(
            os.path.join(path, 'halo_0000/data/particledata_022'))
        exists_file = os.path.isfile(
            os.path.join(path, 'halo_0000/data/particledata_022',
                         'eagle_subfind_particles_022.0.hdf5'))

        print(f"\n{' macsis | halo 0 | z=0 ':-^60}")
        print(f"Data directory exists: {exists_dir}.")
        print(f"Data file exists: {exists_file}.")

        # Read in ceagle | halo 0 | z=0
        path = '/cosma5/data/dp004/C-EAGLE/Complete_Sample'
        exists_dir = os.path.isdir(
            os.path.join(path, 'CE_00/data/particledata_029_z000p000'))
        print(f"\n{' ceagle | halo 0 | z=0 ':-^60}")
        print(f"Data directory exists: {exists_dir}.")
        collection_exists_file = []
        file_index = 0
        exists_file = True

        while exists_file:
            exists_file = os.path.isfile(
                os.path.join(
                    path, f'CE_00/data/particledata_029_z000p000',
                    f'eagle_subfind_particles_029_z000p000.{str(file_index)}.hdf5'
                ))
            collection_exists_file.append(exists_file)
            print(f"Data file {file_index:03d} exists: {exists_file}.")
            file_index += 1

        print(f"{' SOFTWARE TEST ':=^60}")
        for sim in ['celr_e', 'celr_b', 'macsis', 'ceagle']:
            cluster = Cluster(simulation_name=sim,
                              clusterID=0,
                              redshift='z000p000')
            print(f"\n {sim}{' | halo 0 | z=0 ':-^60}")
            # print("cluster.groups_filePaths", cluster.groups_filePaths(), sep='\n')
            # Check the files exist
            for file in cluster.groups_filePaths():
                print(os.path.isfile(file), file)

            # print("cluster.partdata_filePaths", cluster.partdata_filePaths(), sep='\n')
            # Check the files exist
            for file in cluster.partdata_filePaths():
                print(os.path.isfile(file), file)
コード例 #2
0
filepath = "/local/scratch/altamura/analysis_results/"
filename = f"bahamas-box-5r200spheres.jpg"

fig = plt.figure(figsize=(15, 15))
ax = fig.add_subplot(111)
ax.set_aspect('equal')
# ax.set_xlim([0, 400])
# ax.set_ylim([0, 400])
ax.set_xlabel(r'$x$ \quad [cMpc]')
ax.set_ylabel(r'$y$ \quad [cMpc]')

n_largeM = 0
n_total = 0

for counter, file in enumerate(cluster.groups_filePaths()):
    print(f"[+] Analysing eagle_subfind_tab file {counter}")
    with h5py.File(file, 'r') as group_file:
        cop = group_file['/FOF/GroupCentreOfPotential'][:]
        m500 = group_file['/FOF/Group_M_Crit500'][:] * 10**10
        r200 = group_file['/FOF/Group_R_Crit200'][:]
        n_total += len(m500)
        m_filter = np.where(m500 > 10**13)[0]
        n_largeM += len(m_filter)

        ax.scatter(cop[m_filter, 0],
                   cop[m_filter, 1],
                   marker='o',
                   s=2,
                   c='r',
                   alpha=1)