CAMB: Multiple Source Windows Lead to Different Cl's

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Luca Suter
Posts: 5
Joined: October 06 2023
Affiliation: UniGe

CAMB: Multiple Source Windows Lead to Different Cl's

Post by Luca Suter »

I have been trying to fix up my code and I noticed that when you have multiple windows when calculating the cl's the value of the cl's will be different . Is there any reason why this may occur? I have posted the code below, I am not sure if something is wrong with the setup. The Cl that I get for a bin, using the first window function, will depend on the bin in the other window function.

Code: Select all

pars=camb.CAMBparams()
pars.set_cosmology(H0=67.5, ombh2=0.022, omch2=0.122, mnu=0.06, omk=0, tau=0.06)
pars.InitPower.set_params(As=2e-9, ns=0.965, r=0)
pars.set_for_lmax(700, lens_potential_accuracy=0)


pars.Want_CMB = False 
pars.SourceTerms.counts_density = True
pars.SourceTerms.counts_redshift = True
pars.SourceTerms.counts_lensing = False
pars.SourceTerms.counts_velocity = False
pars.SourceTerms.counts_radial = False
pars.SourceTerms.counts_timedelay = False
pars.SourceTerms.counts_ISW = False
pars.SourceTerms.counts_potential = False  

z1=redshifts[0]
z2=redshifts[1]


rs=np.arange(0, 3, 0.0001)
WW1=top_hat(rs, z1-sep,z1+sep)
WW2=top_hat(rs, z2-sep,z2+sep)

pars.SourceWindows = [SplinedSourceWindow(bias=1.5, z=rs, W=WW1),
                                SplinedSourceWindow(bias=1.5, z=rs, W=WW2)]


results=camb.get_results(pars)
        

The tophat function:

Code: Select all


def top_hat(x, a, b):
    """
    Top-hat function that is 1 between a and b (inclusive) and 0 elsewhere.
    
    Parameters:
    - x: Input array or scalar value.
    - a: Start of the interval where the function is 1.
    - b: End of the interval where the function is 1.
    
    Returns:
    - Array or scalar value with 1 inside the interval [a, b] and 0 outside.
    """
    return np.where((x >= a) & (x <= b), 1, 0)
Antony Lewis
Posts: 1983
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: CAMB: Multiple Source Windows Lead to Different Cl's

Post by Antony Lewis »

It uses the smallest step size needed by any window, so adding another window can affect precision of the first.

(not hat is not supported - windows should be differentiable)
Luca Suter
Posts: 5
Joined: October 06 2023
Affiliation: UniGe

Re: CAMB: Multiple Source Windows Lead to Different Cl's

Post by Luca Suter »

That makes sense. I'm assuming it affects the accuracy of the 'W1XW2" result as well?

I'll look into a better function than my top hat function, thank you!
Post Reply