예제 #1
0
    def _mean_galprop_fraction(self, **kwargs):
        """
        Expectation value of the galprop for galaxies living in the input halos.  

        Parameters 
        ----------
        prim_haloprop : array, optional keyword argument 
            Array of mass-like variable upon which occupation statistics are based. 
            If ``prim_haloprop`` is not passed, then ``halo_table`` keyword argument must be passed. 

        halo_table : object, optional keyword argument 
            Data table storing halo catalog. 
            If ``halo_table`` is not passed, then ``prim_haloprop`` keyword argument must be passed. 

        Returns 
        -------
        mean_galprop_fraction : array_like
            Values of the galprop fraction evaluated at the input primary halo properties. 

        """
        # Retrieve the array storing the mass-like variable
        if 'halo_table' in kwargs.keys():
            prim_haloprop = kwargs['halo_table'][self.prim_haloprop_key]
        elif 'prim_haloprop' in kwargs.keys():
            prim_haloprop = kwargs['prim_haloprop']
        else:
            raise KeyError("Must pass one of the following keyword arguments to mean_occupation:\n"
                "``halo_table`` or  ``prim_haloprop``")

        if self._logparam is True:
            prim_haloprop = np.log10(prim_haloprop)

        # Update self._abcissa, in case the user has changed it
        self._abcissa = getattr(self, self.galprop_key+'_abcissa')

        model_ordinates = [self.param_dict[ordinate_key] for ordinate_key in self._ordinates_keys]
        if self._interpol_method=='polynomial':
            mean_galprop_fraction = model_helpers.polynomial_from_table(
                self._abcissa, model_ordinates, prim_haloprop)
        elif self._interpol_method=='spline':
            spline_function = model_helpers.custom_spline(
                self._abcissa, model_ordinates,
                    k=self._spline_degree)
            mean_galprop_fraction = spline_function(prim_haloprop)
        else:
            raise IOError("Input interpol_method must be 'polynomial' or 'spline'.")

        # Enforce boundary conditions 
        mean_galprop_fraction[mean_galprop_fraction<0]=0
        mean_galprop_fraction[mean_galprop_fraction>1]=1

        return mean_galprop_fraction
    def radprof_modfunc(self,profile_parameter_key,input_abcissa):
        """
        Factor by which the halo profile parameters of gal_type galaxies 
        differ from the profile parameter of their underlying dark matter halo. 

        Parameters 
        ----------
        profile_parameter_key : string
            Dictionary key of the profile parameter being modulated, e.g., 'halo_NFW_conc'. 

        input_abcissa : array_like
            array of primary halo property 

        Returns 
        -------
        output_profile_modulation : array_like
            Values of the multiplicative factor that will be used to 
            modulate the halo profile parameters. 

        Notes 
        -----
        Either assumes the profile parameters are modulated from those 
        of the underlying dark matter halo by a polynomial function 
        of the primary halo property, or is interpolated from a grid. 
        Either way, the behavior of this method is fully determined by 
        its values at the model's (abcissa, ordinates), specified by 
        self.abcissa_dict and self.ordinates_dict.
        """

        model_abcissa, model_ordinates = (
            self._retrieve_model_abcissa_ordinates(profile_parameter_key)
            )

        if self.interpol_method=='polynomial':
            output_profile_modulation = model_helpers.polynomial_from_table(
                model_abcissa,model_ordinates,input_abcissa)
        elif self.interpol_method=='spline':
            modulating_function = self.spline_function[profile_parameter_key]
            output_profile_modulation = modulating_function(input_abcissa)
        else:
            raise IOError("Input interpol_method must be 'polynomial' or 'spline'.")

        return output_profile_modulation
예제 #3
0
    def radprof_modfunc(self, profile_parameter_key, input_abcissa):
        """
        Factor by which the halo profile parameters of gal_type galaxies 
        differ from the profile parameter of their underlying dark matter halo. 

        Parameters 
        ----------
        profile_parameter_key : string
            Dictionary key of the profile parameter being modulated, e.g., 'halo_NFW_conc'. 

        input_abcissa : array_like
            array of primary halo property 

        Returns 
        -------
        output_profile_modulation : array_like
            Values of the multiplicative factor that will be used to 
            modulate the halo profile parameters. 

        Notes 
        -----
        Either assumes the profile parameters are modulated from those 
        of the underlying dark matter halo by a polynomial function 
        of the primary halo property, or is interpolated from a grid. 
        Either way, the behavior of this method is fully determined by 
        its values at the model's (abcissa, ordinates), specified by 
        self.abcissa_dict and self.ordinates_dict.
        """

        model_abcissa, model_ordinates = (
            self._retrieve_model_abcissa_ordinates(profile_parameter_key))

        if self.interpol_method == 'polynomial':
            output_profile_modulation = model_helpers.polynomial_from_table(
                model_abcissa, model_ordinates, input_abcissa)
        elif self.interpol_method == 'spline':
            modulating_function = self.spline_function[profile_parameter_key]
            output_profile_modulation = modulating_function(input_abcissa)
        else:
            raise IOError(
                "Input interpol_method must be 'polynomial' or 'spline'.")

        return output_profile_modulation
