From de727d3073e8a3057b31f705c95b8ce89c027c23 Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Fri, 18 Sep 2020 10:10:10 -0500 Subject: [PATCH] pep8 changes made by atom --- .../centrals/trivial_phase_space.py | 36 +++-- .../analytic_models/profile_model_template.py | 70 +++++--- .../satellites/nfw/biased_nfw_phase_space.py | 149 +++++++++++------- .../satellites/nfw/nfw_profile.py | 76 +++++---- 4 files changed, 202 insertions(+), 129 deletions(-) diff --git a/halotools/empirical_models/phase_space_models/analytic_models/centrals/trivial_phase_space.py b/halotools/empirical_models/phase_space_models/analytic_models/centrals/trivial_phase_space.py index 5cf0a899c..ba08a8a31 100644 --- a/halotools/empirical_models/phase_space_models/analytic_models/centrals/trivial_phase_space.py +++ b/halotools/empirical_models/phase_space_models/analytic_models/centrals/trivial_phase_space.py @@ -11,8 +11,8 @@ from .....sim_manager import sim_defaults -__author__ = ['Andrew Hearin'] -__all__ = ['TrivialPhaseSpace'] +__author__ = ["Andrew Hearin"] +__all__ = ["TrivialPhaseSpace"] class TrivialPhaseSpace(object): @@ -22,11 +22,13 @@ class TrivialPhaseSpace(object): :math:`P(\vec{x}_{\rm cen}, \vec{v}_{\rm cen}) = \delta^{(6)}(\vec{x}_{\rm halo}, \vec{v}_{\rm halo})`. """ - def __init__(self, - cosmology=sim_defaults.default_cosmology, - redshift=sim_defaults.default_redshift, - mdef=model_defaults.halo_mass_definition, - **kwargs): + def __init__( + self, + cosmology=sim_defaults.default_cosmology, + redshift=sim_defaults.default_redshift, + mdef=model_defaults.halo_mass_definition, + **kwargs + ): """ Parameters ---------- @@ -40,11 +42,17 @@ def __init__(self, String specifying the halo mass definition, e.g., 'vir' or '200m'. Default is set in `~halotools.empirical_models.model_defaults`. """ - self._mock_generation_calling_sequence = ['assign_phase_space'] - self._galprop_dtypes_to_allocate = np.dtype([ - ('x', 'f8'), ('y', 'f8'), ('z', 'f8'), - ('vx', 'f8'), ('vy', 'f8'), ('vz', 'f8'), - ]) + self._mock_generation_calling_sequence = ["assign_phase_space"] + self._galprop_dtypes_to_allocate = np.dtype( + [ + ("x", "f8"), + ("y", "f8"), + ("z", "f8"), + ("vx", "f8"), + ("vy", "f8"), + ("vz", "f8"), + ] + ) self.param_dict = {} @@ -56,6 +64,6 @@ def __init__(self, def assign_phase_space(self, table, **kwargs): r""" """ - phase_space_keys = ['x', 'y', 'z', 'vx', 'vy', 'vz'] + phase_space_keys = ["x", "y", "z", "vx", "vy", "vz"] for key in phase_space_keys: - table[key][:] = table['halo_'+key][:] + table[key][:] = table["halo_" + key][:] diff --git a/halotools/empirical_models/phase_space_models/analytic_models/profile_model_template.py b/halotools/empirical_models/phase_space_models/analytic_models/profile_model_template.py index 54f35a988..49a99c6d5 100644 --- a/halotools/empirical_models/phase_space_models/analytic_models/profile_model_template.py +++ b/halotools/empirical_models/phase_space_models/analytic_models/profile_model_template.py @@ -17,11 +17,11 @@ from ... import model_defaults -newtonG = G.to(u.km*u.km*u.Mpc/(u.Msun*u.s*u.s)) +newtonG = G.to(u.km * u.km * u.Mpc / (u.Msun * u.s * u.s)) -__author__ = ['Andrew Hearin', 'Benedikt Diemer'] +__author__ = ["Andrew Hearin", "Benedikt Diemer"] -__all__ = ['AnalyticDensityProf'] +__all__ = ["AnalyticDensityProf"] @six.add_metaclass(ABCMeta) @@ -63,8 +63,8 @@ def __init__(self, cosmology, redshift, mdef, **kwargs): # The following four attributes are derived quantities from the above, # so that self-consistency between them is ensured self.density_threshold = halo_boundary_functions.density_threshold( - cosmology=self.cosmology, - redshift=self.redshift, mdef=self.mdef) + cosmology=self.cosmology, redshift=self.redshift, mdef=self.mdef + ) self.halo_boundary_key = model_defaults.get_halo_boundary_key(self.mdef) self.prim_haloprop_key = model_defaults.get_halo_mass_key(self.mdef) @@ -157,11 +157,13 @@ def mass_density(self, radius, mass, *prof_params): """ halo_radius = self.halo_mass_to_halo_radius(mass) - scaled_radius = radius/halo_radius + scaled_radius = radius / halo_radius - dimensionless_mass = self.dimensionless_mass_density(scaled_radius, *prof_params) + dimensionless_mass = self.dimensionless_mass_density( + scaled_radius, *prof_params + ) - density = self.density_threshold*dimensionless_mass + density = self.density_threshold * dimensionless_mass return density def _enclosed_dimensionless_mass_integrand(self, scaled_radius, *prof_params): @@ -183,8 +185,10 @@ def _enclosed_dimensionless_mass_integrand(self, scaled_radius, *prof_params): integrand: array_like function to be integrated to yield the amount of enclosed mass. """ - dimensionless_density = self.dimensionless_mass_density(scaled_radius, *prof_params) - return dimensionless_density*4*np.pi*scaled_radius**2 + dimensionless_density = self.dimensionless_mass_density( + scaled_radius, *prof_params + ) + return dimensionless_density * 4 * np.pi * scaled_radius ** 2 def cumulative_mass_PDF(self, scaled_radius, *prof_params): r""" @@ -219,12 +223,20 @@ def cumulative_mass_PDF(self, scaled_radius, *prof_params): for i in range(len(x)): enclosed_mass[i], _ = quad_integration( - self._enclosed_dimensionless_mass_integrand, 0., x[i], epsrel=1e-5, - args=prof_params) + self._enclosed_dimensionless_mass_integrand, + 0.0, + x[i], + epsrel=1e-5, + args=prof_params, + ) total, _ = quad_integration( - self._enclosed_dimensionless_mass_integrand, 0., 1.0, epsrel=1e-5, - args=prof_params) + self._enclosed_dimensionless_mass_integrand, + 0.0, + 1.0, + epsrel=1e-5, + args=prof_params, + ) return enclosed_mass / total @@ -259,7 +271,7 @@ def enclosed_mass(self, radius, total_mass, *prof_params): """ radius = np.atleast_1d(radius).astype(np.float64) scaled_radius = radius / self.halo_mass_to_halo_radius(total_mass) - mass = self.cumulative_mass_PDF(scaled_radius, *prof_params)*total_mass + mass = self.cumulative_mass_PDF(scaled_radius, *prof_params) * total_mass return mass @@ -289,7 +301,9 @@ def dimensionless_circular_velocity(self, scaled_radius, *prof_params): See :ref:`halo_profile_definitions` for derivations and implementation details. """ - return np.sqrt(self.cumulative_mass_PDF(scaled_radius, *prof_params)/scaled_radius) + return np.sqrt( + self.cumulative_mass_PDF(scaled_radius, *prof_params) / scaled_radius + ) def virial_velocity(self, total_mass): r""" The circular velocity evaluated at the halo boundary, @@ -310,8 +324,9 @@ def virial_velocity(self, total_mass): See :ref:`halo_profile_definitions` for derivations and implementation details. """ - return halo_boundary_functions.halo_mass_to_virial_velocity(total_mass, - self.cosmology, self.redshift, self.mdef) + return halo_boundary_functions.halo_mass_to_virial_velocity( + total_mass, self.cosmology, self.redshift, self.mdef + ) def circular_velocity(self, radius, total_mass, *prof_params): r""" @@ -344,13 +359,14 @@ def circular_velocity(self, radius, total_mass, *prof_params): halo_radius = self.halo_mass_to_halo_radius(total_mass) scaled_radius = np.atleast_1d(radius) / halo_radius return self.dimensionless_circular_velocity( - scaled_radius, *prof_params)*self.virial_velocity(total_mass) + scaled_radius, *prof_params + ) * self.virial_velocity(total_mass) def _vmax_helper(self, scaled_radius, *prof_params): """ Helper function used to calculate `vmax` and `rmax`. """ encl = self.cumulative_mass_PDF(scaled_radius, *prof_params) - return -1.*encl/scaled_radius + return -1.0 * encl / scaled_radius def rmax(self, total_mass, *prof_params): r""" Radius at which the halo attains its maximum circular velocity. @@ -380,7 +396,7 @@ def rmax(self, total_mass, *prof_params): result = scipy_minimize(self._vmax_helper, guess, args=prof_params) - return result.x[0]*halo_radius + return result.x[0] * halo_radius def vmax(self, total_mass, *prof_params): r""" Maximum circular velocity of the halo profile. @@ -408,7 +424,9 @@ def vmax(self, total_mass, *prof_params): result = scipy_minimize(self._vmax_helper, guess, args=prof_params) halo_radius = self.halo_mass_to_halo_radius(total_mass) - return self.circular_velocity(result.x[0]*halo_radius, total_mass, *prof_params) + return self.circular_velocity( + result.x[0] * halo_radius, total_mass, *prof_params + ) def halo_mass_to_halo_radius(self, total_mass): r""" @@ -434,8 +452,8 @@ def halo_mass_to_halo_radius(self, total_mass): """ return halo_boundary_functions.halo_mass_to_halo_radius( - total_mass, cosmology=self.cosmology, - redshift=self.redshift, mdef=self.mdef) + total_mass, cosmology=self.cosmology, redshift=self.redshift, mdef=self.mdef + ) def halo_radius_to_halo_mass(self, radius): r""" @@ -461,5 +479,5 @@ def halo_radius_to_halo_mass(self, radius): """ return halo_boundary_functions.halo_radius_to_halo_mass( - radius, cosmology=self.cosmology, - redshift=self.redshift, mdef=self.mdef) + radius, cosmology=self.cosmology, redshift=self.redshift, mdef=self.mdef + ) diff --git a/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/biased_nfw_phase_space.py b/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/biased_nfw_phase_space.py index fa7315cbb..a7bcf1561 100644 --- a/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/biased_nfw_phase_space.py +++ b/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/biased_nfw_phase_space.py @@ -14,16 +14,18 @@ from ..... import model_defaults -__author__ = ('Andrew Hearin', ) -__all__ = ('BiasedNFWPhaseSpace', ) +__author__ = ("Andrew Hearin",) +__all__ = ("BiasedNFWPhaseSpace",) -lookup_table_performance_warning = ("You have selected {0} bins to digitize host halo concentration \n" +lookup_table_performance_warning = ( + "You have selected {0} bins to digitize host halo concentration \n" "and {1} bins to digitize the galaxy bias parameter.\n" "To populate mocks, the BiasedNFWPhaseSpace class builds a lookup table with shape ({0}, {1}, {2}),\n" "one entry for every numerical solution to the Jeans equation.\n" "Using this fine of a binning requires a long pre-computation of {3} integrals\n." - "Make sure you actually need to use so many bins") + "Make sure you actually need to use so many bins" +) class BiasedNFWPhaseSpace(NFWPhaseSpace): @@ -37,6 +39,7 @@ class BiasedNFWPhaseSpace(NFWPhaseSpace): including descriptions of how the relevant equations are implemented in the Halotools code base, see :ref:`nfw_profile_tutorial`. """ + def __init__(self, profile_integration_tol=1e-5, **kwargs): r""" Parameters @@ -142,20 +145,30 @@ def __init__(self, profile_integration_tol=1e-5, **kwargs): NFWPhaseSpace.__init__(self, **kwargs) self._profile_integration_tol = profile_integration_tol - self.gal_prof_param_keys = ['conc_NFWmodel', 'conc_gal_bias'] + self.gal_prof_param_keys = ["conc_NFWmodel", "conc_gal_bias"] prof_lookup_bins = self._retrieve_prof_lookup_info(**kwargs) self.setup_prof_lookup_tables(*prof_lookup_bins) - self._mock_generation_calling_sequence = ['calculate_conc_gal_bias', 'assign_phase_space'] - self._methods_to_inherit = ['calculate_conc_gal_bias'] - - self._galprop_dtypes_to_allocate = np.dtype([ - ('host_centric_distance', 'f8'), - ('x', 'f8'), ('y', 'f8'), ('z', 'f8'), - ('vx', 'f8'), ('vy', 'f8'), ('vz', 'f8'), - ('conc_gal_bias', 'f8'), ('conc_galaxy', 'f8') - ]) + self._mock_generation_calling_sequence = [ + "calculate_conc_gal_bias", + "assign_phase_space", + ] + self._methods_to_inherit = ["calculate_conc_gal_bias"] + + self._galprop_dtypes_to_allocate = np.dtype( + [ + ("host_centric_distance", "f8"), + ("x", "f8"), + ("y", "f8"), + ("z", "f8"), + ("vx", "f8"), + ("vy", "f8"), + ("vz", "f8"), + ("conc_gal_bias", "f8"), + ("conc_galaxy", "f8"), + ] + ) self.param_dict = self._initialize_conc_bias_param_dict(**kwargs) @@ -163,37 +176,50 @@ def _initialize_conc_bias_param_dict(self, **kwargs): r""" Set up the appropriate number of keys in the parameter dictionary and give the keys standardized names. """ - if 'conc_gal_bias_logM_abscissa' in list(kwargs.keys()): + if "conc_gal_bias_logM_abscissa" in list(kwargs.keys()): _conc_bias_logM_abscissa = np.atleast_1d( - kwargs.get('conc_gal_bias_logM_abscissa')).astype('f4') - d = ({'conc_gal_bias_param'+str(i): 1. - for i in range(len(_conc_bias_logM_abscissa))}) - d2 = ({'conc_gal_bias_logM_abscissa_param'+str(i): float(logM) - for i, logM in enumerate(_conc_bias_logM_abscissa)}) + kwargs.get("conc_gal_bias_logM_abscissa") + ).astype("f4") + d = { + "conc_gal_bias_param" + str(i): 1.0 + for i in range(len(_conc_bias_logM_abscissa)) + } + d2 = { + "conc_gal_bias_logM_abscissa_param" + str(i): float(logM) + for i, logM in enumerate(_conc_bias_logM_abscissa) + } self._num_conc_bias_params = len(_conc_bias_logM_abscissa) for key, value in d2.items(): d[key] = value return d else: - return {'conc_gal_bias': 1.} + return {"conc_gal_bias": 1.0} def _retrieve_prof_lookup_info(self, **kwargs): r""" Retrieve the arrays defining the lookup table control points """ - cmin, cmax = model_defaults.min_permitted_conc, model_defaults.max_permitted_conc - dc = 1. - npts_conc = int(np.round((cmax-cmin)/float(dc))) + cmin, cmax = ( + model_defaults.min_permitted_conc, + model_defaults.max_permitted_conc, + ) + dc = 1.0 + npts_conc = int(np.round((cmax - cmin) / float(dc))) default_conc_arr = np.linspace(cmin, cmax, npts_conc) - conc_arr = kwargs.get('concentration_bins', default_conc_arr) + conc_arr = kwargs.get("concentration_bins", default_conc_arr) - conc_gal_bias_arr = kwargs.get('conc_gal_bias_bins', - model_defaults.default_conc_gal_bias_bins) + conc_gal_bias_arr = kwargs.get( + "conc_gal_bias_bins", model_defaults.default_conc_gal_bias_bins + ) npts_conc, npts_gal_bias = len(conc_arr), len(conc_gal_bias_arr) - if npts_conc*npts_gal_bias > 300: - args = (npts_conc, npts_gal_bias, model_defaults.Npts_radius_table, - npts_conc*npts_gal_bias*model_defaults.Npts_radius_table) + if npts_conc * npts_gal_bias > 300: + args = ( + npts_conc, + npts_gal_bias, + model_defaults.Npts_radius_table, + npts_conc * npts_gal_bias * model_defaults.Npts_radius_table, + ) warn(lookup_table_performance_warning.format(*args)) return [conc_arr, conc_gal_bias_arr] @@ -235,7 +261,7 @@ def _clipped_galaxy_concentration(self, halo_conc, conc_gal_bias): r""" Private method used to ensure that biased concentrations are still bound by the min/max bounds permitted by the lookup tables. """ - gal_conc = conc_gal_bias*halo_conc + gal_conc = conc_gal_bias * halo_conc try: cmin = self._conc_NFWmodel_lookup_table_min @@ -335,7 +361,9 @@ def cumulative_mass_PDF(self, scaled_radius, halo_conc): """ return NFWPhaseSpace.cumulative_mass_PDF(self, scaled_radius, halo_conc) - def dimensionless_radial_velocity_dispersion(self, scaled_radius, halo_conc, conc_gal_bias): + def dimensionless_radial_velocity_dispersion( + self, scaled_radius, halo_conc, conc_gal_bias + ): r""" Analytical solution to the isotropic jeans equation for an NFW potential, rendered dimensionless via scaling by the virial velocity. @@ -361,8 +389,12 @@ def dimensionless_radial_velocity_dispersion(self, scaled_radius, halo_conc, con The returned result has the same dimension as the input ``scaled_radius``. """ gal_conc = self._clipped_galaxy_concentration(halo_conc, conc_gal_bias) - return biased_dimless_vrad_disp(scaled_radius, halo_conc, gal_conc, - profile_integration_tol=self._profile_integration_tol) + return biased_dimless_vrad_disp( + scaled_radius, + halo_conc, + gal_conc, + profile_integration_tol=self._profile_integration_tol, + ) def radial_velocity_dispersion(self, radius, total_mass, halo_conc, conc_gal_bias): r""" @@ -394,13 +426,12 @@ def radial_velocity_dispersion(self, radius, total_mass, halo_conc, conc_gal_bia """ virial_velocities = self.virial_velocity(total_mass) halo_radius = self.halo_mass_to_halo_radius(total_mass) - scaled_radius = radius/halo_radius + scaled_radius = radius / halo_radius - dimensionless_velocities = ( - self.dimensionless_radial_velocity_dispersion( - scaled_radius, halo_conc, conc_gal_bias) - ) - return dimensionless_velocities*virial_velocities + dimensionless_velocities = self.dimensionless_radial_velocity_dispersion( + scaled_radius, halo_conc, conc_gal_bias + ) + return dimensionless_velocities * virial_velocities def calculate_conc_gal_bias(self, seed=None, **kwargs): r""" Calculate the ratio of the galaxy concentration to the halo concentration, @@ -430,33 +461,39 @@ def calculate_conc_gal_bias(self, seed=None, **kwargs): Ratio of the galaxy concentration to the halo concentration, :math:`c_{\rm gal}/c_{\rm halo}`. """ - if 'table' in list(kwargs.keys()): - table = kwargs['table'] + if "table" in list(kwargs.keys()): + table = kwargs["table"] mass = table[self.prim_haloprop_key] - elif 'prim_haloprop' in list(kwargs.keys()): - mass = np.atleast_1d(kwargs['prim_haloprop']).astype('f4') + elif "prim_haloprop" in list(kwargs.keys()): + mass = np.atleast_1d(kwargs["prim_haloprop"]).astype("f4") else: - msg = ("\nYou must pass either a ``table`` or ``prim_haloprop`` argument \n" - "to the ``assign_conc_gal_bias`` function of the ``BiasedNFWPhaseSpace`` class.\n") + msg = ( + "\nYou must pass either a ``table`` or ``prim_haloprop`` argument \n" + "to the ``assign_conc_gal_bias`` function of the ``BiasedNFWPhaseSpace`` class.\n" + ) raise KeyError(msg) - if 'conc_gal_bias_logM_abscissa_param0' in self.param_dict.keys(): - abscissa_keys = list('conc_gal_bias_logM_abscissa_param'+str(i) - for i in range(self._num_conc_bias_params)) + if "conc_gal_bias_logM_abscissa_param0" in self.param_dict.keys(): + abscissa_keys = list( + "conc_gal_bias_logM_abscissa_param" + str(i) + for i in range(self._num_conc_bias_params) + ) abscissa = [self.param_dict[key] for key in abscissa_keys] - ordinates_keys = list('conc_gal_bias_param'+str(i) - for i in range(self._num_conc_bias_params)) + ordinates_keys = list( + "conc_gal_bias_param" + str(i) + for i in range(self._num_conc_bias_params) + ) ordinates = [self.param_dict[key] for key in ordinates_keys] result = np.interp(np.log10(mass), abscissa, ordinates) else: - result = np.zeros_like(mass) + self.param_dict['conc_gal_bias'] + result = np.zeros_like(mass) + self.param_dict["conc_gal_bias"] - if 'table' in list(kwargs.keys()): - table['conc_gal_bias'][:] = result - halo_conc = table['conc_NFWmodel'] + if "table" in list(kwargs.keys()): + table["conc_gal_bias"][:] = result + halo_conc = table["conc_NFWmodel"] gal_conc = self._clipped_galaxy_concentration(halo_conc, result) - table['conc_galaxy'][:] = gal_conc + table["conc_galaxy"][:] = gal_conc else: return result diff --git a/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/nfw_profile.py b/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/nfw_profile.py index d600e7ecd..e7ec7eea0 100644 --- a/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/nfw_profile.py +++ b/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/nfw_profile.py @@ -20,8 +20,8 @@ from ......sim_manager import sim_defaults -__all__ = ('NFWProfile', ) -__author__ = ('Andrew Hearin', 'Benedikt Diemer') +__all__ = ("NFWProfile",) +__author__ = ("Andrew Hearin", "Benedikt Diemer") class NFWProfile(AnalyticDensityProf): @@ -35,13 +35,16 @@ class NFWProfile(AnalyticDensityProf): implemented in the Halotools code base, see :ref:`nfw_profile_tutorial`. """ - def __init__(self, - cosmology=sim_defaults.default_cosmology, - redshift=sim_defaults.default_redshift, - mdef=model_defaults.halo_mass_definition, - conc_mass_model=model_defaults.conc_mass_model, - concentration_key=model_defaults.concentration_key, - **kwargs): + + def __init__( + self, + cosmology=sim_defaults.default_cosmology, + redshift=sim_defaults.default_redshift, + mdef=model_defaults.halo_mass_definition, + conc_mass_model=model_defaults.conc_mass_model, + concentration_key=model_defaults.concentration_key, + **kwargs + ): r""" Parameters ---------- @@ -79,18 +82,20 @@ def __init__(self, """ AnalyticDensityProf.__init__(self, cosmology, redshift, mdef) - self.gal_prof_param_keys = ['conc_NFWmodel'] - self.halo_prof_param_keys = ['conc_NFWmodel'] + self.gal_prof_param_keys = ["conc_NFWmodel"] + self.halo_prof_param_keys = ["conc_NFWmodel"] - self.publications = ['arXiv:9611107', 'arXiv:0002395'] + self.publications = ["arXiv:9611107", "arXiv:0002395"] - self._initialize_conc_mass_behavior(conc_mass_model, - concentration_key=concentration_key) + self._initialize_conc_mass_behavior( + conc_mass_model, concentration_key=concentration_key + ) def _initialize_conc_mass_behavior(self, conc_mass_model, **kwargs): - if conc_mass_model == 'direct_from_halo_catalog': - self.concentration_key = kwargs.get('concentration_key', - model_defaults.concentration_key) + if conc_mass_model == "direct_from_halo_catalog": + self.concentration_key = kwargs.get( + "concentration_key", model_defaults.concentration_key + ) self.conc_mass_model = conc_mass_model @@ -170,24 +175,29 @@ def conc_NFWmodel(self, *args, **kwargs): >>> fake_halo_table = Table({'halo_mvir': fake_masses}) >>> model_conc = nfw.conc_NFWmodel(table=fake_halo_table) """ - if self.conc_mass_model == 'direct_from_halo_catalog': + if self.conc_mass_model == "direct_from_halo_catalog": try: - table = kwargs['table'] + table = kwargs["table"] except KeyError: - msg = ("Must pass ``table`` argument to the ``conc_NFWmodel`` function\n" - "when ``conc_mass_model`` is set to ``direct_from_halo_catalog``\n") + msg = ( + "Must pass ``table`` argument to the ``conc_NFWmodel`` function\n" + "when ``conc_mass_model`` is set to ``direct_from_halo_catalog``\n" + ) raise KeyError(msg) - result = direct_from_halo_catalog(table=table, - concentration_key=self.concentration_key) - - elif self.conc_mass_model == 'dutton_maccio14': - msg = ("Must either pass a ``prim_haloprop`` argument, \n" - "or a ``table`` argument with an astropy Table that has the ``{0}`` key") + result = direct_from_halo_catalog( + table=table, concentration_key=self.concentration_key + ) + + elif self.conc_mass_model == "dutton_maccio14": + msg = ( + "Must either pass a ``prim_haloprop`` argument, \n" + "or a ``table`` argument with an astropy Table that has the ``{0}`` key" + ) try: - mass = kwargs['table'][self.prim_haloprop_key] + mass = kwargs["table"][self.prim_haloprop_key] except: try: - mass = kwargs['prim_haloprop'] + mass = kwargs["prim_haloprop"] except: raise KeyError(msg.format(self.prim_haloprop_key)) result = dutton_maccio14(mass, self.redshift) @@ -473,7 +483,7 @@ def rmax(self, total_mass, conc): """ halo_radius = self.halo_mass_to_halo_radius(total_mass) scale_radius = halo_radius / conc - return 2.16258*scale_radius + return 2.16258 * scale_radius def vmax(self, total_mass, conc): r""" Maximum circular velocity of the halo profile, @@ -608,7 +618,7 @@ def mc_generate_nfw_radial_positions(self, **kwargs): >>> radial_positions = nfw.mc_generate_nfw_radial_positions(halo_mass = 1e12, conc = 10) >>> radial_positions = nfw.mc_generate_nfw_radial_positions(halo_radius = 0.25) """ - kwargs['mdef'] = self.mdef - kwargs['cosmology'] = self.cosmology - kwargs['redshift'] = self.redshift + kwargs["mdef"] = self.mdef + kwargs["cosmology"] = self.cosmology + kwargs["redshift"] = self.redshift return standalone_mc_generate_nfw_radial_positions(**kwargs)