forked from lesgourg/class_public
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added 11 notebooks and equivalent scripts (cambridge version)
- Loading branch information
Showing
22 changed files
with
4,152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false, | ||
"deletable": true, | ||
"editable": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# import necessary modules\n", | ||
"# uncomment to get plots displayed in notebook\n", | ||
"%matplotlib inline\n", | ||
"import matplotlib\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import numpy as np\n", | ||
"from classy import Class\n", | ||
"from scipy.optimize import fsolve\n", | ||
"from scipy.interpolate import interp1d\n", | ||
"import math" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false, | ||
"deletable": true, | ||
"editable": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# esthetic definitions for the plots\n", | ||
"font = {'size' : 16, 'family':'STIXGeneral'}\n", | ||
"axislabelfontsize='large'\n", | ||
"matplotlib.rc('font', **font)\n", | ||
"matplotlib.mathtext.rcParams['legend.fontsize']='medium'\n", | ||
"plt.rcParams[\"figure.figsize\"] = [8.0,6.0]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false, | ||
"deletable": true, | ||
"editable": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"#############################################\n", | ||
"#\n", | ||
"# Cosmological parameters and other CLASS parameters\n", | ||
"#\n", | ||
"common_settings = {# wich output? ClTT, transfer functions delta_i and theta_i\n", | ||
" 'output':'tCl,pCl,lCl',\n", | ||
" # LambdaCDM parameters\n", | ||
" 'h':0.67556,\n", | ||
" 'omega_b':0.022032,\n", | ||
" 'omega_cdm':0.12038,\n", | ||
" 'A_s':2.215e-9,\n", | ||
" 'tau_reio':0.0925,\n", | ||
" # Take fixed value for primordial Helium (instead of automatic BBN adjustment)\n", | ||
" 'YHe':0.246}\n", | ||
" # other output and precision parameters\n", | ||
" #'l_max_scalars':3000}\n", | ||
"###############\n", | ||
"# \n", | ||
"# call CLASS \n", | ||
"#\n", | ||
"###############\n", | ||
"#\n", | ||
"# scalars only\n", | ||
"#\n", | ||
"M = Class()\n", | ||
"M.set(common_settings)\n", | ||
"M.set({'output':'tCl,pCl','modes':'s','lensing':'no','n_s':0.9619,'l_max_scalars':3000})\n", | ||
"M.compute()\n", | ||
"cls = M.raw_cl(3000)\n", | ||
"M.struct_cleanup()\n", | ||
"M.empty()\n", | ||
"#\n", | ||
"# tensors only\n", | ||
"#\n", | ||
"M = Class()\n", | ||
"M.set(common_settings)\n", | ||
"l_max_tensors = 600\n", | ||
"M.set({'output':'tCl,pCl','modes':'t','lensing':'no','r':0.1,'n_t':0,'l_max_tensors':l_max_tensors})\n", | ||
"# for l_max=600 we can keep default precision\n", | ||
"# for l_max = 3000 we would need to import many high precision settings from the file cl_ref.pre\n", | ||
"#M.set({'output':'tCl,pCl','modes':'t','lensing':'no','r':0.1,'n_t':0,'l_max_tensors':3000})\n", | ||
"#M.set({\n", | ||
"#'recfast_Nz0':100000,\n", | ||
"#'tol_thermo_integration':1.e-5,\n", | ||
"#'recfast_x_He0_trigger_delta':0.01,\n", | ||
"#'recfast_x_H0_trigger_delta':0.01,\n", | ||
"#'evolver':0,\n", | ||
"#'k_min_tau0':0.002,\n", | ||
"#'k_max_tau0_over_l_max':3.,\n", | ||
"#'k_step_sub':0.015,\n", | ||
"#'k_step_super':0.0001,\n", | ||
"#'k_step_super_reduction':0.1,\n", | ||
"#'start_small_k_at_tau_c_over_tau_h':0.0004,\n", | ||
"#'start_large_k_at_tau_h_over_tau_k':0.05,\n", | ||
"#'tight_coupling_trigger_tau_c_over_tau_h':0.005,\n", | ||
"#'tight_coupling_trigger_tau_c_over_tau_k':0.008,\n", | ||
"#'start_sources_at_tau_c_over_tau_h':0.006,\n", | ||
"#'l_max_g':50,\n", | ||
"#'l_max_pol_g':25,\n", | ||
"#'l_max_ur':50,\n", | ||
"#'tol_perturb_integration':1.e-6,\n", | ||
"#'perturb_sampling_stepsize':0.01,\n", | ||
"#'radiation_streaming_approximation':2,\n", | ||
"#'radiation_streaming_trigger_tau_over_tau_k':240.,\n", | ||
"#'radiation_streaming_trigger_tau_c_over_tau':100.,\n", | ||
"#'ur_fluid_approximation':2,\n", | ||
"#'ur_fluid_trigger_tau_over_tau_k':50.,\n", | ||
"#'l_logstep':1.026,\n", | ||
"#'l_linstep':25,\n", | ||
"#'hyper_sampling_flat':12.,\n", | ||
"#'hyper_nu_sampling_step':10.,\n", | ||
"#'hyper_phi_min_abs':1.e-10,\n", | ||
"#'hyper_x_tol':1.e-4,\n", | ||
"#'hyper_flat_approximation_nu':1.e6,\n", | ||
"#'q_linstep':0.20,\n", | ||
"#'q_logstep_spline':20.,\n", | ||
"#'q_logstep_trapzd':0.5,\n", | ||
"#'q_numstep_transition':250,\n", | ||
"#'transfer_neglect_delta_k_T_t2':100.,\n", | ||
"#'transfer_neglect_delta_k_T_e':100.,\n", | ||
"#'transfer_neglect_delta_k_T_b':100.,\n", | ||
"#'neglect_CMB_sources_below_visibility':1.e-30,\n", | ||
"#'transfer_neglect_late_source':3000.\n", | ||
"#})\n", | ||
"M.compute()\n", | ||
"clt = M.raw_cl(l_max_tensors)\n", | ||
"M.struct_cleanup()\n", | ||
"M.empty()\n", | ||
"#\n", | ||
"# scalars + tensors (only in this case we can get the correct lensed ClBB)\n", | ||
"#\n", | ||
"M = Class()\n", | ||
"M.set(common_settings)\n", | ||
"M.set({'output':'tCl,pCl,lCl','modes':'s,t','lensing':'yes','r':0.1,'n_s':0.9619,'n_t':0,'l_max_scalars':3000,'l_max_tensors':l_max_tensors})\n", | ||
"M.compute()\n", | ||
"cl_tot = M.raw_cl(3000)\n", | ||
"cl_lensed = M.lensed_cl(3000)\n", | ||
"M.struct_cleanup()\n", | ||
"M.empty()\n", | ||
"#\n", | ||
"#################\n", | ||
"#\n", | ||
"# start plotting\n", | ||
"#\n", | ||
"#################\n", | ||
"#\n", | ||
"plt.xlim([2,3000])\n", | ||
"plt.ylim([1.e-8,10])\n", | ||
"plt.xlabel(r\"$\\ell$\")\n", | ||
"plt.ylabel(r\"$\\ell (\\ell+1) C_l^{XY} / 2 \\pi \\,\\,\\, [\\times 10^{10}]$\")\n", | ||
"plt.title(r\"$r=0.1$\")\n", | ||
"plt.grid()\n", | ||
"#\n", | ||
"ell = cl_tot['ell']\n", | ||
"ellt = clt['ell']\n", | ||
"factor = 1.e10*ell*(ell+1.)/2./math.pi\n", | ||
"factort = 1.e10*ellt*(ellt+1.)/2./math.pi\n", | ||
"#\n", | ||
"plt.loglog(ell,factor*cls['tt'],'r-',label=r'$\\mathrm{TT(s)}$')\n", | ||
"plt.loglog(ellt,factort*clt['tt'],'r:',label=r'$\\mathrm{TT(t)}$')\n", | ||
"plt.loglog(ell,factor*cls['ee'],'b-',label=r'$\\mathrm{EE(s)}$')\n", | ||
"plt.loglog(ellt,factort*clt['ee'],'b:',label=r'$\\mathrm{EE(t)}$')\n", | ||
"plt.loglog(ellt,factort*clt['bb'],'g:',label=r'$\\mathrm{BB(t)}$')\n", | ||
"plt.loglog(ell,factor*(cl_lensed['bb']-cl_tot['bb']),'g-',label=r'$\\mathrm{BB(lensing)}$')\n", | ||
"plt.legend(loc='right',bbox_to_anchor=(1.4, 0.5))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false, | ||
"deletable": true, | ||
"editable": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"plt.savefig('cl_ST.pdf',bbox_inches='tight')" | ||
] | ||
} | ||
], | ||
"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.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false, | ||
"deletable": true, | ||
"editable": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# import necessary modules\n", | ||
"# uncomment to get plots displayed in notebook\n", | ||
"%matplotlib inline\n", | ||
"import matplotlib\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import numpy as np\n", | ||
"from classy import Class\n", | ||
"from scipy.optimize import fsolve\n", | ||
"from scipy.interpolate import interp1d\n", | ||
"import math" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false, | ||
"deletable": true, | ||
"editable": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# esthetic definitions for the plots\n", | ||
"font = {'size' : 16, 'family':'STIXGeneral'}\n", | ||
"axislabelfontsize='large'\n", | ||
"matplotlib.rc('font', **font)\n", | ||
"matplotlib.mathtext.rcParams['legend.fontsize']='medium'\n", | ||
"plt.rcParams[\"figure.figsize\"] = [8.0,6.0]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false, | ||
"deletable": true, | ||
"editable": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"#############################################\n", | ||
"#\n", | ||
"# Cosmological parameters and other CLASS parameters\n", | ||
"#\n", | ||
"common_settings = {# wich output? ClTT, transfer functions delta_i and theta_i\n", | ||
" 'output':'tCl,pCl,lCl',\n", | ||
" 'lensing':'yes',\n", | ||
" # LambdaCDM parameters\n", | ||
" 'h':0.67556,\n", | ||
" 'omega_b':0.022032,\n", | ||
" 'omega_cdm':0.12038,\n", | ||
" 'A_s':2.215e-9,\n", | ||
" 'n_s':0.9619,\n", | ||
" 'tau_reio':0.0925,\n", | ||
" # Take fixed value for primordial Helium (instead of automatic BBN adjustment)\n", | ||
" 'YHe':0.246,\n", | ||
" # other output and precision parameters\n", | ||
" 'l_max_scalars':5000}\n", | ||
"###############\n", | ||
"# \n", | ||
"# call CLASS \n", | ||
"#\n", | ||
"M = Class()\n", | ||
"M.set(common_settings)\n", | ||
"M.compute()\n", | ||
"cl_tot = M.raw_cl(3000)\n", | ||
"cl_lensed = M.lensed_cl(3000)\n", | ||
"M.struct_cleanup() # clean output\n", | ||
"M.empty() # clean input\n", | ||
"#\n", | ||
"M.set(common_settings) # new input\n", | ||
"M.set({'temperature contributions':'tsw'}) \n", | ||
"M.compute()\n", | ||
"cl_tsw = M.raw_cl(3000) \n", | ||
"M.struct_cleanup()\n", | ||
"M.empty()\n", | ||
"#\n", | ||
"M.set(common_settings)\n", | ||
"M.set({'temperature contributions':'eisw'})\n", | ||
"M.compute()\n", | ||
"cl_eisw = M.raw_cl(3000) \n", | ||
"M.struct_cleanup()\n", | ||
"M.empty()\n", | ||
"#\n", | ||
"M.set(common_settings)\n", | ||
"M.set({'temperature contributions':'lisw'})\n", | ||
"M.compute()\n", | ||
"cl_lisw = M.raw_cl(3000) \n", | ||
"M.struct_cleanup()\n", | ||
"M.empty()\n", | ||
"#\n", | ||
"M.set(common_settings)\n", | ||
"M.set({'temperature contributions':'dop'})\n", | ||
"M.compute()\n", | ||
"cl_dop = M.raw_cl(3000) \n", | ||
"#\n", | ||
"#################\n", | ||
"#\n", | ||
"# start plotting\n", | ||
"#\n", | ||
"#################\n", | ||
"#\n", | ||
"plt.xlim([2,3000])\n", | ||
"plt.xlabel(r\"$\\ell$\")\n", | ||
"plt.ylabel(r\"$\\ell (\\ell+1) C_l^{TT} / 2 \\pi \\,\\,\\, [\\times 10^{10}]$\")\n", | ||
"plt.grid()\n", | ||
"#\n", | ||
"ell = cl_tot['ell']\n", | ||
"factor = 1.e10*ell*(ell+1.)/2./math.pi\n", | ||
"plt.semilogx(ell,factor*cl_tsw['tt'],'c-',label=r'$\\mathrm{T+SW}$')\n", | ||
"plt.semilogx(ell,factor*cl_eisw['tt'],'r-',label=r'$\\mathrm{early-ISW}$')\n", | ||
"plt.semilogx(ell,factor*cl_lisw['tt'],'y-',label=r'$\\mathrm{late-ISW}$')\n", | ||
"plt.semilogx(ell,factor*cl_dop['tt'],'g-',label=r'$\\mathrm{Doppler}$')\n", | ||
"plt.semilogx(ell,factor*cl_tot['tt'],'r-',label=r'$\\mathrm{total}$')\n", | ||
"plt.semilogx(ell,factor*cl_lensed['tt'],'k-',label=r'$\\mathrm{lensed}$')\n", | ||
"#\n", | ||
"plt.legend(loc='right',bbox_to_anchor=(1.4, 0.5))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false, | ||
"deletable": true, | ||
"editable": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"plt.savefig('cltt_terms.pdf',bbox_inches='tight')" | ||
] | ||
} | ||
], | ||
"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.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
Oops, something went wrong.