mirror of
https://github.com/Richard-Sti/csiborgtools.git
synced 2024-12-23 03:28:03 +00:00
113 lines
55 KiB
Text
113 lines
55 KiB
Text
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# $P(k, H_0)$\n",
|
||
|
"\n",
|
||
|
"Quick notebook to see how the power spectrum depends on $H_0$."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import numpy as np\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import camb\n",
|
||
|
"from camb import model\n",
|
||
|
"\n",
|
||
|
"%matplotlib inline"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 19,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def get_pk(h):\n",
|
||
|
" pars = camb.CAMBparams()\n",
|
||
|
"\n",
|
||
|
" pars.set_cosmology(H0=h*100, ombh2=0.04825 * h**2, omch2=(0.307 - 0.04825) * h**2)\n",
|
||
|
" pars.InitPower.set_params(ns=0.9611)\n",
|
||
|
" pars.set_matter_power(redshifts=[0.], kmax=40)\n",
|
||
|
"\n",
|
||
|
" #Non-Linear spectra (Halofit)\n",
|
||
|
" pars.NonLinear = model.NonLinear_both\n",
|
||
|
" results = camb.get_results(pars)\n",
|
||
|
" results.calc_power_spectra(pars)\n",
|
||
|
" kh_nonlin, z_nonlin, pk_nonlin = results.get_matter_power_spectrum(minkh=1e-3, maxkh=50, npoints = 200)\n",
|
||
|
"\n",
|
||
|
" return kh_nonlin, pk_nonlin[0]\n",
|
||
|
"\n",
|
||
|
"kh_nonlin, pk_nonlin_reference = get_pk(0.705)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 25,
|
||
|
"metad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aGYlp3P2fh0Im+kExZzi4OXkknJ0rPr3E12nbsJQBU3B3o29KZ3kC/1fV0e+vsWQoi/Ex4eTu3atbGzsyt87cSJE7i6uhIQEGC29xk8eDA3b95kypQpxMfHExwczObNm4ssqEhKSuLSpUtFvq558+asXr2at99+mw8//JBq1aoxffp0nnvuOUBp1TJkyBCSk5Px8PCgbdu2HDp0CA8PD7PV/nc0JtPDNFwo/dLT03FxcSEtLQ1nZ2e1yxEWIjVbz/c7LrLg4BXyDcr/Mu1qujO+UyAh1dwe6s5Vdn42xxOPczT+KKeTThOZHElmfqZZ661gXYHqLtWp5lKNGq41qONWh/qV6uNi+2gBzGg0ERWfwYFLSey/mMTBy8nk5hsLjzetWpERraryZEMfGa4VohTJzc0lOjqaatWqFQlJovS539/Vw2QbCXZC3Ie+wMivh67y3fYLpOXkA0qge6t7HRr6PXhIis2IZWfMTnZd28WJhBMUmAqKHLfR2lDVpSrVnKtR2akyXg5euNu742TjRAXrCtjqbNGghEe9QU9OQQ4Z+gwScxJJzL7ziM+KJzYjFoPp3n2qqjhVoYF7g8JHHbc62FvZP/SfS7a+gF3nbrL+5A22nEmg4PbdS383eyZ2qkm/JpUl4AlRCkiwKzsk2P0NCXbCXHZGJfLB72cKGwLX9nLinafqFs5N+yfJOclsvrKZ9ZfWczr5dJFjPhV8aOHdgiZeTahfqT41XGtgpTXPzIh8Qz5X069yOe0yl9Mucyn1EpHJkcRkxNx1rk6jI9A1kAbuDajvXp/6leoT6BqIje7B+9wlZuTy25FYFhy8SlJmHgBVKznwzpN1eaKel8zDE0JFEuz
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.figure()\n",
|
||
|
"\n",
|
||
|
"for h in [0.65, 0.70, 0.75]:\n",
|
||
|
" __, pk = get_pk(h)\n",
|
||
|
" plt.plot(kh_nonlnie, pk / pk_nonlin_reference, label=r\"$h = {}$\".format(h))\n",
|
||
|
"\n",
|
||
|
"plt.legend()\n",
|
||
|
"plt.xscale(\"log\")\n",
|
||
|
"plt.xlabel(r\"$k ~ [h / \\mathrm{Mpc}]$\")\n",
|
||
|
"plt.ylabel(r\"$P(k, h) / P(k, h=0.705)$\")\n",
|
||
|
"\n",
|
||
|
"plt.tight_layout()\n",
|
||
|
"plt.savefig(\"../plots/pk_h0_dependence.png\", dpi=450)\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "venv_csiborg",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.11.7"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|