Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 71 additions & 4 deletions clpipe/utils/cosmosis_mcmc_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,16 @@
import numpy as np
from astropy.io import fits
from astropy.table import Table
from getdist import MCSamples, plots
from IPython.display import Math, display

# getdist switches matplotlib to Agg on import when it does not recognise the
# notebook backend (older versions only look for 'ipykern'), which stops the
# figures from showing inline. Keep the backend that was active before.
_backend = mpl.get_backend()
from getdist import MCSamples, plots # noqa: E402
if mpl.get_backend() != _backend:
plt.switch_backend(_backend)

from IPython.display import Math, display # noqa: E402

try:
from cosmosis.postprocessing.inputs import read_input as _cosmosis_read
Expand All @@ -75,11 +83,69 @@
"axes.labelsize": 18,
"xtick.labelsize": 13,
"ytick.labelsize": 13,
"legend.fontsize": 15,
"legend.fontsize": 18,
"legend.frameon": False,
"legend.handlelength": 3.0,
"legend.handleheight": 1.4,
"figure.dpi": 150,
}

# ══════════════════════════════════════════════════════════════════════════════
# Shared style for the paper's line and point figures
# ══════════════════════════════════════════════════════════════════════════════

# Page widths of the two-column journal layout, in inches. Figures are drawn
# at the width they are printed at, so font sizes below are the printed sizes.
TEXT_WIDTH = 7.1
COLUMN_WIDTH = 3.4

# One color and one marker per richness bin (20-35, 35-70, 70-100, 100-200).
# Okabe-Ito based, ordered so that no two neighbouring bins merge under
# deuteranopia, protanopia or tritanopia.
RICHNESS_COLORS = ["#5E3C99", "#D55E00", "#56B4E9", "#E69F00"]
RICHNESS_MARKERS = ["o", "s", "^", "D"]

PAPER_FIGURE_RC = {
"font.size": 8,
"axes.labelsize": 9,
"axes.titlesize": 9,
"legend.fontsize": 8,
"xtick.labelsize": 8,
"ytick.labelsize": 8,
"axes.linewidth": 0.7,
"lines.linewidth": 1.4,
"lines.markersize": 4,
"legend.framealpha": 0.9,
"legend.edgecolor": "0.8",
"savefig.dpi": 300,
}


def use_paper_style():
"""Apply PAPER_FIGURE_RC to every figure made afterwards in the session."""
mpl.rcParams.update(PAPER_FIGURE_RC)


def add_grid(ax, which="both"):
"""Major grid in solid grey and minor grid dotted, dark enough for print."""
if which in ("both", "major"):
ax.grid(True, which="major", linestyle="-", linewidth=0.6, color="0.70")
if which in ("both", "minor"):
ax.grid(True, which="minor", linestyle=":", linewidth=0.5, color="0.78")
ax.set_axisbelow(True)


def richness_label(low, high):
"""Legend label for a richness bin, e.g. '$20 < \\lambda < 35$'."""
return rf"${low:.0f} < \lambda < {high:.0f}$"


def thicken_legend_lines(fig, linewidth=2.5):
"""Thicker line handles in the figure legends, so thin contour styles read in print."""
for legend in fig.legends:
for line in legend.get_lines():
line.set_linewidth(linewidth)


@dataclass
class ChainStyle:
Expand Down Expand Up @@ -354,7 +420,7 @@ def _resolve(name: str) -> str:
g = plots.get_subplot_plotter(width_inch=config.figsize)
g.settings.axes_fontsize = 13
g.settings.lab_fontsize = 18
g.settings.legend_fontsize = 15
g.settings.legend_fontsize = 18
g.settings.figure_legend_loc = "upper right"
g.settings.axis_tick_x_rotation = 45
g.settings.num_plot_contours = 2
Expand All @@ -373,6 +439,7 @@ def _resolve(name: str) -> str:
markers=plot_markers,
param_limits=config.param_limits,
)
thicken_legend_lines(g.fig)

if multiple_fiducials:
for marker, style in zip(fiducial_values, styles):
Expand Down
98 changes: 51 additions & 47 deletions examples/capish_simulation/analysis_summary.ipynb

Large diffs are not rendered by default.