예제 #4
0
    def _mean_galprop_fraction(self, **kwargs):
        """
        Expectation value of the galprop for galaxies living in the input halos.  

        Parameters 
        ----------
        prim_haloprop : array_like, optional keyword argument
            Array of primary halo property, e.g., `mvir`, 
            at which the galprop fraction is being computed. 
            Functionality is equivalent to using the prim_haloprop keyword argument. 

        halos : table, optional keyword argument
            Astropy Table containing a halo catalog. 
            If the ``halos`` keyword argument is passed, 
            ``self.prim_haloprop_key`` must be a column of the halo catalog. 

        galaxy_table : table, optional keyword argument
            Astropy Table containing a galaxy catalog. 
            If the ``galaxy_table`` keyword argument is passed, 
            ``self.prim_haloprop_key`` must be a column of the galaxy catalog. 

        input_param_dict : dict, optional keyword argument 
            If passed, the model will first update 
            its param_dict with input_param_dict, altering the behavior of the model. 

        Returns 
        -------
        mean_galprop_fraction : array_like
            Values of the galprop fraction evaluated at the input primary halo properties. 

        """
        model_helpers.update_param_dict(self, **kwargs)

        # Retrieve the array storing the mass-like variable
        if 'galaxy_table' in kwargs.keys():
            key = model_defaults.host_haloprop_prefix+self.prim_haloprop_key
            prim_haloprop = kwargs['galaxy_table'][key]
        elif 'halos' in kwargs.keys():
            prim_haloprop = kwargs['halos'][self.prim_haloprop_key]
        elif 'prim_haloprop' in kwargs.keys():
            prim_haloprop = kwargs['prim_haloprop']
        else:
            raise KeyError("Must pass one of the following keyword arguments to mean_occupation:\n"
                "``halos``, ``prim_haloprop``, or ``galaxy_table``")

        if self._logparam is True:
            prim_haloprop = np.log10(prim_haloprop)

        # Update self._abcissa, in case the user has changed it
        self._abcissa = getattr(self, self.galprop_key+'_abcissa')

        model_ordinates = [self.param_dict[ordinate_key] for ordinate_key in self._ordinates_keys]
        if self._interpol_method=='polynomial':
            mean_galprop_fraction = model_helpers.polynomial_from_table(
                self._abcissa, model_ordinates, prim_haloprop)
        elif self._interpol_method=='spline':
            spline_function = model_helpers.custom_spline(
                self._abcissa, model_ordinates,
                    k=self._spline_degree)
            mean_galprop_fraction = spline_function(prim_haloprop)
        else:
            raise IOError("Input interpol_method must be 'polynomial' or 'spline'.")

        # Enforce boundary conditions 
        mean_galprop_fraction[mean_galprop_fraction<0]=0
        mean_galprop_fraction[mean_galprop_fraction>1]=1

        return mean_galprop_fraction
예제 #5
0
    def _mean_galprop_fraction(self, **kwargs):
        """
        Expectation value of the galprop for galaxies living in the input halos.  

        Parameters 
        ----------
        prim_haloprop : array_like, optional keyword argument
            Array of primary halo property, e.g., `mvir`, 
            at which the galprop fraction is being computed. 
            Functionality is equivalent to using the prim_haloprop keyword argument. 

        halos : table, optional keyword argument
            Astropy Table containing a halo catalog. 
            If the ``halos`` keyword argument is passed, 
            ``self.prim_haloprop_key`` must be a column of the halo catalog. 

        galaxy_table : table, optional keyword argument
            Astropy Table containing a galaxy catalog. 
            If the ``galaxy_table`` keyword argument is passed, 
            ``self.prim_haloprop_key`` must be a column of the galaxy catalog. 

        input_param_dict : dict, optional keyword argument 
            If passed, the model will first update 
            its param_dict with input_param_dict, altering the behavior of the model. 

        Returns 
        -------
        mean_galprop_fraction : array_like
            Values of the galprop fraction evaluated at the input primary halo properties. 

        """
        model_helpers.update_param_dict(self, **kwargs)

        # Retrieve the array storing the mass-like variable
        if 'galaxy_table' in kwargs.keys():
            key = model_defaults.host_haloprop_prefix + self.prim_haloprop_key
            prim_haloprop = kwargs['galaxy_table'][key]
        elif 'halos' in kwargs.keys():
            prim_haloprop = kwargs['halos'][self.prim_haloprop_key]
        elif 'prim_haloprop' in kwargs.keys():
            prim_haloprop = kwargs['prim_haloprop']
        else:
            raise KeyError(
                "Must pass one of the following keyword arguments to mean_occupation:\n"
                "``halos``, ``prim_haloprop``, or ``galaxy_table``")

        if self._logparam is True:
            prim_haloprop = np.log10(prim_haloprop)

        # Update self._abcissa, in case the user has changed it
        self._abcissa = getattr(self, self.galprop_key + '_abcissa')

        model_ordinates = [
            self.param_dict[ordinate_key]
            for ordinate_key in self._ordinates_keys
        ]
        if self._interpol_method == 'polynomial':
            mean_galprop_fraction = model_helpers.polynomial_from_table(
                self._abcissa, model_ordinates, prim_haloprop)
        elif self._interpol_method == 'spline':
            spline_function = model_helpers.custom_spline(
                self._abcissa, model_ordinates, k=self._spline_degree)
            mean_galprop_fraction = spline_function(prim_haloprop)
        else:
            raise IOError(
                "Input interpol_method must be 'polynomial' or 'spline'.")

        # Enforce boundary conditions
        mean_galprop_fraction[mean_galprop_fraction < 0] = 0
        mean_galprop_fraction[mean_galprop_fraction > 1] = 1

        return mean_galprop_fraction