{"id":18620504,"url":"https://github.com/simonsobs/hmvec","last_synced_at":"2025-04-11T02:31:08.175Z","repository":{"id":53755073,"uuid":"166606038","full_name":"simonsobs/hmvec","owner":"simonsobs","description":"Vectorized halo model code written entirely in pure Python / numpy ","archived":false,"fork":false,"pushed_at":"2025-02-12T03:02:50.000Z","size":7679,"stargazers_count":9,"open_issues_count":4,"forks_count":10,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-25T08:11:35.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonsobs.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-19T23:56:20.000Z","updated_at":"2025-03-10T13:40:44.000Z","dependencies_parsed_at":"2022-09-11T17:51:29.880Z","dependency_job_id":"54f4e92b-18a6-4545-950e-ab91472bc70c","html_url":"https://github.com/simonsobs/hmvec","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fhmvec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fhmvec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fhmvec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fhmvec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonsobs","download_url":"https://codeload.github.com/simonsobs/hmvec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248329547,"owners_count":21085557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T04:06:37.513Z","updated_at":"2025-04-11T02:31:06.654Z","avatar_url":"https://github.com/simonsobs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=======\nhmvec\n=======\n\n`hmvec` is a fast pure Python/numpy vectorized general halo model and HOD code. Currently, it includes support for (a) 3d power spectra involving NFW, Battaglia electron density profiles and galaxy HODs and (b) 2d power spectra including tSZ, cosmic shear, galaxy-galaxy lensing and CMB lensing.\n\nIt calculates a vectorized FFT for a given profile over all points in mass and\nredshift, but it currently does have one double loop over mass and redshift\nto interpolate the profile Fourier transforms to the target wavenumbers. Every\nother part of the code is vectorized. Heavy memory usage can be an issue -- watch out for that!\n\n\n* Free software: BSD license\n* Documentation: in the works\n\nDependencies\n------------\n\n* Python\u003e=2.7 or Python\u003e=3.4\n* numpy, scipy, matplotlib\n* camb (Python package, recommend using `dev` branch)\n\nCredits\n-------\n\nThe theory used here follows the approach outlined in the appendix of\narxiv:1810.13423. This code has greatly benefited from comparisons with the\nimplementation written by Moritz\nMunchmeyer and Matt Johnson for that paper. Some of the HOD functions are copied (and\nmodified) from there.\n\nInstallation\n------------\n\nClone this repository and install with symbolic links as follows\nso that changes you make to the code are immediately reflected.\n\n\n.. code-block:: console\n\n   pip install -e . --user\n\n\t\t\t\t\n\nUsage\n-----\n\nOne can quickly get the matter power spectrum for desired wavenumbers and\nredshifts after specifying the mass grid to integrate over. Note that\nthe analytic NFW profile is initialized by default.\n\n.. code-block:: python\n\t\t\n\timport hmvec as hm\n\tzs = np.linspace(0.,3.,20)\n\tms = np.geomspace(2e10,1e17,200)\n\tks = np.geomspace(1e-4,100,1001)\n\thcos = hm.HaloModel(zs,ks,ms=ms)\n\tpmm_1h = hcos.get_power_1halo(name=\"nfw\")\n\tpmm_2h = hcos.get_power_2halo(name=\"nfw\")\n\nYou can add functions that implement a profile of your choice. An electron\nprofile from Battaglia 2016 has also been implemented. It needs to\nbe FFTd numerically to get the electron power spectrum, which is done as follows:\n\n\n.. code-block:: python\n\t\t\t\t\n   hcos.add_battaglia_profile(\"electron\",family=\"AGN\",xmax=20,nxs=5000)\n   pee_1h = hcos.get_power_1halo(name=\"electron\")\n   pee_2h = hcos.get_power_2halo(name=\"electron\")\n\t\nCross-spectra can also be calculated:\n\n.. code-block:: python\n\t\t\t\t\n   pme_1h = hcos.get_power_1halo(\"nfw\",\"electron\")\n   pme_2h = hcos.get_power_2halo(\"nfw\",\"electron\")\n   \nAn HOD can be added as follows:\n\n.. code-block:: python\n\t\t\t\t\n   hcos.add_hod(name=\"g\",mthresh=10**10.5+zs*0.)\n\nand galaxy spectra and cross-spectra with matter and electrons can be\ncalculated just as above by specifying the chosen name for the HOD.\nIf the galaxy number density `ngal` is provided instead of `mthresh`,\nthe latter will be found iteratively.\n\nCosmic Shear / CMB Lensing autospectrum\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n`HaloModel` inherits from `cosmology.Cosmology` which contains some\nconvenient functions involving Limber integrals. To get a cosmic shear\npower spectrum for example, you first build the total matter power\nspectrum and pass it to the relevant member function of `cosmology.Cosmology`,\n\n.. code-block:: python\n\t\t\t\t\n   pmm_1h = hcos.get_power_1halo(name=\"nfw\")\n   pmm_2h = hcos.get_power_2halo(name=\"nfw\")\n   Pmm = pmm_1h + pmm_2h\n   \n   ells = np.linspace(100,600,10)\n   Cls = hcos.C_kk(ells,zs,ks,Pmm,lzs1=2.5,lzs2=2.5)\n\n\nGalaxy-galaxy lensing / Galaxy-CMB lensing\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nSimilarly, one can obtain cross-spectra for galaxy-galaxy lensing\nand galaxy-CMB lensing,\n\n.. code-block:: python\n\t\t\t\t\n   hcos.add_hod(name=\"g\",mthresh=10**10.5+zs*0.)\n   pgm_1h = hcos.get_power_1halo(\"nfw\",\"electron\")\n   pgm_2h = hcos.get_power_2halo(\"nfw\",\"electron\")\n   Pgm = pgm_1h + pgm_2h\n   \n   ells = np.linspace(100,600,10)\n   Cls = hcos.C_kg(ells,zs,ks,Pgm,gzs=0.8,lzs=2.5)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonsobs%2Fhmvec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonsobs%2Fhmvec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonsobs%2Fhmvec/lists"}