Example #1
0
def test_loop_apertures(i):
    # Create a cluster object
    cluster = Cluster(simulation_name='ceagle', clusterID=i, redshift='z000p000')
    apertures = cluster.generate_apertures()

    for aperture in apertures:
        # Create a PhaseDiagram object and link it to the cluster object
        t_rho_diagram = PhaseDiagram(cluster, aperture=aperture)
        t_rho_diagram.info()

        # Test the map output
        t_rho_diagram.setup_plot()
Example #2
0
    def make_simstats(self,
                      save2hdf5: bool = True) -> Union[pd.DataFrame, None]:
        if not self.is_metadata():
            print('[+] Metadata file not found.')
            self.make_metadata()
        df = pd.DataFrame(columns=self.cols)
        iterator = itertools.product(self.simulation.clusterIDAllowed,
                                     self.simulation.redshiftAllowed)
        print(
            f"{'':<30s} {' process ID ':^25s} | {' halo ID ':^15s} | {' halo redshift ':^20s}\n"
        )
        for process_n, (halo_id, halo_z) in enumerate(list(iterator)):
            if self.simulation.sample_completeness[
                    halo_id,
                    self.simulation.redshiftAllowed.index(halo_z)]:
                print(
                    f"{'Processing...':<30s} {process_n:^25d} | {halo_id:^15d} | {halo_z:^20s}"
                )
                cluster = Cluster(
                    simulation_name=self.simulation.simulation_name,
                    clusterID=halo_id,
                    redshift=halo_z)
                read = pull.FOFRead(cluster)
                df = df.append(
                    {
                        'cluster_id':
                        cluster.clusterID,
                        'redshift_float':
                        cluster.z,
                        'R_2500_crit':
                        cluster.r2500,
                        'R_500_crit':
                        cluster.r500,
                        'R_200_crit':
                        cluster.r200,
                        'R_aperture':
                        cluster.generate_apertures()[self.aperture_id],
                        'M_2500_crit':
                        cluster.mass_units(cluster.M2500, unit_system='astro'),
                        'M_500_crit':
                        cluster.mass_units(cluster.M500, unit_system='astro'),
                        'M_200_crit':
                        cluster.mass_units(cluster.M200, unit_system='astro'),
                        'M_aperture_T':
                        cluster.mass_units(read.pull_mass_aperture(
                            'Total_mass')[self.aperture_id],
                                           unit_system='astro'),
                        'M_aperture_0':
                        cluster.mass_units(read.pull_mass_aperture(
                            'ParType0_mass')[self.aperture_id],
                                           unit_system='astro'),
                        'M_aperture_1':
                        cluster.mass_units(read.pull_mass_aperture(
                            'ParType1_mass')[self.aperture_id],
                                           unit_system='astro'),
                        'M_aperture_4':
                        cluster.mass_units(read.pull_mass_aperture(
                            'ParType4_mass')[self.aperture_id],
                                           unit_system='astro'),
                        'rotTvelT':
                        read.pull_rot_vel_angle_between(
                            'Total_angmom', 'Total_ZMF')[self.aperture_id],
                        'rot0rot4':
                        read.pull_rot_vel_angle_between(
                            'ParType0_angmom',
                            'ParType4_angmom')[self.aperture_id],
                        'rot1rot4':
                        read.pull_rot_vel_angle_between(
                            'ParType1_angmom',
                            'ParType4_angmom')[self.aperture_id],
                        'vel0vel1':
                        read.pull_rot_vel_angle_between(
                            'ParType0_ZMF', 'ParType1_ZMF')[self.aperture_id],
                        'peculiar_velocity_T_magnitude':
                        read.pull_peculiar_velocity_magnitude('Total_ZMF')[
                            self.aperture_id],
                        'peculiar_velocity_0_magnitude':
                        read.pull_peculiar_velocity_magnitude('ParType0_ZMF')[
                            self.aperture_id],
                        'peculiar_velocity_1_magnitude':
                        read.pull_peculiar_velocity_magnitude('ParType1_ZMF')[
                            self.aperture_id],
                        'peculiar_velocity_4_magnitude':
                        read.pull_peculiar_velocity_magnitude('ParType4_ZMF')[
                            self.aperture_id],
                        'angular_momentum_T_magnitude':
                        cluster.momentum_units(
                            read.pull_angular_momentum_magnitude(
                                'Total_angmom')[self.aperture_id],
                            unit_system='astro'),
                        'angular_momentum_0_magnitude':
                        cluster.momentum_units(
                            read.pull_angular_momentum_magnitude(
                                'ParType0_angmom')[self.aperture_id],
                            unit_system='astro'),
                        'angular_momentum_1_magnitude':
                        cluster.momentum_units(
                            read.pull_angular_momentum_magnitude(
                                'ParType1_angmom')[self.aperture_id],
                            unit_system='astro'),
                        'angular_momentum_4_magnitude':
                        cluster.momentum_units(
                            read.pull_angular_momentum_magnitude(
                                'ParType4_angmom')[self.aperture_id],
                            unit_system='astro'),
                        'kinetic_energy_T':
                        cluster.energy_units(read.pull_kinetic_energy(
                            'Total_kin_energy')[self.aperture_id],
                                             unit_system='SI'),
                        'kinetic_energy_0':
                        cluster.energy_units(read.pull_kinetic_energy(
                            'ParType0_kin_energy')[self.aperture_id],
                                             unit_system='SI'),
                        'kinetic_energy_1':
                        cluster.energy_units(read.pull_kinetic_energy(
                            'ParType1_kin_energy')[self.aperture_id],
                                             unit_system='SI'),
                        'thermal_energy':
                        cluster.energy_units(read.pull_thermal_energy(
                            'Total_th_energy')[self.aperture_id],
                                             unit_system='SI'),
                        'substructure_mass_T':
                        cluster.mass_units(read.pull_substructure_mass(
                            'Total_substructure_mass')[self.aperture_id],
                                           unit_system='astro'),
                        'dynamical_merging_index_T':
                        read.pull_dynamical_merging_index(
                            'Total_dyn_mergindex')[self.aperture_id],
                        'thermodynamic_merging_index_T':
                        read.pull_thermodynamic_merging_index(
                            'Total_therm_mergindex')[self.aperture_id],
                        'substructure_fraction_T':
                        read.pull_substructure_merging_index(
                            'Total_substructure_fraction')[self.aperture_id]
                    },
                    ignore_index=True)
            else:
                print(
                    f"{'Skip - sample_completeness':<30s} {process_n:^25d} | {halo_id:^15d} | {halo_z:^20s}"
                )

        print(df.info())
        if save2hdf5:
            self.h5store(os.path.join(self.path, self.filename),
                         df,
                         key=f'aperture{self.aperture_id}')
            if os.path.isfile(os.path.join(self.path, self.filename)):
                print(
                    f"[+] Saved\n[+]\tPath: {self.path}\n[+]\tFile: {self.filename}"
                )
        else:
            return df