Skip to content

Instantly share code, notes, and snippets.

@DavidMStraub
Created November 18, 2019 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidMStraub/778f8acc2261733b4aeeb21531e85195 to your computer and use it in GitHub Desktop.
Save DavidMStraub/778f8acc2261733b4aeeb21531e85195 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import h5py\n",
"f = h5py.File('pmc_321_th-only_50k.hdf5', 'r')\n",
"samples = f['/data/final/samples'][:]"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"data = samples[:,:23]\n",
"data[:, 0] = -data[:, 0] # xi' -> rho\n",
"data[:, 1] = 1/2 * data[:, 1] # xi'' -> c"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"cen = np.mean(data, axis=0)"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [],
"source": [
"err = np.std(data, axis=0)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"cov = np.cov(data.T)"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [],
"source": [
"corr = cov / np.outer(err, err)"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.2037, 0.1232, 1.0838, 0.0199, 0.0197, 0.2192, 0.02, 0.0609, 0.1748, 0.1853, 0.5612, 0.2298, 6.5741, 0.3621, 5.4689, 6.9501, 6.9014, 1.4028, 1.8169, 2.6673, 3.0142, 3.7579, 4.2467]\n"
]
}
],
"source": [
"print(list(np.round(err, 4)))"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[-1.0729, 0.4754, -3.7687, -0.0605, -0.0005, -0.0947, 0.04, -0.0982, 0.6118, -0.0046, -0.2978, 0.1252, -8.0423, -1.9132, -3.6415, -3.3573, 4.9115, -2.076, 0.1641, 3.3932, 0.0477, 2.1572, 0.6514]\n"
]
}
],
"source": [
"print(list(np.round(cen, 4)))"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(23, 23)"
]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"corr.shape"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[1.0, -0.951, 0.864, 0.014, -0.0, -0.582, -0.029, -0.014, -0.028, -0.021, 0.115, 0.008, -0.957, -0.026, -0.768, -0.036, 0.288, 0.025, 0.258, 0.209, -0.047, 0.081, 0.139], [-0.951, 1.0, -0.961, -0.013, 0.005, 0.567, 0.031, -0.144, 0.01, -0.005, -0.014, -0.012, 0.909, 0.034, 0.645, 0.108, -0.354, -0.01, -0.228, -0.311, 0.198, -0.082, -0.075], [0.864, -0.961, 1.0, 0.012, -0.008, -0.406, -0.026, 0.194, -0.002, 0.016, -0.036, 0.007, -0.829, -0.022, -0.627, -0.147, 0.332, 0.005, 0.201, 0.329, -0.201, 0.065, 0.065], [0.014, -0.013, 0.012, 1.0, 0.021, -0.017, -0.004, 0.052, 0.013, -0.007, -0.001, -0.005, 0.076, 0.008, 0.014, -0.05, -0.008, -0.018, 0.006, 0.006, -0.01, 0.022, -0.017], [-0.0, 0.005, -0.008, 0.021, 1.0, -0.097, 0.0, 0.18, -0.01, -0.01, 0.011, 0.011, 0.002, 0.006, 0.013, 0.008, -0.05, 0.012, 0.003, 0.012, -0.028, 0.009, -0.005], [-0.582, 0.567, -0.406, -0.017, -0.097, 1.0, 0.022, 0.174, 0.056, 0.053, -0.252, -0.002, 0.556, 0.048, 0.23, -0.139, -0.221, -0.051, -0.16, -0.054, 0.13, -0.144, 0.004], [-0.029, 0.031, -0.026, -0.004, 0.0, 0.022, 1.0, -0.18, 0.005, -0.01, 0.001, -0.004, -0.232, 0.005, 0.03, -0.002, -0.006, -0.006, 0.002, -0.016, 0.034, -0.012, 0.015], [-0.014, -0.144, 0.194, 0.052, 0.18, 0.174, -0.18, 1.0, -0.01, 0.028, -0.11, -0.031, 0.061, -0.02, 0.266, -0.264, 0.182, 0.027, 0.095, 0.393, -0.53, 0.009, -0.185], [-0.028, 0.01, -0.002, 0.013, -0.01, 0.056, 0.005, -0.01, 1.0, -0.218, -0.224, 0.01, 0.028, 0.009, -0.0, 0.101, 0.005, -0.973, 0.182, -0.061, -0.051, 0.376, -0.168], [-0.021, -0.005, 0.016, -0.007, -0.01, 0.053, -0.01, 0.028, -0.218, 1.0, -0.396, 0.004, 0.022, 0.009, 0.032, -0.05, 0.143, 0.212, -0.8, 0.002, -0.078, -0.075, 0.245], [0.115, -0.014, -0.036, -0.001, 0.011, -0.252, 0.001, -0.11, -0.224, -0.396, 1.0, -0.042, -0.115, -0.0, -0.185, 0.328, -0.306, 0.21, 0.294, -0.151, 0.233, 0.143, 0.007], [0.008, -0.012, 0.007, -0.005, 0.011, -0.002, -0.004, -0.031, 0.01, 0.004, -0.042, 1.0, -0.004, -0.001, 0.022, -0.004, -0.0, 0.064, -0.105, -0.027, -0.013, -0.012, -0.011], [-0.957, 0.909, -0.829, 0.076, 0.002, 0.556, -0.232, 0.061, 0.028, 0.022, -0.115, -0.004, 1.0, 0.024, 0.74, 0.031, -0.277, -0.031, -0.25, -0.205, 0.036, -0.077, -0.139], [-0.026, 0.034, -0.022, 0.008, 0.006, 0.048, 0.005, -0.02, 0.009, 0.009, -0.0, -0.001, 0.024, 1.0, -0.048, -0.0, -0.011, -0.007, -0.015, -0.027, 0.018, -0.023, 0.026], [-0.768, 0.645, -0.627, 0.014, 0.013, 0.23, 0.03, 0.266, -0.0, 0.032, -0.185, 0.022, 0.74, -0.048, 1.0, -0.127, -0.092, -0.004, -0.214, 0.053, -0.171, -0.081, -0.257], [-0.036, 0.108, -0.147, -0.05, 0.008, -0.139, -0.002, -0.264, 0.101, -0.05, 0.328, -0.004, 0.031, -0.0, -0.127, 1.0, -0.796, -0.101, 0.001, -0.419, 0.091, 0.756, -0.448], [0.288, -0.354, 0.332, -0.008, -0.05, -0.221, -0.006, 0.182, 0.005, 0.143, -0.306, -0.0, -0.277, -0.011, -0.092, -0.796, 1.0, -0.004, -0.024, 0.268, -0.193, -0.617, 0.63], [0.025, -0.01, 0.005, -0.018, 0.012, -0.051, -0.006, 0.027, -0.973, 0.212, 0.21, 0.064, -0.031, -0.007, -0.004, -0.101, -0.004, 1.0, -0.141, 0.071, 0.045, -0.363, 0.158], [0.258, -0.228, 0.201, 0.006, 0.003, -0.16, 0.002, 0.095, 0.182, -0.8, 0.294, -0.105, -0.25, -0.015, -0.214, 0.001, -0.024, -0.141, 1.0, 0.087, 0.04, 0.078, -0.173], [0.209, -0.311, 0.329, 0.006, 0.012, -0.054, -0.016, 0.393, -0.061, 0.002, -0.151, -0.027, -0.205, -0.027, 0.053, -0.419, 0.268, 0.071, 0.087, 1.0, -0.597, 0.101, -0.271], [-0.047, 0.198, -0.201, -0.01, -0.028, 0.13, 0.034, -0.53, -0.051, -0.078, 0.233, -0.013, 0.036, 0.018, -0.171, 0.091, -0.193, 0.045, 0.04, -0.597, 1.0, -0.256, 0.417], [0.081, -0.082, 0.065, 0.022, 0.009, -0.144, -0.012, 0.009, 0.376, -0.075, 0.143, -0.012, -0.077, -0.023, -0.081, 0.756, -0.617, -0.363, 0.078, 0.101, -0.256, 1.0, -0.74], [0.139, -0.075, 0.065, -0.017, -0.005, 0.004, 0.015, -0.185, -0.168, 0.245, 0.007, -0.011, -0.139, 0.026, -0.257, -0.448, 0.63, 0.158, -0.173, -0.271, 0.417, -0.74, 1.0]]\n"
]
}
],
"source": [
"print(np.round(corr, 3).tolist())"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {},
"outputs": [],
"source": [
"parameters = \"\"\"CLN rho2_xi\n",
"CLN c_xi\n",
"CLN xi3\n",
"chi_2(1)\n",
"chi_2p(1)\n",
"chi_2pp(1)\n",
"chi_3p(1)\n",
"chi_3pp(1)\n",
"eta(1)\n",
"etap(1)\n",
"etapp(1)\n",
"CLN l_1(1)\n",
"CLN lp_1(1)\n",
"CLN l_2(1)\n",
"CLN lp_2(1)\n",
"CLN l_3(1)\n",
"CLN lp_3(1)\n",
"CLN l_4(1)\n",
"CLN lp_4(1)\n",
"CLN l_5(1)\n",
"CLN lp_5(1)\n",
"CLN l_6(1)\n",
"CLN lp_6(1)\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['CLN rho2_xi',\n",
" 'CLN c_xi',\n",
" 'CLN xi3',\n",
" 'chi_2(1)',\n",
" 'chi_2p(1)',\n",
" 'chi_2pp(1)',\n",
" 'chi_3p(1)',\n",
" 'chi_3pp(1)',\n",
" 'eta(1)',\n",
" 'etap(1)',\n",
" 'etapp(1)',\n",
" 'CLN l_1(1)',\n",
" 'CLN lp_1(1)',\n",
" 'CLN l_2(1)',\n",
" 'CLN lp_2(1)',\n",
" 'CLN l_3(1)',\n",
" 'CLN lp_3(1)',\n",
" 'CLN l_4(1)',\n",
" 'CLN lp_4(1)',\n",
" 'CLN l_5(1)',\n",
" 'CLN lp_5(1)',\n",
" 'CLN l_6(1)',\n",
" 'CLN lp_6(1)']"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"parameters.splitlines()"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"- CLN rho2_xi: -1.073 ± 0.204\n",
"- CLN c_xi: 0.475 ± 0.123\n",
"- CLN xi3: -3.769 ± 1.084\n",
"- chi_2(1): -0.060 ± 0.020\n",
"- chi_2p(1): -0.000 ± 0.020\n",
"- chi_2pp(1): -0.095 ± 0.219\n",
"- chi_3p(1): 0.040 ± 0.020\n",
"- chi_3pp(1): -0.098 ± 0.061\n",
"- eta(1): 0.612 ± 0.175\n",
"- etap(1): -0.005 ± 0.185\n",
"- etapp(1): -0.298 ± 0.561\n",
"- CLN l_1(1): 0.125 ± 0.230\n",
"- CLN lp_1(1): -8.042 ± 6.574\n",
"- CLN l_2(1): -1.913 ± 0.362\n",
"- CLN lp_2(1): -3.641 ± 5.469\n",
"- CLN l_3(1): -3.357 ± 6.950\n",
"- CLN lp_3(1): 4.911 ± 6.901\n",
"- CLN l_4(1): -2.076 ± 1.403\n",
"- CLN lp_4(1): 0.164 ± 1.817\n",
"- CLN l_5(1): 3.393 ± 2.667\n",
"- CLN lp_5(1): 0.048 ± 3.014\n",
"- CLN l_6(1): 2.157 ± 3.758\n",
"- CLN lp_6(1): 0.651 ± 4.247\n"
]
}
],
"source": [
"for i, p in enumerate(parameters.splitlines()):\n",
" print('- {}: {:.3f} ± {:.3f}'.format(p, cen[i], err[i]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment