diff --git a/notebooks/mflike_tutorial.ipynb b/notebooks/mflike_tutorial.ipynb index 0588b74..5e8462c 100644 --- a/notebooks/mflike_tutorial.ipynb +++ b/notebooks/mflike_tutorial.ipynb @@ -27,8 +27,8 @@ "text": [ " Numpy : 1.23.1\n", "Matplotlib : 3.3.3\n", - " CAMB : 1.4.0\n", - " Cobaya : 3.2.2\n" + " CAMB : 1.5.0\n", + " Cobaya : 3.4.1\n" ] } ], @@ -96,25 +96,32 @@ " \"a_psee\": 0.003,\n", " \"a_pste\": 0.042,\n", " \"xi\": 0.10,\n", + " \"beta_s\": -2.5, #beta radio\n", + " \"alpha_s\": 1, #alpha radio\n", + " \"T_effd\": 19.6, #effective galactic dust temperature\n", + " \"beta_d\": 1.5, #beta galactic dust\n", + " \"alpha_dT\": -0.6, #galactic dust ell slope for T\n", + " \"alpha_dE\": -0.4, #galactic dust ell slope for E\n", + " \"alpha_p\": 1, #CIB poisson ell slope \n", "}\n", "\n", "nuisance_params = {\n", " \"bandint_shift_LAT_93\": 0, # only ideal values for now\n", " \"bandint_shift_LAT_145\": 0,\n", " \"bandint_shift_LAT_225\": 0,\n", - " \"calT_LAT_93\": 1,\n", + " # \"calT_LAT_93\": 1,\n", " \"calE_LAT_93\": 1,\n", - " \"calT_LAT_145\": 1,\n", + " # \"calT_LAT_145\": 1,\n", " \"calE_LAT_145\": 1,\n", - " \"calT_LAT_225\": 1,\n", + " # \"calT_LAT_225\": 1,\n", " \"calE_LAT_225\": 1,\n", " \"cal_LAT_93\": 1,\n", " \"cal_LAT_145\": 1,\n", " \"cal_LAT_225\": 1,\n", - " \"calG_all\": 1,\n", - " \"alpha_LAT_93\": 0,\n", - " \"alpha_LAT_145\": 0,\n", - " \"alpha_LAT_225\": 0,\n", + " # \"calG_all\": 1,\n", + " # \"alpha_LAT_93\": 0,\n", + " # \"alpha_LAT_145\": 0,\n", + " # \"alpha_LAT_225\": 0,\n", "}" ] }, @@ -187,6 +194,16 @@ "Pass --enable-32bits-pci-domain to configure to support such devices\n", "(warning: it would break the library ABI, don't enable unless really needed).\n" ] + }, + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ @@ -369,7 +386,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -409,7 +426,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -430,7 +447,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -478,7 +495,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -495,7 +512,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -516,7 +533,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -566,7 +583,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -594,7 +611,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -615,7 +632,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -656,7 +673,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -698,7 +715,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -710,7 +727,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 21, "metadata": {}, "outputs": [], "source": [ @@ -726,7 +743,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 22, "metadata": {}, "outputs": [ { @@ -789,14 +806,14 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "/home/serenagiardiello/.local/lib/python3.8/site-packages/sacc/sacc.py:370: UserWarning: Empty index selected - maybe you should check the tracer order?\n", + "/home/serenagiardiello/anaconda3/envs/mflike/lib/python3.8/site-packages/sacc/sacc.py:378: UserWarning: Empty index selected - maybe you should check the tracer order?\n", " warnings.warn(\"Empty index selected - maybe you \"\n" ] }, @@ -882,7 +899,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ @@ -892,11 +909,17 @@ " k: {\n", " \"prior\": {\n", " \"min\": 0.9 * v if v != 0 else -0.5,\n", - " \"max\": 1.1 * v if v != 0 else +0.5,\n", + " \"max\": 1.1 * v if (v != 0 and v > 0) else +0.5,\n", " }\n", " }\n", " for k, v in sampled_params.items()\n", - " if k not in [\"logA\", \"As\"]\n", + " if k not in [\"logA\", \"As\",\"beta_s\",\n", + " \"alpha_s\",\n", + " \"T_effd\",\n", + " \"beta_d\",\n", + " \"alpha_dT\",\n", + " \"alpha_dE\",\n", + " \"alpha_p\" ]\n", " }\n", ")\n", "\n", @@ -909,6 +932,65 @@ "}" ] }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'cosmomc_theta': {'prior': {'min': 0.009368280000000001,\n", + " 'max': 0.011450120000000001}},\n", + " 'logA': {'prior': {'min': 2.7396000000000003, 'max': 3.3484000000000003},\n", + " 'drop': True},\n", + " 'As': {'value': 'lambda logA: 1e-10*np.exp(logA)'},\n", + " 'ombh2': {'prior': {'min': 0.020133, 'max': 0.024607000000000004}},\n", + " 'omch2': {'prior': {'min': 0.108, 'max': 0.132}},\n", + " 'ns': {'prior': {'min': 0.86841, 'max': 1.06139}},\n", + " 'Alens': {'prior': {'min': 0.9, 'max': 1.1}},\n", + " 'tau': {'prior': {'min': 0.04896, 'max': 0.059840000000000004}},\n", + " 'a_tSZ': {'prior': {'min': 2.9699999999999998, 'max': 3.63}},\n", + " 'a_kSZ': {'prior': {'min': 1.4400000000000002, 'max': 1.7600000000000002}},\n", + " 'a_p': {'prior': {'min': 6.210000000000001, 'max': 7.590000000000001}},\n", + " 'beta_p': {'prior': {'min': 1.9800000000000002, 'max': 2.4200000000000004}},\n", + " 'a_c': {'prior': {'min': 4.41, 'max': 5.390000000000001}},\n", + " 'beta_c': {'prior': {'min': 1.9800000000000002, 'max': 2.4200000000000004}},\n", + " 'a_s': {'prior': {'min': 2.79, 'max': 3.4100000000000006}},\n", + " 'T_d': {'prior': {'min': 8.64, 'max': 10.56}},\n", + " 'a_gtt': {'prior': {'min': 2.52, 'max': 3.08}},\n", + " 'a_gte': {'prior': {'min': 0.09000000000000001, 'max': 0.11000000000000001}},\n", + " 'a_gee': {'prior': {'min': 0.09000000000000001, 'max': 0.11000000000000001}},\n", + " 'a_psee': {'prior': {'min': 0.0027, 'max': 0.0033000000000000004}},\n", + " 'a_pste': {'prior': {'min': 0.0378, 'max': 0.046200000000000005}},\n", + " 'xi': {'prior': {'min': 0.09000000000000001, 'max': 0.11000000000000001}},\n", + " 'beta_s': -2.5,\n", + " 'alpha_s': 1,\n", + " 'T_effd': 19.6,\n", + " 'beta_d': 1.5,\n", + " 'alpha_dT': -0.6,\n", + " 'alpha_dE': -0.4,\n", + " 'alpha_p': 1,\n", + " 'bandint_shift_LAT_93': {'prior': {'min': -0.5, 'max': 0.5}},\n", + " 'bandint_shift_LAT_145': {'prior': {'min': -0.5, 'max': 0.5}},\n", + " 'bandint_shift_LAT_225': {'prior': {'min': -0.5, 'max': 0.5}},\n", + " 'calE_LAT_93': {'prior': {'min': 0.9, 'max': 1.1}},\n", + " 'calE_LAT_145': {'prior': {'min': 0.9, 'max': 1.1}},\n", + " 'calE_LAT_225': {'prior': {'min': 0.9, 'max': 1.1}},\n", + " 'cal_LAT_93': {'prior': {'min': 0.9, 'max': 1.1}},\n", + " 'cal_LAT_145': {'prior': {'min': 0.9, 'max': 1.1}},\n", + " 'cal_LAT_225': {'prior': {'min': 0.9, 'max': 1.1}}}" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sampled_params" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -921,7 +1003,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -958,7 +1040,27 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['cosmomc_theta', 'logA', 'ombh2', 'omch2', 'ns', 'Alens', 'tau', 'a_tSZ', 'a_kSZ', 'a_p', 'beta_p', 'a_c', 'beta_c', 'a_s', 'T_d', 'a_gtt', 'a_gte', 'a_gee', 'a_psee', 'a_pste', 'xi', 'bandint_shift_LAT_93', 'bandint_shift_LAT_145', 'bandint_shift_LAT_225', 'calE_LAT_93', 'calE_LAT_145', 'calE_LAT_225', 'cal_LAT_93', 'cal_LAT_145', 'cal_LAT_225'])" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "model.parameterization.sampled_params().keys()" + ] + }, + { + "cell_type": "code", + "execution_count": 28, "metadata": {}, "outputs": [], "source": [ @@ -977,7 +1079,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 29, "metadata": {}, "outputs": [], "source": [ @@ -1001,7 +1103,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -1014,11 +1116,21 @@ ], "source": [ "deriv = {k: None for k in fisher_params}\n", + "fg_fix = {\"beta_s\": -2.5, #beta radio\n", + " \"alpha_s\": 1, #alpha radio\n", + " \"T_effd\": 19.6, #effective galactic dust temperature\n", + " \"beta_d\": 1.5, #beta galactic dust\n", + " \"alpha_dT\": -0.6, #galactic dust ell slope for T\n", + " \"alpha_dE\": -0.4, #galactic dust ell slope for E\n", + " \"alpha_p\": 1, #CIB poisson ell slope \n", + "}\n", + "\n", "for i, p in enumerate(fisher_params):\n", "\n", " def _get_power_spectra(epsilon):\n", " point = defaults.copy()\n", " point.update({p: point[p] * (1 + epsilon) if point[p] != 0 else point[p] + epsilon})\n", + " point.update(fg_fix)\n", " model.logposterior(point)\n", " cl = model.theory[\"camb\"].get_Cl(ell_factor=True)\n", " return mflike._get_power_spectra(cl, **point)\n", @@ -1058,7 +1170,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 31, "metadata": {}, "outputs": [ { @@ -1112,32 +1224,32 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "param: cosmomc_theta, sigma: 1.4053440860980095e-06, Fisher S/N: 7406.869323299701\n", - "param: logA, sigma: 0.01855164505777501, Fisher S/N: 164.08248381855805\n", - "param: ombh2, sigma: 6.30669212421406e-05, Fisher S/N: 354.70258511767366\n", - "param: omch2, sigma: 0.0011026235986169512, Fisher S/N: 108.83133659620476\n", - "param: ns, sigma: 0.0031898296323270353, Fisher S/N: 302.4926441905579\n", - "param: tau, sigma: 0.010459712037500625, Fisher S/N: 5.20090799870615\n", - "param: a_tSZ, sigma: 0.06920457173257455, Fisher S/N: 47.68471095742208\n", - "param: a_kSZ, sigma: 0.14426113756334474, Fisher S/N: 11.09099808184615\n", - "param: a_p, sigma: 0.04943973006023647, Fisher S/N: 139.56386880739774\n", - "param: beta_p, sigma: 0.007950350536488635, Fisher S/N: 276.71735854953334\n", - "param: a_c, sigma: 0.12552552490040478, Fisher S/N: 39.035885361863954\n", - "param: beta_c, sigma: 0.02338641763845622, Fisher S/N: 94.07169725654596\n", - "param: a_s, sigma: 0.01111388203280301, Fisher S/N: 278.9304395035184\n", - "param: a_gtt, sigma: 0.21178590795462116, Fisher S/N: 13.220898534004203\n", - "param: a_gte, sigma: 0.014857196412751907, Fisher S/N: 6.730744968422856\n", - "param: a_gee, sigma: 0.0023950784545167104, Fisher S/N: 41.752285738872985\n", - "param: a_psee, sigma: 0.004542298460564408, Fisher S/N: 0.6604585819372231\n", - "param: a_pste, sigma: 0.0034694877635880386, Fisher S/N: 12.105533399133503\n", - "param: xi, sigma: 0.007469144085455909, Fisher S/N: 13.388414904824547\n" + "param: cosmomc_theta, sigma: 1.4053440860980404e-06, Fisher S/N: 7406.869323299538\n", + "param: logA, sigma: 0.018551645057774506, Fisher S/N: 164.08248381856248\n", + "param: ombh2, sigma: 6.306692124213734e-05, Fisher S/N: 354.7025851176921\n", + "param: omch2, sigma: 0.0011026235986169705, Fisher S/N: 108.83133659620286\n", + "param: ns, sigma: 0.003189829632327165, Fisher S/N: 302.4926441905456\n", + "param: tau, sigma: 0.010459712037500509, Fisher S/N: 5.2009079987062075\n", + "param: a_tSZ, sigma: 0.06920457173258697, Fisher S/N: 47.68471095741352\n", + "param: a_kSZ, sigma: 0.14426113756336395, Fisher S/N: 11.090998081844672\n", + "param: a_p, sigma: 0.049439730060229836, Fisher S/N: 139.56386880741644\n", + "param: beta_p, sigma: 0.00795035053648887, Fisher S/N: 276.7173585495251\n", + "param: a_c, sigma: 0.12552552490037042, Fisher S/N: 39.03588536187464\n", + "param: beta_c, sigma: 0.02338641763845552, Fisher S/N: 94.07169725654877\n", + "param: a_s, sigma: 0.011113882032803496, Fisher S/N: 278.9304395035062\n", + "param: a_gtt, sigma: 0.2117859079545539, Fisher S/N: 13.2208985340084\n", + "param: a_gte, sigma: 0.01485719641275419, Fisher S/N: 6.730744968421822\n", + "param: a_gee, sigma: 0.002395078454516678, Fisher S/N: 41.75228573887355\n", + "param: a_psee, sigma: 0.004542298460563816, Fisher S/N: 0.660458581937309\n", + "param: a_pste, sigma: 0.003469487763588105, Fisher S/N: 12.105533399133272\n", + "param: xi, sigma: 0.007469144085457632, Fisher S/N: 13.38841490482146\n" ] } ], @@ -1156,7 +1268,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -1212,7 +1324,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 34, "metadata": {}, "outputs": [ { @@ -1249,7 +1361,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 35, "metadata": {}, "outputs": [], "source": [ @@ -1281,7 +1393,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 36, "metadata": {}, "outputs": [ { @@ -1333,13 +1445,14 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 37, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ + "[mflike] Computing bandpass at first step, no shifts\n", "log-likelihood value = -3578.006563536072\n", "Χ² value = 3079.648922352865\n" ] @@ -1361,9 +1474,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "mflike", "language": "python", - "name": "python3" + "name": "mflike" }, "language_info": { "codemirror_mode": { @@ -1375,7 +1488,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.8.15" }, "org": null, "widgets": {