Generate mock data for a cluster

In this example we generate mock data with a variety of systematic effects including photometric redshifts, source galaxy distributions, and shape noise. We then populate a galaxy cluster object. This notebooks is organised as follows: - Imports and configuration setup - Generate mock data with different source galaxy options - Generate mock data with different field-of-view options - Generate mock data with different galaxy cluster options (only available with the Numcosmo and/or CCL backends). Use the os.environ['CLMM_MODELING_BACKEND'] line below to select your backend.

import os

## Uncomment the following line if you want to use a specific modeling backend among 'ct' (cluster-toolkit), 'ccl' (CCL) or 'nc' (Numcosmo). Default is 'ccl'
# os.environ['CLMM_MODELING_BACKEND'] = 'nc'
import numpy as np
import matplotlib.pyplot as plt

%matplotlib inline
import clmm

Make sure we know which version we’re using

clmm.__version__
'1.12.0'

Import mock data module and setup the configuration

from clmm.support import mock_data as mock
from clmm import Cosmology

Mock data generation requires a defined cosmology

mock_cosmo = Cosmology(H0=70.0, Omega_dm0=0.27 - 0.045, Omega_b0=0.045, Omega_k0=0.0)

Mock data generation requires some cluster information. The default is to work with the NFW profile, using the “200,mean” mass definition. The Numcosmo and CCL backends allow for more flexibility (see last section of this notebook)

cosmo = mock_cosmo
cluster_id = "Awesome_cluster"
cluster_m = 1.0e15  # M200,m
cluster_z = 0.3
src_z = 0.8
concentration = 4
ngals = 1000  # number of source galaxies

# Cluster centre coordinates
cluster_ra = 50.0
cluster_dec = 87.0

Generate the mock catalog with different source galaxy options

  • Clean data: no noise, all galaxies at the same redshift

zsrc_min = cluster_z + 0.1
ideal_data = mock.generate_galaxy_catalog(
    cluster_m,
    cluster_z,
    concentration,
    cosmo,
    src_z,
    ngals=ngals,
    cluster_ra=cluster_ra,
    cluster_dec=cluster_dec,
)
# let's put all these quantities in a single dictionary to facilitate clarity
cluster_kwargs = {
    "cluster_m": cluster_m,
    "cluster_z": cluster_z,
    "cluster_ra": cluster_ra,
    "cluster_dec": cluster_dec,
    "cluster_c": concentration,
    "cosmo": cosmo,
}
ideal_data = mock.generate_galaxy_catalog(**cluster_kwargs, zsrc=src_z, ngals=ngals)
  • Noisy data: shape noise, all galaxies at the same redshift

noisy_data_src_z = mock.generate_galaxy_catalog(
    **cluster_kwargs, zsrc=src_z, shapenoise=0.05, ngals=ngals
)
  • Noisy data: shape noise plus measurement error, all galaxies at the same redshift

noisy_data_src_z_e_err = mock.generate_galaxy_catalog(
    **cluster_kwargs, zsrc=src_z, shapenoise=0.05, mean_e_err=0.05, ngals=ngals
)

WARNING: Experimental feature. Uncertainties are created by simply drawing random numbers near the value specified by mean_e_err. Use at your own risk. This will be improved in future releases.

  • Noisy data: photo-z errors (and pdfs!), all galaxies at the same redshift. At present, the pdfs are generated by drawing a random value from a Normal distribution with mean ztrue and width given by dz = (1+z)*photoz_sigma_unscaled, and the pdf is this Normal distribution centered around z instead of ztrue.

noisy_data_photoz = mock.generate_galaxy_catalog(
    **cluster_kwargs,
    zsrc=src_z,
    shapenoise=0.05,
    photoz_sigma_unscaled=0.05,
    pz_bins=101,
    ngals=ngals
)

In the default PDF storing (pzpdf_type='shared_bins'), the values of the PDF are added to the pzpdf column and the binning scheme is stored in the pzpdf_info attribute:

noisy_data_photoz.pzpdf_info
{'type': 'shared_bins',
 'zbins': array([0.        , 0.01959865, 0.0391973 , 0.05879595, 0.0783946 ,
        0.09799325, 0.1175919 , 0.13719055, 0.15678921, 0.17638786,
        0.19598651, 0.21558516, 0.23518381, 0.25478246, 0.27438111,
        0.29397976, 0.31357841, 0.33317706, 0.35277571, 0.37237436,
        0.39197301, 0.41157166, 0.43117031, 0.45076896, 0.47036762,
        0.48996627, 0.50956492, 0.52916357, 0.54876222, 0.56836087,
        0.58795952, 0.60755817, 0.62715682, 0.64675547, 0.66635412,
        0.68595277, 0.70555142, 0.72515007, 0.74474872, 0.76434737,
        0.78394603, 0.80354468, 0.82314333, 0.84274198, 0.86234063,
        0.88193928, 0.90153793, 0.92113658, 0.94073523, 0.96033388,
        0.97993253, 0.99953118, 1.01912983, 1.03872848, 1.05832713,
        1.07792578, 1.09752444, 1.11712309, 1.13672174, 1.15632039,
        1.17591904, 1.19551769, 1.21511634, 1.23471499, 1.25431364,
        1.27391229, 1.29351094, 1.31310959, 1.33270824, 1.35230689,
        1.37190554, 1.3915042 , 1.41110285, 1.4307015 , 1.45030015,
        1.4698988 , 1.48949745, 1.5090961 , 1.52869475, 1.5482934 ,
        1.56789205, 1.5874907 , 1.60708935, 1.626688  , 1.64628665,
        1.6658853 , 1.68548395, 1.70508261, 1.72468126, 1.74427991,
        1.76387856, 1.78347721, 1.80307586, 1.82267451, 1.84227316,
        1.86187181, 1.88147046, 1.90106911, 1.92066776, 1.94026641,
        1.95986506])}
noisy_data_photoz[:5]
GCData
defined by: cosmo=None
with columns: ra, dec, e1, e2, z, ztrue, pzpdf, id
and pzpdf: shared_bins [0. 0.02 0.04 0.06 0.08 ... 1.88 1.9 1.92 1.94 1.96]
5 objects
radece1e2zztruepzpdfid
float64float64float64float64float64float64float64[101]int64
46.2572880823355286.89223054243050.08236207803522719-0.054118540767148880.69871031819970640.83.622089304592751e-13 .. 1.0180322952717169e-420
50.0777871562318987.10740150490655-0.014752252971336390.038828008441195870.73929621321758590.89.870794333079776e-15 .. 5.1047370592912794e-401
48.4080987988511986.87728907171557-1.2575884722892804e-050.020962676367362040.90093032742937560.87.709520397996465e-22 .. 3.849218150728941e-302
53.01436891183186686.9440239760556-0.011911350886457556-0.058930111442774110.84479698293503340.83.2663820149084725e-19 .. 2.0599039175494822e-333
53.43523018790920587.09017457767816-0.019995431173391790.023543677736634350.61913835656937030.82.345198551898936e-10 .. 2.86718907682299e-484

It is also possible to generate individual binning of the PDF with pzpdf_type='individual_bins'. In this case, both the bin values and the PDF are added to the pzpdf column:

mock.generate_galaxy_catalog(
    **cluster_kwargs,
    zsrc=src_z,
    shapenoise=0.05,
    photoz_sigma_unscaled=0.05,
    pz_bins=101,
    ngals=ngals,
    pzpdf_type="individual_bins"
)[:5]
GCData
defined by: cosmo=None
with columns: ra, dec, e1, e2, z, ztrue, pzbins, pzpdf, id
and pzpdf: individual_bins
5 objects
radece1e2zztruepzbinspzpdfid
float64float64float64float64float64float64float64[101]float64[101]int64
51.7180958895545586.794184998981240.045171775281032730.0079544195667603690.71151929310340460.80.0 .. 1.61151929310340461.1876947502964896e-13 .. 8.54955402967386e-220
46.70800163801112686.88819976612274-0.012879815467979831-0.081754480509692020.69456815514609630.80.0 .. 1.59456815514609645.172194687003747e-13 .. 8.549554029673739e-221
49.3945199868530587.20677909110817-0.00396285839757514950.01749945061672090.83158050787762080.80.0 .. 1.7315805078776211.2824084572051592e-18 .. 8.549554029673739e-222
46.86063450494019486.93654387908563-0.0462597921376629650.0053228967998943670.69178144860663620.80.0 .. 1.59178144860663646.565150731239997e-13 .. 8.549554029673677e-223
51.26562279760640586.86646628375920.0316686284294420.0507252738466855150.75637302584879640.80.0 .. 1.65637302584879652.0400190276050062e-15 .. 8.549554029673739e-224