Binary file modified examples/capish_simulation/figures/capish_redmapper.pdf
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/capish_simulation/run_in2p3_both_mean/TJPCov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ stages:
nprocess: 1
inputs:
fiducial_cosmology: /sps/lsst/groups/clusters/cl_pipeline_project/TXPipe_data/cosmodc2/fiducial_cosmology.yml
clusters_sacc_file: ../mock_DC2like_cluster_sacc_mean.sacc
clusters_sacc_file: ../../../data/capish_simulation/mock_DC2like_cluster_sacc_mean.sacc
config: ./config_in2p3_both.yml
resume: false
output_dir: ./outputs_both
Expand Down
167 changes: 60 additions & 107 deletions examples/cosmodc2_redmapper/crow_clcosmo_benchmark.ipynb

Large diffs are not rendered by default.

120 changes: 63 additions & 57 deletions examples/cosmodc2_redmapper/data_clcosmosim_txpipe.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ ceci TJPCov.yml
ceci Firecrown.yml

cd ./outputs_both
cosmosis sampler_file.ini
mpirun -n ${SLURM_NTASKS} cosmosis --mpi sampler_file.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/bash
#SBATCH --time=25:00:00
#SBATCH --partition=hpc,lsst
#SBATCH --cpus-per-task=1
#SBATCH --mem=80gb
#SBATCH --ntasks=51

module load conda
export HDF5_DO_MPI_FILE_SYNC=0
#export PYTHONPATH=/sps/lsst/groups/clusters/cl_pipeline_project/TXPipe:$PYTHONPATH
conda activate /sps/lsst/groups/clusters/cl_pipeline_project/conda_envs/txpipe_clp
export PYTHONPATH=/sps/lsst/users/ebarroso/CLPipe:$PYTHONPATH
export PYTHONPATH=/sps/lsst/groups/clusters/cl_pipeline_project/TXPipe:$PYTHONPATH

ceci TXPipe.yml

conda deactivate
conda activate /sps/lsst/groups/clusters/cl_pipeline_project/conda_envs/firecrown_developer_clp
export PYTHONPATH=/sps/lsst/users/ebarroso/CLPipe:$PYTHONPATH

ceci TJPCov.yml
ceci Firecrown.yml

cd ./outputs_both
export OMP_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
export MKL_NUM_THREADS=1
export NUMEXPR_NUM_THREADS=1
mpirun -n ${SLURM_NTASKS} cosmosis --mpi sampler_file.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ ceci TJPCov.yml
ceci Firecrown.yml

cd ./outputs_both
cosmosis sampler_file.ini
mpirun -n ${SLURM_NTASKS} cosmosis --mpi sampler_file.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ ceci TJPCov.yml
ceci Firecrown.yml

cd ./outputs_both
cosmosis sampler_file.ini
mpirun -n ${SLURM_NTASKS} cosmosis --mpi sampler_file.ini

Large diffs are not rendered by default.

Binary file not shown.
Binary file modified examples/cosmodc2_redmapper/figures/clpipe_vs_payerne.pdf
Binary file not shown.
Binary file modified examples/cosmodc2_redmapper/figures/cluster_halo_redshift.pdf
Binary file not shown.
Binary file modified examples/cosmodc2_redmapper/figures/cosmodc2_contour.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file modified examples/cosmodc2_redmapper/figures/full_fit_baseline.pdf
Binary file not shown.
Binary file modified examples/cosmodc2_redmapper/figures/mass_richness_fiducial.pdf
Binary file not shown.
Binary file modified examples/cosmodc2_redmapper/figures/mass_richness_pdf.pdf
Binary file not shown.
Binary file modified examples/cosmodc2_redmapper/figures/miscentering.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified examples/cosmodc2_redmapper/figures/summary_cosmo.pdf
Binary file not shown.
Binary file modified examples/cosmodc2_redmapper/figures/summary_tension_cosmo.pdf
Binary file not shown.
56 changes: 33 additions & 23 deletions examples/cosmodc2_redmapper/miscentering_fiducial.ipynb

Large diffs are not rendered by default.

188 changes: 101 additions & 87 deletions examples/cosmodc2_redmapper/mor_fiducial.ipynb

Large diffs are not rendered by default.

89 changes: 50 additions & 39 deletions examples/cosmodc2_redmapper/plot_samples.ipynb

Large diffs are not rendered by default.

Loading
Loading