├── .github ├── dependabot.yml └── workflows │ ├── ci_tests.yaml │ ├── cron_tests.yaml │ └── wheels.yaml ├── .gitignore ├── .readthedocs.yaml ├── CHANGES.rst ├── LICENSE ├── MANIFEST.in ├── README.rst ├── cextern └── README.rst ├── docs ├── Makefile ├── _static │ ├── bijective_distribution_matching_demo.png │ ├── cam_example_assembias_clf.png │ ├── cam_example_bulge_disk_ratio.png │ ├── cam_example_complex_sfr.png │ ├── cam_example_complex_sfr_dmdt_correlation.png │ ├── cam_example_complex_sfr_recovery.png │ ├── color_correlation_pdf.png │ ├── dm-splatting-large.png │ ├── fuzzy_binning_example.png │ ├── halotools.css │ ├── matched_distributions.png │ ├── mbk10_nsat_up0_behavior.png │ ├── monte_carlo_example.png │ ├── monte_carlo_example2.png │ ├── noisy_percentile_demo.png │ ├── non_poisson_mc_realization.png │ ├── quenching_gradient_model_clustering.png │ ├── quenching_gradient_models.png │ └── spin_percentile.png ├── _templates │ └── autosummary │ │ ├── base.rst │ │ ├── class.rst │ │ └── module.rst ├── changelog.rst ├── conf.py ├── full_ref_api │ └── halotools_full_api.rst ├── function_usage │ ├── abundance_matching.rst │ ├── empirical_model_factory_functions.rst │ ├── hod_occupation_functions.rst │ ├── index.rst │ ├── mock_observables_functions.rst │ ├── phase_space_models_functions.rst │ ├── processing_simulation_data.rst │ └── utility_functions.rst ├── index.rst ├── install.rst ├── installation_troubleshooting.rst ├── installing_halotools_with_virtualenv.rst ├── make.bat ├── notebooks │ ├── cam_modeling │ │ ├── cam_complex_sfr_tutorial.ipynb │ │ ├── cam_decorated_clf.ipynb │ │ └── cam_disk_bulge_ratios_demo.ipynb │ ├── galcat_analysis │ │ ├── basic_examples │ │ │ ├── galaxy_catalog_analysis_tutorial │ │ │ ├── galaxy_catalog_analysis_tutorial1.ipynb │ │ │ ├── galaxy_catalog_analysis_tutorial10.ipynb │ │ │ ├── galaxy_catalog_analysis_tutorial2.ipynb │ │ │ ├── galaxy_catalog_analysis_tutorial3.ipynb │ │ │ ├── galaxy_catalog_analysis_tutorial4.ipynb │ │ │ ├── galaxy_catalog_analysis_tutorial5.ipynb │ │ │ ├── galaxy_catalog_analysis_tutorial6.ipynb │ │ │ ├── galaxy_catalog_analysis_tutorial7.ipynb │ │ │ ├── galaxy_catalog_analysis_tutorial8.ipynb │ │ │ └── galaxy_catalog_analysis_tutorial9.ipynb │ │ └── intermediate_examples │ │ │ ├── galaxy_catalog_intermediate_analysis_tutorial1.ipynb │ │ │ └── quenching_gradient_tutorial.ipynb │ ├── halocat_analysis │ │ └── basic_examples │ │ │ ├── halo_catalog_analysis_tutorial1.ipynb │ │ │ └── halo_catalog_analysis_tutorial2.ipynb │ ├── hod_modeling │ │ ├── hod_modeling_tutorial1.ipynb │ │ ├── hod_modeling_tutorial2.ipynb │ │ ├── hod_modeling_tutorial3.ipynb │ │ ├── hod_modeling_tutorial4.ipynb │ │ └── hod_modeling_tutorial5.ipynb │ ├── intrinsic_alignments │ │ ├── hod_modeling_tutorial_with_alignments.ipynb │ │ └── measuring_correlations_tutorial.ipynb │ └── subhalo_modeling │ │ ├── subhalo_modeling_tutorial1.ipynb │ │ ├── subhalo_modeling_tutorial2.ipynb │ │ ├── subhalo_modeling_tutorial3.ipynb │ │ ├── subhalo_modeling_tutorial4.ipynb │ │ └── subhalo_modeling_tutorial5.ipynb ├── overview.rst ├── quickstart_and_tutorials │ ├── development │ │ ├── bug_reports.rst │ │ ├── citing_halotools.rst │ │ ├── contributors.rst │ │ ├── getting_started.rst │ │ └── index.rst │ ├── getting_started_overview.rst │ ├── index.rst │ ├── managing_catalogs │ │ └── supported_sim_list.rst │ ├── mock_observations │ │ ├── calculating_counts_in_cells.rst │ │ └── mock_obs_pos_formatting.rst │ ├── quickstart_guides │ │ ├── halo_catalog_analysis_quickstart.rst │ │ ├── working_with_alternative_catalogs.rst │ │ └── working_with_halotools_provided_catalogs.rst │ └── tutorials │ │ ├── catalog_analysis │ │ ├── galcat_analysis │ │ │ ├── basic_examples │ │ │ │ ├── clustering_examples │ │ │ │ │ ├── angular_crosscorr.png │ │ │ │ │ ├── galaxy_catalog_analysis_tutorial2.rst │ │ │ │ │ ├── galaxy_catalog_analysis_tutorial3.rst │ │ │ │ │ ├── galaxy_catalog_analysis_tutorial4.rst │ │ │ │ │ ├── galaxy_catalog_analysis_tutorial9.rst │ │ │ │ │ ├── gg_lensing_tutorial3.png │ │ │ │ │ ├── mock_fullsky.png │ │ │ │ │ ├── mock_octant.png │ │ │ │ │ ├── one_two_halo_clustering.png │ │ │ │ │ ├── output_9_1.png │ │ │ │ │ ├── random_vs_analytic.png │ │ │ │ │ ├── wp_red_blue_cross.png │ │ │ │ │ ├── wp_tutorial4.png │ │ │ │ │ └── wtheta1.png │ │ │ │ ├── crossmatching_galaxy_catalogs.rst │ │ │ │ ├── galaxy_catalog_analysis_tutorial1.rst │ │ │ │ ├── group_identification │ │ │ │ │ ├── galaxy_catalog_analysis_tutorial5.rst │ │ │ │ │ └── group_richness_vs_group_cenmass.png │ │ │ │ ├── isolation_criteria │ │ │ │ │ └── galaxy_catalog_analysis_tutorial10.rst │ │ │ │ ├── output_18_1.png │ │ │ │ ├── output_23_1.png │ │ │ │ ├── velocity_statistics │ │ │ │ │ ├── cluster_bcg_infall_velocity.png │ │ │ │ │ ├── cluster_dispersion_profile.png │ │ │ │ │ ├── galaxy_catalog_analysis_tutorial6.rst │ │ │ │ │ └── galaxy_catalog_analysis_tutorial7.rst │ │ │ │ └── void_stats │ │ │ │ │ ├── galaxy_catalog_analysis_tutorial8.rst │ │ │ │ │ └── vpf_upf_tutorial.png │ │ │ ├── index.rst │ │ │ └── intermediate_examples │ │ │ │ └── isolation_criteria │ │ │ │ └── galaxy_catalog_intermediate_analysis_tutorial1.rst │ │ └── halocat_analysis │ │ │ ├── basic_examples │ │ │ ├── figs │ │ │ │ ├── radial_profile_halocat_tutorial_fig1.png │ │ │ │ └── radial_profile_halocat_tutorial_fig2.png │ │ │ ├── halo_catalog_analysis_tutorial1.rst │ │ │ ├── halo_catalog_analysis_tutorial2.rst │ │ │ └── nsub_vs_hostmass.png │ │ │ ├── crossmatching_halo_catalogs.rst │ │ │ ├── index.rst │ │ │ ├── rockstar_subhalo_nomenclature.rst │ │ │ └── subhalo_membership.png │ │ ├── merger_tree_analysis_example.rst │ │ ├── model_building │ │ ├── altering_param_dict.rst │ │ ├── cam_tutorial_pages │ │ │ ├── cam_complex_sfr.rst │ │ │ ├── cam_decorated_clf.rst │ │ │ ├── cam_disk_bulge_ratios.rst │ │ │ ├── cam_quenching_gradients.rst │ │ │ └── cam_tutorial.rst │ │ ├── composing_models │ │ │ ├── hod_modeling │ │ │ │ ├── hod_modeling_tutorial0.rst │ │ │ │ ├── hod_modeling_tutorial1.rst │ │ │ │ ├── hod_modeling_tutorial2.rst │ │ │ │ ├── hod_modeling_tutorial3.rst │ │ │ │ ├── hod_modeling_tutorial4.rst │ │ │ │ ├── hod_modeling_tutorial5.rst │ │ │ │ ├── writing_your_own_hod_occupation_component.rst │ │ │ │ ├── writing_your_own_hod_profile_component.rst │ │ │ │ └── zheng07_using_cenocc_model_tutorial.rst │ │ │ ├── index.rst │ │ │ └── subhalo_modeling │ │ │ │ ├── subhalo_modeling_tutorial0.rst │ │ │ │ ├── subhalo_modeling_tutorial1.rst │ │ │ │ ├── subhalo_modeling_tutorial2.rst │ │ │ │ ├── subhalo_modeling_tutorial3.rst │ │ │ │ ├── subhalo_modeling_tutorial4.rst │ │ │ │ └── subhalo_modeling_tutorial5.rst │ │ ├── halotools_design.png │ │ ├── index.rst │ │ └── preloaded_models │ │ │ ├── abundance_matching_composite_model.rst │ │ │ ├── behroozi10_composite_model.rst │ │ │ ├── cacciato09_composite_model.rst │ │ │ ├── hearin15_composite_model.rst │ │ │ ├── index.rst │ │ │ ├── leauthaud11_composite_model.rst │ │ │ ├── preloaded_models_list.rst │ │ │ ├── tinker13_composite_model.rst │ │ │ ├── zheng07_composite_model.rst │ │ │ ├── zu_mandelbaum15_composite_model.rst │ │ │ └── zu_mandelbaum16_composite_model.rst │ │ ├── reducing_and_caching_a_new_rockstar_catalog.rst │ │ ├── user_supplied_halo_catalogs.rst │ │ └── working_with_alternative_particle_data.rst ├── source_notes │ ├── convert_tutorials.py │ ├── empirical_models │ │ ├── assembias_models │ │ │ └── heaviside_assembias_source_code_notes.rst │ │ ├── factories │ │ │ ├── hod_mock_factory_source_notes.rst │ │ │ ├── hod_model_factory_source_notes.rst │ │ │ ├── index.rst │ │ │ ├── model_factory_composite_sequence_mechanisms.rst │ │ │ ├── np_repeat_tutorial.png │ │ │ ├── subhalo_mock_factory_source_notes.rst │ │ │ └── subhalo_model_factory_source_notes.rst │ │ └── phase_space_models │ │ │ ├── jeans_equation_derivations.rst │ │ │ ├── monte_carlo_galprof_source_notes.rst │ │ │ ├── nfw_profile_source_notes.rst │ │ │ └── profile_template_source_notes.rst │ ├── index.rst │ └── mock_observables │ │ └── zspace_distortions.rst ├── usage_tutorials │ ├── cache_management │ │ └── relocating_simulation_data.rst │ └── empirical_models │ │ ├── assembias_models │ │ └── heaviside_assembias_tutorial.rst │ │ └── subhalo_phase_space │ │ └── subhalo_phase_space_tutorial.rst ├── whats_new.rst └── whats_new_history │ ├── whats_new_0.5.rst │ ├── whats_new_0.6.rst │ ├── whats_new_0.7.rst │ ├── whats_new_0.8.rst │ └── whats_new_v0x_history.rst ├── halotools ├── __init__.py ├── _astropy_init.py ├── conftest.py ├── custom_exceptions.py ├── data │ └── README.rst ├── empirical_models │ ├── __init__.py │ ├── abunmatch │ │ ├── __init__.py │ │ ├── bin_free_cam.py │ │ ├── conditional_abunmatch_bin_based.py │ │ ├── engines │ │ │ ├── __init__.py │ │ │ ├── bin_free_cam_kernel.pyx │ │ │ └── setup_package.py │ │ ├── noisy_percentile.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── naive_python_cam.py │ │ │ ├── test_bin_free_cam.py │ │ │ ├── test_conditional_abunmatch.py │ │ │ ├── test_noisy_percentile.py │ │ │ ├── test_pure_python.py │ │ │ ├── test_sample2_window_function.py │ │ │ └── test_single_unit.py │ ├── assembias_models │ │ ├── __init__.py │ │ ├── heaviside_assembias.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ └── test_assembias.py │ ├── component_model_templates │ │ ├── __init__.py │ │ ├── binary_galprop_models.py │ │ ├── prim_galprop_model.py │ │ ├── scatter_models.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_binary_galprop_models.py │ │ │ ├── test_prim_galprop_model.py │ │ │ └── test_scatter_models.py │ ├── composite_models │ │ ├── __init__.py │ │ ├── hod_models │ │ │ ├── __init__.py │ │ │ ├── cacciato09.py │ │ │ ├── hearin15.py │ │ │ ├── leauthaud11.py │ │ │ ├── tests │ │ │ │ ├── __init__.py │ │ │ │ ├── test_tinker13.py │ │ │ │ ├── test_zheng07.py │ │ │ │ └── test_zu_mandelbaum16.py │ │ │ ├── tinker13.py │ │ │ ├── zheng07.py │ │ │ ├── zu_mandelbaum15.py │ │ │ └── zu_mandelbaum16.py │ │ ├── sfr_models │ │ │ ├── __init__.py │ │ │ └── smhm_binary_sfr.py │ │ ├── smhm_models │ │ │ ├── __init__.py │ │ │ └── behroozi10.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ └── test_preloaded_models.py │ ├── factories │ │ ├── __init__.py │ │ ├── hod_mock_factory.py │ │ ├── hod_model_factory.py │ │ ├── mock_factory_template.py │ │ ├── mock_helpers.py │ │ ├── model_factory_template.py │ │ ├── prebuilt_model_factory.py │ │ ├── subhalo_mock_factory.py │ │ ├── subhalo_model_factory.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_clf_support.py │ │ │ ├── test_hod_factory.py │ │ │ ├── test_hod_mock_factory.py │ │ │ ├── test_hod_model_factory.py │ │ │ ├── test_mock_helpers.py │ │ │ ├── test_prebuilt_hod_model_factory.py │ │ │ ├── test_prebuilt_subhalo_model_factory.py │ │ │ └── test_subhalo_model_factory.py │ ├── ia_models │ │ ├── README.md │ │ ├── __init__.py │ │ ├── ia_model_components.py │ │ ├── ia_strength_models.py │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── test_ia_model_components.py │ │ │ ├── test_ia_strength_models.py │ │ │ └── test_watson_distribution.py │ │ └── watson_distribution.py │ ├── model_defaults.py │ ├── model_helpers.py │ ├── occupation_models │ │ ├── __init__.py │ │ ├── cacciato09_components.py │ │ ├── engines │ │ │ ├── __init__.py │ │ │ ├── cacciato09_sats_mc_prim_galprop_engine.pyx │ │ │ └── setup_package.py │ │ ├── leauthaud11_components.py │ │ ├── negative_binomial_sats.py │ │ ├── occupation_model_template.py │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── test_cacciato09_clf.py │ │ │ ├── test_leauthaud11_hod.py │ │ │ ├── test_negative_binomial_sats.py │ │ │ ├── test_occupation_component.py │ │ │ ├── test_tinker13.py │ │ │ ├── test_zheng07_centrals.py │ │ │ ├── test_zheng07_satellites.py │ │ │ └── test_zu_mandelbaum15_components.py │ │ ├── tinker13_components.py │ │ ├── zheng07_components.py │ │ └── zu_mandelbaum15_components.py │ ├── phase_space_models │ │ ├── __init__.py │ │ ├── analytic_models │ │ │ ├── __init__.py │ │ │ ├── centrals │ │ │ │ ├── __init__.py │ │ │ │ ├── tests │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── test_trivial_phase_space.py │ │ │ │ │ └── test_trivial_profile.py │ │ │ │ ├── trivial_phase_space.py │ │ │ │ └── trivial_profile.py │ │ │ ├── halo_boundary_functions.py │ │ │ ├── monte_carlo_helpers.py │ │ │ ├── profile_model_template.py │ │ │ ├── satellites │ │ │ │ ├── __init__.py │ │ │ │ └── nfw │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── biased_nfw_phase_space.py │ │ │ │ │ ├── conc_mass │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── direct_from_halo_catalog.py │ │ │ │ │ ├── dutton_maccio14.py │ │ │ │ │ └── tests │ │ │ │ │ │ ├── __init__.py │ │ │ │ │ │ └── test_conc_mass.py │ │ │ │ │ ├── kernels │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── biased_isotropic_velocity.py │ │ │ │ │ ├── mass_profile.py │ │ │ │ │ ├── mc_generate_nfw_radial_positions.py │ │ │ │ │ ├── tests │ │ │ │ │ │ ├── __init__.py │ │ │ │ │ │ ├── data │ │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ │ ├── van_den_bosch_nfw_vr_disp_c10.dat │ │ │ │ │ │ │ ├── van_den_bosch_nfw_vr_disp_c5.dat │ │ │ │ │ │ │ ├── van_den_bosch_nfw_vr_disp_ch10_cg5.dat │ │ │ │ │ │ │ └── van_den_bosch_nfw_vr_disp_ch5_cg10.dat │ │ │ │ │ │ ├── setup_package.py │ │ │ │ │ │ ├── test_biased_isotropic_velocity.py │ │ │ │ │ │ ├── test_mc_generate_nfw_radial_positions.py │ │ │ │ │ │ └── test_unbiased_isotropic_velocity.py │ │ │ │ │ └── unbiased_isotropic_velocity.py │ │ │ │ │ ├── nfw_phase_space.py │ │ │ │ │ ├── nfw_profile.py │ │ │ │ │ ├── sfr_biased_nfw_phase_space.py │ │ │ │ │ └── tests │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── test_biased_nfw │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── test_biased_nfw_consistency.py │ │ │ │ │ ├── test_biased_nfw_consistency_mockpop.py │ │ │ │ │ ├── test_biased_nfw_initialization.py │ │ │ │ │ ├── test_biased_nfw_phase_space.py │ │ │ │ │ ├── test_biased_nfw_phase_space_argument_handling.py │ │ │ │ │ ├── test_conc_gal_bias_behavior.py │ │ │ │ │ └── test_mockpop.py │ │ │ │ │ ├── test_conc_mass_inheritance │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── test_direct_from_halo_catalog.py │ │ │ │ │ ├── test_nfw_phase_space │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── test_nfw_phase_space.py │ │ │ │ │ ├── test_nfw_phase_space_argument_handling.py │ │ │ │ │ ├── test_nfw_phase_space_functions.py │ │ │ │ │ ├── test_nfw_phase_space_initialization.py │ │ │ │ │ └── test_nfw_phase_space_monte_carlo.py │ │ │ │ │ └── test_nfw_profile │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── test_colossus_consistency.py │ │ │ │ │ └── test_nfw_profile.py │ │ │ └── tests │ │ │ │ ├── __init__.py │ │ │ │ └── test_halo_boundary_functions.py │ │ └── subhalo_based_models │ │ │ ├── __init__.py │ │ │ ├── subhalo_phase_space.py │ │ │ ├── subhalo_selection_kernel.py │ │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_composite_model.py │ │ │ ├── test_subhalo_phase_space.py │ │ │ └── test_subhalo_selection_kernel.py │ ├── sfr_models │ │ ├── __init__.py │ │ ├── halo_mass_quenching.py │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── test_halo_mass_quenching.py │ │ │ └── test_zu_mandelbaum16.py │ │ └── zu_mandelbaum16.py │ ├── smhm_models │ │ ├── __init__.py │ │ ├── behroozi10.py │ │ ├── moster13.py │ │ ├── smhm_helpers.py │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── test_behroozi10.py │ │ │ ├── test_moster13.py │ │ │ ├── test_redshift_defensiveness.py │ │ │ └── test_zu_mandelbaum15.py │ │ └── zu_mandelbaum15.py │ └── tests │ │ ├── __init__.py │ │ └── test_model_helpers.py ├── extern │ └── __init__.py ├── mock_observables │ ├── __init__.py │ ├── catalog_analysis_helpers.py │ ├── counts_in_cells │ │ ├── __init__.py │ │ ├── counts_in_cylinders.py │ │ ├── engines │ │ │ ├── __init__.py │ │ │ ├── conditions │ │ │ │ ├── __init__.py │ │ │ │ ├── conditions.pxd │ │ │ │ └── conditions.pyx │ │ │ ├── counts_in_cylinders_engine.pyx │ │ │ └── setup_package.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── pure_python_counts_in_cells.py │ │ │ └── test_counts_in_cylinders.py │ ├── group_identification │ │ ├── __init__.py │ │ ├── fof_groups.py │ │ └── test_groups │ │ │ ├── __init__.py │ │ │ └── test_fof_groups.py │ ├── ia_correlations │ │ ├── __init__.py │ │ ├── alignment_helpers.py │ │ ├── ed_3d.py │ │ ├── ed_3d_one_two_halo_decomp.py │ │ ├── ed_projected.py │ │ ├── ee_3d.py │ │ ├── ee_3d_one_two_halo_decomp.py │ │ ├── ee_projected.py │ │ ├── gi_minus_3d.py │ │ ├── gi_minus_projected.py │ │ ├── gi_plus_3d.py │ │ ├── gi_plus_projected.py │ │ ├── ii_minus_3d.py │ │ ├── ii_minus_projected.py │ │ ├── ii_plus_3d.py │ │ ├── ii_plus_projected.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_ed_3d.py │ │ │ ├── test_ed_projected.py │ │ │ ├── test_ee_3d.py │ │ │ ├── test_ee_projected.py │ │ │ ├── test_gi_minus_3d.py │ │ │ ├── test_gi_minus_projected.py │ │ │ ├── test_gi_plus_3d.py │ │ │ ├── test_gi_plus_projected.py │ │ │ ├── test_ii_minus_3d.py │ │ │ ├── test_ii_minus_projected.py │ │ │ ├── test_ii_plus_3d.py │ │ │ └── test_ii_plus_projected.py │ ├── isolation_functions │ │ ├── __init__.py │ │ ├── conditional_cylindrical_isolation.py │ │ ├── conditional_spherical_isolation.py │ │ ├── cylindrical_isolation.py │ │ ├── engines │ │ │ ├── __init__.py │ │ │ ├── cylindrical_isolation_engine.pyx │ │ │ ├── isolation_criteria_marking_functions.pxd │ │ │ ├── isolation_criteria_marking_functions.pyx │ │ │ ├── marked_cylindrical_isolation_engine.pyx │ │ │ ├── marked_spherical_isolation_engine.pyx │ │ │ ├── setup_package.py │ │ │ └── spherical_isolation_engine.pyx │ │ ├── isolation_functions_helpers.py │ │ ├── spherical_isolation.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── pure_python_isolation.py │ │ │ ├── test_brute_force_comparisons.py │ │ │ ├── test_conditional_cylindrical_isolation.py │ │ │ ├── test_conditional_spherical_isolation.py │ │ │ ├── test_cylindrical_isolation.py │ │ │ ├── test_isolation_helpers.py │ │ │ ├── test_pure_python_isolation.py │ │ │ └── test_spherical_isolation.py │ ├── large_scale_density │ │ ├── __init__.py │ │ ├── large_scale_density_spherical_annulus.py │ │ ├── large_scale_density_spherical_volume.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_large_scale_density_spherical_annulus.py │ │ │ └── test_large_scale_density_spherical_volume.py │ ├── mock_observables_helpers.py │ ├── mock_survey.py │ ├── occupation_stats.py │ ├── pair_counters │ │ ├── __init__.py │ │ ├── cpairs │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── distances.pxd │ │ │ ├── distances.pyx │ │ │ ├── npairs_3d_engine.pyx │ │ │ ├── npairs_jackknife_3d_engine.pyx │ │ │ ├── npairs_jackknife_xy_z_engine.pyx │ │ │ ├── npairs_per_object_3d_engine.pyx │ │ │ ├── npairs_projected_engine.pyx │ │ │ ├── npairs_s_mu_engine.pyx │ │ │ ├── npairs_xy_z_engine.pyx │ │ │ ├── pairwise_distance_3d_engine.pyx │ │ │ ├── pairwise_distance_xy_z_engine.pyx │ │ │ ├── pairwise_distances.pyx │ │ │ ├── setup_package.py │ │ │ └── weighted_npairs_s_mu_engine.pyx │ │ ├── marked_cpairs │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── conditional_pairwise_distances.pyx │ │ │ ├── custom_marking_func.pxd │ │ │ ├── custom_marking_func.pyx │ │ │ ├── custom_weighting_func.pxd │ │ │ ├── custom_weighting_func.pyx │ │ │ ├── distances.pxd │ │ │ ├── distances.pyx │ │ │ ├── marked_npairs_3d_engine.pyx │ │ │ ├── marked_npairs_xy_z_engine.pyx │ │ │ ├── marking_functions.pxd │ │ │ ├── marking_functions.pyx │ │ │ ├── positional_marked_npairs_3d_engine.pyx │ │ │ ├── positional_marked_npairs_xy_z_engine.pyx │ │ │ ├── positional_marking_functions.pxd │ │ │ ├── positional_marking_functions.pyx │ │ │ ├── positional_projected_marking_functions.pxd │ │ │ ├── positional_projected_marking_functions.pyx │ │ │ └── setup_package.py │ │ ├── marked_npairs_3d.py │ │ ├── marked_npairs_xy_z.py │ │ ├── mesh_helpers.py │ │ ├── npairs_3d.py │ │ ├── npairs_jackknife_3d.py │ │ ├── npairs_jackknife_xy_z.py │ │ ├── npairs_per_object_3d.py │ │ ├── npairs_projected.py │ │ ├── npairs_s_mu.py │ │ ├── npairs_xy_z.py │ │ ├── pairs.py │ │ ├── pairwise_distance_3d.py │ │ ├── pairwise_distance_xy_z.py │ │ ├── positional_marked_npairs_3d.py │ │ ├── positional_marked_npairs_xy_z.py │ │ ├── rectangular_mesh.py │ │ ├── rectangular_mesh_2d.py │ │ ├── test_pair_counters │ │ │ ├── __init__.py │ │ │ ├── pure_python_distance_matrix.py │ │ │ ├── pure_python_npairs_per_object_3d.py │ │ │ ├── test_marked_npairs_3d.py │ │ │ ├── test_marked_npairs_xy_z.py │ │ │ ├── test_mesh_helpers.py │ │ │ ├── test_non_cubic_volumes.py │ │ │ ├── test_npairs_3d.py │ │ │ ├── test_npairs_jackknife_3d.py │ │ │ ├── test_npairs_jackknife_xy_z.py │ │ │ ├── test_npairs_per_object_3d.py │ │ │ ├── test_npairs_projected.py │ │ │ ├── test_npairs_s_mu.py │ │ │ ├── test_npairs_xy_z.py │ │ │ ├── test_pairwise_distance_3d.py │ │ │ ├── test_rectangular_mesh.py │ │ │ ├── test_weighted_npairs_s_mu.py │ │ │ └── test_wnpairs_pure_python.py │ │ └── weighted_npairs_s_mu.py │ ├── pairwise_velocities │ │ ├── __init__.py │ │ ├── engines │ │ │ ├── __init__.py │ │ │ ├── mean_radial_velocity_vs_r_engine.pyx │ │ │ ├── radial_pvd_vs_r_engine.pyx │ │ │ ├── setup_package.py │ │ │ ├── velocity_marked_npairs_3d_engine.pyx │ │ │ ├── velocity_marked_npairs_xy_z_engine.pyx │ │ │ ├── velocity_marking_functions.pxd │ │ │ └── velocity_marking_functions.pyx │ │ ├── los_pvd_vs_rp.py │ │ ├── mean_los_velocity_vs_rp.py │ │ ├── mean_radial_velocity_vs_r.py │ │ ├── pairwise_velocities_helpers.py │ │ ├── radial_pvd_vs_r.py │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── pure_python_mean_radial_velocity_vs_r.py │ │ │ ├── test_los_pvd_vs_rp.py │ │ │ ├── test_mean_los_velocity_vs_rp.py │ │ │ ├── test_mean_radial_velocity_vs_r.py │ │ │ ├── test_pairwise_velocity_helpers.py │ │ │ ├── test_pairwise_velocity_stats.py │ │ │ ├── test_pure_python_mean_radial_velocity_vs_r.py │ │ │ ├── test_radial_pvd_vs_r.py │ │ │ └── test_velocity_marked_npairs_3d.py │ │ ├── velocity_marked_npairs_3d.py │ │ └── velocity_marked_npairs_xy_z.py │ ├── radial_profiles │ │ ├── __init__.py │ │ ├── engines │ │ │ ├── __init__.py │ │ │ ├── radial_profile_3d_engine.pyx │ │ │ └── setup_package.py │ │ ├── radial_profile_3d.py │ │ ├── radial_profiles_helpers.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ └── test_radial_profile_3d.py │ ├── surface_density │ │ ├── __init__.py │ │ ├── engines │ │ │ ├── __init__.py │ │ │ ├── mean_delta_sigma_engine.pyx │ │ │ ├── mean_ds_one_two_halo_decomp_halo_id_engine.pyx │ │ │ ├── mean_ds_one_two_halo_decomp_rhalo_engine.pyx │ │ │ ├── setup_package.py │ │ │ ├── weighted_npairs_per_object_xy_engine.pyx │ │ │ └── weighted_npairs_xy_engine.pyx │ │ ├── mass_in_cylinders.py │ │ ├── mean_delta_sigma.py │ │ ├── surface_density.py │ │ ├── surface_density_helpers.py │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── pure_python_weighted_npairs_per_object_xy.py │ │ │ ├── pure_python_weighted_npairs_xy.py │ │ │ ├── test_mass_in_cylinders.py │ │ │ ├── test_mean_delta_sigma.py │ │ │ ├── test_pure_python_weighted_npairs_xy.py │ │ │ ├── test_surface_density.py │ │ │ ├── test_surface_density_helpers.py │ │ │ ├── test_weighted_npairs_per_object_xy.py │ │ │ └── test_weighted_npairs_xy.py │ │ ├── weighted_npairs_per_object_xy.py │ │ └── weighted_npairs_xy.py │ ├── tensor_calculations │ │ ├── __init__.py │ │ ├── engines │ │ │ ├── __init__.py │ │ │ ├── inertia_tensor_3d_engine.pyx │ │ │ └── setup_package.py │ │ ├── inertia_tensor.py │ │ ├── tensor_derived_quantities.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_inertia_tensor.py │ │ │ └── test_tensor_derived_quantities.py │ ├── tests │ │ ├── __init__.py │ │ ├── cf_helpers.py │ │ ├── test_catalog_analysis_helpers.py │ │ ├── test_mock_observables_helpers.py │ │ ├── test_mock_survey.py │ │ └── test_occupation_stats.py │ ├── two_point_clustering │ │ ├── __init__.py │ │ ├── angular_tpcf.py │ │ ├── clustering_helpers.py │ │ ├── marked_tpcf.py │ │ ├── rp_pi_tpcf.py │ │ ├── rp_pi_tpcf_jackknife.py │ │ ├── s_mu_tpcf.py │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── locate_external_unit_testing_data.py │ │ │ ├── test_angular_tpcf.py │ │ │ ├── test_clustering_helpers.py │ │ │ ├── test_marked_tpcf.py │ │ │ ├── test_rp_pi_tpcf.py │ │ │ ├── test_rp_pi_tpcf_jackknife.py │ │ │ ├── test_s_mu_tpcf.py │ │ │ ├── test_tpcf.py │ │ │ ├── test_tpcf_estimators.py │ │ │ ├── test_tpcf_jackknife.py │ │ │ ├── test_tpcf_multipole.py │ │ │ ├── test_tpcf_one_two_halo.py │ │ │ ├── test_wp.py │ │ │ └── test_wp_jackknife.py │ │ ├── tpcf.py │ │ ├── tpcf_estimators.py │ │ ├── tpcf_jackknife.py │ │ ├── tpcf_multipole.py │ │ ├── tpcf_one_two_halo_decomp.py │ │ ├── wp.py │ │ └── wp_jackknife.py │ ├── velocity_decomposition │ │ ├── __init__.py │ │ ├── radial_velocity_decomposition.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ └── test_radial_velocity.py │ └── void_statistics │ │ ├── __init__.py │ │ ├── tests │ │ ├── __init__.py │ │ ├── test_underdensity_prob_func.py │ │ └── test_void_prob_func.py │ │ ├── underdensity_prob_func.py │ │ └── void_prob_func.py ├── sim_manager │ ├── __init__.py │ ├── cached_halo_catalog.py │ ├── download_manager.py │ ├── fake_sim.py │ ├── halo_table_cache.py │ ├── halo_table_cache_log_entry.py │ ├── ptcl_table_cache.py │ ├── ptcl_table_cache_log_entry.py │ ├── rockstar_hlist_reader.py │ ├── setup_package.py │ ├── sim_defaults.py │ ├── supported_sims.py │ ├── tabular_ascii_reader.py │ ├── tests │ │ ├── __init__.py │ │ ├── data │ │ │ └── dummy_halocat_0.07812.list │ │ ├── helper_functions.py │ │ ├── test_cached_halo_catalog.py │ │ ├── test_download_manager.py │ │ ├── test_fake_sim.py │ │ ├── test_halo_table_cache.py │ │ ├── test_halo_table_cache_log_entry.py │ │ ├── test_load_default_halocat.py │ │ ├── test_ptcl_table_cache.py │ │ ├── test_ptcl_table_cache_log_entry.py │ │ ├── test_rockstar_hlist_reader.py │ │ ├── test_supported_sims.py │ │ ├── test_tabular_ascii_reader.py │ │ ├── test_user_supplied_halo_catalog.py │ │ └── test_user_supplied_ptcl_catalog.py │ ├── user_supplied_halo_catalog.py │ └── user_supplied_ptcl_catalog.py ├── tests │ ├── __init__.py │ ├── coveragerc │ ├── ddc.py │ ├── docs_code_block_tests │ │ ├── __init__.py │ │ ├── test_hod_model_factory_tutorial.py │ │ └── test_preloaded_mockpop.py │ ├── setup_package.py │ ├── test_amurrica.py │ ├── test_seed.py │ ├── test_subpkg_imports.py │ └── usa.py └── utils │ ├── __init__.py │ ├── array_indexing_manipulations.py │ ├── array_utils.py │ ├── conditional_percentile.py │ ├── crossmatch.py │ ├── distribution_matching.py │ ├── engines │ ├── __init__.py │ ├── conditional_rank_kernel.pyx │ └── setup_package.py │ ├── group_member_generator.py │ ├── inverse_transformation_sampling.py │ ├── io_utils.py │ ├── load_umachine_binaries.py │ ├── mcrotations.py │ ├── probabilistic_binning.py │ ├── python_string_comparisons.py │ ├── rotations2d.py │ ├── rotations3d.py │ ├── spherical_geometry.py │ ├── table_utils.py │ ├── tests │ ├── __init__.py │ ├── data │ │ └── dummy_ascii.dat │ ├── setup_package.py │ ├── test_2d_rotations.py │ ├── test_3d_rotations.py │ ├── test_array_indexing_manipulations.py │ ├── test_array_utils.py │ ├── test_compute_richness.py │ ├── test_conditional_percentile.py │ ├── test_crossmatch.py │ ├── test_distribution_matching.py │ ├── test_group_member_generator.py │ ├── test_io_utils.py │ ├── test_its.py │ ├── test_mcrotations.py │ ├── test_probabilistic_binning.py │ ├── test_python_string_comparisons.py │ ├── test_rotate_vector_collection.py │ ├── test_table_utils.py │ ├── test_value_added_halo_table_functions.py │ └── test_vector_utilities.py │ ├── value_added_halo_table_functions.py │ └── vector_utilities.py ├── pyproject.toml ├── requirements.txt ├── scripts ├── README.rst ├── convert_documentation_tutorials.py ├── download_additional_halocat.py ├── download_initial_halocat.py ├── rebuild_halo_table_cache_log.py └── rebuild_ptcl_table_cache_log.py ├── setup.py └── tox.ini /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" # See documentation for possible values 9 | directory: ".github/workflows" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | groups: 13 | actions: 14 | patterns: 15 | - "*" 16 | -------------------------------------------------------------------------------- /.github/workflows/cron_tests.yaml: -------------------------------------------------------------------------------- 1 | name: Cron Tests 2 | 3 | on: 4 | workflow_dispatch: null 5 | schedule: 6 | # Runs "First of every month at 3:15am Central" 7 | - cron: '15 8 1 * *' 8 | 9 | jobs: 10 | # Github Actions supports ubuntu, windows, and macos virtual environments: 11 | # https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners 12 | ci_tests: 13 | name: ${{ matrix.name }} 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | matrix: 17 | include: 18 | - name: Ubuntu - Python 3.11 with all optional dependencies 19 | os: ubuntu-latest 20 | python: "3.11" 21 | toxenv: 'py11-test-alldeps' 22 | 23 | - name: MacOs - Python 3.11 with all optional dependencies 24 | os: macos-latest 25 | python: "3.11" 26 | toxenv: 'py11-test-alldeps' 27 | 28 | - name: Ubuntu - Python 3.12 with all optional dependencies 29 | os: ubuntu-latest 30 | python: "3.12" 31 | toxenv: 'py312-test-alldeps' 32 | 33 | - name: MacOs - Python 3.12 with all optional dependencies 34 | os: macos-latest 35 | python: "3.12" 36 | toxenv: 'py312-test-alldeps' 37 | 38 | steps: 39 | - name: Checkout code 40 | uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 41 | with: 42 | fetch-depth: 0 43 | - name: Set up python ${{ matrix.python }} on ${{ matrix.os }} 44 | uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 45 | with: 46 | python-version: ${{ matrix.python }} 47 | - name: Install base dependencies 48 | run: | 49 | python -m pip install --upgrade pip 50 | python -m pip install tox codecov 51 | - name: Test with tox 52 | run: | 53 | tox -e ${{ matrix.toxenv }} 54 | -------------------------------------------------------------------------------- /.github/workflows/wheels.yaml: -------------------------------------------------------------------------------- 1 | name: Build wheels 2 | 3 | on: 4 | workflow_dispatch: 5 | release: 6 | types: 7 | - published 8 | 9 | jobs: 10 | build_wheels: 11 | name: Build wheels on ${{ matrix.os }} 12 | runs-on: ${{ matrix.os }} 13 | strategy: 14 | matrix: 15 | os: [ubuntu-22.04, macos-latest] 16 | 17 | steps: 18 | - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 19 | 20 | # Used to host cibuildwheel 21 | - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 22 | 23 | - name: Install cibuildwheel 24 | run: python -m pip install cibuildwheel==2.10.0 25 | 26 | - name: Build wheels 27 | # uses: pypa/cibuildwheel@d4a2945fcc8d13f20a1b99d461b8e844d5fc6e23 # v2.21.1 28 | run: python -m cibuildwheel --output-dir wheelhouse 29 | env: 30 | CIBW_BEFORE_BUILD: pip install numpy>=2 Cython extension-helpers 31 | CIBW_PROJECT_REQUIRES_PYTHON: ">=3.11" 32 | CIBW_SKIP: pp* 33 | 34 | - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 35 | with: 36 | name: wheels-${{ matrix.os }} 37 | path: ./wheelhouse/*.whl 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled files 2 | *.py[co] 3 | *.a 4 | *.o 5 | *.so 6 | __pycache__ 7 | 8 | .tox/* 9 | # Ignore .c files by default to avoid including generated code. If you want to 10 | # add a non-generated .c extension, use `git add -f filename.c`. 11 | *.c 12 | *.cpp 13 | 14 | # Other generated files 15 | MANIFEST 16 | */version.py 17 | */cython_version.py 18 | htmlcov 19 | .coverage 20 | 21 | # Sphinx 22 | docs/api 23 | docs/_build 24 | 25 | # Eclipse editor project files 26 | .project 27 | .pydevproject 28 | .settings 29 | 30 | # Packages/installer info 31 | *.egg 32 | *.egg-info 33 | dist 34 | build 35 | eggs 36 | parts 37 | bin 38 | var 39 | sdist 40 | develop-eggs 41 | .installed.cfg 42 | distribute-*.tar.gz 43 | 44 | # Other 45 | .*.swp 46 | *~ 47 | temporary_testing_script.py 48 | *.ipynb 49 | .ipynb_checkpoints/* 50 | */.ipynb_checkpoints/* 51 | */*/.ipynb_checkpoints/* 52 | .pytest_cache/* 53 | 54 | # Mac OSX 55 | .DS_Store 56 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | build: 4 | os: ubuntu-22.04 5 | apt_packages: 6 | - graphviz 7 | tools: 8 | python: "3.11" 9 | 10 | sphinx: 11 | configuration: docs/conf.py 12 | 13 | python: 14 | install: 15 | - method: pip 16 | path: . 17 | extra_requirements: 18 | - docs 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, UChicago Argonne, LLC 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst 2 | include CHANGES.rst 3 | include licenses/LICENSE.rst 4 | include setup.cfg 5 | include pyproject.toml 6 | include tox.ini 7 | 8 | recursive-include halotools *.pyx *.pxd *.c *.cpp *.h 9 | recursive-include docs * 10 | recursive-include scripts * 11 | 12 | prune build 13 | prune docs/_build 14 | prune docs/api 15 | 16 | global-exclude *.pyc *.o 17 | -------------------------------------------------------------------------------- /cextern/README.rst: -------------------------------------------------------------------------------- 1 | External C Libraries 2 | ==================== 3 | 4 | This directory contains C libraries included with halotools. Note that only C 5 | libraries not maintained by halotools developers should be stored here. 6 | Cython and wrapper code should be in an appropriate location within 7 | the halotools/halotools source tree. 8 | -------------------------------------------------------------------------------- /docs/_static/bijective_distribution_matching_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/bijective_distribution_matching_demo.png -------------------------------------------------------------------------------- /docs/_static/cam_example_assembias_clf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/cam_example_assembias_clf.png -------------------------------------------------------------------------------- /docs/_static/cam_example_bulge_disk_ratio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/cam_example_bulge_disk_ratio.png -------------------------------------------------------------------------------- /docs/_static/cam_example_complex_sfr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/cam_example_complex_sfr.png -------------------------------------------------------------------------------- /docs/_static/cam_example_complex_sfr_dmdt_correlation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/cam_example_complex_sfr_dmdt_correlation.png -------------------------------------------------------------------------------- /docs/_static/cam_example_complex_sfr_recovery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/cam_example_complex_sfr_recovery.png -------------------------------------------------------------------------------- /docs/_static/color_correlation_pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/color_correlation_pdf.png -------------------------------------------------------------------------------- /docs/_static/dm-splatting-large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/dm-splatting-large.png -------------------------------------------------------------------------------- /docs/_static/fuzzy_binning_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/fuzzy_binning_example.png -------------------------------------------------------------------------------- /docs/_static/halotools.css: -------------------------------------------------------------------------------- 1 | @import url("bootstrap-astropy.css"); 2 | 3 | div.topbar { 4 | background-image: url("dm-splatting-large.png"); 5 | } -------------------------------------------------------------------------------- /docs/_static/matched_distributions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/matched_distributions.png -------------------------------------------------------------------------------- /docs/_static/mbk10_nsat_up0_behavior.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/mbk10_nsat_up0_behavior.png -------------------------------------------------------------------------------- /docs/_static/monte_carlo_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/monte_carlo_example.png -------------------------------------------------------------------------------- /docs/_static/monte_carlo_example2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/monte_carlo_example2.png -------------------------------------------------------------------------------- /docs/_static/noisy_percentile_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/noisy_percentile_demo.png -------------------------------------------------------------------------------- /docs/_static/non_poisson_mc_realization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/non_poisson_mc_realization.png -------------------------------------------------------------------------------- /docs/_static/quenching_gradient_model_clustering.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/quenching_gradient_model_clustering.png -------------------------------------------------------------------------------- /docs/_static/quenching_gradient_models.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/quenching_gradient_models.png -------------------------------------------------------------------------------- /docs/_static/spin_percentile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/_static/spin_percentile.png -------------------------------------------------------------------------------- /docs/_templates/autosummary/base.rst: -------------------------------------------------------------------------------- 1 | {% extends "autosummary_core/base.rst" %} 2 | {# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #} -------------------------------------------------------------------------------- /docs/_templates/autosummary/class.rst: -------------------------------------------------------------------------------- 1 | {% extends "autosummary_core/class.rst" %} 2 | {# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #} -------------------------------------------------------------------------------- /docs/_templates/autosummary/module.rst: -------------------------------------------------------------------------------- 1 | {% extends "autosummary_core/module.rst" %} 2 | {# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #} -------------------------------------------------------------------------------- /docs/changelog.rst: -------------------------------------------------------------------------------- 1 | .. _changelog: 2 | 3 | ************** 4 | Full Changelog 5 | ************** 6 | 7 | .. include:: ../CHANGES.rst 8 | -------------------------------------------------------------------------------- /docs/full_ref_api/halotools_full_api.rst: -------------------------------------------------------------------------------- 1 | .. _complete_reference_api: 2 | 3 | ************************************* 4 | Comprehensive Halotools Reference/API 5 | ************************************* 6 | 7 | .. automodapi:: halotools.empirical_models 8 | .. automodapi:: halotools.empirical_models.model_defaults 9 | 10 | .. automodapi:: halotools.custom_exceptions 11 | 12 | .. automodapi:: halotools.sim_manager 13 | .. automodapi:: halotools.sim_manager.sim_defaults 14 | 15 | .. automodapi:: halotools.utils 16 | 17 | .. automodapi:: halotools.mock_observables 18 | .. automodapi:: halotools.mock_observables.pair_counters 19 | .. automodapi:: halotools.mock_observables.pair_counters.marked_cpairs 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/function_usage/abundance_matching.rst: -------------------------------------------------------------------------------- 1 | .. _abundance_matching: 2 | 3 | Abundance Matching and Age Matching 4 | ==================================================== 5 | 6 | .. currentmodule:: halotools.empirical_models 7 | 8 | .. autosummary:: 9 | 10 | conditional_abunmatch_bin_based 11 | -------------------------------------------------------------------------------- /docs/function_usage/empirical_model_factory_functions.rst: -------------------------------------------------------------------------------- 1 | .. _empirical_model_factory_functions: 2 | 3 | Model Factories 4 | ================================== 5 | 6 | All of these can be imported from `halotools.empirical_models`. 7 | 8 | .. currentmodule:: halotools.empirical_models 9 | 10 | HOD Model Factories 11 | --------------------- 12 | 13 | .. autosummary:: 14 | 15 | HodModelFactory 16 | HodMockFactory 17 | 18 | Subhalo Model Factories 19 | -------------------------- 20 | 21 | .. autosummary:: 22 | 23 | SubhaloModelFactory 24 | SubhaloMockFactory 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/function_usage/hod_occupation_functions.rst: -------------------------------------------------------------------------------- 1 | .. _hod_occupation_functions: 2 | 3 | HOD Occupation Component Models 4 | ================================== 5 | 6 | All of these can be imported from `halotools.empirical_models`. 7 | 8 | .. currentmodule:: halotools.empirical_models 9 | 10 | Zheng et al. (2007) 11 | -------------------- 12 | 13 | .. autosummary:: 14 | 15 | Zheng07Cens 16 | AssembiasZheng07Cens 17 | Zheng07Sats 18 | AssembiasZheng07Sats 19 | 20 | Leauthaud et al. (2011) 21 | ------------------------- 22 | 23 | .. autosummary:: 24 | 25 | Leauthaud11Cens 26 | AssembiasLeauthaud11Cens 27 | Leauthaud11Sats 28 | AssembiasLeauthaud11Sats 29 | 30 | Tinker et al. (2013) 31 | ------------------------- 32 | 33 | .. autosummary:: 34 | 35 | Tinker13Cens 36 | -------------------------------------------------------------------------------- /docs/function_usage/index.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _function_usage_examples: 3 | 4 | **************************************** 5 | Function-usage examples by category 6 | **************************************** 7 | 8 | Here we present docstrings of the most commonly used functions and classes 9 | grouped together by functionality. 10 | Many docstrings contain example code to demonstrate basic usage. 11 | For documentation of functions not listed here, see :ref:`complete_reference_api`. 12 | 13 | Modeling the Galaxy-Halo Connection 14 | ===================================== 15 | 16 | Composite models 17 | ------------------ 18 | 19 | HOD models 20 | ~~~~~~~~~~~~ 21 | 22 | .. toctree:: 23 | :maxdepth: 1 24 | 25 | ../quickstart_and_tutorials/tutorials/model_building/preloaded_models/zheng07_composite_model 26 | ../quickstart_and_tutorials/tutorials/model_building/preloaded_models/leauthaud11_composite_model 27 | ../quickstart_and_tutorials/tutorials/model_building/preloaded_models/tinker13_composite_model 28 | ../quickstart_and_tutorials/tutorials/model_building/preloaded_models/hearin15_composite_model 29 | ../quickstart_and_tutorials/tutorials/model_building/preloaded_models/zu_mandelbaum15_composite_model 30 | ../quickstart_and_tutorials/tutorials/model_building/preloaded_models/zu_mandelbaum16_composite_model 31 | 32 | CLF models 33 | ~~~~~~~~~~ 34 | 35 | .. toctree:: 36 | :maxdepth: 1 37 | 38 | ../quickstart_and_tutorials/tutorials/model_building/preloaded_models/cacciato09_composite_model 39 | 40 | Subhalo-based models 41 | ~~~~~~~~~~~~~~~~~~~~~ 42 | 43 | .. toctree:: 44 | :maxdepth: 1 45 | 46 | ../quickstart_and_tutorials/tutorials/model_building/preloaded_models/behroozi10_composite_model 47 | abundance_matching 48 | 49 | Component models 50 | ------------------ 51 | 52 | .. toctree:: 53 | :maxdepth: 2 54 | 55 | phase_space_models_functions 56 | hod_occupation_functions 57 | empirical_model_factory_functions 58 | 59 | Making Mock Observations 60 | =========================== 61 | 62 | .. toctree:: 63 | :maxdepth: 1 64 | 65 | mock_observables_functions 66 | 67 | Processing Simulation Data 68 | ============================= 69 | 70 | .. toctree:: 71 | :maxdepth: 1 72 | 73 | processing_simulation_data 74 | 75 | Utility Functions 76 | ============================= 77 | 78 | .. toctree:: 79 | :maxdepth: 1 80 | 81 | utility_functions 82 | 83 | 84 | -------------------------------------------------------------------------------- /docs/function_usage/mock_observables_functions.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _mock_observables_functions: 4 | 5 | Two-Point Correlation Functions 6 | ================================== 7 | 8 | All of these can be imported from `halotools.mock_observables`. 9 | 10 | .. currentmodule:: halotools.mock_observables 11 | 12 | .. autosummary:: 13 | 14 | tpcf 15 | wp 16 | rp_pi_tpcf 17 | tpcf_multipole 18 | s_mu_tpcf 19 | tpcf_jackknife 20 | tpcf_one_two_halo_decomp 21 | mean_delta_sigma 22 | marked_tpcf 23 | 24 | 25 | Calculating the HOD 26 | ==================== 27 | 28 | .. autosummary:: 29 | 30 | hod_from_mock 31 | 32 | 33 | Galaxy Group Statistics 34 | ========================== 35 | 36 | .. autosummary:: 37 | 38 | FoFGroups 39 | 40 | Isolation Criteria 41 | ========================== 42 | 43 | .. autosummary:: 44 | 45 | spherical_isolation 46 | cylindrical_isolation 47 | conditional_spherical_isolation 48 | conditional_cylindrical_isolation 49 | 50 | Pairwise Velocities 51 | ========================== 52 | 53 | .. autosummary:: 54 | 55 | mean_radial_velocity_vs_r 56 | mean_los_velocity_vs_rp 57 | radial_pvd_vs_r 58 | los_pvd_vs_rp 59 | 60 | Radial Profiles 61 | ========================== 62 | 63 | .. autosummary:: 64 | 65 | radial_profile_3d 66 | 67 | Void Statistics 68 | ========================== 69 | 70 | .. autosummary:: 71 | 72 | void_prob_func 73 | underdensity_prob_func 74 | 75 | Large Scale Density 76 | ========================== 77 | 78 | .. autosummary:: 79 | 80 | large_scale_density_spherical_volume 81 | large_scale_density_spherical_annulus 82 | 83 | 84 | Tensor Calculations 85 | ==================== 86 | 87 | .. autosummary:: 88 | 89 | inertia_tensor_per_object 90 | principal_axes_from_inertia_tensors 91 | 92 | -------------------------------------------------------------------------------- /docs/function_usage/phase_space_models_functions.rst: -------------------------------------------------------------------------------- 1 | .. _phase_space_models_functions: 2 | 3 | Phase Space Component Models 4 | ============================ 5 | 6 | All of these can be imported from `halotools.empirical_models`. 7 | 8 | .. currentmodule:: halotools.empirical_models 9 | 10 | Halo Mass Definitions 11 | --------------------- 12 | 13 | .. autosummary:: 14 | 15 | halo_mass_to_halo_radius 16 | halo_radius_to_halo_mass 17 | delta_vir 18 | density_threshold 19 | 20 | NFW Profile Models 21 | ------------------ 22 | 23 | .. autosummary:: 24 | 25 | NFWProfile 26 | NFWPhaseSpace 27 | 28 | Subhalo-based Profiles 29 | ---------------------- 30 | 31 | .. autosummary:: 32 | 33 | SubhaloPhaseSpace 34 | 35 | Central Galaxy Profile Models 36 | ----------------------------- 37 | 38 | .. autosummary:: 39 | 40 | TrivialProfile 41 | TrivialPhaseSpace 42 | 43 | Monte Carlo Realizations of Galaxy Profiles 44 | ------------------------------------------- 45 | 46 | .. autosummary:: 47 | 48 | NFWPhaseSpace.mc_generate_nfw_phase_space_points 49 | NFWProfile.mc_generate_nfw_radial_positions 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /docs/function_usage/processing_simulation_data.rst: -------------------------------------------------------------------------------- 1 | .. _processing_simulation_data: 2 | 3 | Using and Generating Halotools-Formatted Catalogs 4 | ==================================================== 5 | 6 | All of these can be imported from `halotools.sim_manager`. 7 | 8 | .. currentmodule:: halotools.sim_manager 9 | 10 | .. autosummary:: 11 | 12 | CachedHaloCatalog 13 | UserSuppliedHaloCatalog 14 | 15 | 16 | Reading and Reducing Halo ASCII Data 17 | =============================================== 18 | 19 | .. autosummary:: 20 | 21 | RockstarHlistReader 22 | TabularAsciiReader 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/function_usage/utility_functions.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _utility_functions: 4 | 5 | 6 | .. currentmodule:: halotools.utils 7 | 8 | 9 | Cross-matching catalogs with a common object ID 10 | ======================================================== 11 | 12 | .. autosummary:: 13 | 14 | crossmatch 15 | unsorting_indices 16 | 17 | 18 | Calculating quantities for objects grouped into a common halo 19 | =============================================================== 20 | 21 | .. autosummary:: 22 | 23 | group_member_generator 24 | compute_richness 25 | 26 | 27 | Generating Monte Carlo realizations 28 | =============================================================== 29 | 30 | .. autosummary:: 31 | 32 | monte_carlo_from_cdf_lookup 33 | build_cdf_lookup 34 | 35 | 36 | Matching one distribution to another 37 | =============================================================== 38 | 39 | .. autosummary:: 40 | 41 | distribution_matching_indices 42 | resample_x_to_match_y 43 | bijective_distribution_matching 44 | 45 | Probabilistic binning 46 | =============================================================== 47 | 48 | .. autosummary:: 49 | 50 | fuzzy_digitize 51 | 52 | Estimating two-dimensional PDFs 53 | =============================================================== 54 | 55 | .. autosummary:: 56 | 57 | sliding_conditional_percentile 58 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | ======================= 2 | Halotools Documentation 3 | ======================= 4 | 5 | 6 | Halotools is a specialized python package for building and testing models of the 7 | galaxy-halo connection, and analyzing catalogs of dark matter halos. 8 | The core functionality of the package includes: 9 | 10 | * Fast generation of synthetic galaxy populations using HODs, abundance matching, and related methods 11 | * Efficient algorithms for calculating galaxy clustering, lensing, z-space distortions, and other astronomical statistics 12 | * A modular, object-oriented framework for designing your own galaxy evolution model 13 | * End-to-end support for reducing halo catalogs and caching them as fast-loading hdf5 files 14 | 15 | For more information about the scope of the package, see :ref:`halotools_science_overview`. The source code is publicly available at https://github.com/astropy/halotools. 16 | 17 | 18 | ****************** 19 | Getting Started 20 | ****************** 21 | 22 | .. toctree:: 23 | :maxdepth: 1 24 | 25 | install 26 | quickstart_and_tutorials/index 27 | function_usage/index 28 | source_notes/index 29 | quickstart_and_tutorials/development/index 30 | 31 | *********** 32 | What's New? 33 | *********** 34 | 35 | .. toctree:: 36 | :maxdepth: 1 37 | 38 | whats_new 39 | changelog 40 | 41 | ********* 42 | Reference 43 | ********* 44 | 45 | .. toctree:: 46 | :maxdepth: 1 47 | 48 | full_ref_api/halotools_full_api 49 | 50 | 51 | ********************* 52 | License and Credits 53 | ********************* 54 | 55 | .. toctree:: 56 | :maxdepth: 1 57 | 58 | quickstart_and_tutorials/development/contributors 59 | quickstart_and_tutorials/development/citing_halotools 60 | 61 | -------------------------------------------------------------------------------- /docs/installation_troubleshooting.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _installation_troubleshooting: 4 | 5 | **************************************************** 6 | Installation Troubleshooting 7 | **************************************************** 8 | 9 | This page of the documentation collects together solutions 10 | to known installation problems. If you have trouble installing 11 | Halotools and the issue is not resolved here, please contact 12 | the development team and raise an Issue on 13 | `The GitHub Issues page `_. 14 | 15 | 1. Older versions of the gcc compiler may not support all the optimization 16 | flags that are used to compile the Cython code. These flags are chosen according 17 | to the ``extra_compile_args`` list of strings that appears in the handful of 18 | ``setup_package.py`` files throughout the code. If this list contains a flag 19 | not used by your version of gcc, you can simply delete each 20 | appearance of the offending flag, and then install the code by 21 | building the modified source code. 22 | See `GitHub Issue 561 `_ for further details. 23 | 24 | 2. If you are a Mac user and you are not using the version of gcc that ships 25 | with OS X, you may need to temporarily switch compilers to clang. 26 | As described in `GitHub Issue 447 `_, 27 | try ``export CC=clang; pip install halotools`` to resolve this issue. 28 | 29 | -------------------------------------------------------------------------------- /docs/installing_halotools_with_virtualenv.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _installing_halotools_with_virtualenv: 4 | 5 | **************************************************** 6 | Installing Halotools using a virtual environment 7 | **************************************************** 8 | 9 | If you use `conda `_ to manage 10 | your python distribution and package dependencies, it is easy to 11 | create a virtual environment that will automatically have compatible versions of the necessary dependencies required by Halotools. 12 | By installing into a virtual environment, you will not change any of the 13 | packages that are already installed system-wide on your machine. In the example below, we will use conda to create a virtual environment with all the dependencies handled automatically:: 14 | 15 | conda create -n htenv python=3.11 halotools=0.9 h5py ipython jupyter matplotlib 16 | 17 | In order to activate this environment:: 18 | 19 | conda activate htenv 20 | 21 | Or, alternatively, you can install the latest master branch by following the :ref:`install_from_source` instructions. 22 | 23 | Any additional packages you install into the ``htenv`` virtual environment will not impact your system-wide environment. Whenever you want to do science involving Halotools, 24 | just activate the environment and import the code. When you are done 25 | and wish to return to your normal system environment:: 26 | 27 | conda deactivate 28 | -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/development/bug_reports.rst: -------------------------------------------------------------------------------- 1 | .. _bug_reports: 2 | 3 | ************************* 4 | Submitting a Bug Report 5 | ************************* 6 | 7 | If you find or just suspect buggy behavior in Halotools, 8 | please raise an issue on GitHub. Navigate to the 9 | `Halotools Issues page `_, 10 | create a new issue with a description of the problem and 11 | the full Traceback (if applicable), and attach a *bug* label to the issue. 12 | 13 | -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/development/contributors.rst: -------------------------------------------------------------------------------- 1 | .. _contributor_list: 2 | 3 | ************************** 4 | Package contributors 5 | ************************** 6 | 7 | Halotools project coordinator 8 | =============================== 9 | 10 | * Andrew Hearin 11 | 12 | Lead developers 13 | ========================== 14 | 15 | * Andrew Hearin 16 | * Duncan Campbell 17 | * Erik Tollerud 18 | 19 | Core package contributors 20 | ========================== 21 | 22 | * Matt Becker 23 | * Peter Behroozi 24 | * Chris Bradshaw 25 | * Duncan Campbell 26 | * Matt Craig 27 | * Benedikt Diemer 28 | * Yu Feng 29 | * Nathan Goldbaum 30 | * Nick Hand 31 | * Andrew Hearin 32 | * Elise Jennings 33 | * Johannes Ulf Lange 34 | * Francois Lanusse 35 | * Alexie Leauthaud 36 | * P.L. Lim 37 | * Yao-Yuan Mao 38 | * Surhud More 39 | * John Parejko 40 | * Alan Pearl 41 | * Manodeep Sinha 42 | * Brigitta Sipocz 43 | * Erik Tollerud 44 | * Doug Watson 45 | * Haojie Xu 46 | * Andrew Zentner 47 | 48 | Other credits 49 | ============= 50 | 51 | * Special thanks to Ralf Kaehler and the Kavli Institute for Particle Astrophysics and Cosmology (KIPAC) for the use of the visualization of an n-body simulation that is used in the top banner of these documentation pages. 52 | -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/development/getting_started.rst: -------------------------------------------------------------------------------- 1 | .. _getting_started_developers: 2 | 3 | ************************* 4 | Contributing to Halotools 5 | ************************* 6 | 7 | All halotools development happens in the github repository. To contribute, first clone the repo. 8 | Then install the dependencies listed on the :ref:`step_by_step_install` page. 9 | 10 | 11 | Code 12 | ==== 13 | 14 | Halotools testing is handled with tox:: 15 | 16 | tox -e test 17 | 18 | Docs 19 | ==== 20 | 21 | Then build documentation with tox, :: 22 | 23 | tox -e build_docs 24 | -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/development/index.rst: -------------------------------------------------------------------------------- 1 | .. _developer-docs: 2 | 3 | ======================= 4 | Developer documentation 5 | ======================= 6 | 7 | The developer documentation contains guidlines for how to 8 | stay up-to-date on Halotools development, submit bug reports and 9 | contribute to the Halotools code base. 10 | 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | bug_reports 16 | getting_started 17 | contributors 18 | ../../changelog 19 | -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/angular_crosscorr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/angular_crosscorr.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/gg_lensing_tutorial3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/gg_lensing_tutorial3.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/mock_fullsky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/mock_fullsky.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/mock_octant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/mock_octant.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/one_two_halo_clustering.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/one_two_halo_clustering.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/output_9_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/output_9_1.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/random_vs_analytic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/random_vs_analytic.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/wp_red_blue_cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/wp_red_blue_cross.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/wp_tutorial4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/wp_tutorial4.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/wtheta1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/clustering_examples/wtheta1.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/group_identification/group_richness_vs_group_cenmass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/group_identification/group_richness_vs_group_cenmass.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/output_18_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/output_18_1.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/output_23_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/output_23_1.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/velocity_statistics/cluster_bcg_infall_velocity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/velocity_statistics/cluster_bcg_infall_velocity.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/velocity_statistics/cluster_dispersion_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/velocity_statistics/cluster_dispersion_profile.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/void_stats/vpf_upf_tutorial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/galcat_analysis/basic_examples/void_stats/vpf_upf_tutorial.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/halocat_analysis/basic_examples/figs/radial_profile_halocat_tutorial_fig1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/halocat_analysis/basic_examples/figs/radial_profile_halocat_tutorial_fig1.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/halocat_analysis/basic_examples/figs/radial_profile_halocat_tutorial_fig2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/halocat_analysis/basic_examples/figs/radial_profile_halocat_tutorial_fig2.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/halocat_analysis/basic_examples/nsub_vs_hostmass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/halocat_analysis/basic_examples/nsub_vs_hostmass.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/halocat_analysis/index.rst: -------------------------------------------------------------------------------- 1 | .. _halo_catalog_analysis_tutorial: 2 | 3 | ********************************************************************** 4 | Tutorials on analyzing halo catalogs 5 | ********************************************************************** 6 | 7 | By following these tutorials, you will learn how to use Halotools to 8 | analyze a halo catalog. Each of the examples below is in principle stand-alone, 9 | so that you can pick and choose from any of the pages below according to 10 | the kind of analysis you are most interested in. 11 | In cases where material covered in a previous example is necessary 12 | to understand some aspect of one of the more complicated later calculations, 13 | a link to the previous example will always be provided. 14 | 15 | Basic examples 16 | =================== 17 | Each of the examples in this section gives a specific demonstration of how to perform a 18 | straightforward calculation on a halo catalog. By reading through 19 | these examples, you will gain a working knowledge of all the major functions 20 | in the `~halotools.mock_observables` package. 21 | 22 | halo properties as a function of halo mass 23 | ------------------------------------------------- 24 | 25 | .. toctree:: 26 | :maxdepth: 1 27 | 28 | basic_examples/halo_catalog_analysis_tutorial1 29 | 30 | cross-matching halo catalogs 31 | ------------------------------------------------- 32 | 33 | .. toctree:: 34 | :maxdepth: 1 35 | 36 | crossmatching_halo_catalogs 37 | 38 | halo properties as a function of distance from a nearby halo 39 | -------------------------------------------------------------- 40 | 41 | .. toctree:: 42 | :maxdepth: 1 43 | 44 | basic_examples/halo_catalog_analysis_tutorial2 45 | 46 | -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/catalog_analysis/halocat_analysis/subhalo_membership.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/catalog_analysis/halocat_analysis/subhalo_membership.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/model_building/altering_param_dict.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _altering_param_dict: 4 | 5 | ************************************************* 6 | Changing Composite Model Parameters 7 | ************************************************* 8 | 9 | All Halotools composite models have a ``param_dict`` attribute, 10 | a python dictionary storing the complete collection 11 | of tunable parameters of the model. By altering the values of stored 12 | in ``param_dict``, you change the behavior of the model. 13 | If you are running an MCMC-type likelihood analysis, 14 | your walker should explore the parameter space of (some subset of) 15 | the parameters stored in the model ``param_dict``. 16 | 17 | For information about how changes in ``param_dict`` propagate through 18 | Halotools source code, see :ref:`param_dict_mechanism` section 19 | of the :ref:`composite_model_constructor_bookkeeping_mechanisms` page 20 | in the documentation. 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/model_building/composing_models/hod_modeling/hod_modeling_tutorial0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _hod_modeling_tutorial0: 3 | 4 | **************************************************************** 5 | Tutorial on building an HOD-style model 6 | **************************************************************** 7 | 8 | .. currentmodule:: halotools.empirical_models 9 | 10 | This section of the documentation describes how you can 11 | build a custom-designed HOD-style model of the galaxy-halo connection. 12 | This material is most easily learned by way of example, and so 13 | the remainder of the tutorial is organized into a sequence 14 | of worked examples of increasing complexity. 15 | 16 | .. toctree:: 17 | :maxdepth: 1 18 | 19 | hod_modeling_tutorial1 20 | hod_modeling_tutorial2 21 | hod_modeling_tutorial3 22 | hod_modeling_tutorial4 23 | hod_modeling_tutorial5 24 | -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/model_building/composing_models/hod_modeling/writing_your_own_hod_profile_component.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _writing_your_own_hod_profile_component: 4 | 5 | *********************************************************************** 6 | Writing your own HOD profile component 7 | *********************************************************************** 8 | 9 | Tutorial coming soon! 10 | -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/model_building/composing_models/index.rst: -------------------------------------------------------------------------------- 1 | .. _composing_new_models: 2 | 3 | ********************************************************************** 4 | Tutorial on designing your own model of the galaxy-halo connection 5 | ********************************************************************** 6 | 7 | By following this tutorial, you will learn how to use the 8 | Halotools framework to design your own model of the galaxy-halo connection. 9 | The `~halotools.empirical_models` factories come in two different types, 10 | *HOD-style models* and *subhalo-based models.* In HOD-style models, 11 | there is no connection between the abundance of satellite 12 | galaxies in a host halo and the number of subhalos in that host halo. In these models, 13 | satellite abundance in each halo is determined by a Monte Carlo realization 14 | of some analytical model. Examples of this approach to the galaxy-halo connection 15 | include the HOD, CLF and CSMF, as well as extensions of these that include additional 16 | features such as color-dependence. 17 | 18 | By contrast, in subhalo-based models there is a one-to-one 19 | correspondence between subhalos and satellite galaxies. In these models, 20 | every host halo in the simulation is connected to a central galaxy, 21 | and every subhalo is connected a satellite. Examples include traditional abundance 22 | matching, age matching, and parameterized stellar-to-halo mass models 23 | such as Behroozi et al. (2010) and Moster et al. (2010). 24 | 25 | The implementation of these two different approaches to the galaxy-halo connection 26 | is sufficiently different that the modeling for each is done by a separate factory. 27 | The `~halotools.empirical_models.HodModelFactory` builds HOD-style models, 28 | and the `~halotools.empirical_models.SubhaloModelFactory` builds 29 | subhalo-based models. Choose which class of model you are most interested in 30 | and follow the link to the appropriate tutorial: 31 | 32 | .. toctree:: 33 | :maxdepth: 1 34 | 35 | subhalo_modeling/subhalo_modeling_tutorial0 36 | hod_modeling/hod_modeling_tutorial0 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/model_building/composing_models/subhalo_modeling/subhalo_modeling_tutorial0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _subhalo_modeling_tutorial0: 3 | 4 | **************************************************************** 5 | Tutorial on building a subhalo-based model 6 | **************************************************************** 7 | 8 | .. currentmodule:: halotools.empirical_models 9 | 10 | This section of the documentation describes how you can 11 | build a custom-designed subhalo-based model of the galaxy-halo connection. 12 | This material is most easily learned by way of example, and so 13 | the remainder of the tutorial is organized into a sequence 14 | of worked examples of increasing complexity. 15 | 16 | .. toctree:: 17 | :maxdepth: 1 18 | 19 | subhalo_modeling_tutorial1 20 | subhalo_modeling_tutorial2 21 | subhalo_modeling_tutorial3 22 | subhalo_modeling_tutorial4 23 | subhalo_modeling_tutorial5 24 | -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/model_building/halotools_design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/quickstart_and_tutorials/tutorials/model_building/halotools_design.png -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/model_building/preloaded_models/abundance_matching_composite_model.rst: -------------------------------------------------------------------------------- 1 | .. _abundance_matching_composite_model: 2 | 3 | ********************************************* 4 | Traditional Abundance Matching Model 5 | ********************************************* 6 | 7 | Halotools does not provide an implementation of traditional SHAM. 8 | See the `deconvolution abundance matching code `_ 9 | for a fast and well-written code written by Yao-Yuan Mao 10 | that provides a python wrapper around the deconvolution kernel written by Peter Behroozi. 11 | -------------------------------------------------------------------------------- /docs/quickstart_and_tutorials/tutorials/model_building/preloaded_models/preloaded_models_list.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _preloaded_models_list: 4 | 5 | ********************************************* 6 | List of All Preloaded Models Grouped by Type 7 | ********************************************* 8 | 9 | This page is just a quick reference for every prebuilt model provided by Halotools. 10 | See :ref:`preloaded_models_overview` for more information. 11 | 12 | HOD Models 13 | =========== 14 | 15 | .. toctree:: 16 | :maxdepth: 1 17 | 18 | zheng07_composite_model 19 | leauthaud11_composite_model 20 | hearin15_composite_model 21 | tinker13_composite_model 22 | zu_mandelbaum15_composite_model 23 | zu_mandelbaum16_composite_model 24 | 25 | CLF Models 26 | ========== 27 | 28 | .. toctree:: 29 | :maxdepth: 1 30 | 31 | cacciato09_composite_model 32 | 33 | 34 | Subhalo-based Models 35 | ==================== 36 | 37 | .. toctree:: 38 | :maxdepth: 1 39 | 40 | behroozi10_composite_model 41 | abundance_matching_composite_model 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/source_notes/empirical_models/assembias_models/heaviside_assembias_source_code_notes.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _heaviside_assembias_source_code_notes: 4 | 5 | **************************************************** 6 | Source code notes on the HeavisideAssembias class 7 | **************************************************** 8 | -------------------------------------------------------------------------------- /docs/source_notes/empirical_models/factories/index.rst: -------------------------------------------------------------------------------- 1 | .. _mock_making_tutorials: 2 | 3 | *************************************** 4 | Tutorial on the mock-making algorithms 5 | *************************************** 6 | 7 | This section of the documentation gives a detailed explanation of 8 | the Halotools algorithm for making mock galaxy catalogs. Because of differences 9 | in memory allocation, HOD-style mocks are generated with a significantly 10 | different algorithm than subhalo-based mocks, and so there are separate tutorials 11 | for those two mock-making factory classes: 12 | :ref:`hod_mock_factory_source_notes` and :ref:`subhalo_mock_factory_source_notes`, respectively. 13 | 14 | Both tutorials are dense as they cover all aspects of the Halotools source code 15 | implementing mock-making. If you are instead just looking for information on how to 16 | build an HOD-style or subhalo-based model, instead refer to the 17 | :ref:`model_building` section of the documentation. 18 | 19 | 20 | -------------------------------------------------------------------------------- /docs/source_notes/empirical_models/factories/np_repeat_tutorial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/docs/source_notes/empirical_models/factories/np_repeat_tutorial.png -------------------------------------------------------------------------------- /docs/source_notes/empirical_models/phase_space_models/monte_carlo_galprof_source_notes.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: halotools.empirical_models 4 | 5 | .. _monte_carlo_galprof_mixin_tutorial: 6 | 7 | ************************************************************ 8 | Source code notes on `~MonteCarloGalProf` 9 | ************************************************************ 10 | 11 | This tutorial remains to be written. See `Github Issue 209 `_ 12 | 13 | 14 | .. _monte_carlo_galprof_spatial_positions: 15 | 16 | 17 | Monte Carlo Generation of Spatial Positions 18 | ============================================== 19 | 20 | 21 | .. _monte_carlo_galprof_lookup_tables: 22 | 23 | Building lookup tables for the spatial and velocity profiles 24 | ------------------------------------------------------------- 25 | 26 | 27 | .. _prof_param_keys_mechanism: 28 | 29 | Explanation of the ``prof_param_keys`` mechanism 30 | ---------------------------------------------------- 31 | 32 | 33 | 34 | 35 | 36 | .. _monte_carlo_galprof_velocities: 37 | 38 | Monte Carlo Generation of Velocities 39 | ============================================== 40 | -------------------------------------------------------------------------------- /docs/source_notes/index.rst: -------------------------------------------------------------------------------- 1 | .. _tutorials_by_category: 2 | 3 | ******************************************** 4 | Source code notes grouped by category 5 | ******************************************** 6 | 7 | Here we present notes on the source code implementation of 8 | the most commonly used functions and classes, 9 | grouped together by functionality. 10 | If you are instead looking for a quick reference 11 | on basic usage, see :ref:`function_usage_examples`. 12 | For documentation of the API of all functions and classes in the package, 13 | see :ref:`complete_reference_api`. 14 | 15 | 16 | Modeling the Galaxy-Halo Connection 17 | ===================================== 18 | 19 | Phase Space Component Models 20 | ------------------------------- 21 | 22 | .. toctree:: 23 | :maxdepth: 1 24 | 25 | empirical_models/phase_space_models/profile_template_source_notes 26 | empirical_models/phase_space_models/nfw_profile_source_notes 27 | 28 | Factories 29 | ------------------------------- 30 | 31 | .. toctree:: 32 | :maxdepth: 1 33 | 34 | empirical_models/factories/subhalo_model_factory_source_notes 35 | empirical_models/factories/subhalo_mock_factory_source_notes 36 | empirical_models/factories/hod_model_factory_source_notes 37 | empirical_models/factories/hod_mock_factory_source_notes 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/whats_new.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _whats_new: 4 | 5 | ******************************************* 6 | What's New in Halotools v0.9? 7 | ******************************************* 8 | 9 | Halotools ``v0.9`` is now available for installation with conda and pip. 10 | This release brings in a new feature set to forward model the intrinsic alignments of galaxies. 11 | See https://github.com/astropy/halotools/pull/1056 for details on this feature, 12 | and :ref:`whats_new_v0x_history` for full release history information. 13 | -------------------------------------------------------------------------------- /docs/whats_new_history/whats_new_0.6.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _whats_new_v0p6: 4 | 5 | ***************************** 6 | What's New in Halotools v0.6? 7 | ***************************** 8 | 9 | Halotools ``v0.6`` is now available for installation with conda and pip. New features are summarized below. See :ref:`changelog` for details on smaller issues and bug-fixes. See :ref:`whats_new_v0x_history` for full release history information. 10 | 11 | Quick Installation Verification 12 | =============================== 13 | 14 | It is now much faster to verify successful installation of the latest version of halotools. After installing the code, you can now run a targeted subset of unit tests, rather than the entire test suite: 15 | 16 | .. code:: python 17 | 18 | import halotools 19 | halotools.test_installation() 20 | 21 | 22 | New Mock Observables 23 | ==================== 24 | 25 | Radial distances and velocities 26 | ------------------------------- 27 | There are new functions in the `~halotools.mock_observables` sub-package that calculate element-wise radial distances and velocities, `~halotools.mock_observables.radial_distance` and `~halotools.mock_observables.radial_distance_and_velocity`. 28 | 29 | Jackknife error estimation 30 | --------------------------- 31 | New functions `~halotools.mock_observables.wp_jackknife` and `~halotools.mock_observables.rp_pi_tpcf_jackknife` give jackknife error estimation for the `~halotools.mock_observables.wp` and `~halotools.mock_observables.rp_pi_tpcf` functions. 32 | 33 | Weighted pair counts as a function of (s, mu) 34 | --------------------------------------------- 35 | New `halotools.mock_observables.pair_counters.weighted_npairs_s_mu` function gives weighting option for counting pairs in (s, mu) space. 36 | 37 | Utility functions 38 | ================== 39 | 40 | Matching two distributions for statistical comparison 41 | ------------------------------------------------------ 42 | The `halotools.utils.distribution_matching_indices` function Monte Carlo resamples one distribution until it matches another. 43 | 44 | 45 | API Change 46 | ========== 47 | 48 | * The `~halotools.mock_observables.pair_counters.npairs_s_mu` function now has a change to the meaning of the ``mu_bins`` input argument. This argument should now be interpreted as the conventional mu=cos(theta_LOS) instead of mu=sin(theta_LOS). 49 | -------------------------------------------------------------------------------- /docs/whats_new_history/whats_new_0.7.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _whats_new_v0p7: 4 | 5 | ******************************************* 6 | What's New in Halotools v0.7? 7 | ******************************************* 8 | 9 | Halotools ``v0.7`` is now available for installation with conda and pip. New features are summarized below. See :ref:`changelog` for details on smaller issues and bug-fixes. See :ref:`whats_new_v0x_history` for full release history information. 10 | 11 | 12 | New Utility Functions 13 | ===================== 14 | 15 | Probabilistic binning 16 | ------------------------------------------------ 17 | The `~halotools.utils.fuzzy_digitize` function in `halotools.utils` allows you to discretize an 18 | array in a probabilistic fashion, which can be useful for applications of conditional abundance matching. 19 | 20 | Estimation of Conditional Probability Distributions 21 | ----------------------------------------------------- 22 | The `~halotools.utils.sliding_conditional_percentile` function in `halotools.utils` calculates Prob(< y | x) for any arbitrary distribution of two-dimensional data. This function can be used to estimate, for example, quantiles of galaxy size as a function of stellar mass, and also should be useful in applications of conditional abundance matching. 23 | 24 | 25 | New Mock Observables 26 | ==================== 27 | 28 | Inertia Tensor calculation 29 | ------------------------------- 30 | The pairwise calculation `~halotools.mock_observables.inertia_tensor_per_object` computes the inertia tensor of a mass distribution surrounding each point in a sample of galaxies or halos. 31 | 32 | API Changes 33 | =========== 34 | 35 | * The old implementation of the `~halotools.empirical_models.conditional_abunmatch` function has been renamed to be `~halotools.empirical_models.conditional_abunmatch_bin_based`. 36 | 37 | * There is an entirely distinct, bin-free implementation of Conditional Abundance Matching that now bears the name `~halotools.empirical_models.conditional_abunmatch`. 38 | 39 | * The `~halotools.mock_observables.mean_delta_sigma` function has replaced the previous calculation of gg-lensing. See #95 and #980. 40 | 41 | Bug Fixes 42 | ========= 43 | See issues tagged with the v0.7 milestone for a complete list of all bug fixes and changes. 44 | -------------------------------------------------------------------------------- /docs/whats_new_history/whats_new_0.8.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _whats_new_v0p8: 4 | 5 | ******************************************* 6 | What's New in Halotools v0.8? 7 | ******************************************* 8 | 9 | Halotools ``v0.8`` is now available for installation with conda and pip. This is primarily a bug-fix release that also brings Halotools up-to-date with its dependencies. See :ref:`changelog` for details on smaller issues and bug-fixes. See :ref:`whats_new_v0x_history` for full release history information. 10 | -------------------------------------------------------------------------------- /docs/whats_new_history/whats_new_v0x_history.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _whats_new_v0x_history: 4 | 5 | ***************************** 6 | Version v0.x release history 7 | ***************************** 8 | 9 | Links to the "What's New?" sections of the documentation for all ``v0.x`` versions of the code appear below: 10 | 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | whats_new_0.5 16 | whats_new_0.6 17 | whats_new_0.7 18 | whats_new_0.8 19 | -------------------------------------------------------------------------------- /halotools/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Halotools is a specialized python package 3 | for building and testing models of the galaxy-halo connection, 4 | and analyzing catalogs of dark matter halos. 5 | """ 6 | from ._astropy_init import * 7 | 8 | from . import custom_exceptions 9 | 10 | 11 | def test_installation(*args, **kwargs): 12 | kwargs.setdefault('args', '') 13 | if kwargs['args']: 14 | kwargs['args'] += ' ' 15 | kwargs['args'] += '-m installation_test' 16 | return test(*args, **kwargs) 17 | -------------------------------------------------------------------------------- /halotools/_astropy_init.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | 3 | __all__ = ["__version__"] 4 | 5 | try: 6 | from .version import version as __version__ 7 | except ImportError: 8 | __version__ = "" 9 | -------------------------------------------------------------------------------- /halotools/conftest.py: -------------------------------------------------------------------------------- 1 | """Configure Test Suite. 2 | 3 | This file is used to configure the behavior of pytest when using the Astropy 4 | test infrastructure. It needs to live inside the package in order for it to 5 | get picked up when running the tests inside an interpreter using 6 | `halotools.test()`. 7 | 8 | """ 9 | 10 | import os 11 | 12 | try: 13 | from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS 14 | 15 | ASTROPY_HEADER = True 16 | except ImportError: 17 | ASTROPY_HEADER = False 18 | 19 | 20 | def pytest_configure(config): 21 | """Configure Pytest with Astropy. 22 | 23 | Parameters 24 | ---------- 25 | config : pytest configuration 26 | 27 | """ 28 | if ASTROPY_HEADER: 29 | 30 | config.option.astropy_header = True 31 | 32 | # Customize the following lines to add/remove entries from the list of 33 | # packages for which version numbers are displayed when running the tests. 34 | PYTEST_HEADER_MODULES.pop("Pandas", None) 35 | PYTEST_HEADER_MODULES["scikit-image"] = "skimage" 36 | 37 | from . import __version__ 38 | 39 | packagename = os.path.basename(os.path.dirname(__file__)) 40 | TESTED_VERSIONS[packagename] = __version__ 41 | -------------------------------------------------------------------------------- /halotools/custom_exceptions.py: -------------------------------------------------------------------------------- 1 | """ 2 | Classes for all Halotools-specific exceptions. 3 | """ 4 | 5 | __all__ = ('HalotoolsError', 'InvalidCacheLogEntry') 6 | 7 | 8 | class HalotoolsError(Exception): 9 | """ Base class of all Halotools-specific exceptions. 10 | """ 11 | 12 | def __init__(self, message): 13 | super(HalotoolsError, self).__init__(message) 14 | 15 | 16 | class InvalidCacheLogEntry(Exception): 17 | """ Base class of all Halotools-specific exceptions. 18 | """ 19 | 20 | def __init__(self, message): 21 | super(InvalidCacheLogEntry, self).__init__(message) 22 | 23 | 24 | ######################################## 25 | 26 | class AmurricaError(HalotoolsError): 27 | """ Built-in mechanism to prevent ridiculous spelling-choice contributions to the repository. 28 | """ 29 | 30 | def __init__(self, basename, linenum, correct_spelling, offending_spelling): 31 | message = ("\nOn line number "+str(linenum)+" of the source code file ``"+basename+"``,\n" 32 | "you have incorrectly spelled the word ``"+correct_spelling+"`` " 33 | "as ``"+offending_spelling+"``.\n" 34 | "Contributions to Halotools that support King George are strictly forbidden.\n") 35 | super(AmurricaError, self).__init__(message) 36 | 37 | 38 | class SpellingError(HalotoolsError): 39 | """ Built-in mechanism to common misspellings contributed by certain repo contributors 40 | who need not be named. 41 | """ 42 | 43 | def __init__(self, basename, linenum, correct_spelling, offending_spelling): 44 | message = ("\nOn line number "+str(linenum)+" of the source code file ``"+basename+"``,\n" 45 | "you have incorrectly spelled the word ``"+correct_spelling+"`` " 46 | "as ``"+offending_spelling+"``.\n") 47 | super(SpellingError, self).__init__(message) 48 | -------------------------------------------------------------------------------- /halotools/data/README.rst: -------------------------------------------------------------------------------- 1 | Data directory 2 | ============== 3 | 4 | This directory contains small data files included with Halotools. 5 | Large files such as halo catalogs should be 6 | downloaded and stored in the Halotools cache directory. 7 | -------------------------------------------------------------------------------- /halotools/empirical_models/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | from __future__ import (absolute_import, division, print_function, 3 | unicode_literals) 4 | 5 | 6 | from .model_defaults import * 7 | from .model_helpers import * 8 | 9 | from .factories import * 10 | from .assembias_models import * 11 | from .phase_space_models import * 12 | from .component_model_templates import * 13 | from .sfr_models import * 14 | from .occupation_models import * 15 | from .smhm_models import * 16 | from .composite_models import * 17 | from .abunmatch import * 18 | from .ia_models import * 19 | -------------------------------------------------------------------------------- /halotools/empirical_models/abunmatch/__init__.py: -------------------------------------------------------------------------------- 1 | from .conditional_abunmatch_bin_based import * 2 | from .noisy_percentile import * 3 | from .engines import cython_bin_free_cam_kernel 4 | from .bin_free_cam import conditional_abunmatch 5 | -------------------------------------------------------------------------------- /halotools/empirical_models/abunmatch/engines/__init__.py: -------------------------------------------------------------------------------- 1 | from .bin_free_cam_kernel import cython_bin_free_cam_kernel, get_value_at_rank 2 | -------------------------------------------------------------------------------- /halotools/empirical_models/abunmatch/engines/setup_package.py: -------------------------------------------------------------------------------- 1 | from distutils.extension import Extension 2 | import os 3 | import numpy as np 4 | 5 | PATH_TO_PKG = os.path.relpath(os.path.dirname(__file__)) 6 | SOURCES = ("bin_free_cam_kernel.pyx",) 7 | THIS_PKG_NAME = ".".join(__name__.split(".")[:-1]) 8 | 9 | 10 | def get_extensions(): 11 | 12 | names = [THIS_PKG_NAME + "." + src.replace(".pyx", "") for src in SOURCES] 13 | sources = [os.path.join(PATH_TO_PKG, srcfn) for srcfn in SOURCES] 14 | include_dirs = [np.get_include()] 15 | libraries = [] 16 | language = "c++" 17 | extra_compile_args = ["-Ofast"] 18 | 19 | extensions = [] 20 | for name, source in zip(names, sources): 21 | extensions.append( 22 | Extension( 23 | name=name, 24 | sources=[source], 25 | include_dirs=include_dirs, 26 | libraries=libraries, 27 | language=language, 28 | extra_compile_args=extra_compile_args, 29 | ) 30 | ) 31 | 32 | return extensions 33 | -------------------------------------------------------------------------------- /halotools/empirical_models/abunmatch/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/abunmatch/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/abunmatch/tests/naive_python_cam.py: -------------------------------------------------------------------------------- 1 | """ Naive python implementation of bin-free conditional abundance matching 2 | """ 3 | import numpy as np 4 | 5 | 6 | def sample2_window_indices(ix1, x_sample1, x_sample2, nwin): 7 | """ For the point x1 = x_sample1[ix1], determine the indices of 8 | the window surrounding each point in sample 2 that defines the 9 | conditional probability distribution for `ynew`. 10 | """ 11 | nhalfwin = int(nwin/2) 12 | npts2 = len(x_sample2) 13 | 14 | x1 = x_sample1[ix1] 15 | iy2 = min(np.searchsorted(x_sample2, x1), npts2-1) 16 | 17 | if iy2 <= nhalfwin: 18 | init_iy2_low, init_iy2_high = 0, nwin 19 | elif iy2 >= npts2 - nhalfwin - 1: 20 | init_iy2_low, init_iy2_high = npts2-nwin, npts2 21 | else: 22 | init_iy2_low = iy2 - nhalfwin 23 | init_iy2_high = init_iy2_low+nwin 24 | 25 | return init_iy2_low, init_iy2_high 26 | 27 | 28 | def pure_python_rank_matching(x_sample1, ranks_sample1, 29 | x_sample2, ranks_sample2, y_sample2, nwin): 30 | """ Naive algorithm for implementing bin-free conditional abundance matching 31 | for use in unit-testing. 32 | """ 33 | result = np.zeros_like(x_sample1) 34 | 35 | n1 = len(x_sample1) 36 | 37 | for i in range(n1): 38 | low, high = sample2_window_indices(i, x_sample1, x_sample2, nwin) 39 | sorted_window = np.sort(y_sample2[low:high]) 40 | rank1 = ranks_sample1[i] 41 | result[i] = sorted_window[rank1] 42 | 43 | return result 44 | -------------------------------------------------------------------------------- /halotools/empirical_models/abunmatch/tests/test_conditional_abunmatch.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | from astropy.utils import NumpyRNGContext 5 | 6 | from ..conditional_abunmatch_bin_based import conditional_abunmatch_bin_based 7 | 8 | 9 | def test_conditional_abunmatch_bin_based1(): 10 | with NumpyRNGContext(43): 11 | x = np.random.normal(loc=0, scale=0.1, size=100) 12 | y = np.linspace(10, 20, 100) 13 | model_y = conditional_abunmatch_bin_based(x, y, seed=43, npts_lookup_table=len(y)) 14 | msg = "monotonic cam does not preserve mean" 15 | assert np.allclose(model_y.mean(), y.mean(), rtol=0.1), msg 16 | 17 | 18 | def test_conditional_abunmatch_bin_based2(): 19 | with NumpyRNGContext(43): 20 | x = np.random.normal(loc=0, scale=0.1, size=100) 21 | y = np.linspace(10, 20, 100) 22 | model_y = conditional_abunmatch_bin_based(x, y, seed=43, npts_lookup_table=len(y)) 23 | idx_x_sorted = np.argsort(x) 24 | msg = "monotonic cam does not preserve correlation" 25 | high = model_y[idx_x_sorted][-50:].mean() 26 | low = model_y[idx_x_sorted][:50].mean() 27 | mean = model_y.mean() 28 | high_low_fracdiff = (high-low)/mean 29 | assert high_low_fracdiff > 0.1 30 | 31 | 32 | def test_conditional_abunmatch_bin_based3(): 33 | with NumpyRNGContext(43): 34 | x = np.random.normal(loc=0, scale=0.1, size=100) 35 | y = np.linspace(10, 20, 100) 36 | model_y = conditional_abunmatch_bin_based(x, y, sigma=0.01, seed=43, npts_lookup_table=len(y)) 37 | idx_x_sorted = np.argsort(x) 38 | msg = "low-noise cam does not preserve correlation" 39 | high = model_y[idx_x_sorted][-50:].mean() 40 | low = model_y[idx_x_sorted][:50].mean() 41 | mean = model_y.mean() 42 | high_low_fracdiff = (high-low)/mean 43 | assert high_low_fracdiff > 0.1 44 | -------------------------------------------------------------------------------- /halotools/empirical_models/abunmatch/tests/test_noisy_percentile.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | from scipy.stats import spearmanr 5 | from astropy.utils.misc import NumpyRNGContext 6 | 7 | from ..noisy_percentile import noisy_percentile 8 | 9 | 10 | __all__ = ('test_noisy_percentile1', ) 11 | 12 | 13 | fixed_seed = 43 14 | npts = int(1e5) 15 | with NumpyRNGContext(fixed_seed): 16 | u = np.random.uniform(0, 1, npts) 17 | uran = np.random.uniform(0, 1, npts) 18 | 19 | 20 | def test_noisy_percentile1(): 21 | 22 | r_desired = 0.5 23 | u2 = noisy_percentile(u, r_desired, seed=fixed_seed+1) 24 | r_achieved = spearmanr(u, u2)[0] 25 | assert np.allclose(r_desired, r_achieved, atol=0.02) 26 | 27 | 28 | def test_noisy_percentile2(): 29 | 30 | r_desired = 0.1 31 | u2 = noisy_percentile(u, r_desired, seed=fixed_seed+1) 32 | r_achieved = spearmanr(u, u2)[0] 33 | assert np.allclose(r_desired, r_achieved, atol=0.02) 34 | 35 | 36 | def test_noisy_percentile3(): 37 | 38 | r_desired = 0.99 39 | u2 = noisy_percentile(u, r_desired, random_percentile=uran) 40 | r_achieved = spearmanr(u, u2)[0] 41 | assert np.allclose(r_desired, r_achieved, atol=0.02) 42 | 43 | 44 | def test_negative_unity_noisy_percentile(): 45 | """Regression test for #939. 46 | """ 47 | r_desired = -1 48 | u2 = noisy_percentile(u, r_desired, seed=fixed_seed) 49 | assert np.allclose(u2, u[::-1]) 50 | -------------------------------------------------------------------------------- /halotools/empirical_models/abunmatch/tests/test_single_unit.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | from astropy.utils.misc import NumpyRNGContext 5 | from ..bin_free_cam import conditional_abunmatch 6 | 7 | 8 | fixed_seed = 5 9 | 10 | 11 | def test(): 12 | pass 13 | -------------------------------------------------------------------------------- /halotools/empirical_models/assembias_models/__init__.py: -------------------------------------------------------------------------------- 1 | from .heaviside_assembias import * 2 | -------------------------------------------------------------------------------- /halotools/empirical_models/assembias_models/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/assembias_models/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/component_model_templates/__init__.py: -------------------------------------------------------------------------------- 1 | from .binary_galprop_models import * 2 | from .scatter_models import * 3 | from .prim_galprop_model import PrimGalpropModel 4 | -------------------------------------------------------------------------------- /halotools/empirical_models/component_model_templates/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/component_model_templates/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/composite_models/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | This sub-package contains all the composite models 3 | that come pre-built with Halotools via the 4 | `~halotools.empirical_models.PrebuiltHodModelFactory` and 5 | `~halotools.empirical_models.PrebuiltSubhaloModelFactory` 6 | classes. 7 | """ 8 | 9 | from .hod_models import * 10 | from .smhm_models import * 11 | from .sfr_models import * 12 | -------------------------------------------------------------------------------- /halotools/empirical_models/composite_models/hod_models/__init__.py: -------------------------------------------------------------------------------- 1 | from .zheng07 import * 2 | from .cacciato09 import * 3 | from .leauthaud11 import * 4 | from .tinker13 import * 5 | from .hearin15 import * 6 | from .zu_mandelbaum15 import * 7 | from .zu_mandelbaum16 import * 8 | -------------------------------------------------------------------------------- /halotools/empirical_models/composite_models/hod_models/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/composite_models/hod_models/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/composite_models/hod_models/tests/test_tinker13.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | import pytest 5 | 6 | from ....factories import PrebuiltHodModelFactory 7 | 8 | from .....sim_manager import FakeSim 9 | 10 | 11 | __all__ = ("test_tinker13_instantiation", "test_tinker13_populate") 12 | 13 | 14 | def test_tinker13_instantiation(): 15 | """Verify that we can successfully instantiate the tinker13 model""" 16 | model = PrebuiltHodModelFactory("tinker13") 17 | 18 | model = PrebuiltHodModelFactory( 19 | "tinker13", 20 | quiescent_fraction_abscissa=[1e12, 1e13, 1e14, 1e15], 21 | quiescent_fraction_ordinates=[0.25, 0.5, 0.75, 0.9], 22 | ) 23 | 24 | 25 | def test_tinker13_populate(): 26 | """Demonstrate that Tinker13 model successfully populates, and also that 27 | the monte carlo realization has a statistically consistent quiescent fraction 28 | with the underlying model. 29 | 30 | Note that this serves as a regression test for https://github.com/astropy/halotools/issues/672. 31 | """ 32 | model = PrebuiltHodModelFactory( 33 | "tinker13", 34 | quiescent_fraction_abscissa=[1e12, 1e15], 35 | quiescent_fraction_ordinates=[0.5, 0.5], 36 | ) 37 | fake_sim = FakeSim(num_halos_per_massbin=500) 38 | model.populate_mock(fake_sim, seed=43) 39 | 40 | mask = model.mock.galaxy_table["halo_mvir"] > 1e12 41 | mask *= model.mock.galaxy_table["halo_mvir"] < 1e15 42 | mask *= model.mock.galaxy_table["gal_type"] == "centrals" 43 | cens = model.mock.galaxy_table[mask] 44 | mc_quiescent_fraction = np.mean(cens["central_sfr_designation"] == "quiescent") 45 | assert np.allclose(mc_quiescent_fraction, 0.5, rtol=0.1) 46 | -------------------------------------------------------------------------------- /halotools/empirical_models/composite_models/sfr_models/__init__.py: -------------------------------------------------------------------------------- 1 | from .smhm_binary_sfr import * 2 | -------------------------------------------------------------------------------- /halotools/empirical_models/composite_models/smhm_models/__init__.py: -------------------------------------------------------------------------------- 1 | from .behroozi10 import * 2 | -------------------------------------------------------------------------------- /halotools/empirical_models/composite_models/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/composite_models/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/factories/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | from __future__ import absolute_import, division, print_function, unicode_literals 3 | 4 | 5 | from .mock_factory_template import * 6 | from .subhalo_mock_factory import * 7 | from .hod_mock_factory import * 8 | 9 | from .model_factory_template import * 10 | from .hod_model_factory import * 11 | from .subhalo_model_factory import * 12 | from .prebuilt_model_factory import * 13 | -------------------------------------------------------------------------------- /halotools/empirical_models/factories/tests/__init__.py: -------------------------------------------------------------------------------- 1 | from .test_subhalo_model_factory import * 2 | from .test_hod_factory import * 3 | -------------------------------------------------------------------------------- /halotools/empirical_models/factories/tests/test_clf_support.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | from ..prebuilt_model_factory import HodModelFactory 5 | from ...occupation_models.occupation_model_template import OccupationComponent 6 | 7 | from ....sim_manager import FakeSim 8 | 9 | 10 | class DummyCLF(OccupationComponent): 11 | """ Bare bones class used to verify that HodMockFactory supports CLF-style models. 12 | 13 | This implementation can be used as a baseline pattern to match 14 | for users writing their own CLF-style models. 15 | """ 16 | 17 | def __init__(self, gal_type, threshold, upper_occupation_bound, prim_haloprop_key): 18 | 19 | super(DummyCLF, self).__init__(gal_type=gal_type, threshold=threshold, 20 | upper_occupation_bound=upper_occupation_bound, 21 | prim_haloprop_key=prim_haloprop_key) 22 | 23 | self._mock_generation_calling_sequence = ['mc_occupation', 'mc_luminosity'] 24 | self._galprop_dtypes_to_allocate = np.dtype( 25 | [('luminosity', 'f4'), ('halo_num_'+gal_type, 'i4')]) 26 | 27 | def mean_occupation(self, **kwargs): 28 | mass = kwargs['table'][self.prim_haloprop_key] 29 | return np.zeros_like(mass) + 0.05 30 | 31 | def mc_luminosity(self, **kwargs): 32 | table = kwargs['table'] 33 | table['luminosity'][:] = np.linspace(0, 1, len(table)) 34 | 35 | 36 | def test_clf_support(): 37 | """ Regression test verifying that HodMockFactory supports CLF-style models. 38 | 39 | In particular, the test ensures that sub-classes of OccupationComponent 40 | can assign additional galaxy properties besides number of galaxies. 41 | """ 42 | dummy_model_dict = {'centrals_occupation': DummyCLF('centrals', -19, 1., 'halo_mvir')} 43 | model = HodModelFactory(**dummy_model_dict) 44 | 45 | # Ensure that the additional galaxy property defined by the component model 46 | # makes it into the _galprop_dtypes_to_allocate of the composite model 47 | assert 'luminosity' in model._galprop_dtypes_to_allocate.names 48 | 49 | # Ensure that we can populate a mock 50 | # and that the luminosity assignment occurs as expected 51 | halocat = FakeSim() 52 | model.populate_mock(halocat) 53 | assert np.allclose(model.mock.galaxy_table['luminosity'], 54 | np.linspace(0, 1, len(model.mock.galaxy_table))) 55 | -------------------------------------------------------------------------------- /halotools/empirical_models/factories/tests/test_mock_helpers.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | import numpy as np 6 | import pytest 7 | from astropy.table import Table 8 | 9 | from ..mock_helpers import infer_mask_from_kwargs 10 | from ....custom_exceptions import HalotoolsError 11 | 12 | __all__ = ('test_infer_mask_from_kwargs_consistency', ) 13 | 14 | 15 | def test_infer_mask_from_kwargs_consistency(): 16 | x = np.arange(10) 17 | t = Table({'x': x}) 18 | mask1 = infer_mask_from_kwargs(t, x=4) 19 | 20 | def f(t): 21 | return t['x'] == 4 22 | 23 | mask2 = infer_mask_from_kwargs(t, mask_function=f) 24 | assert np.all(mask1 == mask2) 25 | 26 | 27 | def test_infer_trivial_mask_from_kwargs(): 28 | x = np.arange(10) 29 | t = Table({'x': x}) 30 | mask = infer_mask_from_kwargs(t) 31 | assert len(t) == len(t[mask]) 32 | 33 | 34 | def test_too_many_args(): 35 | x = np.arange(10) 36 | t = Table({'x': x, 'y': x}) 37 | with pytest.raises(HalotoolsError) as err: 38 | mask = infer_mask_from_kwargs(t, x=4, y=5) 39 | substr = "Only a single mask at a time is permitted " 40 | assert substr in err.value.args[0] 41 | -------------------------------------------------------------------------------- /halotools/empirical_models/factories/tests/test_prebuilt_hod_model_factory.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import absolute_import, division, print_function 4 | 5 | import numpy as np 6 | import pytest 7 | from pathlib import Path 8 | 9 | from ...factories import PrebuiltHodModelFactory 10 | 11 | from ....sim_manager import FakeSim 12 | 13 | 14 | __all__ = ("test_fake_mock_population", "test_fake_mock_observations1") 15 | 16 | 17 | # Determine whether the machine is mine 18 | # This will be used to select tests whose 19 | # returned values depend on the configuration 20 | # of my personal cache directory files 21 | aph_home = "/Users/aphearin" 22 | detected_home = Path.home() 23 | if aph_home == detected_home: 24 | APH_MACHINE = True 25 | else: 26 | APH_MACHINE = False 27 | 28 | 29 | @pytest.mark.skipif("not APH_MACHINE") 30 | def test_fake_mock_population(): 31 | halocat = FakeSim(num_halos_per_massbin=25) 32 | for modelname in PrebuiltHodModelFactory.prebuilt_model_nickname_list: 33 | model = PrebuiltHodModelFactory(modelname) 34 | model.populate_mock(halocat) 35 | model.populate_mock(halocat) 36 | 37 | 38 | @pytest.mark.skipif("not APH_MACHINE") 39 | def test_fake_mock_observations1(): 40 | model = PrebuiltHodModelFactory("zu_mandelbaum16") 41 | result = model.compute_average_galaxy_clustering(num_iterations=1, simname="fake") 42 | 43 | result = model.compute_average_galaxy_clustering( 44 | num_iterations=1, 45 | simname="fake", 46 | summary_statistic="mean", 47 | gal_type="centrals", 48 | include_crosscorr=True, 49 | rbins=np.array((0.1, 0.2, 0.3)), 50 | redshift=0, 51 | halo_finder="rockstar", 52 | ) 53 | -------------------------------------------------------------------------------- /halotools/empirical_models/ia_models/README.md: -------------------------------------------------------------------------------- 1 | # Intrinsic Alignment Models 2 | 3 | This directory contains classes and functions for modelling the intrinsic alignment(s) of galaxies. 4 | 5 | 6 | ## Empirical IA Models 7 | 8 | The code necessary to build empirical models for IA are located in the following files: 9 | 10 | * `ia_model_componenets.py` 11 | 12 | The alignment models in `ia_model_componenets.py` use an implemntation of the Watson distribution available [here](https://github.com/duncandc/watson_dist), which must be in your `PYTHONPATH`. 13 | 14 | A notebook demonstrating of the IA model components is in the [notebooks](../../notebooks/) dirctory. 15 | 16 | 17 | ## Auxiliary Models 18 | 19 | In addition to models for galaxy-halo alignments, this direcory contains models for the number and position of galaxies to assist in examining various alignment effects. These include: 20 | 21 | * `nfw_phase_space.py` 22 | * `occupation_models.py` 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /halotools/empirical_models/ia_models/__init__.py: -------------------------------------------------------------------------------- 1 | from .ia_model_components import * 2 | from .ia_strength_models import * 3 | from .watson_distribution import DimrothWatson 4 | -------------------------------------------------------------------------------- /halotools/empirical_models/ia_models/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/ia_models/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/occupation_models/__init__.py: -------------------------------------------------------------------------------- 1 | from .occupation_model_template import * 2 | from .zheng07_components import * 3 | from .leauthaud11_components import * 4 | from .cacciato09_components import * 5 | from .tinker13_components import * 6 | from .zu_mandelbaum15_components import * 7 | from .negative_binomial_sats import * 8 | -------------------------------------------------------------------------------- /halotools/empirical_models/occupation_models/engines/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | from .cacciato09_sats_mc_prim_galprop_engine import cacciato09_sats_mc_prim_galprop_engine 6 | 7 | __all__ = ('cacciato09_sats_mc_prim_galprop_engine', ) 8 | -------------------------------------------------------------------------------- /halotools/empirical_models/occupation_models/engines/setup_package.py: -------------------------------------------------------------------------------- 1 | from distutils.extension import Extension 2 | import os 3 | import numpy as np 4 | 5 | PATH_TO_PKG = os.path.relpath(os.path.dirname(__file__)) 6 | SOURCES = ("cacciato09_sats_mc_prim_galprop_engine.pyx",) 7 | THIS_PKG_NAME = ".".join(__name__.split(".")[:-1]) 8 | 9 | 10 | def get_extensions(): 11 | 12 | names = [THIS_PKG_NAME + "." + src.replace(".pyx", "") for src in SOURCES] 13 | sources = [os.path.join(PATH_TO_PKG, srcfn) for srcfn in SOURCES] 14 | include_dirs = [np.get_include()] 15 | libraries = [] 16 | language = "c++" 17 | extra_compile_args = ["-Ofast"] 18 | 19 | extensions = [] 20 | for name, source in zip(names, sources): 21 | extensions.append( 22 | Extension( 23 | name=name, 24 | sources=[source], 25 | include_dirs=include_dirs, 26 | libraries=libraries, 27 | language=language, 28 | extra_compile_args=extra_compile_args, 29 | ) 30 | ) 31 | 32 | return extensions 33 | -------------------------------------------------------------------------------- /halotools/empirical_models/occupation_models/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/occupation_models/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/__init__.py: -------------------------------------------------------------------------------- 1 | from .subhalo_based_models import * 2 | from .analytic_models import * 3 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/__init__.py: -------------------------------------------------------------------------------- 1 | from .centrals import * 2 | from .satellites import * 3 | from .halo_boundary_functions import * 4 | from .monte_carlo_helpers import MonteCarloGalProf 5 | from .profile_model_template import AnalyticDensityProf 6 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/centrals/__init__.py: -------------------------------------------------------------------------------- 1 | from .trivial_phase_space import TrivialPhaseSpace 2 | from .trivial_profile import TrivialProfile 3 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/centrals/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/phase_space_models/analytic_models/centrals/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/centrals/tests/test_trivial_phase_space.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | from ..trivial_phase_space import TrivialPhaseSpace 6 | 7 | __all__ = ('test_trivial_phase_space', ) 8 | 9 | 10 | def test_trivial_phase_space(): 11 | model = TrivialPhaseSpace() 12 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/centrals/tests/test_trivial_profile.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | import numpy as np 6 | from astropy.cosmology import WMAP9 7 | 8 | from ..trivial_profile import TrivialProfile 9 | 10 | from ..... import model_defaults 11 | 12 | from ......sim_manager import sim_defaults 13 | 14 | 15 | __all__ = ('test_enclosed_mass1', 'test_enclosed_mass2') 16 | 17 | 18 | def test_enclosed_mass1(): 19 | """ 20 | """ 21 | model = TrivialProfile() 22 | m = model.enclosed_mass(0.01, 1e12) 23 | assert np.all(m == 1e12) 24 | 25 | 26 | def test_enclosed_mass2(): 27 | """ 28 | """ 29 | model = TrivialProfile() 30 | m = model.enclosed_mass([0.1, 0.2], 1e12) 31 | assert np.all(m == 1e12) 32 | 33 | 34 | def test_dimensionless_mass_density1(): 35 | model = TrivialProfile() 36 | d = model.dimensionless_mass_density(0.1, 1e12) 37 | 38 | 39 | def test_dimensionless_mass_density2(): 40 | model = TrivialProfile() 41 | d = model.dimensionless_mass_density([0.1, 0.2], 1e12) 42 | 43 | 44 | def test_instance_attrs(): 45 | """ Require that all model variants have ``cosmology``, ``redshift`` and ``mdef`` attributes. 46 | """ 47 | default_model = TrivialProfile() 48 | wmap9_model = TrivialProfile(cosmology=WMAP9) 49 | m200_model = TrivialProfile(mdef='200m') 50 | assert default_model.cosmology == sim_defaults.default_cosmology 51 | assert m200_model.cosmology == sim_defaults.default_cosmology 52 | assert wmap9_model.cosmology == WMAP9 53 | 54 | assert default_model.redshift == sim_defaults.default_redshift 55 | assert m200_model.redshift == sim_defaults.default_redshift 56 | assert wmap9_model.redshift == sim_defaults.default_redshift 57 | 58 | assert default_model.mdef == model_defaults.halo_mass_definition 59 | assert m200_model.mdef == '200m' 60 | assert wmap9_model.mdef == model_defaults.halo_mass_definition 61 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/__init__.py: -------------------------------------------------------------------------------- 1 | from .nfw import * 2 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/__init__.py: -------------------------------------------------------------------------------- 1 | from .nfw_profile import NFWProfile 2 | from .nfw_phase_space import NFWPhaseSpace 3 | from .biased_nfw_phase_space import BiasedNFWPhaseSpace 4 | from .sfr_biased_nfw_phase_space import SFRBiasedNFWPhaseSpace 5 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/conc_mass/__init__.py: -------------------------------------------------------------------------------- 1 | from .dutton_maccio14 import dutton_maccio14 2 | from .direct_from_halo_catalog import direct_from_halo_catalog 3 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/conc_mass/direct_from_halo_catalog.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import division, print_function, absolute_import, unicode_literals 4 | 5 | __all__ = ("direct_from_halo_catalog",) 6 | 7 | 8 | def direct_from_halo_catalog(**kwargs): 9 | """ 10 | Function returns the concentrations that are already present 11 | in an input halo catalog. 12 | 13 | Parameters 14 | ---------- 15 | table : object 16 | `~astropy.table.Table` storing halo catalog. 17 | 18 | concentration_key : string 19 | Name of the table column storing the concentration 20 | 21 | Returns 22 | ------- 23 | concentration : array_like 24 | Concentrations of the input halos. 25 | """ 26 | try: 27 | table = kwargs["table"] 28 | concentration_key = kwargs["concentration_key"] 29 | except KeyError: 30 | msg = ( 31 | "The ``direct_from_halo_catalog`` function accepts two keyword arguments:\n" 32 | "``table`` and ``concentration_key``" 33 | ) 34 | raise KeyError(msg) 35 | 36 | try: 37 | concentration = table[concentration_key] 38 | except: 39 | msg = ( 40 | "The ``{0}`` key does not appear in the input halo catalog.\n" 41 | "However, you have selected the ``direct_from_halo_catalog`` option \n" 42 | "to model the concentration-mass relation.\n" 43 | "The available keys are:\n\n{1}\n" 44 | ) 45 | raise KeyError(msg.format(concentration_key, list(table.keys()))) 46 | 47 | return concentration 48 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/conc_mass/dutton_maccio14.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import division, print_function, absolute_import, unicode_literals 4 | 5 | import numpy as np 6 | 7 | 8 | __all__ = ("dutton_maccio14",) 9 | 10 | 11 | def dutton_maccio14(mass, redshift): 12 | r"""Power-law fit to the concentration-mass relation from 13 | Equations 12 & 13 of Dutton and Maccio 2014, arXiv:1402.7073. 14 | 15 | :math:`\log_{10}c(M, z) \equiv a + b\log_{10}(M / M_{0}),` 16 | 17 | where :math:`a, b, M_{0}` are defined as follows: 18 | 19 | :math:`a = 0.537 + (1.025 - 0.537)\exp(-0.718z^{1.08})` 20 | 21 | :math:`b = -0.097 + 0.024z` 22 | 23 | :math:`M_{0} = 10^{12}M_{\odot}/h` 24 | 25 | Parameters 26 | ---------- 27 | mass : array_like 28 | 29 | redshift : array_like 30 | 31 | Returns 32 | ------- 33 | concentration : array_like 34 | 35 | Notes 36 | ----- 37 | This model is based on virial mass definition and 38 | was only calibrated for the Planck 1-year cosmology. 39 | 40 | Examples 41 | -------- 42 | >>> c = dutton_maccio14(1e12, 0) 43 | >>> c = dutton_maccio14(np.logspace(11, 15, 100), 0) 44 | """ 45 | 46 | a = 0.537 + (1.025 - 0.537) * np.exp(-0.718 * redshift**1.08) 47 | b = -0.097 + 0.024 * redshift 48 | m0 = 1.0e12 49 | 50 | logc = a + b * np.log10(mass / m0) 51 | return 10**logc 52 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/conc_mass/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/conc_mass/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/conc_mass/tests/test_conc_mass.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | import numpy as np 6 | from astropy.table import Table 7 | from astropy.utils.misc import NumpyRNGContext 8 | import pytest 9 | 10 | from ..dutton_maccio14 import dutton_maccio14 11 | from ..direct_from_halo_catalog import direct_from_halo_catalog 12 | 13 | __all__ = ('test_dutton_maccio14', 'test_direct_from_halo_catalog1') 14 | 15 | fixed_seed = 43 16 | 17 | 18 | def test_dutton_maccio14(): 19 | r""" 20 | """ 21 | 22 | Npts = int(1e3) 23 | mass = np.logspace(10, 15, Npts) 24 | z = 0. 25 | conc = dutton_maccio14(mass, z) 26 | assert np.all(conc > 1) 27 | assert np.all(conc < 100) 28 | assert np.all(np.diff(conc) < 0) 29 | 30 | 31 | def test_direct_from_halo_catalog1(): 32 | r""" 33 | """ 34 | Npts = int(10) 35 | mass = np.logspace(10, 15, Npts) 36 | with NumpyRNGContext(fixed_seed): 37 | conc = np.random.uniform(0, 100, Npts) 38 | t = Table({'conc': conc, 'halo_mvir': mass}) 39 | conc_result = direct_from_halo_catalog(table=t, concentration_key='conc') 40 | assert np.allclose(conc, conc_result) 41 | 42 | 43 | def test_direct_from_halo_catalog2(): 44 | r""" 45 | """ 46 | Npts = int(10) 47 | mass = np.logspace(10, 15, Npts) 48 | with NumpyRNGContext(fixed_seed): 49 | conc = np.random.uniform(0, 100, Npts) 50 | t = Table({'conc': conc, 'halo_mvir': mass}) 51 | 52 | with pytest.raises(KeyError) as err: 53 | conc_result = direct_from_halo_catalog(table=t, concentration_key='Air Bud') 54 | substr = "The ``Air Bud`` key does not appear in the input halo catalog." 55 | assert substr in err.value.args[0] 56 | 57 | 58 | def test_direct_from_halo_catalog3(): 59 | r""" 60 | """ 61 | Npts = int(10) 62 | mass = np.logspace(10, 15, Npts) 63 | with NumpyRNGContext(fixed_seed): 64 | conc = np.random.uniform(0, 100, Npts) 65 | t = Table({'conc': conc, 'halo_mvir': mass}) 66 | 67 | with pytest.raises(KeyError) as err: 68 | conc_result = direct_from_halo_catalog(table=t) 69 | substr = "The ``direct_from_halo_catalog`` function accepts two keyword arguments" 70 | assert substr in err.value.args[0] 71 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/kernels/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from .mass_profile import cumulative_mass_PDF as nfw_cumulative_mass_PDF 4 | from .mass_profile import dimensionless_mass_density as nfw_dimensionless_mass_density 5 | from .unbiased_isotropic_velocity import ( 6 | dimensionless_radial_velocity_dispersion as unbiased_dimless_vrad_disp, 7 | ) 8 | from .mc_generate_nfw_radial_positions import ( 9 | mc_generate_nfw_radial_positions as standalone_mc_generate_nfw_radial_positions, 10 | ) 11 | 12 | from .biased_isotropic_velocity import ( 13 | dimensionless_radial_velocity_dispersion as biased_dimless_vrad_disp, 14 | ) 15 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/kernels/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/kernels/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/kernels/tests/data/README.md: -------------------------------------------------------------------------------- 1 | These data store the result of calculations performed by Frank van den Bosch using independently written Fortran code. One file pertains to c=5 NFW halos, the other c=10. The header provided by Frank appears below. 2 | 3 | col 1: integer (ignore) 4 | 5 | col 2: r/rvir 6 | 7 | col 3: sigma_r(r) / Vvir 8 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/kernels/tests/setup_package.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/kernels/tests/test_biased_isotropic_velocity.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | from astropy.utils.data import get_pkg_data_filename 5 | 6 | from ..unbiased_isotropic_velocity import dimensionless_radial_velocity_dispersion as unbiased_dimless_vel_rad_disp 7 | from ..biased_isotropic_velocity import dimensionless_radial_velocity_dispersion as biased_dimless_vel_rad_disp 8 | 9 | 10 | __all__ = ('test_unbiased_vel_rad_disp1', ) 11 | 12 | 13 | def test_unbiased_vel_rad_disp1(): 14 | scaled_radius = np.logspace(-2, 0, 25) 15 | halo_conc = 5 16 | unbiased_result = unbiased_dimless_vel_rad_disp(scaled_radius, halo_conc) 17 | 18 | gal_conc = halo_conc 19 | biased_result = biased_dimless_vel_rad_disp(scaled_radius, halo_conc, gal_conc) 20 | assert np.allclose(unbiased_result, biased_result) 21 | 22 | 23 | def test_unbiased_vel_rad_disp2(): 24 | scaled_radius = np.logspace(-2, 0, 25) 25 | halo_conc = 5 26 | unbiased_result = unbiased_dimless_vel_rad_disp(scaled_radius, halo_conc) 27 | 28 | gal_conc = 2*halo_conc 29 | biased_result = biased_dimless_vel_rad_disp(scaled_radius, halo_conc, gal_conc) 30 | assert not np.allclose(unbiased_result, biased_result) 31 | 32 | 33 | def test_unbiased_vel_rad_disp_external_ch10_cg5(): 34 | halo_conc, gal_conc = 10, 5 35 | fname = get_pkg_data_filename('data/van_den_bosch_nfw_vr_disp_ch10_cg5.dat') 36 | x = np.loadtxt(fname) 37 | frank_r_by_Rvir = x[:, 1] 38 | frank_dimless_sigma_rad = x[:, 2] 39 | aph_result = biased_dimless_vel_rad_disp(frank_r_by_Rvir, halo_conc, gal_conc) 40 | assert np.allclose(aph_result, frank_dimless_sigma_rad, rtol=1e-3) 41 | 42 | 43 | def test_unbiased_vel_rad_disp_external_ch5_cg10(): 44 | halo_conc, gal_conc = 5, 10 45 | fname = get_pkg_data_filename('data/van_den_bosch_nfw_vr_disp_ch5_cg10.dat') 46 | x = np.loadtxt(fname) 47 | frank_r_by_Rvir = x[:, 1] 48 | frank_dimless_sigma_rad = x[:, 2] 49 | aph_result = biased_dimless_vel_rad_disp(frank_r_by_Rvir, halo_conc, gal_conc) 50 | assert np.allclose(aph_result, frank_dimless_sigma_rad, rtol=1e-3) 51 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/kernels/tests/test_mc_generate_nfw_radial_positions.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import pytest 4 | 5 | from ..mc_generate_nfw_radial_positions import mc_generate_nfw_radial_positions 6 | from ........custom_exceptions import HalotoolsError 7 | 8 | __all__ = ('test_mc_generate_nfw_radial_positions1', ) 9 | 10 | 11 | def test_mc_generate_nfw_radial_positions1(): 12 | with pytest.raises(HalotoolsError) as err: 13 | __ = mc_generate_nfw_radial_positions(num_pts=10) 14 | substr = ("If keyword argument ``halo_radius`` is unspecified, " 15 | "argument ``halo_mass`` must be specified.") 16 | assert substr in err.value.args[0] 17 | 18 | 19 | def test_mc_generate_nfw_radial_positions2(): 20 | 21 | with pytest.raises(HalotoolsError) as err: 22 | __ = mc_generate_nfw_radial_positions(num_pts=10, halo_mass=(2, 3)) 23 | substr = ("Input ``halo_mass`` must be a float") 24 | assert substr in err.value.args[0] 25 | 26 | 27 | def test_mc_generate_nfw_radial_positions3(): 28 | 29 | with pytest.raises(HalotoolsError) as err: 30 | __ = mc_generate_nfw_radial_positions(num_pts=10, halo_radius=(2, 3)) 31 | substr = ("Input ``halo_radius`` must be a float") 32 | assert substr in err.value.args[0] 33 | 34 | 35 | def test_mc_generate_nfw_radial_positions4(): 36 | 37 | with pytest.raises(HalotoolsError) as err: 38 | __ = mc_generate_nfw_radial_positions(num_pts=10, halo_radius=0.5, conc=(2, 3)) 39 | substr = ("Input ``conc`` must be a float") 40 | assert substr in err.value.args[0] 41 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/kernels/tests/test_unbiased_isotropic_velocity.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | from astropy.utils.data import get_pkg_data_filename 5 | 6 | from ..unbiased_isotropic_velocity import dimensionless_radial_velocity_dispersion as unbiased_dimless_vel_rad_disp 7 | 8 | 9 | __all__ = ('test_unbiased_vel_rad_disp1', ) 10 | 11 | 12 | def test_unbiased_vel_rad_disp1(): 13 | scaled_radius = np.logspace(-2, 0, 25) 14 | conc = 5 15 | result = unbiased_dimless_vel_rad_disp(scaled_radius, conc) 16 | 17 | 18 | def test_unbiased_vel_rad_disp_external_c5(): 19 | fname = get_pkg_data_filename('data/van_den_bosch_nfw_vr_disp_c5.dat') 20 | x = np.loadtxt(fname) 21 | frank_r_by_Rvir = x[:, 1] 22 | frank_dimless_sigma_rad = x[:, 2] 23 | aph_dimless_sigma_rad = unbiased_dimless_vel_rad_disp(frank_r_by_Rvir, 5) 24 | assert np.allclose(frank_dimless_sigma_rad, aph_dimless_sigma_rad, rtol=1e-3) 25 | 26 | 27 | def test_unbiased_vel_rad_disp_external_c10(): 28 | fname = get_pkg_data_filename('data/van_den_bosch_nfw_vr_disp_c10.dat') 29 | x = np.loadtxt(fname) 30 | frank_r_by_Rvir = x[:, 1] 31 | frank_dimless_sigma_rad = x[:, 2] 32 | aph_dimless_sigma_rad = unbiased_dimless_vel_rad_disp(frank_r_by_Rvir, 10) 33 | assert np.allclose(frank_dimless_sigma_rad, aph_dimless_sigma_rad, rtol=1e-3) 34 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/kernels/unbiased_isotropic_velocity.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | from scipy.integrate import quad as quad_integration 5 | 6 | from .mass_profile import _g_integral 7 | 8 | 9 | __all__ = ("dimensionless_radial_velocity_dispersion",) 10 | 11 | 12 | def _jeans_integrand_term1(y): 13 | r""" """ 14 | return np.log(1 + y) / (y**3 * (1 + y) ** 2) 15 | 16 | 17 | def _jeans_integrand_term2(y): 18 | r""" """ 19 | return 1 / (y**2 * (1 + y) ** 3) 20 | 21 | 22 | def dimensionless_radial_velocity_dispersion(scaled_radius, *conc): 23 | r""" 24 | Analytical solution to the isotropic jeans equation for an NFW potential, 25 | rendered dimensionless via scaling by the virial velocity. 26 | 27 | :math:`\tilde{\sigma}^{2}_{r}(\tilde{r})\equiv\sigma^{2}_{r}(\tilde{r})/V_{\rm vir}^{2} = \frac{c^{2}\tilde{r}(1 + c\tilde{r})^{2}}{g(c)}\int_{c\tilde{r}}^{\infty}{\rm d}y\frac{g(y)}{y^{3}(1 + y)^{2}}` 28 | 29 | See :ref:`nfw_jeans_velocity_profile_derivations` for derivations and implementation details. 30 | 31 | Parameters 32 | ----------- 33 | scaled_radius : array_like 34 | Length-Ngals numpy array storing the halo-centric distance 35 | *r* scaled by the halo boundary :math:`R_{\Delta}`, so that 36 | :math:`0 <= \tilde{r} \equiv r/R_{\Delta} <= 1`. 37 | 38 | conc : float 39 | Concentration of the halo. 40 | 41 | Returns 42 | ------- 43 | result : array_like 44 | Radial velocity dispersion profile scaled by the virial velocity. 45 | The returned result has the same dimension as the input ``scaled_radius``. 46 | """ 47 | x = np.atleast_1d(scaled_radius).astype(np.float64) 48 | result = np.zeros_like(x) 49 | 50 | prefactor = conc * (conc * x) * (1.0 + conc * x) ** 2 / _g_integral(conc) 51 | 52 | lower_limit = conc * x 53 | upper_limit = float("inf") 54 | for i in range(len(x)): 55 | term1, _ = quad_integration( 56 | _jeans_integrand_term1, lower_limit[i], upper_limit, epsrel=1e-5 57 | ) 58 | term2, _ = quad_integration( 59 | _jeans_integrand_term2, lower_limit[i], upper_limit, epsrel=1e-5 60 | ) 61 | result[i] = term1 - term2 62 | 63 | return np.sqrt(result * prefactor) 64 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/test_biased_nfw/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/test_biased_nfw/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/test_biased_nfw/test_biased_nfw_consistency.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | import numpy as np 6 | 7 | from ...biased_nfw_phase_space import BiasedNFWPhaseSpace 8 | from ...nfw_phase_space import NFWPhaseSpace 9 | 10 | __all__ = ('test_biased_unbiased_agreement1', ) 11 | 12 | 13 | conc_bins = np.linspace(2, 30, 10) 14 | gal_bias_bins = np.linspace(0.1, 20, 5) 15 | gal_bias_bins = np.insert(gal_bias_bins, np.searchsorted(gal_bias_bins, 1), 1) 16 | 17 | 18 | def test_biased_unbiased_agreement1(): 19 | """ 20 | """ 21 | nfw = NFWPhaseSpace() 22 | biased_nfw = BiasedNFWPhaseSpace() 23 | 24 | rbins = np.logspace(-2, 0, 100) 25 | c, b = 5, 1 26 | dimless_vrad1 = nfw.dimensionless_radial_velocity_dispersion(rbins, c) 27 | dimless_vrad2 = biased_nfw.dimensionless_radial_velocity_dispersion(rbins, c, b) 28 | assert np.allclose(dimless_vrad1, dimless_vrad2) 29 | 30 | 31 | def test_biased_unbiased_disagreement1(): 32 | """ 33 | """ 34 | nfw = NFWPhaseSpace() 35 | biased_nfw = BiasedNFWPhaseSpace() 36 | 37 | rbins = np.logspace(-2, 0, 100) 38 | c, b = 5, 2 39 | dimless_vrad1 = nfw.dimensionless_radial_velocity_dispersion(rbins, c) 40 | dimless_vrad2 = biased_nfw.dimensionless_radial_velocity_dispersion(rbins, c, b) 41 | assert not np.allclose(dimless_vrad1, dimless_vrad2) 42 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/test_conc_mass_inheritance/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/test_conc_mass_inheritance/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/test_nfw_phase_space/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/test_nfw_phase_space/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/test_nfw_phase_space/test_nfw_phase_space.py: -------------------------------------------------------------------------------- 1 | """ Explicit test that Monte Carlo realizations of NFWPhaseSpace 2 | do indeed trace an NFW profile. 3 | """ 4 | import numpy as np 5 | import pytest 6 | 7 | from ..test_nfw_profile import analytic_nfw_density_outer_shell_normalization 8 | from ..test_nfw_profile import monte_carlo_density_outer_shell_normalization 9 | 10 | from ...nfw_phase_space import NFWPhaseSpace 11 | 12 | __all__ = ['test_mc_dimensionless_radial_distance'] 13 | 14 | fixed_seed = 43 15 | 16 | 17 | @pytest.mark.installation_test 18 | def test_mc_dimensionless_radial_distance(): 19 | r""" Method used to test `~halotools.empirical_models.NFWPhaseSpace._mc_dimensionless_radial_distance`. 20 | 21 | Method uses the `~halotools.empirical_models.analytic_nfw_density_outer_shell_normalization` function 22 | and the `~halotools.empirical_models.monte_carlo_density_outer_shell_normalization` function 23 | to verify that the points returned by `~halotools.empirical_models.NFWPhaseSpace._mc_dimensionless_radial_distance` 24 | do indeed trace an NFW profile. 25 | 26 | """ 27 | nfw = NFWPhaseSpace() 28 | 29 | Npts = int(5e4) 30 | c5 = np.zeros(Npts) + 5 31 | c10 = np.zeros(Npts) + 10 32 | c15 = np.zeros(Npts) + 15 33 | 34 | r5 = nfw._mc_dimensionless_radial_distance(c5, seed=43) 35 | r10 = nfw._mc_dimensionless_radial_distance(c10, seed=43) 36 | r15 = nfw._mc_dimensionless_radial_distance(c15, seed=43) 37 | 38 | assert np.all(r15 <= 1) 39 | assert np.all(r15 >= 0) 40 | assert np.all(r10 <= 1) 41 | assert np.all(r10 >= 0) 42 | assert np.all(r5 <= 1) 43 | assert np.all(r5 >= 0) 44 | 45 | assert np.mean(r15) < np.mean(r10) 46 | assert np.mean(r10) < np.mean(r5) 47 | assert np.median(r15) < np.median(r10) 48 | assert np.median(r10) < np.median(r5) 49 | 50 | num_rbins = 15 51 | rbins = np.linspace(0.05, 1, num_rbins) 52 | for r, c in zip([r5, r10, r15], [5, 10, 15]): 53 | rbin_midpoints, monte_carlo_ratio = ( 54 | monte_carlo_density_outer_shell_normalization(rbins, r)) 55 | analytical_ratio = ( 56 | analytic_nfw_density_outer_shell_normalization(rbin_midpoints, c)) 57 | assert np.allclose(monte_carlo_ratio, analytical_ratio, 0.05) 58 | 59 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/test_nfw_phase_space/test_nfw_phase_space_initialization.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | 5 | from ...nfw_phase_space import NFWPhaseSpace 6 | 7 | 8 | __all__ = ('test_constructor1', ) 9 | 10 | fixed_seed = 43 11 | 12 | 13 | def test_constructor1(): 14 | r""" Test that composite phase space models have all the appropriate attributes. 15 | """ 16 | nfw = NFWPhaseSpace() 17 | 18 | # NFWPhaseSpace attributes 19 | assert hasattr(nfw, 'assign_phase_space') 20 | assert hasattr(nfw, '_galprop_dtypes_to_allocate') 21 | 22 | # AnalyticDensityProf attributes 23 | assert hasattr(nfw, 'circular_velocity') 24 | 25 | # NFWProfile attributes 26 | assert hasattr(nfw, 'mass_density') 27 | assert hasattr(nfw, 'halo_prof_param_keys') 28 | assert hasattr(nfw, 'gal_prof_param_keys') 29 | assert hasattr(nfw, '_mc_dimensionless_radial_distance') 30 | 31 | # concentration-mass relation 32 | assert hasattr(nfw, 'conc_NFWmodel') 33 | assert hasattr(nfw, 'conc_mass_model') 34 | 35 | 36 | def test_constructor2(): 37 | r""" Test that composite phase space models have all the appropriate attributes. 38 | """ 39 | nfw = NFWPhaseSpace(concentration_bins=np.linspace(5, 10, 3)) 40 | 41 | # MonteCarloGalProf attributes 42 | assert not hasattr(nfw, 'logradius_array') 43 | assert not hasattr(nfw, 'rad_prof_func_table') 44 | assert not hasattr(nfw, 'vel_prof_func_table') 45 | 46 | nfw.build_lookup_tables() 47 | assert hasattr(nfw, 'logradius_array') 48 | assert hasattr(nfw, 'rad_prof_func_table') 49 | assert hasattr(nfw, 'vel_prof_func_table') 50 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/test_nfw_profile/__init__.py: -------------------------------------------------------------------------------- 1 | from .test_nfw_profile import analytic_nfw_density_outer_shell_normalization 2 | from .test_nfw_profile import monte_carlo_density_outer_shell_normalization 3 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/satellites/nfw/tests/test_nfw_profile/test_colossus_consistency.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | from astropy.cosmology import Planck15 5 | from itertools import product 6 | 7 | from ...nfw_profile import NFWProfile 8 | 9 | 10 | def test_colossus_vmax_consistency_z0(): 11 | """ 12 | """ 13 | try: 14 | from colossus.cosmology import cosmology 15 | from colossus.halo.profile_nfw import NFWProfile as ColossusNFW 16 | except ImportError: 17 | return 18 | _cosmo = cosmology.setCosmology('planck15') 19 | nfw = NFWProfile(cosmology=Planck15) 20 | 21 | masses_to_check = 10**np.array((11., 12, 13, 14, 15)) 22 | conc_to_check = [5., 10., 15.] 23 | 24 | z = 0 25 | for M, c in product(masses_to_check, conc_to_check): 26 | 27 | colossus_nfw = ColossusNFW(M=M, c=c, mdef='vir', z=z) 28 | colossus_vmax, colossus_rmax = colossus_nfw.Vmax() 29 | halotools_vmax = nfw.vmax(M, c)[0] 30 | 31 | msg = ("\nM = {0:.2e}, c = {1:.1f}, z = {2:.1f}\n" 32 | "Colossus Vmax = {3:.2f}\nHalotools Vmax = {4:.2f}\n".format( 33 | M, c, z, colossus_vmax, halotools_vmax)) 34 | assert np.allclose(colossus_vmax, halotools_vmax, rtol=0.05), msg 35 | 36 | 37 | def test_colossus_vmax_consistency_z1(): 38 | """ 39 | """ 40 | try: 41 | from colossus.cosmology import cosmology 42 | from colossus.halo.profile_nfw import NFWProfile as ColossusNFW 43 | except ImportError: 44 | return 45 | _cosmo = cosmology.setCosmology('planck15') 46 | 47 | masses_to_check = 10**np.array((11., 12, 13, 14, 15)) 48 | conc_to_check = [5., 10., 15.] 49 | 50 | z = 1. 51 | nfw = NFWProfile(cosmology=Planck15, redshift=z) 52 | 53 | for M, c in product(masses_to_check, conc_to_check): 54 | 55 | colossus_nfw = ColossusNFW(M=M, c=c, mdef='vir', z=z) 56 | colossus_vmax, colossus_rmax = colossus_nfw.Vmax() 57 | halotools_vmax = nfw.vmax(M, c)[0] 58 | 59 | msg = ("\nM = {0:.2e}, c = {1:.1f}, z = {2:.1f}\n" 60 | "Colossus Vmax = {3:.2f}\nHalotools Vmax = {4:.2f}\n".format( 61 | M, c, z, colossus_vmax, halotools_vmax)) 62 | assert np.allclose(colossus_vmax, halotools_vmax, rtol=0.05), msg 63 | 64 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/analytic_models/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/phase_space_models/analytic_models/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/subhalo_based_models/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from .subhalo_selection_kernel import * 4 | from .subhalo_phase_space import SubhaloPhaseSpace, default_inherited_subhalo_props_dict 5 | -------------------------------------------------------------------------------- /halotools/empirical_models/phase_space_models/subhalo_based_models/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/phase_space_models/subhalo_based_models/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/sfr_models/__init__.py: -------------------------------------------------------------------------------- 1 | from .halo_mass_quenching import * 2 | from .zu_mandelbaum16 import * 3 | -------------------------------------------------------------------------------- /halotools/empirical_models/sfr_models/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/sfr_models/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/sfr_models/tests/test_halo_mass_quenching.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | 5 | from ..halo_mass_quenching import HaloMassInterpolQuenching 6 | 7 | __all__ = ('test_boundary_values', 'test_extrapolation', 'test_log_convention') 8 | 9 | 10 | def test_boundary_values(): 11 | 12 | model = HaloMassInterpolQuenching('halo_mvir', [1e12, 1e15], [0.25, 0.9]) 13 | mass_array = np.logspace(12, 15, 1000) 14 | quiescent_fraction = model.mean_quiescent_fraction(prim_haloprop=mass_array) 15 | assert quiescent_fraction[0] == 0.25 16 | assert quiescent_fraction[-1] == 0.9 17 | assert np.all(quiescent_fraction <= 0.9) 18 | assert np.all(quiescent_fraction >= 0.25) 19 | 20 | 21 | def test_extrapolation(): 22 | 23 | model = HaloMassInterpolQuenching('halo_mvir', [1e12, 1e15], [0.25, 0.9]) 24 | mass_array = np.logspace(10, 20, 1000) 25 | quiescent_fraction = model.mean_quiescent_fraction(prim_haloprop=mass_array) 26 | 27 | assert quiescent_fraction[0] == 0. 28 | assert quiescent_fraction[-1] == 1. 29 | assert np.all(quiescent_fraction >= 0.) 30 | assert np.all(quiescent_fraction <= 1.) 31 | 32 | 33 | def test_log_convention(): 34 | model = HaloMassInterpolQuenching('halo_mvir', [1e12, 1e15], [0.25, 0.9]) 35 | 36 | quiescent_fraction = model.mean_quiescent_fraction(prim_haloprop=1e12) 37 | assert quiescent_fraction == 0.25 38 | 39 | quiescent_fraction = model.mean_quiescent_fraction(prim_haloprop=1e15) 40 | assert quiescent_fraction == 0.9 41 | -------------------------------------------------------------------------------- /halotools/empirical_models/smhm_models/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | from __future__ import absolute_import, division, print_function, unicode_literals 3 | 4 | from .behroozi10 import * 5 | from .moster13 import * 6 | from .zu_mandelbaum15 import * 7 | -------------------------------------------------------------------------------- /halotools/empirical_models/smhm_models/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/empirical_models/smhm_models/tests/__init__.py -------------------------------------------------------------------------------- /halotools/empirical_models/smhm_models/tests/test_redshift_defensiveness.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import pytest 4 | import warnings 5 | from ...smhm_models import Behroozi10SmHm 6 | 7 | from ....sim_manager import sim_defaults 8 | from ....custom_exceptions import HalotoolsError 9 | 10 | 11 | def test_behroozi10_redshift_safety(): 12 | """ """ 13 | model = Behroozi10SmHm() 14 | 15 | with warnings.catch_warnings(record=True) as w: 16 | result0 = model.mean_log_halo_mass(11) 17 | assert "default_redshift" in str(w[-1].message) 18 | result1 = model.mean_log_halo_mass(11, redshift=4) 19 | result2 = model.mean_log_halo_mass(11, redshift=sim_defaults.default_redshift) 20 | 21 | assert result0 == result2 22 | assert result0 != result1 23 | 24 | with warnings.catch_warnings(record=True) as w: 25 | result0 = model.mean_stellar_mass(prim_haloprop=1e12) 26 | assert "default_redshift" in str(w[-1].message) 27 | result1 = model.mean_stellar_mass(prim_haloprop=1e12, redshift=4) 28 | result2 = model.mean_stellar_mass( 29 | prim_haloprop=1e12, redshift=sim_defaults.default_redshift 30 | ) 31 | assert result0 == result2 32 | assert result0 != result1 33 | 34 | model = Behroozi10SmHm(redshift=sim_defaults.default_redshift) 35 | result0 = model.mean_log_halo_mass(11) 36 | with pytest.raises(HalotoolsError): 37 | result1 = model.mean_log_halo_mass(11, redshift=4) 38 | result2 = model.mean_log_halo_mass(11, redshift=model.redshift) 39 | assert result0 == result2 40 | 41 | result0 = model.mean_stellar_mass(prim_haloprop=1e12) 42 | with pytest.raises(HalotoolsError): 43 | result1 = model.mean_stellar_mass(prim_haloprop=1e12, redshift=4) 44 | result2 = model.mean_stellar_mass(prim_haloprop=1e12, redshift=model.redshift) 45 | assert result0 == result2 46 | -------------------------------------------------------------------------------- /halotools/empirical_models/smhm_models/tests/test_zu_mandelbaum15.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import division, print_function, absolute_import, unicode_literals 4 | 5 | import numpy as np 6 | 7 | from ...smhm_models import ZuMandelbaum15SmHm 8 | 9 | 10 | __all__ = ('test_mc_scatter1', ) 11 | 12 | 13 | def test_mc_scatter1(): 14 | model = ZuMandelbaum15SmHm(redshift=0) 15 | sm = model.mc_stellar_mass(prim_haloprop=1e12) 16 | -------------------------------------------------------------------------------- /halotools/empirical_models/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | from __future__ import (absolute_import, division, print_function, 3 | unicode_literals) 4 | -------------------------------------------------------------------------------- /halotools/extern/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | """ 3 | """ 4 | -------------------------------------------------------------------------------- /halotools/mock_observables/__init__.py: -------------------------------------------------------------------------------- 1 | """ This sub-package contains the functions 2 | used to make astronomical observations on 3 | mock galaxy populations, and also analyze halo catalogs 4 | and other point data in periodic cubes. 5 | """ 6 | from __future__ import absolute_import 7 | 8 | from .group_identification import * 9 | from .mock_survey import * 10 | from .pairwise_velocities import * 11 | from .isolation_functions import * 12 | from .void_statistics import * 13 | from .catalog_analysis_helpers import * 14 | from .pair_counters import (npairs_3d, npairs_projected, npairs_xy_z, 15 | marked_npairs_3d, marked_npairs_xy_z) 16 | from .radial_profiles import * 17 | from .two_point_clustering import * 18 | from .large_scale_density import * 19 | from .counts_in_cells import * 20 | from .occupation_stats import hod_from_mock, get_haloprop_of_galaxies 21 | from .surface_density import * 22 | from .velocity_decomposition import * 23 | from .tensor_calculations import * 24 | from .ia_correlations import * 25 | -------------------------------------------------------------------------------- /halotools/mock_observables/counts_in_cells/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from .counts_in_cylinders import counts_in_cylinders 4 | -------------------------------------------------------------------------------- /halotools/mock_observables/counts_in_cells/engines/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | """ 3 | """ 4 | from __future__ import absolute_import, division, print_function, unicode_literals 5 | 6 | from .counts_in_cylinders_engine import counts_in_cylinders_engine 7 | 8 | __all__ = ('counts_in_cylinders_engine', ) 9 | -------------------------------------------------------------------------------- /halotools/mock_observables/counts_in_cells/engines/conditions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/mock_observables/counts_in_cells/engines/conditions/__init__.py -------------------------------------------------------------------------------- /halotools/mock_observables/counts_in_cells/engines/conditions/conditions.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | 3 | cimport numpy as cnp 4 | 5 | cdef class Condition: 6 | cdef bint func(self, cnp.int64_t, cnp.int64_t) 7 | 8 | cdef class AlwaysTrue(Condition): 9 | cdef bint func(self, cnp.int64_t, cnp.int64_t) 10 | 11 | cdef class MassFrac(Condition): 12 | cdef cnp.float64_t[:] mass1 13 | cdef cnp.float64_t[:] mass2 14 | cdef float fmin 15 | cdef float fmax 16 | cdef bint lower_equality 17 | cdef bint upper_equality 18 | 19 | cdef bint func(self, cnp.int64_t, cnp.int64_t) 20 | -------------------------------------------------------------------------------- /halotools/mock_observables/counts_in_cells/engines/setup_package.py: -------------------------------------------------------------------------------- 1 | from distutils.extension import Extension 2 | import os 3 | import numpy as np 4 | 5 | PATH_TO_PKG = os.path.relpath(os.path.dirname(__file__)) 6 | SOURCES = ("counts_in_cylinders_engine.pyx",) 7 | THIS_PKG_NAME = ".".join(__name__.split(".")[:-1]) 8 | 9 | 10 | def get_extensions(): 11 | 12 | names = [THIS_PKG_NAME + "." + src.replace(".pyx", "") for src in SOURCES] 13 | sources = [os.path.join(PATH_TO_PKG, srcfn) for srcfn in SOURCES] 14 | include_dirs = [np.get_include()] 15 | libraries = [] 16 | language = "c++" 17 | extra_compile_args = ["-Ofast"] 18 | 19 | extensions = [] 20 | for name, source in zip(names, sources): 21 | extensions.append( 22 | Extension( 23 | name=name, 24 | sources=[source], 25 | include_dirs=include_dirs, 26 | libraries=libraries, 27 | language=language, 28 | extra_compile_args=extra_compile_args, 29 | ) 30 | ) 31 | 32 | return extensions 33 | -------------------------------------------------------------------------------- /halotools/mock_observables/counts_in_cells/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/mock_observables/counts_in_cells/tests/__init__.py -------------------------------------------------------------------------------- /halotools/mock_observables/group_identification/__init__.py: -------------------------------------------------------------------------------- 1 | """ This subpackage contains modules that identify groups of galaxies 2 | from mock data. 3 | """ 4 | from __future__ import absolute_import 5 | 6 | from .fof_groups import FoFGroups 7 | 8 | __all__ = ('FoFGroups', ) 9 | -------------------------------------------------------------------------------- /halotools/mock_observables/group_identification/test_groups/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | from __future__ import (absolute_import, division, print_function, 3 | unicode_literals) 4 | 5 | from .test_fof_groups import * 6 | -------------------------------------------------------------------------------- /halotools/mock_observables/ia_correlations/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Package containing functions that calculate many variations on galaxy/halo alignments. 3 | """ 4 | from __future__ import absolute_import 5 | 6 | # ellipticity-ellipticity tpcf 7 | from .ee_3d import ee_3d 8 | from .ee_projected import ee_projected 9 | 10 | # ellipticity-direction tpcf 11 | from .ed_3d import ed_3d 12 | from .ed_projected import ed_projected 13 | 14 | # gravitational shear-intrinsic ellipticity tpcf 15 | from .gi_plus_3d import gi_plus_3d 16 | from .gi_plus_projected import gi_plus_projected 17 | from .gi_minus_3d import gi_minus_3d 18 | from .gi_minus_projected import gi_minus_projected 19 | 20 | # intrinsic ellipticity-intrinsic ellipticity tpcf 21 | from .ii_plus_3d import ii_plus_3d 22 | from .ii_plus_projected import ii_plus_projected 23 | from .ii_minus_3d import ii_minus_3d 24 | from .ii_minus_projected import ii_minus_projected 25 | 26 | # decomposed functions 27 | from .ee_3d_one_two_halo_decomp import ee_3d_one_two_halo_decomp 28 | from .ed_3d_one_two_halo_decomp import ed_3d_one_two_halo_decomp 29 | 30 | __all__ = ('ee_3d', 'ee_projected', 31 | 'ed_3d', 'ed_projected', 32 | 'gi_plus_3d', 'gi_plus_projected', 33 | 'gi_minus_3d', 'gi_minus_projected', 34 | 'ii_plus_3d', 'ii_plus_projected', 35 | 'ii_minus_3d', 'ii_minus_projected', 36 | 'ee_3d_one_two_halo_decomp', 'ed_3d_one_two_halo_decomp') 37 | -------------------------------------------------------------------------------- /halotools/mock_observables/ia_correlations/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/mock_observables/ia_correlations/tests/__init__.py -------------------------------------------------------------------------------- /halotools/mock_observables/isolation_functions/__init__.py: -------------------------------------------------------------------------------- 1 | """ Sub-package of `~halotools.mock_observables` providing the 2 | isolation criteria functionality. 3 | """ 4 | 5 | from .spherical_isolation import spherical_isolation 6 | from .cylindrical_isolation import cylindrical_isolation 7 | from .conditional_spherical_isolation import conditional_spherical_isolation 8 | from .conditional_cylindrical_isolation import conditional_cylindrical_isolation 9 | 10 | __all__ = ('spherical_isolation', 'cylindrical_isolation', 11 | 'conditional_spherical_isolation', 'conditional_cylindrical_isolation') 12 | -------------------------------------------------------------------------------- /halotools/mock_observables/isolation_functions/engines/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | from .spherical_isolation_engine import spherical_isolation_engine 6 | from .cylindrical_isolation_engine import cylindrical_isolation_engine 7 | from .marked_spherical_isolation_engine import marked_spherical_isolation_engine 8 | from .marked_cylindrical_isolation_engine import marked_cylindrical_isolation_engine 9 | 10 | __all__ = ('spherical_isolation_engine', 'cylindrical_isolation_engine', 11 | 'marked_spherical_isolation_engine', 'marked_cylindrical_isolation_engine') 12 | -------------------------------------------------------------------------------- /halotools/mock_observables/isolation_functions/engines/isolation_criteria_marking_functions.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | cimport numpy as cnp 3 | 4 | cdef bint trivial(cnp.float64_t* w1, cnp.float64_t* w2) 5 | cdef bint gt_cond(cnp.float64_t* w1, cnp.float64_t* w2) 6 | cdef bint lt_cond(cnp.float64_t* w1, cnp.float64_t* w2) 7 | cdef bint eq_cond(cnp.float64_t* w1, cnp.float64_t* w2) 8 | cdef bint neq_cond(cnp.float64_t* w1, cnp.float64_t* w2) 9 | cdef bint tg_cond(cnp.float64_t* w1, cnp.float64_t* w2) 10 | cdef bint lg_cond(cnp.float64_t* w1, cnp.float64_t* w2) 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /halotools/mock_observables/isolation_functions/engines/isolation_criteria_marking_functions.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | # cython: profile=False 3 | """ Module containing C implementations of the isolation functions. 4 | """ 5 | from __future__ import absolute_import, division, print_function, unicode_literals 6 | cimport numpy as np 7 | 8 | __author__ = ["Duncan Campbell", "Andrew Hearin"] 9 | __all__ = ('trivial', 'gt_cond', 'lt_cond', 'eq_cond', 'neq_cond', 'tg_cond', 'lg_cond') 10 | 11 | cdef bint trivial(cnp.float64_t* w1, cnp.float64_t* w2): 12 | """ 13 | 0 14 | """ 15 | cdef bint result = 1 16 | return result 17 | 18 | cdef bint gt_cond(cnp.float64_t* w1, cnp.float64_t* w2): 19 | """ 20 | 1 21 | """ 22 | cdef bint result 23 | result = (w1[0]>w2[0]) 24 | return result 25 | 26 | cdef bint lt_cond(cnp.float64_t* w1, cnp.float64_t* w2): 27 | """ 28 | 2 29 | """ 30 | cdef bint result 31 | result = (w1[0](w2[0]+w1[1])) 56 | return result 57 | 58 | cdef bint lg_cond(cnp.float64_t* w1, cnp.float64_t* w2): 59 | """ 60 | 6 61 | """ 62 | cdef bint result 63 | result = (w1[0]<(w2[0]+w1[1])) 64 | return result 65 | 66 | -------------------------------------------------------------------------------- /halotools/mock_observables/isolation_functions/engines/setup_package.py: -------------------------------------------------------------------------------- 1 | from distutils.extension import Extension 2 | import os 3 | import numpy as np 4 | 5 | PATH_TO_PKG = os.path.relpath(os.path.dirname(__file__)) 6 | SOURCES = ( 7 | "spherical_isolation_engine.pyx", 8 | "cylindrical_isolation_engine.pyx", 9 | "marked_spherical_isolation_engine.pyx", 10 | "marked_cylindrical_isolation_engine.pyx", 11 | "isolation_criteria_marking_functions.pyx", 12 | ) 13 | THIS_PKG_NAME = ".".join(__name__.split(".")[:-1]) 14 | 15 | 16 | def get_extensions(): 17 | 18 | names = [THIS_PKG_NAME + "." + src.replace(".pyx", "") for src in SOURCES] 19 | sources = [os.path.join(PATH_TO_PKG, srcfn) for srcfn in SOURCES] 20 | include_dirs = [np.get_include()] 21 | libraries = [] 22 | language = "c++" 23 | extra_compile_args = ["-Ofast"] 24 | 25 | extensions = [] 26 | for name, source in zip(names, sources): 27 | extensions.append( 28 | Extension( 29 | name=name, 30 | sources=[source], 31 | include_dirs=include_dirs, 32 | libraries=libraries, 33 | language=language, 34 | extra_compile_args=extra_compile_args, 35 | ) 36 | ) 37 | 38 | return extensions 39 | -------------------------------------------------------------------------------- /halotools/mock_observables/isolation_functions/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/mock_observables/isolation_functions/tests/__init__.py -------------------------------------------------------------------------------- /halotools/mock_observables/isolation_functions/tests/pure_python_isolation.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | 5 | 6 | def naive_spherical_isolation(x1arr, y1arr, z1arr, x2arr, y2arr, z2arr, 7 | rmax, xperiod, yperiod, zperiod): 8 | """ 9 | """ 10 | npts1 = len(x1arr) 11 | is_isolated = np.zeros(npts1, dtype=bool) 12 | for i, x1, y1, z1 in zip(range(npts1), x1arr, y1arr, z1arr): 13 | dx = np.abs(x2arr - x1) 14 | dy = np.abs(y2arr - y1) 15 | dz = np.abs(z2arr - z1) 16 | dx = np.where(dx > xperiod/2., xperiod - dx, dx) 17 | dy = np.where(dy > yperiod/2., yperiod - dy, dy) 18 | dz = np.where(dz > zperiod/2., zperiod - dz, dz) 19 | d = np.sqrt(dx**2 + dy**2 + dz**2) 20 | if np.any(d < rmax): 21 | is_isolated[i] = False 22 | else: 23 | is_isolated[i] = True 24 | return is_isolated 25 | 26 | 27 | def naive_cylindrical_isolation(x1arr, y1arr, z1arr, x2arr, y2arr, z2arr, 28 | rp_max, pi_max, xperiod, yperiod, zperiod): 29 | """ 30 | """ 31 | npts1 = len(x1arr) 32 | is_isolated = np.zeros(npts1, dtype=bool) 33 | for i, x1, y1, z1 in zip(range(npts1), x1arr, y1arr, z1arr): 34 | dx = np.abs(x2arr - x1) 35 | dy = np.abs(y2arr - y1) 36 | dz = np.abs(z2arr - z1) 37 | dx = np.where(dx > xperiod/2., xperiod - dx, dx) 38 | dy = np.where(dy > yperiod/2., yperiod - dy, dy) 39 | dz = np.where(dz > zperiod/2., zperiod - dz, dz) 40 | dxy = np.sqrt(dx**2 + dy**2) 41 | 42 | if np.any((dxy < rp_max) & (dz < pi_max)): 43 | is_isolated[i] = False 44 | else: 45 | is_isolated[i] = True 46 | return is_isolated 47 | -------------------------------------------------------------------------------- /halotools/mock_observables/isolation_functions/tests/test_pure_python_isolation.py: -------------------------------------------------------------------------------- 1 | """ Module providing testing for the brute force isolation functions 2 | """ 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | import numpy as np 6 | from astropy.utils.misc import NumpyRNGContext 7 | 8 | from .pure_python_isolation import naive_spherical_isolation 9 | 10 | from ...tests.cf_helpers import generate_locus_of_3d_points, generate_3d_regular_mesh 11 | 12 | __all__ = ('test_naive_spherical_isolation1', ) 13 | 14 | fixed_seed = 43 15 | 16 | 17 | def test_naive_spherical_isolation1(): 18 | npts2 = 45 19 | sample1 = generate_3d_regular_mesh(5) # 0.1, 0.3, 0.5, 0.7, 0.9 20 | npts1 = sample1.shape[0] 21 | sample2 = generate_locus_of_3d_points(npts2, xc=0.101, yc=0.3, zc=0.3) 22 | x1arr, y1arr, z1arr = sample1[:, 0], sample1[:, 1], sample1[:, 2] 23 | x2arr, y2arr, z2arr = sample2[:, 0], sample2[:, 1], sample2[:, 2] 24 | 25 | rmax = 0.02 26 | xperiod, yperiod, zperiod = 1, 1, 1 27 | result = naive_spherical_isolation(x1arr, y1arr, z1arr, x2arr, y2arr, z2arr, 28 | rmax, xperiod, yperiod, zperiod) 29 | assert result.sum() == npts1 - 1 30 | 31 | 32 | def test_naive_spherical_isolation2(): 33 | npts2 = 45 34 | sample1 = generate_3d_regular_mesh(5) # 0.1, 0.3, 0.5, 0.7, 0.9 35 | npts1 = sample1.shape[0] 36 | sample2a = generate_locus_of_3d_points(npts2, xc=0.101, yc=0.3, zc=0.3) 37 | sample2b = generate_locus_of_3d_points(npts2, xc=0.301, yc=0.3, zc=0.3) 38 | sample2c = generate_locus_of_3d_points(npts2, xc=0.501, yc=0.3, zc=0.3) 39 | sample2 = np.concatenate((sample2a, sample2b, sample2c)) 40 | x1arr, y1arr, z1arr = sample1[:, 0], sample1[:, 1], sample1[:, 2] 41 | x2arr, y2arr, z2arr = sample2[:, 0], sample2[:, 1], sample2[:, 2] 42 | 43 | rmax = 0.02 44 | xperiod, yperiod, zperiod = 1, 1, 1 45 | result = naive_spherical_isolation(x1arr, y1arr, z1arr, x2arr, y2arr, z2arr, 46 | rmax, xperiod, yperiod, zperiod) 47 | assert result.sum() == npts1 - 3 48 | -------------------------------------------------------------------------------- /halotools/mock_observables/large_scale_density/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | 4 | from .large_scale_density_spherical_volume import large_scale_density_spherical_volume 5 | from .large_scale_density_spherical_annulus import large_scale_density_spherical_annulus 6 | -------------------------------------------------------------------------------- /halotools/mock_observables/large_scale_density/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/mock_observables/large_scale_density/tests/__init__.py -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import (absolute_import, division, print_function, unicode_literals) 2 | 3 | from .rectangular_mesh import RectangularDoubleMesh 4 | from .rectangular_mesh_2d import RectangularDoubleMesh2D 5 | from .npairs_3d import npairs_3d 6 | from .npairs_projected import npairs_projected 7 | from .npairs_xy_z import npairs_xy_z 8 | from .marked_npairs_3d import marked_npairs_3d 9 | from .marked_npairs_xy_z import marked_npairs_xy_z 10 | from .npairs_jackknife_3d import npairs_jackknife_3d 11 | from .npairs_jackknife_xy_z import npairs_jackknife_xy_z 12 | from .npairs_s_mu import npairs_s_mu 13 | from .weighted_npairs_s_mu import weighted_npairs_s_mu 14 | from .npairs_per_object_3d import npairs_per_object_3d 15 | from .pairwise_distance_3d import pairwise_distance_3d 16 | from .pairwise_distance_xy_z import pairwise_distance_xy_z 17 | from .positional_marked_npairs_3d import positional_marked_npairs_3d 18 | from .positional_marked_npairs_xy_z import positional_marked_npairs_xy_z 19 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/cpairs/README.md: -------------------------------------------------------------------------------- 1 | #Brute Force Pairwise Distance Calculations 2 | 3 | author : Duncan Campbell 4 | 5 | email : duncan.campbell@yale.edu 6 | 7 | ##Summary 8 | 9 | This module provides functions for "brute force" pairwise distance calculations. 10 | 11 | "Brute force", in this case, means that the distance between all pairs is calculated. 12 | 13 | The primary purpose of these functions is to be called by higher level functions that partition samples of points, only calculating pairwise distances for necessary pairs; however, this module can also be used as a standalone module. 14 | 15 | 16 | ##Organization 17 | 18 | All the functions are written in cython in order to optimizate for speed and to make it easy to import the modules into python. Additionally, the functions are written to be as modulular as possible, decreasing the amount of code that must be repeated often. 19 | 20 | 21 | ##Description of Functions 22 | 23 | All actual distance caclualtions are done using "cdef" functions defined in "distances.pyx". All implemented distanances are 3-D cartesian distances, including radial distances (r) and projected/parallel to the line-of-sight (LOS) distances (r_perp, r_para). Currently, the LOS is defined to be the z-direction (this is sometimes referred to as the distant observer approximation). 24 | 25 | Available functions are: 26 | 27 | * pair_counting_engines : pair counts in bins 28 | * pairwise_distances : a matrix of distances between points 29 | * per_object_npairs : pair counts in bins per object 30 | 31 | There are usually two version of these functions, one assuming non-periodic distances, and another that presumes periodic boundary conditions. However, the functions that assume non-periodic distances can be used for the periodic case if the points have been shifted to account for the periodic boundaries--this is the current approach of the halotools higher level pair counting modules. 32 | 33 | ##Details 34 | ".pxd" files provide function defintions for the associated functions defined in the ".pyx" file. The ".pxd" are necessary in order to be able to import the functions into other cython modules. 35 | 36 | The "setup_package.py" script compiles the cython modules. The modules will not be importable unless they have been compiled. 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/cpairs/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | from .pairwise_distances import * 6 | from .npairs_3d_engine import npairs_3d_engine 7 | from .npairs_projected_engine import npairs_projected_engine 8 | from .npairs_xy_z_engine import npairs_xy_z_engine 9 | from .npairs_jackknife_3d_engine import npairs_jackknife_3d_engine 10 | from .npairs_s_mu_engine import npairs_s_mu_engine 11 | from .weighted_npairs_s_mu_engine import weighted_npairs_s_mu_engine 12 | from .npairs_per_object_3d_engine import npairs_per_object_3d_engine 13 | from .pairwise_distance_3d_engine import pairwise_distance_3d_engine 14 | from .pairwise_distance_xy_z_engine import pairwise_distance_xy_z_engine 15 | from .npairs_jackknife_xy_z_engine import npairs_jackknife_xy_z_engine 16 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/cpairs/distances.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | cimport numpy as cnp 3 | 4 | cdef double periodic_square_distance( 5 | cnp.float64_t x1, cnp.float64_t y1, cnp.float64_t z1, 6 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t z2, 7 | cnp.float64_t* period) 8 | 9 | cdef double square_distance( 10 | cnp.float64_t x1, cnp.float64_t y1, cnp.float64_t z1, 11 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t z2) 12 | 13 | cdef double perp_square_distance( 14 | cnp.float64_t x1, cnp.float64_t y1, cnp.float64_t x2, cnp.float64_t y2) 15 | 16 | cdef double para_square_distance(cnp.float64_t z1, cnp.float64_t z2) 17 | 18 | cdef double periodic_perp_square_distance( 19 | cnp.float64_t x1, cnp.float64_t y1, 20 | cnp.float64_t x2, cnp.float64_t y2, 21 | cnp.float64_t* period) 22 | 23 | cdef double periodic_para_square_distance( 24 | cnp.float64_t z1, cnp.float64_t z2, cnp.float64_t* period) 25 | 26 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/cpairs/setup_package.py: -------------------------------------------------------------------------------- 1 | from distutils.extension import Extension 2 | import os 3 | import numpy as np 4 | 5 | PATH_TO_PKG = os.path.relpath(os.path.dirname(__file__)) 6 | SOURCES = ( 7 | "distances.pyx", 8 | "pairwise_distances.pyx", 9 | "npairs_3d_engine.pyx", 10 | "npairs_projected_engine.pyx", 11 | "npairs_xy_z_engine.pyx", 12 | "npairs_jackknife_3d_engine.pyx", 13 | "npairs_s_mu_engine.pyx", 14 | "pairwise_distance_3d_engine.pyx", 15 | "pairwise_distance_xy_z_engine.pyx", 16 | "weighted_npairs_s_mu_engine.pyx", 17 | "npairs_jackknife_xy_z_engine.pyx", 18 | ) 19 | THIS_PKG_NAME = ".".join(__name__.split(".")[:-1]) 20 | 21 | 22 | def get_extensions(): 23 | 24 | names = [THIS_PKG_NAME + "." + src.replace(".pyx", "") for src in SOURCES] 25 | sources = [os.path.join(PATH_TO_PKG, srcfn) for srcfn in SOURCES] 26 | include_dirs = [np.get_include()] 27 | libraries = [] 28 | language = "c++" 29 | extra_compile_args = ["-Ofast"] 30 | 31 | extensions = [] 32 | for name, source in zip(names, sources): 33 | extensions.append( 34 | Extension( 35 | name=name, 36 | sources=[source], 37 | include_dirs=include_dirs, 38 | libraries=libraries, 39 | language=language, 40 | extra_compile_args=extra_compile_args, 41 | ) 42 | ) 43 | 44 | return extensions 45 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/marked_cpairs/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | from .conditional_pairwise_distances import * 6 | from .marked_npairs_3d_engine import marked_npairs_3d_engine 7 | from .marked_npairs_xy_z_engine import marked_npairs_xy_z_engine 8 | from .positional_marked_npairs_3d_engine import positional_marked_npairs_3d_engine 9 | from .positional_marked_npairs_xy_z_engine import positional_marked_npairs_xy_z_engine -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/marked_cpairs/custom_marking_func.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | cimport numpy as cnp 3 | 4 | ##### declaration of user-defined custom marking function #### 5 | 6 | cdef cnp.float64_t custom_func(cnp.float64_t* w1, cnp.float64_t* w2) 7 | 8 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/marked_cpairs/custom_marking_func.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | # cython: profile=False 3 | """ 4 | Custom weighting function. 5 | """ 6 | 7 | from __future__ import absolute_import, division, print_function, unicode_literals 8 | cimport numpy as cnp 9 | 10 | __author__ = ["Duncan Campbell"] 11 | 12 | cdef cnp.float64_t custom_func(cnp.float64_t* w1, cnp.float64_t* w2): 13 | """ 14 | Modify and use this function with weight_func_id=0 to get a custom function. 15 | """ 16 | return w1[0]*w2[0] 17 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/marked_cpairs/custom_weighting_func.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | 3 | import numpy as np 4 | cimport numpy as np 5 | 6 | #####built in weighting functions#### 7 | 8 | cdef double custom_func(np.float64_t* w1, np.float64_t* w2, np.float64_t* shift) 9 | 10 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/marked_cpairs/custom_weighting_func.pyx: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | # cython: profile=False 3 | """ 4 | objective weighting functions. 5 | """ 6 | 7 | from __future__ import (absolute_import, division, print_function, 8 | unicode_literals) 9 | import sys 10 | cimport cython 11 | import numpy as np 12 | cimport numpy as np 13 | 14 | __author__ = ["Duncan Campbell"] 15 | 16 | cdef double custom_func(np.float64_t* w1, np.float64_t* w2, np.float64_t* shift): 17 | """ 18 | use this function to edit and compile to get a custom function 19 | """ 20 | return w1[0]*w2[0] 21 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/marked_cpairs/distances.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | import numpy as np 3 | cimport numpy as np 4 | 5 | cdef double periodic_square_distance(np.float64_t x1,\ 6 | np.float64_t y1,\ 7 | np.float64_t z1,\ 8 | np.float64_t x2,\ 9 | np.float64_t y2,\ 10 | np.float64_t z2,\ 11 | np.float64_t* period) 12 | 13 | cdef double square_distance(np.float64_t x1, np.float64_t y1, np.float64_t z1,\ 14 | np.float64_t x2, np.float64_t y2, np.float64_t z2) 15 | 16 | cdef double perp_square_distance(np.float64_t x1, np.float64_t y1,\ 17 | np.float64_t x2, np.float64_t y2) 18 | 19 | cdef double para_square_distance(np.float64_t z1, np.float64_t z2) 20 | 21 | cdef double periodic_perp_square_distance(np.float64_t x1, np.float64_t y1,\ 22 | np.float64_t x2, np.float64_t y2,\ 23 | np.float64_t* period) 24 | 25 | cdef double periodic_para_square_distance(np.float64_t z1, np.float64_t z2,\ 26 | np.float64_t* period) 27 | 28 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/marked_cpairs/marking_functions.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | cimport numpy as cnp 3 | 4 | ##### built-in weighting functions#### 5 | 6 | cdef cnp.float64_t mweights(cnp.float64_t* w1, cnp.float64_t* w2) 7 | cdef cnp.float64_t sweights(cnp.float64_t* w1, cnp.float64_t* w2) 8 | cdef cnp.float64_t eqweights(cnp.float64_t* w1, cnp.float64_t* w2) 9 | cdef cnp.float64_t ineqweights(cnp.float64_t* w1, cnp.float64_t* w2) 10 | cdef cnp.float64_t gweights(cnp.float64_t* w1, cnp.float64_t* w2) 11 | cdef cnp.float64_t lweights(cnp.float64_t* w1, cnp.float64_t* w2) 12 | cdef cnp.float64_t tgweights(cnp.float64_t* w1, cnp.float64_t* w2) 13 | cdef cnp.float64_t tlweights(cnp.float64_t* w1, cnp.float64_t* w2) 14 | cdef cnp.float64_t tweights(cnp.float64_t* w1, cnp.float64_t* w2) 15 | cdef cnp.float64_t exweights(cnp.float64_t* w1, cnp.float64_t* w2) 16 | cdef cnp.float64_t ratio_weights(cnp.float64_t* w1, cnp.float64_t* w2) 17 | cdef cnp.float64_t dotweights(cnp.float64_t* w1, cnp.float64_t* w2) 18 | cdef cnp.float64_t squareddotweights(cnp.float64_t* w1, cnp.float64_t* w2) 19 | cdef cnp.float64_t projdotweights(cnp.float64_t* w1, cnp.float64_t* w2) 20 | cdef cnp.float64_t projsquareddotweights(cnp.float64_t* w1, cnp.float64_t* w2) 21 | cdef cnp.float64_t squareddotweights_eq(cnp.float64_t* w1, cnp.float64_t* w2) 22 | cdef cnp.float64_t squareddotweights_ineq(cnp.float64_t* w1, cnp.float64_t* w2) 23 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/marked_cpairs/positional_marking_functions.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | cimport numpy as cnp 3 | 4 | ##### built-in positional weighting functions#### 5 | 6 | cdef cnp.float64_t pos_shape_dot_product_func(cnp.float64_t* w1, cnp.float64_t* w2, 7 | cnp.float64_t x1, cnp.float64_t y1, cnp.float64_t z1, 8 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t z2, cnp.float64_t rsq) 9 | 10 | cdef cnp.float64_t gamma_plus_func(cnp.float64_t* w1, cnp.float64_t* w2, 11 | cnp.float64_t x1, cnp.float64_t y1, cnp.float64_t z1, 12 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t z2, cnp.float64_t rsq) 13 | 14 | cdef cnp.float64_t gamma_cross_func(cnp.float64_t* w1, cnp.float64_t* w2, 15 | cnp.float64_t x1, cnp.float64_t y1, cnp.float64_t z1, 16 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t z2, cnp.float64_t rsq) 17 | 18 | cdef cnp.float64_t squareddot_func(cnp.float64_t* w1, cnp.float64_t* w2, 19 | cnp.float64_t x1, cnp.float64_t y1, cnp.float64_t z1, 20 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t z2, cnp.float64_t rsq) 21 | 22 | cdef cnp.float64_t gamma_gamma_plus_func(cnp.float64_t* w1, cnp.float64_t* w2, 23 | cnp.float64_t x1, cnp.float64_t y1, cnp.float64_t z1, 24 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t z2, cnp.float64_t rsq) 25 | 26 | cdef cnp.float64_t gamma_gamma_cross_func(cnp.float64_t* w1, cnp.float64_t* w2, 27 | cnp.float64_t x1, cnp.float64_t y1, cnp.float64_t z1, 28 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t z2, cnp.float64_t rsq) 29 | 30 | cdef cnp.float64_t squareddot_eq_func(cnp.float64_t* w1, cnp.float64_t* w2, 31 | cnp.float64_t x1, cnp.float64_t y1, cnp.float64_t z1, 32 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t z2, cnp.float64_t rsq) 33 | 34 | cdef cnp.float64_t squareddot_ineq_func(cnp.float64_t* w1, cnp.float64_t* w2, 35 | cnp.float64_t x1, cnp.float64_t y1, cnp.float64_t z1, 36 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t z2, cnp.float64_t rsq) 37 | 38 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/marked_cpairs/positional_projected_marking_functions.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | cimport numpy as cnp 3 | 4 | ##### built-in projected positional weighting functions#### 5 | 6 | cdef cnp.float64_t pos_shape_dot_product_func(cnp.float64_t* w1, cnp.float64_t* w2, 7 | cnp.float64_t x1, cnp.float64_t y1, 8 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t dxy_sq) 9 | 10 | cdef cnp.float64_t gamma_plus_func(cnp.float64_t* w1, cnp.float64_t* w2, 11 | cnp.float64_t x1, cnp.float64_t y1, 12 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t dxy_sq) 13 | 14 | cdef cnp.float64_t gamma_cross_func(cnp.float64_t* w1, cnp.float64_t* w2, 15 | cnp.float64_t x1, cnp.float64_t y1, 16 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t dxy_sq) 17 | 18 | cdef cnp.float64_t squareddot_func(cnp.float64_t* w1, cnp.float64_t* w2, 19 | cnp.float64_t x1, cnp.float64_t y1, 20 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t dxy_sq) 21 | 22 | cdef cnp.float64_t gamma_gamma_plus_func(cnp.float64_t* w1, cnp.float64_t* w2, 23 | cnp.float64_t x1, cnp.float64_t y1, 24 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t dxy_sq) 25 | 26 | cdef cnp.float64_t gamma_gamma_cross_func(cnp.float64_t* w1, cnp.float64_t* w2, 27 | cnp.float64_t x1, cnp.float64_t y1, 28 | cnp.float64_t x2, cnp.float64_t y2, cnp.float64_t dxy_sq) -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/marked_cpairs/setup_package.py: -------------------------------------------------------------------------------- 1 | from distutils.extension import Extension 2 | import os 3 | import numpy as np 4 | 5 | PATH_TO_PKG = os.path.relpath(os.path.dirname(__file__)) 6 | SOURCES = ( 7 | "custom_weighting_func.pyx", 8 | "distances.pyx", 9 | "conditional_pairwise_distances.pyx", 10 | "marked_npairs_3d_engine.pyx", 11 | ) 12 | 13 | THIS_PKG_NAME = ".".join(__name__.split(".")[:-1]) 14 | 15 | 16 | def get_extensions(): 17 | 18 | names = [THIS_PKG_NAME + "." + src.replace(".pyx", "") for src in SOURCES] 19 | sources = [os.path.join(PATH_TO_PKG, srcfn) for srcfn in SOURCES] 20 | include_dirs = [np.get_include()] 21 | libraries = [] 22 | language = "c++" 23 | extra_compile_args = ["-Ofast"] 24 | 25 | extensions = [] 26 | for name, source in zip(names, sources): 27 | extensions.append( 28 | Extension( 29 | name=name, 30 | sources=[source], 31 | include_dirs=include_dirs, 32 | libraries=libraries, 33 | language=language, 34 | extra_compile_args=extra_compile_args, 35 | ) 36 | ) 37 | 38 | return extensions 39 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/test_pair_counters/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | from __future__ import (absolute_import, division, print_function, 3 | unicode_literals) 4 | -------------------------------------------------------------------------------- /halotools/mock_observables/pair_counters/test_pair_counters/pure_python_npairs_per_object_3d.py: -------------------------------------------------------------------------------- 1 | """ Module storing pure python brute force per-object pair-counters used for unit-testing. 2 | """ 3 | 4 | from __future__ import absolute_import, division, print_function, unicode_literals 5 | 6 | import numpy as np 7 | 8 | __all__ = ('pure_python_npairs_per_object_3d', ) 9 | 10 | 11 | def pure_python_npairs_per_object_3d(sample1, sample2, rbins, period=None): 12 | """ 13 | """ 14 | if period is None: 15 | xperiod, yperiod, zperiod = np.inf, np.inf, np.inf 16 | else: 17 | xperiod, yperiod, zperiod = period, period, period 18 | 19 | npts1, npts2, num_rbins = len(sample1), len(sample2), len(rbins) 20 | 21 | counts = np.zeros((npts1, num_rbins), dtype=int) 22 | 23 | for i in range(npts1): 24 | for j in range(npts2): 25 | dx = sample1[i, 0] - sample2[j, 0] 26 | dy = sample1[i, 1] - sample2[j, 1] 27 | dz = sample1[i, 2] - sample2[j, 2] 28 | 29 | if dx > xperiod/2.: 30 | dx = xperiod - dx 31 | elif dx < -xperiod/2.: 32 | dx = -(xperiod + dx) 33 | 34 | if dy > yperiod/2.: 35 | dy = yperiod - dy 36 | elif dy < -yperiod/2.: 37 | dy = -(yperiod + dy) 38 | 39 | if dz > zperiod/2.: 40 | dz = zperiod - dz 41 | elif dz < -zperiod/2.: 42 | dz = -(zperiod + dz) 43 | 44 | d = np.sqrt(dx*dx + dy*dy + dz*dz) 45 | for irbin, r in enumerate(rbins): 46 | if d < r: 47 | counts[i, irbin] += 1 48 | 49 | return counts 50 | -------------------------------------------------------------------------------- /halotools/mock_observables/pairwise_velocities/__init__.py: -------------------------------------------------------------------------------- 1 | """ Sub-package of `~halotools.mock_observables` containing functions used to 2 | calculate pairwise velocity statistics. 3 | """ 4 | from __future__ import absolute_import 5 | 6 | from .mean_radial_velocity_vs_r import mean_radial_velocity_vs_r 7 | from .radial_pvd_vs_r import radial_pvd_vs_r 8 | from .mean_los_velocity_vs_rp import mean_los_velocity_vs_rp 9 | from .los_pvd_vs_rp import los_pvd_vs_rp 10 | from .velocity_marked_npairs_3d import velocity_marked_npairs_3d 11 | from .velocity_marked_npairs_xy_z import velocity_marked_npairs_xy_z 12 | 13 | __all__ = ('mean_radial_velocity_vs_r', 'radial_pvd_vs_r', 14 | 'mean_los_velocity_vs_rp', 'los_pvd_vs_rp') 15 | -------------------------------------------------------------------------------- /halotools/mock_observables/pairwise_velocities/engines/__init__.py: -------------------------------------------------------------------------------- 1 | from .velocity_marked_npairs_3d_engine import velocity_marked_npairs_3d_engine 2 | from .velocity_marked_npairs_xy_z_engine import velocity_marked_npairs_xy_z_engine 3 | from .mean_radial_velocity_vs_r_engine import mean_radial_velocity_vs_r_engine 4 | from .radial_pvd_vs_r_engine import radial_pvd_vs_r_engine 5 | -------------------------------------------------------------------------------- /halotools/mock_observables/pairwise_velocities/engines/setup_package.py: -------------------------------------------------------------------------------- 1 | from distutils.extension import Extension 2 | import os 3 | import numpy as np 4 | 5 | PATH_TO_PKG = os.path.relpath(os.path.dirname(__file__)) 6 | SOURCES = ( 7 | "velocity_marked_npairs_3d_engine.pyx", 8 | "velocity_marking_functions.pyx", 9 | "velocity_marked_npairs_xy_z_engine.pyx", 10 | "mean_radial_velocity_vs_r_engine.pyx", 11 | "radial_pvd_vs_r_engine.pyx", 12 | ) 13 | 14 | THIS_PKG_NAME = ".".join(__name__.split(".")[:-1]) 15 | 16 | 17 | def get_extensions(): 18 | 19 | names = [THIS_PKG_NAME + "." + src.replace(".pyx", "") for src in SOURCES] 20 | sources = [os.path.join(PATH_TO_PKG, srcfn) for srcfn in SOURCES] 21 | include_dirs = [np.get_include()] 22 | libraries = [] 23 | language = "c++" 24 | extra_compile_args = ["-Ofast"] 25 | 26 | extensions = [] 27 | for name, source in zip(names, sources): 28 | extensions.append( 29 | Extension( 30 | name=name, 31 | sources=[source], 32 | include_dirs=include_dirs, 33 | libraries=libraries, 34 | language=language, 35 | extra_compile_args=extra_compile_args, 36 | ) 37 | ) 38 | 39 | return extensions 40 | -------------------------------------------------------------------------------- /halotools/mock_observables/pairwise_velocities/engines/velocity_marking_functions.pxd: -------------------------------------------------------------------------------- 1 | # cython: language_level=2 2 | cimport numpy as cnp 3 | 4 | #####built in weighting functions#### 5 | 6 | #radial functions 7 | cdef void relative_radial_velocity_weights(cnp.float64_t* w1, cnp.float64_t* w2, cnp.float64_t* shift, cnp.float64_t* result1, cnp.float64_t* result2, cnp.float64_t* result3) 8 | cdef void radial_velocity_variance_counter_weights(cnp.float64_t* w1, cnp.float64_t* w2, cnp.float64_t* shift, cnp.float64_t* result1, cnp.float64_t* result2, cnp.float64_t* result3) 9 | 10 | #line-of-sight functions 11 | cdef void relative_los_velocity_weights(cnp.float64_t* w1, cnp.float64_t* w2, cnp.float64_t* shift, cnp.float64_t* result1, cnp.float64_t* result2, cnp.float64_t* result3) 12 | cdef void los_velocity_variance_counter_weights(cnp.float64_t* w1, cnp.float64_t* w2, cnp.float64_t* shift, cnp.float64_t* result1, cnp.float64_t* result2, cnp.float64_t* result3) 13 | -------------------------------------------------------------------------------- /halotools/mock_observables/pairwise_velocities/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/mock_observables/pairwise_velocities/tests/__init__.py -------------------------------------------------------------------------------- /halotools/mock_observables/pairwise_velocities/tests/pure_python_mean_radial_velocity_vs_r.py: -------------------------------------------------------------------------------- 1 | """ Module storing brute force python function `pure_python_mean_radial_velocity_vs_r` 2 | used for unit-testing of the `mean_radial_velocity_vs_r` Cython implementation. 3 | """ 4 | import numpy as np 5 | 6 | 7 | __all__ = ('pure_python_mean_radial_velocity_vs_r', ) 8 | 9 | 10 | def pure_python_mean_radial_velocity_vs_r( 11 | sample1, velocities1, sample2, velocities2, rmin, rmax, Lbox=None): 12 | """ Brute force pure python function calculating mean radial velocities 13 | in a single bin of separation. 14 | """ 15 | if Lbox is None: 16 | xperiod, yperiod, zperiod = np.inf, np.inf, np.inf 17 | else: 18 | xperiod, yperiod, zperiod = Lbox, Lbox, Lbox 19 | 20 | npts1, npts2 = len(sample1), len(sample2) 21 | 22 | running_tally = [] 23 | for i in range(npts1): 24 | for j in range(npts2): 25 | dx = sample1[i, 0] - sample2[j, 0] 26 | dy = sample1[i, 1] - sample2[j, 1] 27 | dz = sample1[i, 2] - sample2[j, 2] 28 | dvx = velocities1[i, 0] - velocities2[j, 0] 29 | dvy = velocities1[i, 1] - velocities2[j, 1] 30 | dvz = velocities1[i, 2] - velocities2[j, 2] 31 | 32 | xsign_flip, ysign_flip, zsign_flip = 1, 1, 1 33 | if dx > xperiod/2.: 34 | dx = xperiod - dx 35 | xsign_flip = -1 36 | elif dx < -xperiod/2.: 37 | dx = -(xperiod + dx) 38 | xsign_flip = -1 39 | 40 | if dy > yperiod/2.: 41 | dy = yperiod - dy 42 | ysign_flip = -1 43 | elif dy < -yperiod/2.: 44 | dy = -(yperiod + dy) 45 | ysign_flip = -1 46 | 47 | if dz > zperiod/2.: 48 | dz = zperiod - dz 49 | zsign_flip = -1 50 | elif dz < -zperiod/2.: 51 | dz = -(zperiod + dz) 52 | zsign_flip = -1 53 | 54 | d = np.sqrt(dx*dx + dy*dy + dz*dz) 55 | 56 | if (d > rmin) & (d < rmax): 57 | vrad = (dx*dvx*xsign_flip + dy*dvy*ysign_flip + dz*dvz*zsign_flip)/d 58 | running_tally.append(vrad) 59 | 60 | if len(running_tally) > 0: 61 | return np.mean(running_tally) 62 | else: 63 | return 0. 64 | -------------------------------------------------------------------------------- /halotools/mock_observables/radial_profiles/__init__.py: -------------------------------------------------------------------------------- 1 | """ Sub-package of `~halotools.mock_observables` containing functions used 2 | to calculate the radial profiles. 3 | """ 4 | 5 | from .radial_profile_3d import radial_profile_3d 6 | 7 | __all__ = ('radial_profile_3d', ) 8 | -------------------------------------------------------------------------------- /halotools/mock_observables/radial_profiles/engines/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from .radial_profile_3d_engine import radial_profile_3d_engine 4 | -------------------------------------------------------------------------------- /halotools/mock_observables/radial_profiles/engines/setup_package.py: -------------------------------------------------------------------------------- 1 | from distutils.extension import Extension 2 | import os 3 | import numpy as np 4 | 5 | PATH_TO_PKG = os.path.relpath(os.path.dirname(__file__)) 6 | SOURCES = ("radial_profile_3d_engine.pyx",) 7 | THIS_PKG_NAME = ".".join(__name__.split(".")[:-1]) 8 | 9 | 10 | def get_extensions(): 11 | 12 | names = [THIS_PKG_NAME + "." + src.replace(".pyx", "") for src in SOURCES] 13 | sources = [os.path.join(PATH_TO_PKG, srcfn) for srcfn in SOURCES] 14 | include_dirs = [np.get_include()] 15 | libraries = [] 16 | language = "c++" 17 | extra_compile_args = ["-Ofast"] 18 | 19 | extensions = [] 20 | for name, source in zip(names, sources): 21 | extensions.append( 22 | Extension( 23 | name=name, 24 | sources=[source], 25 | include_dirs=include_dirs, 26 | libraries=libraries, 27 | language=language, 28 | extra_compile_args=extra_compile_args, 29 | ) 30 | ) 31 | 32 | return extensions 33 | -------------------------------------------------------------------------------- /halotools/mock_observables/radial_profiles/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/mock_observables/radial_profiles/tests/__init__.py -------------------------------------------------------------------------------- /halotools/mock_observables/surface_density/__init__.py: -------------------------------------------------------------------------------- 1 | from .mass_in_cylinders import total_mass_enclosed_per_cylinder 2 | from .mean_delta_sigma import mean_delta_sigma 3 | -------------------------------------------------------------------------------- /halotools/mock_observables/surface_density/engines/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function, unicode_literals 2 | 3 | from .weighted_npairs_xy_engine import weighted_npairs_xy_engine 4 | from .weighted_npairs_per_object_xy_engine import weighted_npairs_per_object_xy_engine 5 | from .mean_delta_sigma_engine import mean_delta_sigma_engine 6 | 7 | from .mean_ds_one_two_halo_decomp_halo_id_engine import mean_ds_12h_halo_id_engine 8 | from .mean_ds_one_two_halo_decomp_rhalo_engine import mean_ds_12h_rhalo_engine 9 | -------------------------------------------------------------------------------- /halotools/mock_observables/surface_density/engines/setup_package.py: -------------------------------------------------------------------------------- 1 | from distutils.extension import Extension 2 | import os 3 | import numpy as np 4 | 5 | PATH_TO_PKG = os.path.relpath(os.path.dirname(__file__)) 6 | SOURCES = ( 7 | "weighted_npairs_xy_engine.pyx", 8 | "weighted_npairs_per_object_xy_engine.pyx", 9 | "mean_delta_sigma_engine.pyx", 10 | ) 11 | 12 | THIS_PKG_NAME = ".".join(__name__.split(".")[:-1]) 13 | 14 | 15 | def get_extensions(): 16 | 17 | names = [THIS_PKG_NAME + "." + src.replace(".pyx", "") for src in SOURCES] 18 | sources = [os.path.join(PATH_TO_PKG, srcfn) for srcfn in SOURCES] 19 | include_dirs = [np.get_include()] 20 | libraries = [] 21 | language = "c++" 22 | extra_compile_args = ["-Ofast"] 23 | 24 | extensions = [] 25 | for name, source in zip(names, sources): 26 | extensions.append( 27 | Extension( 28 | name=name, 29 | sources=[source], 30 | include_dirs=include_dirs, 31 | libraries=libraries, 32 | language=language, 33 | extra_compile_args=extra_compile_args, 34 | ) 35 | ) 36 | 37 | return extensions 38 | -------------------------------------------------------------------------------- /halotools/mock_observables/surface_density/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/mock_observables/surface_density/tests/__init__.py -------------------------------------------------------------------------------- /halotools/mock_observables/surface_density/tests/pure_python_weighted_npairs_per_object_xy.py: -------------------------------------------------------------------------------- 1 | """ Module storing pure python brute force per-object pair-counters used for unit-testing. 2 | """ 3 | 4 | from __future__ import absolute_import, division, print_function, unicode_literals 5 | 6 | import numpy as np 7 | 8 | from .pure_python_weighted_npairs_xy import periodic_xy_distance 9 | 10 | __all__ = ('pure_python_weighted_npairs_per_object_xy', ) 11 | 12 | 13 | def pure_python_weighted_npairs_per_object_xy(xarr1, yarr1, xarr2, yarr2, warr2, 14 | rp_bins, xperiod, yperiod): 15 | """ Count the number of pairs as a function of xy-distance, 16 | weighted by the second pair of points. 17 | """ 18 | num_rp_bins = len(rp_bins) 19 | num_pts1 = len(xarr1) 20 | 21 | counts = np.zeros((num_pts1, num_rp_bins)) 22 | weighted_counts = np.zeros((num_pts1, num_rp_bins)) 23 | 24 | for i, x1, y1 in zip(range(num_pts1), xarr1, yarr1): 25 | for x2, y2, w2 in zip(xarr2, yarr2, warr2): 26 | rp_ij = periodic_xy_distance(x1, y1, x2, y2, xperiod, yperiod) 27 | for k, rp_bin_edge in enumerate(rp_bins): 28 | if rp_ij < rp_bin_edge: 29 | counts[i, k] += 1 30 | weighted_counts[i, k] += w2 31 | return counts, weighted_counts 32 | -------------------------------------------------------------------------------- /halotools/mock_observables/surface_density/tests/pure_python_weighted_npairs_xy.py: -------------------------------------------------------------------------------- 1 | """ Pure python functions to aid in unit-testing 2 | """ 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | import numpy as np 6 | 7 | __all__ = ('pure_python_weighted_npairs_xy', 'periodic_xy_distance') 8 | 9 | 10 | def periodic_xy_distance(x1, y1, x2, y2, xperiod, yperiod): 11 | """ Compute the distance between two points in the xy-direction, 12 | accounting for periodic boundary conditions. 13 | """ 14 | dx = abs(x2 - x1) 15 | dy = abs(y2 - y1) 16 | if dx > xperiod/2.: 17 | dx = xperiod - dx 18 | if dy > yperiod/2.: 19 | dy = yperiod - dy 20 | return np.sqrt(dx*dx + dy*dy) 21 | 22 | 23 | def pure_python_weighted_npairs_xy(xarr1, yarr1, xarr2, yarr2, warr2, rp_bins, xperiod, yperiod): 24 | """ Count the number of pairs as a function of xy-distance, 25 | weighted by the second pair of points. 26 | """ 27 | num_rp_bins = len(rp_bins) 28 | counts = np.zeros(num_rp_bins) 29 | weighted_counts = np.zeros(num_rp_bins) 30 | 31 | for x1, y1 in zip(xarr1, yarr1): 32 | for x2, y2, w2 in zip(xarr2, yarr2, warr2): 33 | rp_ij = periodic_xy_distance(x1, y1, x2, y2, xperiod, yperiod) 34 | for k, rp_bin_edge in enumerate(rp_bins): 35 | if rp_ij < rp_bin_edge: 36 | counts[k] += 1 37 | weighted_counts[k] += w2 38 | return counts, weighted_counts 39 | 40 | 41 | -------------------------------------------------------------------------------- /halotools/mock_observables/surface_density/tests/test_pure_python_weighted_npairs_xy.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | import numpy as np 6 | 7 | from .pure_python_weighted_npairs_xy import pure_python_weighted_npairs_xy 8 | 9 | from ...tests.cf_helpers import generate_3d_regular_mesh 10 | 11 | __all__ = ('test_pure_python_weighted_npairs_xy', ) 12 | 13 | fixed_seed = 43 14 | 15 | 16 | def test_pure_python_weighted_npairs_xy(): 17 | """ 18 | """ 19 | npts_per_dim = 5 20 | data1 = generate_3d_regular_mesh(npts_per_dim) 21 | data2 = generate_3d_regular_mesh(npts_per_dim) 22 | w2 = np.zeros(data2.shape[0]) + 2.5 23 | rp_bins = np.array((0.199, 0.201, 0.3)) 24 | xperiod, yperiod = 1, 1 25 | 26 | xarr1, yarr1 = data1[:, 0], data1[:, 1] 27 | xarr2, yarr2 = data2[:, 0], data2[:, 1] 28 | counts, weighted_counts = pure_python_weighted_npairs_xy( 29 | xarr1, yarr1, xarr2, yarr2, w2, rp_bins, xperiod, yperiod) 30 | 31 | npts1_total = npts_per_dim**3 32 | 33 | assert counts[0] == npts1_total*npts_per_dim 34 | assert counts[1] == (npts1_total*5*npts_per_dim) 35 | assert counts[2] == (npts1_total*9*npts_per_dim) 36 | 37 | assert np.all(weighted_counts == 2.5*counts) 38 | 39 | -------------------------------------------------------------------------------- /halotools/mock_observables/surface_density/tests/test_surface_density_helpers.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | import numpy as np 6 | from astropy.cosmology import Planck15 7 | 8 | from ..surface_density_helpers import annular_area_weighted_midpoints 9 | from ..surface_density_helpers import rho_matter_comoving_in_halotools_units 10 | 11 | 12 | __all__ = ('test_annular_area_weighted_midpoints_linear_spacing', ) 13 | 14 | fixed_seed = 43 15 | 16 | 17 | def test_annular_area_weighted_midpoints_linear_spacing(): 18 | """ 19 | """ 20 | rp_bins = np.linspace(0.5, 10, 25) 21 | r_equal_area = annular_area_weighted_midpoints(rp_bins) 22 | assert r_equal_area.shape[0] == rp_bins.shape[0]-1 23 | inner_area = np.pi*(r_equal_area[0]**2 - rp_bins[0]**2) 24 | outer_area = np.pi*(rp_bins[1]**2 - r_equal_area[0]**2) 25 | assert np.allclose(inner_area, outer_area) 26 | 27 | 28 | def test_annular_area_weighted_midpoints_log_spacing(): 29 | """ 30 | """ 31 | rp_bins = np.logspace(-2, 2, 25) 32 | r_equal_area = annular_area_weighted_midpoints(rp_bins) 33 | assert r_equal_area.shape[0] == rp_bins.shape[0]-1 34 | inner_area = np.pi*(r_equal_area[0]**2 - rp_bins[0]**2) 35 | outer_area = np.pi*(rp_bins[1]**2 - r_equal_area[0]**2) 36 | assert np.allclose(inner_area, outer_area) 37 | 38 | 39 | def test_rho_matter_comoving_in_halotools_units(): 40 | """ Manually verify percent-level agreement for 41 | rho_matter with hard-coded Planck15 best-fit values 42 | """ 43 | gee = 4.2994e-9 44 | rhocrit = 3.E4/(8.*np.pi*gee) 45 | rhobar = rhocrit*0.3075 46 | halotools_rhobar = rho_matter_comoving_in_halotools_units(Planck15) 47 | assert np.allclose(halotools_rhobar, rhobar, rtol=0.01) 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /halotools/mock_observables/tensor_calculations/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function, unicode_literals 2 | 3 | from .inertia_tensor import inertia_tensor_per_object 4 | from .tensor_derived_quantities import * 5 | -------------------------------------------------------------------------------- /halotools/mock_observables/tensor_calculations/engines/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function, unicode_literals 2 | 3 | from .inertia_tensor_3d_engine import inertia_tensor_per_object_engine 4 | -------------------------------------------------------------------------------- /halotools/mock_observables/tensor_calculations/engines/setup_package.py: -------------------------------------------------------------------------------- 1 | from distutils.extension import Extension 2 | import os 3 | import numpy as np 4 | 5 | PATH_TO_PKG = os.path.relpath(os.path.dirname(__file__)) 6 | SOURCES = ("inertia_tensor_3d_engine.pyx",) 7 | THIS_PKG_NAME = ".".join(__name__.split(".")[:-1]) 8 | 9 | 10 | def get_extensions(): 11 | 12 | names = [THIS_PKG_NAME + "." + src.replace(".pyx", "") for src in SOURCES] 13 | sources = [os.path.join(PATH_TO_PKG, srcfn) for srcfn in SOURCES] 14 | include_dirs = [np.get_include()] 15 | libraries = [] 16 | language = "c" 17 | extra_compile_args = ["-Ofast"] 18 | 19 | extensions = [] 20 | for name, source in zip(names, sources): 21 | extensions.append( 22 | Extension( 23 | name=name, 24 | sources=[source], 25 | include_dirs=include_dirs, 26 | libraries=libraries, 27 | language=language, 28 | extra_compile_args=extra_compile_args, 29 | ) 30 | ) 31 | 32 | return extensions 33 | -------------------------------------------------------------------------------- /halotools/mock_observables/tensor_calculations/tests/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function, unicode_literals 2 | -------------------------------------------------------------------------------- /halotools/mock_observables/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/mock_observables/tests/__init__.py -------------------------------------------------------------------------------- /halotools/mock_observables/tests/test_mock_survey.py: -------------------------------------------------------------------------------- 1 | """ Module providing unit-testing for the functions in 2 | the `~halotools.mock_observables.mock_survey` module 3 | """ 4 | from __future__ import absolute_import, division, print_function, unicode_literals 5 | 6 | import numpy as np 7 | import pytest 8 | from astropy.utils.misc import NumpyRNGContext 9 | 10 | from ..mock_survey import ra_dec_z 11 | 12 | __all__ = ('test_ra_dec_z', ) 13 | 14 | fixed_seed = 43 15 | 16 | # create some toy data to test functions 17 | N = 100 18 | with NumpyRNGContext(fixed_seed): 19 | x = np.random.random((N, 3)) 20 | v = np.random.random((N, 3))*0.1 21 | period = np.array([1.0, 1.0, 1.0]) 22 | 23 | 24 | @pytest.mark.slow 25 | def test_ra_dec_z(): 26 | """ 27 | test ra_dec_z function 28 | """ 29 | from astropy import cosmology 30 | cosmo = cosmology.FlatLambdaCDM(H0=0.7, Om0=0.3) 31 | 32 | ra, dec, z = ra_dec_z(x, v, cosmo=cosmo) 33 | 34 | assert len(ra) == N 35 | assert len(dec) == N 36 | assert len(z) == N 37 | assert np.all(ra < 2.0*np.pi) & np.all(ra > 0.0), "ra range is incorrect" 38 | assert np.all(dec > -1.0*np.pi/2.0) & np.all(dec < np.pi/2.0), "ra range is incorrect" 39 | -------------------------------------------------------------------------------- /halotools/mock_observables/two_point_clustering/__init__.py: -------------------------------------------------------------------------------- 1 | """ Subpackage containing modules of functions that calculate many variations 2 | on galaxy/halo clustering, e.g., three-dimensional clustering 3 | `~halotools.mock_observables.tpcf`, projected clustering `~halotools.mock_observables.wp`, 4 | RSD multipoles `~halotools.mock_observables.tpcf_multipole`, 5 | galaxy-galaxy lensing `~halotools.mock_observables.mean_delta_sigma`, and more. 6 | """ 7 | from __future__ import absolute_import 8 | 9 | from .angular_tpcf import angular_tpcf 10 | from .s_mu_tpcf import s_mu_tpcf 11 | from .tpcf_multipole import tpcf_multipole 12 | from .wp import wp 13 | from .rp_pi_tpcf import rp_pi_tpcf 14 | from .rp_pi_tpcf_jackknife import rp_pi_tpcf_jackknife 15 | from .tpcf_jackknife import tpcf_jackknife 16 | from .wp_jackknife import wp_jackknife 17 | from .tpcf_one_two_halo_decomp import tpcf_one_two_halo_decomp 18 | from .tpcf import tpcf 19 | from .marked_tpcf import marked_tpcf 20 | 21 | __all__ = ('angular_tpcf', 's_mu_tpcf', 'tpcf_multipole', 'wp', 22 | 'rp_pi_tpcf', 'rp_pi_tpcf_jackknife', 'tpcf_jackknife', 'tpcf_one_two_halo_decomp', 'tpcf', 23 | 'marked_tpcf', 'wp_jackknife') 24 | -------------------------------------------------------------------------------- /halotools/mock_observables/two_point_clustering/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/mock_observables/two_point_clustering/tests/__init__.py -------------------------------------------------------------------------------- /halotools/mock_observables/two_point_clustering/tests/test_tpcf_estimators.py: -------------------------------------------------------------------------------- 1 | """ Module provides unit-testing for `~halotools.mock_observables.tpcf_estimators`. 2 | """ 3 | from __future__ import absolute_import, division, print_function 4 | 5 | import pytest 6 | import numpy as np 7 | 8 | from ..tpcf_estimators import ( 9 | _test_for_zero_division, 10 | _list_estimators, 11 | _TP_estimator_requirements, 12 | ) 13 | from ....custom_exceptions import HalotoolsError 14 | 15 | __all__ = ("test_zero_division1",) 16 | 17 | 18 | def test_zero_division1(): 19 | nbins = 10 20 | DD = np.arange(nbins) + 10 21 | DR = np.arange(nbins) + 10 22 | RR = np.arange(nbins) + 10 23 | ND1, ND2, NR1, NR2 = 100, 100, 100, 100 24 | 25 | for estimator in _list_estimators(): 26 | _test_for_zero_division(DD, DR, RR, ND1, ND2, NR1, NR2, estimator) 27 | 28 | 29 | def test_zero_division2(): 30 | nbins = 10 31 | DD = np.arange(nbins) + 10 32 | DR = np.arange(nbins) + 10 33 | RR = np.arange(nbins) + 10 34 | ND1, ND2, NR1, NR2 = 100, 100, 100, 100 35 | 36 | RR[0] = 0.0 37 | DR[0] = 0.0 38 | for estimator in _list_estimators(): 39 | with pytest.raises(ValueError) as err: 40 | _test_for_zero_division(DD, DR, RR, ND1, ND2, NR1, NR2, estimator) 41 | substr = "you will have at least one NaN returned value" 42 | assert substr in err.value.args[0] 43 | 44 | 45 | def test_TP_estimator_requirements_davis_peebles(): 46 | do_DD, do_DR, do_RR = _TP_estimator_requirements("Davis-Peebles") 47 | assert np.all((do_DD, do_DR, do_RR) == (True, True, False)) 48 | 49 | 50 | def test_TP_estimator_requirements_hewett(): 51 | do_DD, do_DR, do_RR = _TP_estimator_requirements("Hewett") 52 | assert np.all((do_DD, do_DR, do_RR) == (True, True, True)) 53 | 54 | 55 | def test_TP_estimator_requirements_hamilton(): 56 | do_DD, do_DR, do_RR = _TP_estimator_requirements("Hamilton") 57 | assert np.all((do_DD, do_DR, do_RR) == (True, True, True)) 58 | 59 | 60 | def test_TP_estimator_requirements_bad_estimator(): 61 | with pytest.raises(HalotoolsError) as err: 62 | __ = _TP_estimator_requirements("Ron Perlman") 63 | substr = "Input `estimator` must be one of the following" 64 | assert substr in err.value.args[0] 65 | -------------------------------------------------------------------------------- /halotools/mock_observables/two_point_clustering/tests/test_tpcf_multipole.py: -------------------------------------------------------------------------------- 1 | """ Module provides unit-testing for the `~halotools.mock_observables.tpcf_multipole` function. 2 | """ 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | import numpy as np 6 | from astropy.utils.misc import NumpyRNGContext 7 | import pytest 8 | 9 | from ..tpcf_multipole import tpcf_multipole 10 | 11 | __all__ = ['test_tpcf_multipole_monopole', 'test_tpcf_multipole_odd_multipoles'] 12 | 13 | fixed_seed = 43 14 | 15 | 16 | def test_tpcf_multipole_monopole(): 17 | """ 18 | test s_mu_tpcf autocorrelation without periodic boundary conditons. 19 | """ 20 | 21 | xi_mu_s_fake = np.ones((49, 49)) 22 | mu_bins = np.linspace(0.0, 1.0, 50) 23 | result = tpcf_multipole(xi_mu_s_fake, mu_bins, order=0) 24 | 25 | 26 | assert np.all(result) == 1.0, "monopole should be exactly 1 for all mu" 27 | 28 | def test_tpcf_multipole_odd_monopoles(): 29 | """ 30 | test s_mu_tpcf autocorrelation without periodic boundary conditons. 31 | """ 32 | 33 | xi_mu_s_fake = np.ones((49, 49)) 34 | mu_bins = np.linspace(0.0, 1.0, 50) 35 | result_1 = tpcf_multipole(xi_mu_s_fake, mu_bins, order=1) 36 | 37 | result_3 = tpcf_multipole(xi_mu_s_fake, mu_bins, order=3) 38 | 39 | result_5 = tpcf_multipole(xi_mu_s_fake, mu_bins, order=5) 40 | 41 | exact_result = np.zeros(49) 42 | 43 | assert np.allclose(result_1,exact_result, atol=1e-14), "l=1 should be exactly 0 for all mu" 44 | assert np.allclose(result_3,exact_result, atol=1e-14), "l=3 should be exactly 0 for all mu" 45 | assert np.allclose(result_5,exact_result, atol=1e-14), "l-5 should be exactly 0 for all mu" 46 | 47 | 48 | -------------------------------------------------------------------------------- /halotools/mock_observables/velocity_decomposition/__init__.py: -------------------------------------------------------------------------------- 1 | from .radial_velocity_decomposition import radial_distance, radial_distance_and_velocity 2 | -------------------------------------------------------------------------------- /halotools/mock_observables/velocity_decomposition/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/mock_observables/velocity_decomposition/tests/__init__.py -------------------------------------------------------------------------------- /halotools/mock_observables/void_statistics/__init__.py: -------------------------------------------------------------------------------- 1 | """ Sub-package containing functions used to calculate void probability functions. 2 | """ 3 | from __future__ import absolute_import 4 | 5 | from .void_prob_func import void_prob_func 6 | from .underdensity_prob_func import underdensity_prob_func 7 | -------------------------------------------------------------------------------- /halotools/mock_observables/void_statistics/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astropy/halotools/a36cd656ef751891c28b977dd1a12ae18b91b753/halotools/mock_observables/void_statistics/tests/__init__.py -------------------------------------------------------------------------------- /halotools/sim_manager/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | """ The `~halotools.sim_manager` sub-package is responsible 3 | for downloading halo catalogs, reading ascii data, 4 | storing hdf5 binaries and keeping a persistent memory 5 | of their location on disk and associated metadata. 6 | """ 7 | from __future__ import (absolute_import, division, print_function, 8 | unicode_literals) 9 | 10 | import os 11 | from pathlib import Path 12 | 13 | try: 14 | halotools_cache_dirname = os.path.join(Path.home(), '.astropy', 'cache', 'halotools') 15 | os.makedirs(halotools_cache_dirname) 16 | except OSError: 17 | pass 18 | 19 | from .fake_sim import FakeSim 20 | 21 | from .download_manager import DownloadManager 22 | 23 | from .cached_halo_catalog import CachedHaloCatalog 24 | from .user_supplied_halo_catalog import UserSuppliedHaloCatalog 25 | from .user_supplied_ptcl_catalog import UserSuppliedPtclCatalog 26 | 27 | from .rockstar_hlist_reader import RockstarHlistReader 28 | from .tabular_ascii_reader import TabularAsciiReader 29 | from .halo_table_cache import HaloTableCache 30 | from .ptcl_table_cache import PtclTableCache 31 | -------------------------------------------------------------------------------- /halotools/sim_manager/setup_package.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | -------------------------------------------------------------------------------- /halotools/sim_manager/sim_defaults.py: -------------------------------------------------------------------------------- 1 | """ 2 | Module expressing various default settings of the simulation manager sub-package. 3 | 4 | All values hard-coded here appear as unique variables throughout the entire Halotools code base. 5 | This allows you to customize your default settings and be guaranteed that whatever changes you make 6 | will correctly propagate to all relevant behavior. See the in-line comments in the 7 | ``halotools/sim_manager/sim_defaults.py`` source code for 8 | descriptions of the purpose of each variable defined in this module. 9 | 10 | """ 11 | 12 | from astropy import cosmology 13 | 14 | # Set the default argument for the CachedHaloCatalog class. 15 | # Any combination of simname, halo-finder and redshift may be chosen, 16 | # provided that the selected combination corresponds to a catalog in your cache directory 17 | # These choices dictate any behavior that loads an unspecified CachedHaloCatalog into memory, 18 | # such as calling the `populate_mock()` method of composite models 19 | default_simname = 'bolshoi' 20 | default_halo_finder = 'rockstar' 21 | default_version_name = 'halotools_v0p4' 22 | default_redshift = 0.0 23 | default_ptcl_version_name = 'halotools_v0p4' 24 | 25 | # The following two variables are used to define completeness cuts applied to halo catalogs 26 | # The Halotools default completeness cut is to throw out all halos with mpeak < mp*300, 27 | # that is, to throw out any halo for which the virial mass of the main progenitor 28 | # never exceeded 300 particles at any point in its assembly history 29 | # These two variables control how the initially-downloaded "raw" subhalo catalogs were processed 30 | # and converted to the hdf5 binaries made available with Halotools. 31 | # If you wish to use a different completeness definition, you can either modify these two variables, 32 | # or alternatively use a custom-defined cut on the raw catalog. 33 | Num_ptcl_requirement = 300 34 | mass_like_variable_to_apply_cut = 'halo_mpeak' 35 | 36 | default_cosmology = cosmology.WMAP5 37 | 38 | # URLs of websites hosting catalogs used by the package 39 | processed_halo_tables_webloc = 'http://www.astro.yale.edu/aphearin/Data_files/halo_catalogs' 40 | ptcl_tables_webloc = 'http://www.astro.yale.edu/aphearin/Data_files/particle_catalogs' 41 | 42 | default_cache_location = 'pkg_default' 43 | 44 | 45 | ############################################################ 46 | -------------------------------------------------------------------------------- /halotools/sim_manager/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | from __future__ import (absolute_import, division, print_function, 3 | unicode_literals) 4 | 5 | from .test_halo_table_cache_log_entry import TestHaloTableCacheLogEntry 6 | -------------------------------------------------------------------------------- /halotools/sim_manager/tests/helper_functions.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import absolute_import, division, print_function 4 | 5 | import os 6 | import numpy as np 7 | 8 | from astropy.table import Table 9 | from astropy.table import vstack as table_vstack 10 | 11 | from pathlib import Path 12 | 13 | detected_home = Path.home() 14 | 15 | __all__ = ('add_new_row_to_cache_log', ) 16 | 17 | dummy_cache_baseloc = os.path.join(detected_home, '.tmp_dummy_cache') 18 | cache_basename = 'halo_table_cache_log.txt' 19 | 20 | 21 | def get_scenario_cache_fname(scenario): 22 | if type(scenario) is not str: 23 | scenario = str(scenario) 24 | return os.path.join(dummy_cache_baseloc, scenario) 25 | 26 | 27 | def add_new_row_to_cache_log(scenario, 28 | simname, halo_finder, redshift, version_name, **kwargs): 29 | if type(scenario) == int: 30 | scenario = str(scenario) 31 | 32 | try: 33 | new_halo_table_fname = kwargs['fname'] 34 | except KeyError: 35 | new_halo_table_basename = (simname + '.' + halo_finder + '.' + 36 | 'z' + str(np.round(redshift, 3)) + '.' + version_name + '.hdf5') 37 | scenario_dirname = get_scenario_cache_fname(scenario) 38 | new_halo_table_fname = os.path.join(scenario_dirname, 39 | 'halo_tables', simname, halo_finder, new_halo_table_basename) 40 | 41 | redshift = np.round(redshift, 4) 42 | new_table = Table( 43 | {'simname': [simname], 'halo_finder': [halo_finder], 44 | 'redshift': [redshift], 'version_name': [version_name], 45 | 'fname': [new_halo_table_fname]} 46 | ) 47 | 48 | try: 49 | existing_table = kwargs['existing_table'] 50 | return table_vstack([existing_table, new_table]) 51 | except KeyError: 52 | return new_table 53 | -------------------------------------------------------------------------------- /halotools/sim_manager/tests/test_load_default_halocat.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from __future__ import absolute_import, division, print_function, unicode_literals 4 | 5 | 6 | from pathlib import Path 7 | import pytest 8 | 9 | from ..cached_halo_catalog import CachedHaloCatalog 10 | from ..ptcl_table_cache import PtclTableCache 11 | from ..halo_table_cache import HaloTableCache 12 | 13 | from ...utils.python_string_comparisons import compare_strings_py23_safe 14 | 15 | aph_home = '/Users/aphearin' 16 | detected_home = Path.home() 17 | if aph_home == detected_home: 18 | APH_MACHINE = True 19 | else: 20 | APH_MACHINE = False 21 | __all__ = ('test_load_default_halocat', ) 22 | 23 | 24 | @pytest.mark.skipif('not APH_MACHINE') 25 | def test_load_default_halocat(): 26 | """ 27 | """ 28 | halocat = CachedHaloCatalog() 29 | particles = halocat.ptcl_table 30 | halos = halocat.halo_table 31 | 32 | 33 | @pytest.mark.skipif('not APH_MACHINE') 34 | def test_load_all_cached_halocats_from_fname(): 35 | """ 36 | """ 37 | cache = HaloTableCache() 38 | for entry in cache.log: 39 | fname = entry.fname 40 | halocat = CachedHaloCatalog(fname=fname) 41 | -------------------------------------------------------------------------------- /halotools/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Licensed under a 3-clause BSD style license - see LICENSE.rst 2 | """ 3 | This packages contains affiliated package tests. 4 | """ 5 | -------------------------------------------------------------------------------- /halotools/tests/coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | source = {packagename} 3 | omit = 4 | {packagename}/_astropy_init* 5 | {packagename}/conftest* 6 | {packagename}/cython_version* 7 | {packagename}/setup_package* 8 | {packagename}/*/setup_package* 9 | {packagename}/*/*/setup_package* 10 | {packagename}/tests/* 11 | {packagename}/*/tests/* 12 | {packagename}/*/*/tests/* 13 | {packagename}/version* 14 | 15 | [report] 16 | exclude_lines = 17 | # Have to re-enable the standard pragma 18 | pragma: no cover 19 | 20 | # Don't complain about packages we have installed 21 | except ImportError 22 | 23 | # Don't complain if tests don't hit assertions 24 | raise AssertionError 25 | raise NotImplementedError 26 | 27 | # Don't complain about script hooks 28 | def main\(.*\): 29 | 30 | # Ignore branches that don't pertain to this version of Python 31 | pragma: py{ignore_python_version} -------------------------------------------------------------------------------- /halotools/tests/ddc.py: -------------------------------------------------------------------------------- 1 | misspellings = ( 2 | ('separation', 'seperation'), 3 | ) 4 | -------------------------------------------------------------------------------- /halotools/tests/docs_code_block_tests/__init__.py: -------------------------------------------------------------------------------- 1 | """ This sub-package provides a way in which 2 | code written inside a .. code:: python of the .rst files 3 | can be tested. The test runners do not execute such code blocks, 4 | so the simple solution is to just copy-and-paste the blocks 5 | into a testing function. 6 | """ 7 | -------------------------------------------------------------------------------- /halotools/tests/setup_package.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | -------------------------------------------------------------------------------- /halotools/tests/test_seed.py: -------------------------------------------------------------------------------- 1 | """ Module contains functions used to guarantee that only American spellings 2 | are used throughout the package. 3 | """ 4 | 5 | import os 6 | import fnmatch 7 | 8 | from .test_amurrica import source_code_string_generator 9 | from ..custom_exceptions import HalotoolsError 10 | 11 | __all__ = ('test_halotools_usage_of_np_random_seed', ) 12 | 13 | msg = ("The test suite detected a call to np.random.seed in the following filename:\n" 14 | "{0} \nCalls to np.random.seed choose the random number seed \n" 15 | "by setting a global environment variable, \n" 16 | "which is not good coding practice for Halotools source code.\n" 17 | "Any time you use a np.random function, you should instead call that function \n" 18 | "within the namespace of the astropy.utils.misc.NumpyRNGContext context manager.\n" 19 | "The NumpyRNGContext context manager sets the number seed to that of its input variable, \n" 20 | "calls the requested np.random function, and then returns the value of the global seed \n" 21 | "to whatever value it had prior to the function call.\n" 22 | "See the Astropy documentation for further information.\n" 23 | "Example usages of NumpyRNGContext appear throughout Halotools, and also below:\n\n" 24 | ">>> bad_random_x_position = np.random.uniform(0, 250, 100) # BAD \n\n" 25 | ">>> from astropy.utils.misc import NumpyRNGContext \n" 26 | ">>> fixed_seed = 43 \n" 27 | ">>> good_random_x_position = with NumpyRNGContext(fixed_seed): np.random.uniform(0, 250, 100) # GOOD \n\n") 28 | 29 | 30 | def filtered_filename_generator(filepat, top): 31 | for path, dirlist, filelist in os.walk(top): 32 | for name in fnmatch.filter(filelist, filepat): 33 | if 'test_seed' not in name: 34 | yield os.path.join(path, name) 35 | 36 | 37 | def test_halotools_usage_of_np_random_seed(): 38 | dirname_current_module = os.path.dirname(os.path.realpath(__file__)) 39 | base_dirname = os.path.dirname(dirname_current_module) 40 | source_code_file_generator = filtered_filename_generator('*.py', base_dirname) 41 | 42 | for fname in source_code_file_generator: 43 | for i, line in source_code_string_generator(fname): 44 | line = line.lower() 45 | if "np.random.seed" in line: 46 | raise HalotoolsError(msg.format(fname)) 47 | -------------------------------------------------------------------------------- /halotools/tests/test_subpkg_imports.py: -------------------------------------------------------------------------------- 1 | """ Testing module to ensure that all sub-packages can be imported. 2 | """ 3 | 4 | 5 | def test_import_sim_manager(): 6 | from .. import sim_manager 7 | 8 | 9 | def test_import_empirical_models(): 10 | from .. import empirical_models 11 | 12 | 13 | def test_import_mock_observables(): 14 | from .. import mock_observables 15 | 16 | 17 | def test_import_utils(): 18 | from .. import utils 19 | -------------------------------------------------------------------------------- /halotools/tests/usa.py: -------------------------------------------------------------------------------- 1 | misspellings = ( 2 | ('halos', 'haloes'), 3 | ('color', 'colour'), 4 | ('realization', 'realisation'), 5 | ('catalog', 'catalogue'), 6 | ('center', 'centre'), 7 | ('neighbor', 'neighbour'), 8 | ('disk ', 'disc '), 9 | ('fiber', 'fibre') 10 | ) 11 | -------------------------------------------------------------------------------- /halotools/utils/__init__.py: -------------------------------------------------------------------------------- 1 | r""" This module contains helper functions used throughout the Halotools package. 2 | """ 3 | from __future__ import division, print_function, absolute_import, unicode_literals 4 | 5 | from .spherical_geometry import * 6 | from .array_utils import * 7 | from .io_utils import * 8 | from .table_utils import * 9 | from .value_added_halo_table_functions import * 10 | from .group_member_generator import group_member_generator 11 | from .crossmatch import * 12 | from .array_indexing_manipulations import * 13 | from .inverse_transformation_sampling import * 14 | from .distribution_matching import * 15 | from .probabilistic_binning import fuzzy_digitize 16 | from .conditional_percentile import sliding_conditional_percentile 17 | from .vector_utilities import * 18 | -------------------------------------------------------------------------------- /halotools/utils/engines/__init__.py: -------------------------------------------------------------------------------- 1 | from .conditional_rank_kernel import cython_conditional_rank_kernel 2 | -------------------------------------------------------------------------------- /halotools/utils/engines/setup_package.py: -------------------------------------------------------------------------------- 1 | from distutils.extension import Extension 2 | import os 3 | import numpy as np 4 | 5 | PATH_TO_PKG = os.path.relpath(os.path.dirname(__file__)) 6 | SOURCES = ("conditional_rank_kernel.pyx",) 7 | THIS_PKG_NAME = ".".join(__name__.split(".")[:-1]) 8 | 9 | 10 | def get_extensions(): 11 | 12 | names = [THIS_PKG_NAME + "." + src.replace(".pyx", "") for src in SOURCES] 13 | sources = [os.path.join(PATH_TO_PKG, srcfn) for srcfn in SOURCES] 14 | include_dirs = [np.get_include()] 15 | libraries = [] 16 | language = "c++" 17 | extra_compile_args = ["-Ofast"] 18 | 19 | extensions = [] 20 | for name, source in zip(names, sources): 21 | extensions.append( 22 | Extension( 23 | name=name, 24 | sources=[source], 25 | include_dirs=include_dirs, 26 | libraries=libraries, 27 | language=language, 28 | extra_compile_args=extra_compile_args, 29 | ) 30 | ) 31 | 32 | return extensions 33 | -------------------------------------------------------------------------------- /halotools/utils/io_utils.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division, print_function, unicode_literals 2 | 3 | from time import time 4 | import sys 5 | import urllib 6 | 7 | __all__ = ["file_len", "download_file_from_url"] 8 | 9 | 10 | def file_len(fname): 11 | with open(fname) as f: 12 | for i, l in enumerate(f): 13 | pass 14 | return i + 1 15 | 16 | 17 | def download_file_from_url(url, fname): 18 | """Function to download a file from the web to a specific location, 19 | and print a progress bar along the way. 20 | 21 | Parameters 22 | ---------- 23 | url : string 24 | web location of desired file, e.g., 25 | ``http://www.some.website.com/somefile.txt``. 26 | 27 | fname : string 28 | Location and filename to store the downloaded file, e.g., 29 | ``/Users/username/dirname/possibly_new_filename.txt`` 30 | """ 31 | start = time() 32 | print("\n... Downloading data from the following location: \n%s\n" % url) 33 | print(" ... Saving the data with the following filename: \n%s\n" % fname) 34 | 35 | def reporthook(blocks_thus_far, bytes_per_block, file_size_in_bytes): 36 | try: 37 | blocks_in_file = int(round(file_size_in_bytes / bytes_per_block)) 38 | printout_condition = int(round(blocks_in_file / 20)) 39 | if (blocks_thus_far % printout_condition == 0) & (blocks_thus_far > 0): 40 | frac_complete = blocks_thus_far / float(blocks_in_file) 41 | runtime = time() - start 42 | print( 43 | "{0:.0f}% complete, elapsed time = {1:.0f} seconds".format( 44 | frac_complete * 100, runtime 45 | ) 46 | ) 47 | 48 | except ZeroDivisionError: 49 | pass 50 | sys.stdout.flush() 51 | 52 | urllib.request.urlretrieve(url, fname, reporthook) 53 | -------------------------------------------------------------------------------- /halotools/utils/load_umachine_binaries.py: -------------------------------------------------------------------------------- 1 | """ Module stores functions used to load the binary outputs of UniverseMachine into memory 2 | """ 3 | import numpy as np 4 | 5 | 6 | default_sfr_catalog_dtype = np.dtype([('id', '= 10) 51 | assert np.all(result <= 11) 52 | 53 | # Check that values beyond the lower bound are handled correctly 54 | with NumpyRNGContext(fixed_seed): 55 | v = np.random.uniform(x.min()-11, x.min()-10, Npts) 56 | result = np.empty(Npts) 57 | for ii, elt in enumerate(v): 58 | closest_val = x[array_utils.find_idx_nearest_val(x, elt)] 59 | result[ii] = abs(closest_val - elt) 60 | assert np.all(result >= 10) 61 | assert np.all(result <= 11) 62 | -------------------------------------------------------------------------------- /halotools/utils/tests/test_compute_richness.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | from ..crossmatch import compute_richness 5 | 6 | 7 | __all__ = ('test_compute_richness1', ) 8 | 9 | 10 | def test_compute_richness1(): 11 | unique_halo_ids = [5, 2, 100] 12 | halo_id_of_galaxies = [100, 2, 100, 3, 2, 100, 100, 3] 13 | richness = compute_richness(unique_halo_ids, halo_id_of_galaxies) 14 | assert np.all(richness == [0, 2, 4]) 15 | 16 | 17 | def test_compute_richness2(): 18 | unique_halo_ids = [400, 100, 200, 300] 19 | halo_id_of_galaxies = np.random.randint(0, 50, 200) 20 | richness = compute_richness(unique_halo_ids, halo_id_of_galaxies) 21 | assert np.all(richness == [0, 0, 0, 0]) 22 | 23 | 24 | def test_compute_richness3(): 25 | unique_halo_ids = [400, 100, 200, 300] 26 | halo_id_of_galaxies = [0, 999, 100, 200, 100, 200, 999, 300, 200] 27 | richness = compute_richness(unique_halo_ids, halo_id_of_galaxies) 28 | assert np.all(richness == [0, 2, 3, 1]) 29 | 30 | 31 | def test_compute_richness4(): 32 | # Set up a source halo catalog with 100 halos in each mass bin 33 | log_mhost_min, log_mhost_max, dlog_mhost = 10.5, 15.5, 0.5 34 | log_mhost_bins = np.arange(log_mhost_min, log_mhost_max+dlog_mhost, dlog_mhost) 35 | log_mhost_mids = 0.5*(log_mhost_bins[:-1] + log_mhost_bins[1:]) 36 | 37 | num_source_halos_per_bin = 100 38 | source_halo_log_mhost = np.tile(log_mhost_mids, num_source_halos_per_bin) 39 | num_source_halos = len(source_halo_log_mhost) 40 | source_halo_id = np.arange(num_source_halos).astype(int) 41 | 42 | ngals_per_source_halo = 3 43 | num_source_galaxies = num_source_halos*ngals_per_source_halo 44 | source_galaxy_host_halo_id = np.repeat(source_halo_id, ngals_per_source_halo) 45 | 46 | source_halos_richness = compute_richness( 47 | source_halo_id, source_galaxy_host_halo_id) 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /halotools/utils/tests/test_io_utils.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from astropy.utils.data import get_pkg_data_filename 4 | 5 | from ..io_utils import file_len 6 | 7 | __all__ = ('test_file_len', ) 8 | 9 | 10 | def test_file_len(): 11 | fname = get_pkg_data_filename('data/dummy_ascii.dat') 12 | assert file_len(fname) == 4 13 | -------------------------------------------------------------------------------- /halotools/utils/tests/test_mcrotations.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | import numpy as np 4 | from astropy.utils.misc import NumpyRNGContext 5 | from ..vector_utilities import * 6 | from ..mcrotations import * 7 | 8 | __all__ = ('test_random_rotation_3d', 9 | 'test_random_rotation_3d', 10 | 'test_random_perpendicular_directions' ) 11 | 12 | fixed_seed = 43 13 | 14 | 15 | def test_random_rotation_3d(): 16 | """ 17 | simple unit test 18 | """ 19 | 20 | npts = 1000 21 | ndim = 3 22 | 23 | v1 = np.random.random((npts,ndim)) 24 | v2 = random_rotation_3d(v1) 25 | 26 | assert np.shape(v2) == (npts,ndim) 27 | assert np.all(v1 != v2) 28 | 29 | 30 | def test_random_rotation_2d(): 31 | """ 32 | simple unit test 33 | """ 34 | 35 | npts = 1000 36 | ndim = 2 37 | 38 | v1 = np.random.random((npts,ndim)) 39 | v2 = random_rotation_2d(v1) 40 | 41 | assert np.shape(v2) == (npts,ndim) 42 | assert np.all(v1 != v2) 43 | 44 | 45 | def test_random_perpendicular_directions(): 46 | """ 47 | check to make sure dot product is zero. 48 | """ 49 | 50 | npts = 1000 51 | ndim = 3 52 | 53 | v1 = normalized_vectors(np.random.random((npts,ndim))) 54 | v2 = random_perpendicular_directions(v1) 55 | 56 | assert np.allclose(elementwise_dot(v1,v2),np.zeros(npts)) 57 | 58 | -------------------------------------------------------------------------------- /halotools/utils/tests/test_python_string_comparisons.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | from ..python_string_comparisons import _passively_decode_string 4 | 5 | __all__ = ('test_passively_decode_string', ) 6 | 7 | 8 | def test_passively_decode_string(): 9 | __ = _passively_decode_string('a') 10 | __ = _passively_decode_string(1) 11 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | astropy 2 | numpy 3 | scipy 4 | requests 5 | beautifulsoup4 6 | cython 7 | h5py 8 | # setuptools is required as distutils is used directly 9 | setuptools 10 | -------------------------------------------------------------------------------- /scripts/README.rst: -------------------------------------------------------------------------------- 1 | Scripts 2 | ======= 3 | 4 | This directory contains command-line scripts for use with halotools. 5 | 6 | --------------------------------------------------------------------------------