Repository navigation
Major update to internals of phase_space_models sub-package - #709
Merged
Merged
Conversation
added 12 commits
March 22, 2017 10:59
…vel of phase_space_models module:
…g mock-population
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces the following overhaul to the
phase_space_modelssub-package:halotools.empirical_models.phase_space_models. All user-facing functions maintain backwards compatibility. In this PR there are no changes to the API or behavior of existing classes or functions, just internal refactoring to facilitate future extensions.halotools.empirical_models.BiasedNFWPhaseSpaceandhalotools.empirical_models.SFRBiasedNFWPhaseSpacethat allow model galaxies to have biased NFW concentrations and jeans solutions. CC @johannesulf for this particular new feature.The behavior of
BiasedNFWPhaseSpaceandSFRBiasedNFWPhaseSpaceis summarized in the docstrings. The summary below is included mostly for posterity. Since the behavior ofhalotools.empirical_models.NFWPhaseSpacehas not changed, Halotools end-users do not need to know anything about this internal refactoring.Overview of internal refactoring
In previous Halotools versions, there was a complicated chain of multiple inheritance that made it needlessly complicated to extend the behavior of existing classes. This has been largely refactored away. There was short-term motivation for this change: to make it easier to include (and test) the new
BiasedNFWPhaseSpaceandSFRBiasedNFWPhaseSpaceclasses. These changes should make it simpler and more naturally compartmentalized to add new models in the future.empirical_models.phase_space_modelspackage has now been split into two sub-packages,analytic_modelsandsubhalo_based_models.The
analytic_modelsandsubhalo_based_modelsdirectories share no common code, as they implement functions and algorithms that bear no relation to each other. Thesubhalo_based_modelssub-package is unchanged from v0.4.analytic_modelssub-package is organized as follows:All non-trivial mathematical operations are now carried out in stand-alone
kernelsmodules requiring only Numpy and Scipy. With the newly refactored code, the user-facing objects such asNFWPhaseSpaceare now largely state-managers that simply call the stand-alone Numpy kernels in a manner consistent with the state of the attributes of the instance, e.g.,nfw_model.cosmologyandnfw_model.redshift. Most of Halotoolsv0.5is now built based on this design principle.Overview of old and obsolete structure
This PR replaces the old structure, summarized here for posterity:
The
NFWPhaseSpaceclass no longer multiply subclasses from an unseenConcMassclass defined in theconc_mass_models.pymodule. Instead, the constructor ofNFWPhaseSpaceaccepts aconc_mass_modelargument storing a user-defined callable function, or a nickname for one implemented in Halotools.The
NFWPhaseSpaceclass no longer multiply subclasses from an unseenNFWIsotropicJeansclass defined inisotropic_jeans_model_template.py. Instead,NFWPhaseSpaceimplements its own new methods governing the velocity modeling (again, implemented by simply calling the externally-defined NFW jeans velocity kernels with the appropriate arguments).To model the mass density and velocity profiles, the kernels of all non-trivial NFW calculations are carried out in small, stand-alone modules with only Numpy and Scipy dependencies. This design choice has several advantages:
The big picture of this refactoring is to keep with the general design direction in
v0.5to minimize class inheritance and treat classes as essentially state managers, rather than objects that perform involved calculations.