Skip to content

Commit

Permalink
class_sz for unbinned
Browse files Browse the repository at this point in the history
  • Loading branch information
borisbolliet committed Sep 13, 2023
1 parent 526d974 commit b7814bd
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 15 deletions.
18 changes: 15 additions & 3 deletions soliket/clusters/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ class UnbinnedClusterLikelihood(PoissonLikelihood):
params = {"tenToA0":None, "B0":None, "C0":None, "scatter_sz":None, "bias_sz":None}

def initialize(self):

initialize_common(self)

zmax = self.binning['z']['zmax']
Expand All @@ -341,11 +340,15 @@ def initialize(self):

# this is for liklihood computation
self.zcut = self.binning['exclude_zbin']

if self.theorypred['choose_theory'] == 'classy_sz':
self.params = {}
super().initialize()

def get_requirements(self):
return get_requirements(self)
if self.theorypred['choose_theory'] == 'classy_sz':
return {"sz_unbinned_cluster_counts": {}}
else:
return get_requirements(self)

def _get_catalog(self):
return self.catalog, self.columns
Expand Down Expand Up @@ -615,6 +618,15 @@ def Pfunc_per(self, tile_index, marr, z, Y_c, Y_err, params):
return ans


def logp(self, **kwargs):
if self.theorypred['choose_theory'] == 'classy_sz':
return self.theory.get_sz_unbinned_cluster_counts()
else:
pk_intp = self.theory.get_Pk_interpolator()
rate_densities = self._get_rate_fn(pk_intp, **kwargs)
n_expected = self._get_n_expected(pk_intp, **kwargs)
return self.data.loglike(rate_densities, n_expected)

def initialize_common(self):
self.log = logging.getLogger(self.name)
handler = logging.StreamHandler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ theory:
md_hmf : '200c'

stop_at_error: True
timing: True
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# run from SOLikeT/soliket/clusters
# command:
# $ cobaya-run input_files/test_binned_lkl_ccl.yaml -f
output: chains/test_binned_ccl_evaluate
output: chains/test_binned_classy_sz_evaluate

likelihood:
soliket.BinnedClusterLikelihood:
Expand Down Expand Up @@ -130,14 +130,14 @@ theory:

z_min: 0.
z_max: 2.
redshift_epsrel: 1e-6
redshift_epsrel: 1e-4
redshift_epsabs: 1e-100



M_min: 5e13
M_max: 1e16
mass_epsrel: 1e-6
mass_epsrel: 1e-4
mass_epsabs: 1e-100
ndim_redshifts: 50
# 'ndim_masses' : 100,
Expand Down Expand Up @@ -181,15 +181,6 @@ theory:
dz_cluster_count_completeness_grid_mid_z : 1e-2
dz_cluster_count_completeness_grid_high_z : 1e-1



mass_epsrel_cluster_counts : 1e-6
mass_epsabs_cluster_counts : 1e-40

redshift_epsrel_cluster_counts : 1e-6
redshift_epsabs_cluster_counts : 1e-40


# A_ym : 1.9e-05
# B_ym : 0.08
# C_ym : 0.
Expand All @@ -205,3 +196,4 @@ theory:


stop_at_error: True
timing: True
186 changes: 186 additions & 0 deletions soliket/clusters/input_files/test_unbinned_lkl_classy_sz_evaluate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# Direction:
# download sim-kit_NemoCCL_A10tSZ_DR5White_ACT-DR5_tenToA0Tuned from https://astro.ukzn.ac.za/~mjh/ACT/DR5CosmoSims/distribution/
# put in soliket/clusters/data/advact/DR5CosmoSims directory.


# run from SOLikeT/soliket/clusters
# command:
# $ cobaya-run input_files/test_binned_lkl_ccl.yaml -f
output: chains/test_unbinned_classy_sz_evaluate

likelihood:
soliket.UnbinnedClusterLikelihood:
stop_at_error: True
verbose: False

# Data
data:
data_path: 'data/advact/DR5CosmoSims/sim-kit_NemoCCL_A10tSZ_DR5White_ACT-DR5_tenToA0Tuned/NemoCCL_A10tSZ_DR5White_ACT-DR5_tenToA0Tuned/' # Path to data directory
cat_file: 'NemoCCL_A10tSZ_DR5White_ACT-DR5_tenToA0Tuned_mass.fits' # Path to cluster catalog file
# data_path: 'data/advact/DR5CosmoSims/sim-kit_NemoCCL_A10tSZ_DR5White_ACT-DR5/NemoCCL_A10tSZ_DR5White_ACT-DR5/'
# cat_file: 'NemoCCL_A10tSZ_DR5White_ACT-DR5_mass.fits'
Q_file: 'selFn/QFit.fits' # Path to Q function file
tile_file: 'selFn/tileAreas.txt' # Path to tile file
rms_file: 'selFn/RMSTab.fits' # Path to RMS file

# Theory
theorypred:
choose_theory: "classy_sz"
massfunc_mode: 'ccl'
md_hmf: '200c'
md_ym: '200c'
compl_mode: 'erf_diff'
rel_correction: False # Relativistic corrections for tSZ

# Y-M relation
YM:
Mpivot: 4.25e14 # Mpivot in Y-M relation

# Selection function
selfunc:
SNRcut : 5. # S/N cutoff in number counts
# Model for selection function, possibilities are
method: 'SNRbased'
# method: SNRbased / injection
# SNRbased: completeness based in SNR estimates
# injection: estimate completeness using source injection method from nemo (i.e. no Q)
whichQ: 'fit'
# whichQ: fit / injection
# fit : using Q fit data
# injection : using Q source injection data
resolution : 'downsample'
# resolution: full / downsample
# downsample: average rms map, Q into n dwnsmpl_bins
# full: consider full map, Q function, no downsampling
dwnsmpl_bins : 30 # If resolution=downsample, number of bins to use
save_dwsmpld : False # Save downsampled Q and rms to npz file and once it exists read those

debiasDOF : 0.
binning:
# redshift bins for number counts
z:
zmin: 0.
zmax: 2.0 #2.6 # for a new sim
dz: 0.1
# SNR bins for number counts
q:
log10qmin: 0.6
log10qmax: 2.0
dlog10q: 0.25 #1.5 for one bin
# mass bins for number counts
M:
Mmin: 5e13
Mmax: 1e16
dlogM: 0.01
# when excluding low redshift bins for lkl, otherwise should be 0
exclude_zbin: 0

params:
h : 0.68
n_s : 0.965
Omega_b : 0.049
Omega_cdm : 0.261
tau_reio : 0.06
# sigma8 : 0.81
tenToA0 : 1.9e-5 #4.0e-5
B0 : 0.08
scatter_sz : 0.2
bias_sz : 1
# m_nu : 0.
C0: 0.

sigma8:
prior:
min: 0.
max: 4.
ref:
dist: norm
loc: 0.8
scale: 0.001
proposal: 0.001
latex: \sigma_8

sampler:
evaluate:
override:
sigma8: 0.81

theory:
# soliket.clusters.CCL :
# transfer_function : 'boltzmann_camb'
# matter_pk : 'halofit'
# baryons_pk : 'nobaryons'
# md_hmf : '200c'
classy_szfast.classy_sz.classy_sz:
use_class_sz_fast_mode : 1
stop_at_error: True
extra_args:
output: 'sz_cluster_counts_fft'
mass function : 'T08M200c'
concentration parameter : 'B13'

# h': 0.68,
# n_s': 0.965,
# Omega_b': 0.049,
# Omega_cdm': 0.261,
# sigma8': 0.81,
# tau_reio' : 0.06,


z_min: 0.
z_max: 2.
redshift_epsrel: 1e-6
redshift_epsabs: 1e-100



M_min: 5e13
M_max: 1e16
mass_epsrel: 1e-6
mass_epsabs: 1e-100
ndim_redshifts: 50
# 'ndim_masses' : 100,



has_selection_function : 1
experiment : 1 # Planck: 0 / ACT or SO: 1
y_m_relation : 1 # ycenter : 1, # y500 : 0
signal-to-noise_cut-off_for_survey_cluster_completeness : 5.

sz_selection_function_thetas_file : '/Users/boris/Work/CLASS-SZ/SO-SZ/class_sz/class_sz_auxiliary_files/nemo_sim_thetas_120923_30bins.txt'
sz_selection_function_skyfracs_file : '/Users/boris/Work/CLASS-SZ/SO-SZ/class_sz/class_sz_auxiliary_files/nemo_sim_skyfracs_120923_30bins.txt'
sz_selection_function_ylims_file : '/Users/boris/Work/CLASS-SZ/SO-SZ/class_sz/class_sz_auxiliary_files/nemo_sim_ylims_120923_30bins.txt'



bin_z_min_cluster_counts : 0.
bin_z_max_cluster_counts : 2.
bin_dz_cluster_counts : 0.1

bin_dlog10_snr : 0.25
log10_snr_min : 0.6
log10_snr_max : 2.


# A_ym : 1.9e-05
# B_ym : 0.08
# C_ym : 0.
# sigmaM_ym : 0.173
m_pivot_ym_[Msun] : 4.25e14

use_m500c_in_ym_relation : 0
use_skyaveraged_noise: 0 # this will speed-up everything

szcc_dof : 0.
szcc_qtrunc : 0.

N_samp_fftw : 2048
szcounts_fft_nz : 80
szcounts_fft_z_min : 0.0
szcounts_fft_z_max : 2.0
tol_dlnm_dlnq : 0.01
ntab_dlnm_dlnq : 500
szcounts_qmax_fft_padded : 200.

stop_at_error: True

0 comments on commit b7814bd

Please sign in to comment.