{ "cells": [ { "cell_type": "raw", "metadata": {}, "source": [ ".. _cosmology:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Choosing a cosmology model" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Since the new implementation allows to switch on the fly from the ``src`` to the ``obs`` frame, we need to define a cosmolgoy model in order to evaluate the luminosity distance also for dataset independently from the Jet model.\n", "This is implemented in usign the astropy cosmology subpackaged https://docs.astropy.org/en/stable/cosmology/\n", "Moreover, this allows also to change easilyt the cosmology used for the Jet model, passing a specifc cosmology model form astropy " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "tested on jetset 1.2.2\n" ] } ], "source": [ "import jetset\n", "print('tested on jetset',jetset.__version__)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from jetset.cosmo_tools import Cosmo\n", "c=Cosmo()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "the defualt comoslogy is" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "FlatLambdaCDM(name=\"Planck13\", H0=67.8 km / (Mpc s), Om0=0.307, Tcmb0=2.725 K, Neff=3.05, m_nu=[0. 0. 0.06] eV, Ob0=0.0483)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "you can choose a different cosmology model from astropy eg" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "from astropy.cosmology import WMAP9 as cw\n", "c=Cosmo(astropy_cosmo=cw)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "FlatLambdaCDM(name=\"WMAP9\", H0=69.3 km / (Mpc s), Om0=0.286, Tcmb0=2.725 K, Neff=3.04, m_nu=[0. 0. 0.] eV, Ob0=0.0463)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "or you can set directly a luminosity distance in cm" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "c=Cosmo(DL_cm=1e28)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "cosmology is not defined, the luminosity distance has been set to 1e+28 cm" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "IF you don't choose a cosmology model, the default one will be used (`FlatLambdaCDM(name=\"Planck13\", H0=67.8 km / (Mpc s), Om0=0.307, Tcmb0=2.725 K, Neff=3.05, m_nu=[0. 0. 0.06] eV, Ob0=0.0483)`)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Changing cosmology model in data" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "from jetset.data_loader import Data\n", "from jetset.data_loader import ObsData\n", "from jetset.cosmo_tools import Cosmo\n", "from jetset.test_data_helper import test_SEDs\n", "c=Cosmo()\n", "data_table=Data.from_file(test_SEDs[1])\n", "sed_data=ObsData(data_table=data_table,cosmo=c)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Changing cosmology model in Jet models " ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "from jetset.jet_model import Jet\n", "my_jet=Jet(cosmo=c)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "or for already built models" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "my_jet.cosmo=c" ] } ], "metadata": { "kernel_info": { "name": "python3" }, "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.8.2" }, "nteract": { "version": "0.12.3" } }, "nbformat": 4, "nbformat_minor": 4 }