{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "# Example power spectrum calculation\n",
    "In this example, we will calculate the matter power spectrum using a couple of different methods."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pyccl as ccl\n",
    "import pylab as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "We begin by defining a set of cosmological parameters, as usual:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "cosmo = ccl.Cosmology(Omega_c=0.27, Omega_b=0.045, h=0.67, A_s=2.1e-9, n_s=0.96, \n",
    "                      transfer_function='boltzmann')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Note that we have explicitly defined how transfer functions should be calculated for the linear matter power spectrum, by using the `transfer_function` keyword argument. The following types of transfer function are available:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['boltzmann', 'boltzmann_class', 'none', 'emulator', 'fitting_function', 'camb', 'class', 'bbks', 'eisenstein_hu', 'boltzmann_camb']\n"
     ]
    }
   ],
   "source": [
    "print ccl.core.transfer_function_types.keys()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "The default is `boltzmann_class`, which uses a full transfer function calculation from the CLASS Boltzmann code. This is one of the most accurate options at the level of linear pertubation theory, but will be less accurate at non-linear scales.\n",
    "\n",
    "(To improve precision on non-linear scales, one would eventually choose `emulator`, which will use a suite of fast N-body simulations to model the matter transfer function. This is not currently implemented.)\n",
    "\n",
    "If we were less interested in precision but wanted to improve speed, we could have chosen the `eisenstein_hu` option instead.\n",
    "\n",
    "Likewise, the `Cosmology()` object constructor also has a `matter_power_spectrum` argument that can be changed. There is no need to do this for now, however."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "### How CCL caches results\n",
    "Now, we can calculate the linear and non-linear matter power spectra as a function of wavenumber. Before we do that though, let's just perform a quick test to see how CCL caches the results of calculations:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "print cosmo.has_power()\n",
    "print cosmo.has_sigma()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Both of these status indicators are `False`, showing that CCL hasn't yet computer power spectra (transfer functions) or sigma(R); the cache is currently empty. When we calculate the power spectrum, though, the result will be stored (and splined) for future use.\n",
    "\n",
    "### Calculate the matter power spectrum\n",
    "Now, let's calculate the power spectra:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "k = np.logspace(-4., 1., 100) # Wavenumber\n",
    "a = 1. # Scale factor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "pk_lin = ccl.linear_matter_power(cosmo, k, a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "pk_nl = ccl.nonlin_matter_power(cosmo, k, a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAEHCAYAAABGNUbLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmcjXX/x/HX1zAoW0giUlEISbKVTElGtiJrSZJ+LRRK\n6iZjTVpQUZS4u1uQEia5y10mSqXSIlsku5ChrDEz398f39EMjXFm5pxzneX9fNwet3Od61zXx/WY\nPvM93+XzNdZaREQkuuTzOgAREQk+JX8RkSik5C8iEoWU/EVEopCSv4hIFFLyFxGJQkr+IiJRSMlf\nRCQKBTT5G2PijDFLjDEvGWOaBPJeIiLiu0C3/NOA/UBBYGuA7yUiIj7KcfI3xkw1xuw0xqw46Xi8\nMWaNMWadMWZg+uEl1tobgUeBYX6IV0RE/CA3Lf9pQHzmA8aYGGBC+vHqQBdjTDWbUThoH671LyIi\nISB/Tj9grV1ijKl00uF6wHpr7UYAY8wMoK0xpirQHCgBvJCnSEVExG9ynPxPoTywJdPrrUB9a+2T\nwHvZfdAYo7KiIiK5YK01uf2svwZ885TAExISWLRoEdbaPP9JSEjw+/mnOier474cy/z6VH/Xswjt\nZ5Hd+3oWehaBfBaLFi0iISEhz0nbXy3/bUCFTK8rkIPZPUOHDvVTGBAXF+f38091TlbHfTmW+XVO\n482JcHgWjRrF8fPKY+z8bjuxa0ryTqdZpCXv46eVS3l7xhCsteD+R1rBM0grURJKliSm3DmUqFuZ\n8648l4sqG844I+//tpycn9370fZzoWfh2/v+ehbH/wwblrc5NMbanDfa0/v8E621NdNf5wfWAk2B\n7cAyoIu1drUP17IJCQl//4Oi2dChQ/36izCUWAvbfj3Kutkr2LfoO2LWrqLEjlVUOrSasuxgX8Fz\n+KN4Rf46qyxpxc/ipd9X0ueK5pj8MQAYLPbgIUhOxuzbS2zyDkr+vo4CKYf42VZhXfEr2X/Z1RRr\ncRV1O1zABRfm+ttwyInk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P65MMAYoKnX/wavn0Wmc2d5/W/w8HncBrRM\nP2e617F7+Sxy+vOQlxW+PrHWLkkvDZHZ33WBAIwxx+sCPQm8nn7O4PT3ugO7bfq/Kpzl9lkYY5oA\n7YBCwKJgxRtIeXgWDwBNgWLGmMrW2slBCzpA8vAsSgJPkF47y1o7JmhBB1BOngfwPDAhfVww4tYZ\n5eRZGGN2koOfh4An/1PI/FUN3Mrg+lmdaK19LSgReee0z8Ja+ynwaTCD8ogvz+J53H/wkc6XZ5EM\n3BPMoDyU5fOw1h4C7vQmJM+c6lnk6OfBq9k+Yd+K9yM9iwx6Fhn0LE6k55HBL8/Cq+SvukAZ9Cwy\n6Flk0LM4kZ5HBr88C6+Sv+oCZdCzyKBnkUHP4kR6Hhn88iyCMdVTdYHS6Vlk0LPIoGdxIj2PDIF8\nFiG9yEtERAIjpMs7iIhIYCj5i4hEISV/EZEopOQvIhKFlPxFRKKQkr+ISBRS8hcRiUJK/iIiUej/\nATlG5Ecy2O4kAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1083ff4d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(k, pk_lin, 'b-')\n",
    "plt.plot(k, pk_nl, 'r-')\n",
    "plt.xscale('log')\n",
    "plt.yscale('log')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "We can see that the cache has now been populated:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "print cosmo.has_power()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Subsequent calls to `linear_matter_power()` will be faster for the same cosmology (i.e. the same `Cosmology` object).\n",
    "\n",
    "### Power spectrum normalisation, sigma_8\n",
    "We can also calculate the normalisation of the power spectrum, sigma_8. Note that this parameter is currently undefined:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nan\n"
     ]
    }
   ],
   "source": [
    "print cosmo['sigma_8']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "If we now call the `sigma8()` function, this value should be populated (although at present this has not been implemented)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.84006416271\n",
      "nan\n"
     ]
    }
   ],
   "source": [
    "print ccl.sigma8(cosmo)\n",
    "print cosmo['sigma_8']"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
