diff --git a/examples/Paper_v2.0/fig_2halo_miscentering_boost_theory.ipynb b/examples/Paper_v2.0/fig_2halo_miscentering_boost_theory.ipynb new file mode 100644 index 000000000..9c63f2915 --- /dev/null +++ b/examples/Paper_v2.0/fig_2halo_miscentering_boost_theory.ipynb @@ -0,0 +1,204 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Figure to show the new 2-halo term and miscentering functionality" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "\n", + "%matplotlib inline" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Imports specific to clmm " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "\n", + "os.environ[\n", + " \"CLMM_MODELING_BACKEND\"\n", + "] = \"ccl\" # here you may choose ccl, nc (NumCosmo) or ct (cluster_toolkit)\n", + "\n", + "import clmm\n", + "from clmm import Cosmology\n", + "import clmm.utils as u" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Make sure we know which version we're using" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "clmm.__version__" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Define a cosmology using astropy" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cosmo = Cosmology(H0=67.0, Omega_dm0=0.315 - 0.045, Omega_b0=0.045, Omega_k0=0.0)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Define the galaxy cluster model. Here, we choose parameters that describe the galaxy cluster model, including the mass definition, concentration, and mass distribution. For the mass distribution, we choose a distribution that follows an NFW profile." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "moo = clmm.Modeling(massdef=\"mean\", delta_mdef=200, halo_profile_model=\"nfw\")\n", + "\n", + "mass_cl = 1.e14\n", + "z_cl = 0.4\n", + "\n", + "conc_cl = 5.4# Duffy08 value for this halo mass and redshift (see last commented cell)\n", + "halo_bias = 2.4 # Tkinker10 value for this halo mass and redshift (see last commented cell)\n", + "\n", + "moo.set_cosmo(cosmo)\n", + "moo.set_concentration(conc_cl)\n", + "moo.set_mass(mass_cl)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "r_proj = np.logspace(-2, 2, 100)\n", + "\n", + "DeltaSigma = moo.eval_excess_surface_density(r_proj, z_cl)\n", + "\n", + "# Miscentered DeltaSigma\n", + "DeltaSigma_mis = moo.eval_excess_surface_density(r_proj, z_cl, r_mis=0.2)\n", + "\n", + "# 2halo DeltaSigma\n", + "DeltaSigma_2h = moo.eval_excess_surface_density_2h(r_proj, z_cl, halobias=6)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "r_scale = 0.3\n", + "nfw_boost = u.compute_nfw_boost(r_proj, r_scale, boost0=0.2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Plot the predicted profiles" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(7,6))\n", + "\n", + "ax.loglog(r_proj, DeltaSigma,label='1-halo, centered, reference', color='k')\n", + "ax.loglog(r_proj, DeltaSigma/nfw_boost, ls=':', label='1-halo, corrected with NFW boost model', color='grey')\n", + "ax.loglog(r_proj, DeltaSigma_mis , ls ='--', label='1-halo, miscentered, R_mis = 0.2 Mpc')\n", + "ax.loglog(r_proj, DeltaSigma_2h, ls='dashdot', label='2-halo', color='green')\n", + "ax.legend(loc=1, fontsize=13)\n", + "\n", + "ax.set_xlabel('R [Mpc]', fontsize=15)\n", + "ax.set_ylabel(r'$\\Delta\\Sigma$ [M$_\\odot$ Mpc$^{-2}$]', fontsize=15)\n", + "ax.tick_params(axis='x', labelsize=15)\n", + "ax.tick_params(axis='y', labelsize=15)\n", + "ax.set_ylim([8.e10, 1e16])\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('2h_miscentering_boost.png')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Typical values for halo_bias and concentration to use in the the example, computed using CCL\n", + "\n", + "import pyccl as ccl\n", + "\n", + "cosmo = ccl.Cosmology(Omega_c=0.27, Omega_b=0.045, h=0.67, sigma8=0.83, n_s=0.96)\n", + "\n", + "a = 1./(1+z_cl)\n", + "\n", + "bias = ccl.halos.HaloBiasTinker10(mass_def='200m', mass_def_strict=True)\n", + "conc = ccl.halos.concentration.ConcentrationDuffy08(mass_def='200m')\n", + "\n", + "bias(cosmo, mass_cl, a), conc(cosmo, mass_cl, a)\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "wrk", + "language": "python", + "name": "wrk" + }, + "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.10.9" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/Paper_v2.0/paper_formating.py b/examples/Paper_v2.0/paper_formating.py new file mode 100644 index 000000000..36314e1ee --- /dev/null +++ b/examples/Paper_v2.0/paper_formating.py @@ -0,0 +1,423 @@ +import matplotlib as mpl +import pylab as plt + + +def prep_plot( + figsize=(9, 9), + adjust=None, # {'left':0.2, 'right':0.95, 'top':0.94, 'bottom':0.2}, + subplots=False, +): + main_parameters = { + "figure.dpi": 300.0, + "legend.fontsize": 10, + "axes.labelsize": 12, + "axes.titlesize": 12, + "xtick.labelsize": 12, + "ytick.labelsize": 12, + "axes.linewidth": 0.8, + "xtick.major.width": 0.8, + "ytick.major.width": 0.8, + "errorbar.capsize": 0.8, + #'errorbar.capthick': 0.4, + #'errorbar.elinewidth': 0.4, + } + other_parameters = { + "legend": { + "fontsize": 10, + }, + "xlabel": {}, # {'fontsize': 2,}, + "ylabel": {}, # {'fontsize': 20,}, + "xtick": {"labelsize": 10}, + "ytick": {"labelsize": 10}, + } + plt.clf() + _figsize = list(x / 2.54 for x in figsize) + print(_figsize) + if subplots: + try: + fig, axes = plt.subplots(*subplots, figsize=_figsize) + except: + fig, axes = plt.subplots(subplots, figsize=_figsize) + else: + fig = plt.figure(figsize=_figsize) + if adjust is not None: + plt.subplots_adjust(**adjust) + mpl.rcParams.update(main_parameters) + # mpl.rc('xtick', **other_parameters['xtick']) + # mpl.rc('ytick', **other_parameters['ytick']) + + if subplots: + return fig, axes + return fig + + +default = { + "_internal.classic_mode": False, + "agg.path.chunksize": 0, + "animation.avconv_args": [], + "animation.avconv_path": "avconv", + "animation.bitrate": -1, + "animation.codec": "h264", + "animation.convert_args": [], + "animation.convert_path": "convert", + "animation.embed_limit": 20.0, + "animation.ffmpeg_args": [], + "animation.ffmpeg_path": "ffmpeg", + "animation.frame_format": "png", + "animation.html": "none", + "animation.html_args": [], + "animation.writer": "ffmpeg", + "axes.autolimit_mode": "data", + "axes.axisbelow": "line", + "axes.edgecolor": "black", + "axes.facecolor": "white", + "axes.formatter.limits": [-7, 7], + "axes.formatter.min_exponent": 0, + "axes.formatter.offset_threshold": 4, + "axes.formatter.use_locale": False, + "axes.formatter.use_mathtext": False, + "axes.formatter.useoffset": True, + "axes.grid": False, + "axes.grid.axis": "both", + "axes.grid.which": "major", + "axes.labelcolor": "black", + "axes.labelpad": 4.0, + "axes.labelsize": 20.0, + "axes.labelweight": "normal", + "axes.linewidth": 0.8, + "axes.prop_cycle": mpl.cycler( + "color", + [ + "#1f77b4", + "#ff7f0e", + "#2ca02c", + "#d62728", + "#9467bd", + "#8c564b", + "#e377c2", + "#7f7f7f", + "#bcbd22", + "#17becf", + ], + ), + "axes.spines.bottom": True, + "axes.spines.left": True, + "axes.spines.right": True, + "axes.spines.top": True, + "axes.titlepad": 6.0, + "axes.titlesize": 20.0, + "axes.titleweight": "normal", + "axes.unicode_minus": True, + "axes.xmargin": 0.05, + "axes.ymargin": 0.05, + "axes3d.grid": True, + "backend": "module://ipykernel.pylab.backend_inline", + "backend.qt4": None, + "backend.qt5": None, + "backend_fallback": True, + "boxplot.bootstrap": None, + "boxplot.boxprops.color": "black", + "boxplot.boxprops.linestyle": "-", + "boxplot.boxprops.linewidth": 1.0, + "boxplot.capprops.color": "black", + "boxplot.capprops.linestyle": "-", + "boxplot.capprops.linewidth": 1.0, + "boxplot.flierprops.color": "black", + "boxplot.flierprops.linestyle": "none", + "boxplot.flierprops.linewidth": 1.0, + "boxplot.flierprops.marker": "o", + "boxplot.flierprops.markeredgecolor": "black", + "boxplot.flierprops.markerfacecolor": "none", + "boxplot.flierprops.markersize": 6.0, + "boxplot.meanline": False, + "boxplot.meanprops.color": "C2", + "boxplot.meanprops.linestyle": "--", + "boxplot.meanprops.linewidth": 1.0, + "boxplot.meanprops.marker": "^", + "boxplot.meanprops.markeredgecolor": "C2", + "boxplot.meanprops.markerfacecolor": "C2", + "boxplot.meanprops.markersize": 6.0, + "boxplot.medianprops.color": "C1", + "boxplot.medianprops.linestyle": "-", + "boxplot.medianprops.linewidth": 1.0, + "boxplot.notch": False, + "boxplot.patchartist": False, + "boxplot.showbox": True, + "boxplot.showcaps": True, + "boxplot.showfliers": True, + "boxplot.showmeans": False, + "boxplot.vertical": True, + "boxplot.whiskerprops.color": "black", + "boxplot.whiskerprops.linestyle": "-", + "boxplot.whiskerprops.linewidth": 1.0, + "boxplot.whiskers": 1.5, + "contour.corner_mask": True, + "contour.negative_linestyle": "dashed", + "datapath": "/opt/conda/lib/python3.6/site-packages/matplotlib/mpl-data", + "date.autoformatter.day": "%Y-%m-%d", + "date.autoformatter.hour": "%m-%d %H", + "date.autoformatter.microsecond": "%M:%S.%f", + "date.autoformatter.minute": "%d %H:%M", + "date.autoformatter.month": "%Y-%m", + "date.autoformatter.second": "%H:%M:%S", + "date.autoformatter.year": "%Y", + "docstring.hardcopy": False, + "errorbar.capsize": 0.0, + "examples.directory": "", + "figure.autolayout": False, + "figure.constrained_layout.h_pad": 0.04167, + "figure.constrained_layout.hspace": 0.02, + "figure.constrained_layout.use": False, + "figure.constrained_layout.w_pad": 0.04167, + "figure.constrained_layout.wspace": 0.02, + "figure.dpi": 100.0, + "figure.edgecolor": "white", + "figure.facecolor": "white", + "figure.figsize": [6.4, 4.8], + "figure.frameon": True, + "figure.max_open_warning": 20, + "figure.subplot.bottom": 0.11, + "figure.subplot.hspace": 0.2, + "figure.subplot.left": 0.125, + "figure.subplot.right": 0.9, + "figure.subplot.top": 0.88, + "figure.subplot.wspace": 0.2, + "figure.titlesize": "large", + "figure.titleweight": "normal", + "font.cursive": [ + "Apple Chancery", + "Textile", + "Zapf Chancery", + "Sand", + "Script MT", + "Felipa", + "cursive", + ], + "font.family": ["sans-serif"], + "font.fantasy": [ + "Comic Sans MS", + "Chicago", + "Charcoal", + "Impact", + "Western", + "Humor Sans", + "xkcd", + "fantasy", + ], + "font.monospace": [ + "DejaVu Sans Mono", + "Bitstream Vera Sans Mono", + "Computer Modern Typewriter", + "Andale Mono", + "Nimbus Mono L", + "Courier New", + "Courier", + "Fixed", + "Terminal", + "monospace", + ], + "font.sans-serif": [ + "DejaVu Sans", + "Bitstream Vera Sans", + "Computer Modern Sans Serif", + "Lucida Grande", + "Verdana", + "Geneva", + "Lucid", + "Arial", + "Helvetica", + "Avant Garde", + "sans-serif", + ], + "font.serif": [ + "DejaVu Serif", + "Bitstream Vera Serif", + "Computer Modern Roman", + "New Century Schoolbook", + "Century Schoolbook L", + "Utopia", + "ITC Bookman", + "Bookman", + "Nimbus Roman No9 L", + "Times New Roman", + "Times", + "Palatino", + "Charter", + "serif", + ], + "font.size": 10.0, + "font.stretch": "normal", + "font.style": "normal", + "font.variant": "normal", + "font.weight": "normal", + "grid.alpha": 1.0, + "grid.color": "#b0b0b0", + "grid.linestyle": "-", + "grid.linewidth": 0.8, + "hatch.color": "black", + "hatch.linewidth": 1.0, + "hist.bins": 10, + "image.aspect": "equal", + "image.cmap": "viridis", + "image.composite_image": True, + "image.interpolation": "nearest", + "image.lut": 256, + "image.origin": "upper", + "image.resample": True, + "interactive": True, + "keymap.all_axes": ["a"], + "keymap.back": ["left", "c", "backspace"], + "keymap.copy": ["ctrl+c", "cmd+c"], + "keymap.forward": ["right", "v"], + "keymap.fullscreen": ["f", "ctrl+f"], + "keymap.grid": ["g"], + "keymap.grid_minor": ["G"], + "keymap.help": ["f1"], + "keymap.home": ["h", "r", "home"], + "keymap.pan": ["p"], + "keymap.quit": ["ctrl+w", "cmd+w", "q"], + "keymap.quit_all": ["W", "cmd+W", "Q"], + "keymap.save": ["s", "ctrl+s"], + "keymap.xscale": ["k", "L"], + "keymap.yscale": ["l"], + "keymap.zoom": ["o"], + "legend.borderaxespad": 0.5, + "legend.borderpad": 0.4, + "legend.columnspacing": 2.0, + "legend.edgecolor": "0.8", + "legend.facecolor": "inherit", + "legend.fancybox": True, + "legend.fontsize": 20.0, + "legend.framealpha": 0.8, + "legend.frameon": True, + "legend.handleheight": 0.7, + "legend.handlelength": 2.0, + "legend.handletextpad": 0.8, + "legend.labelspacing": 0.5, + "legend.loc": "best", + "legend.markerscale": 1.0, + "legend.numpoints": 1, + "legend.scatterpoints": 1, + "legend.shadow": False, + "legend.title_fontsize": None, + "lines.antialiased": True, + "lines.color": "C0", + "lines.dash_capstyle": "butt", + "lines.dash_joinstyle": "round", + "lines.dashdot_pattern": [6.4, 1.6, 1.0, 1.6], + "lines.dashed_pattern": [3.7, 1.6], + "lines.dotted_pattern": [1.0, 1.65], + "lines.linestyle": "-", + "lines.linewidth": 1.5, + "lines.marker": "None", + "lines.markeredgecolor": "auto", + "lines.markeredgewidth": 1.0, + "lines.markerfacecolor": "auto", + "lines.markersize": 6.0, + "lines.scale_dashes": True, + "lines.solid_capstyle": "projecting", + "lines.solid_joinstyle": "round", + "markers.fillstyle": "full", + "mathtext.bf": "sans:bold", + "mathtext.cal": "cursive", + "mathtext.default": "it", + "mathtext.fallback_to_cm": True, + "mathtext.fontset": "dejavusans", + "mathtext.it": "sans:italic", + "mathtext.rm": "sans", + "mathtext.sf": "sans", + "mathtext.tt": "monospace", + "patch.antialiased": True, + "patch.edgecolor": "black", + "patch.facecolor": "C0", + "patch.force_edgecolor": False, + "patch.linewidth": 1.0, + "path.effects": [], + "path.simplify": True, + "path.simplify_threshold": 0.1111111111111111, + "path.sketch": None, + "path.snap": True, + "pdf.compression": 6, + "pdf.fonttype": 3, + "pdf.inheritcolor": False, + "pdf.use14corefonts": False, + "pgf.preamble": [], + "pgf.rcfonts": True, + "pgf.texsystem": "xelatex", + "polaraxes.grid": True, + "ps.distiller.res": 6000, + "ps.fonttype": 3, + "ps.papersize": "letter", + "ps.useafm": False, + "ps.usedistiller": False, + "savefig.bbox": None, + "savefig.directory": "~", + "savefig.dpi": "figure", + "savefig.edgecolor": "white", + "savefig.facecolor": "white", + "savefig.format": "png", + "savefig.frameon": True, + "savefig.jpeg_quality": 95, + "savefig.orientation": "portrait", + "savefig.pad_inches": 0.1, + "savefig.transparent": False, + "scatter.marker": "o", + "svg.fonttype": "path", + "svg.hashsalt": None, + "svg.image_inline": True, + "text.antialiased": True, + "text.color": "black", + "text.hinting": "auto", + "text.hinting_factor": 8, + "text.latex.preamble": [], + "text.latex.preview": False, + "text.latex.unicode": True, + "text.usetex": False, + "timezone": "UTC", + "tk.window_focus": False, + "toolbar": "toolbar2", + "verbose.fileo": "sys.stdout", + "verbose.level": "silent", + "webagg.address": "127.0.0.1", + "webagg.open_in_browser": True, + "webagg.port": 8988, + "webagg.port_retries": 50, + "xtick.alignment": "center", + "xtick.bottom": True, + "xtick.color": "black", + "xtick.direction": "out", + "xtick.labelbottom": True, + "xtick.labelsize": 18.0, + "xtick.labeltop": False, + "xtick.major.bottom": True, + "xtick.major.pad": 3.5, + "xtick.major.size": 3.5, + "xtick.major.top": True, + "xtick.major.width": 0.8, + "xtick.minor.bottom": True, + "xtick.minor.pad": 3.4, + "xtick.minor.size": 2.0, + "xtick.minor.top": True, + "xtick.minor.visible": False, + "xtick.minor.width": 0.6, + "xtick.top": False, + "ytick.alignment": "center_baseline", + "ytick.color": "black", + "ytick.direction": "out", + "ytick.labelleft": True, + "ytick.labelright": False, + "ytick.labelsize": 18.0, + "ytick.left": True, + "ytick.major.left": True, + "ytick.major.pad": 3.5, + "ytick.major.right": True, + "ytick.major.size": 3.5, + "ytick.major.width": 0.8, + "ytick.minor.left": True, + "ytick.minor.pad": 3.4, + "ytick.minor.right": True, + "ytick.minor.size": 2.0, + "ytick.minor.visible": False, + "ytick.minor.width": 0.6, + "ytick.right": False, +}