Ejemplo n.º 1
0
    def redshift(self, value):
        # check type
        if type(value) != float and type(value) != int and type(
                value) != np.float64:
            raise TypeError("The redshift should be a int or a float.")

        # value check
        if value < 0:
            raise ValueError("The redshift should be larger or equal to 0.")

        # Setting parameters
        self._redshift = value
        self._D_ang = self._cosmo.angular_diameter_distance(self._redshift)
        self._D_lum = self._cosmo.luminosity_distance(self._redshift)
        self._R500 = cluster_global.Mdelta_to_Rdelta(
            self._M500.to_value('Msun'),
            self._redshift,
            delta=500,
            cosmo=self._cosmo) * u.kpc
        self._theta500 = ((self._R500 / self._D_ang).to('') * u.rad).to('deg')
        self._theta_truncation = ((self._R_truncation / self._D_ang).to('') *
                                  u.rad).to('deg')

        # Information
        if not self._silent: print("Setting redshift value")
        if not self._silent:
            print(
                "Setting: D_ang, D_lum, R500, theta500, theta_truncation ; Fixing: cosmo."
            )
Ejemplo n.º 2
0
    def M500(self, value):
        # Type check
        try:
            test = value.to('Msun')
        except:
            raise TypeError(
                "The mass M500 should be a quantity homogeneous to Msun.")

        # Value check
        if value <= 0:
            raise ValueError("Mass M500 should be larger than 0")

        # Setting parameters
        self._M500 = value
        self._R500 = cluster_global.Mdelta_to_Rdelta(
            self._M500.to_value('Msun'),
            self._redshift,
            delta=500,
            cosmo=self._cosmo) * u.kpc
        self._theta500 = ((self._R500 / self._D_ang).to('') * u.rad).to('deg')

        # Information
        if not self._silent: print("Setting M500 value")
        if not self._silent:
            print("Setting: R500, theta500 ; Fixing: redshift, cosmo, D_ang")
Ejemplo n.º 3
0
    def __init__(
        self,
        name='Cluster',
        RA=0.0 * u.deg,
        Dec=0.0 * u.deg,
        redshift=0.01,
        M500=1e15 * u.Unit('Msun'),
        cosmology=astropy.cosmology.Planck15,
        silent=False,
        output_dir='./ClusterModel',
    ):
        """
        Initialize the cluster object. Several attributes of the class cannot 
        be defined externally because of intrications between parameters. For 
        instance, the cosmology cannot be changed on the fly because this would 
        mess up the internal consistency.
        
        Parameters
        ----------
        - name (str): cluster name 
        - RA, Dec (quantity): coordinates or the cluster in equatorial frame
        - redshift (float) : the cluster center cosmological redshift
        - M500 (quantity): the cluster mass 
        - cosmology (astropy.cosmology): the name of the cosmology to use.
        - silent (bool): set to true in order not to print informations when running 
        - output_dir (str): where to save outputs
        
        """

        #---------- Print the code header at launch
        if not silent:
            model_title.show()

        #---------- Admin
        self._silent = silent
        self._output_dir = output_dir

        #---------- Check that the cosmology is indeed a cosmology object
        if hasattr(cosmology, 'h') and hasattr(cosmology, 'Om0'):
            self._cosmo = cosmology
        else:
            raise TypeError(
                "Input cosmology must be an instance of astropy.cosmology")

        #---------- Global properties
        self._name = name
        self._coord = SkyCoord(RA, Dec, frame="icrs")
        self._redshift = redshift
        self._D_ang = self._cosmo.angular_diameter_distance(self._redshift)
        self._D_lum = self._cosmo.luminosity_distance(self._redshift)
        self._M500 = M500
        self._R500 = cluster_global.Mdelta_to_Rdelta(
            self._M500.to_value('Msun'),
            self._redshift,
            delta=500,
            cosmo=self._cosmo) * u.kpc
        self._theta500 = ((self._R500 / self._D_ang).to('') * u.rad).to('deg')

        #---------- Cluster boundery
        self._R_truncation = 3 * self._R500
        self._theta_truncation = ((self._R_truncation / self._D_ang).to('') *
                                  u.rad).to('deg')

        #---------- ICM composition (default: protosolar from Lodders et al 2009: arxiv0901.1149)
        self._helium_mass_fraction = 0.2735
        self._metallicity_sol = 0.0153
        self._abundance = 0.3

        #---------- Extragalactic background light absorbtion
        self._EBL_model = 'dominguez'

        #---------- Physical properties
        self._Rmin = 1.0 * u.kpc
        self._hse_bias = 0.2
        self._X_cr_E = {'X': 0.01, 'R_norm': self._R500}
        self._Epmin = cluster_spectra.pp_pion_kinematic_energy_threshold(
        ) * u.GeV
        self._Epmax = 10.0 * u.PeV
        self._pp_interaction_model = 'Pythia8'

        # Initialize the profile model (not useful but for clarity of variables)
        self._pressure_gas_model = 1
        self._density_gas_model = 1
        self._density_crp_model = 1
        self._magfield_model = 1
        # Set default model using UPP + isoThermal + isobaric
        self.set_pressure_gas_gNFW_param(pressure_model='P13UPP')
        self.set_density_gas_isoT_param(10.0 * u.keV)
        self.set_density_crp_isobaric_scal_param(scal=1.0)
        self.set_magfield_isobaric_scal_param(Bnorm=10 * u.uG, scal=0.5)

        # Cosmic ray protons
        self._spectrum_crp_model = {
            'name': 'PowerLaw',
            'PivotEnergy': 1.0 * u.TeV,
            'Index': 2.5
        }

        #---------- Sampling
        self._Npt_per_decade_integ = 30
        self._map_coord = SkyCoord(RA, Dec, frame="icrs")
        self._map_reso = 0.02 * u.deg
        self._map_fov = [5.0, 5.0] * u.deg
        self._map_header = None