## COSMOMC: all_l_exact data format

Use of Healpix, camb, CLASS, cosmomc, compilers, etc.
Tor Helge Huse
Posts: 6
Joined: December 15 2004
Affiliation: Astrofysisk Institutt, Oslo

### COSMOMC: all_l_exact data format

I'm trying to use the all_l_exact data format in cosmomc with some simulated data, but I keep running into computational errors when doing so. As I can't find any documentation on what the all_l_exact data format should be, I'll ask here: What does the all_l_exact data format actually look like?

regards
Tor Helge Huse

PS: I want to first use CAMB to generate some data and then introduce some noise through my own routine, so CAMB data is my starting point.

Antony Lewis
Posts: 1445
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

### Re: COSMOMC: all_l_exact data format

The all_l_exact format uses the exact full-sky likelihood function given in e.g. Eq. 5 of astro-ph/0502469.

A .dataset file for an all_l_exact simulation would look something like

Code: Select all

name = Planck
has_pol = T
all_l_exact=T
all_l_file = data/Planck.dat
all_l_lmax=2000
Then you just need to make the Planck.dat file with the mock data. The columns in this file are

l C_TT (C_TE C_EE [C_BB]) N_T (N_P) f_sky^eff

The brackets are included if has_pol = T, and C_BB if you have compiled cosmomc with num_cls=4.

C_TT (and the polarized ones similarly) are raw C_l + noise (no l(l+1) or 2\pi factors). i.e. they increase on scales below the beam size due to the larger noise there.

Here's some simple code to make a Planck.dat file from a C_l file output by CAMB (in \mu\rm{K}^2):

Code: Select all

!Simulate CMB C_l data
!Simple version assuming isotropic noise and full sky
!no lensing, no tensors &#40;check input Cl file has only 4 columns!&#41;
!all parameters hard wired in code
!Data points are max likelihood values
!AL&#58; Sept 2004

program CMB_cl_sim
use AMLutils
implicit none

!parameters
character&#40;LEN=*&#41;, parameter &#58;&#58; cl_infile = 'MAPcls.dat'
character&#40;LEN=*&#41;, parameter &#58;&#58; out_name = 'planck.dat'
logical &#58;&#58; DoPol = .true., DoTemp = .true.
real &#58;&#58; NoiseVar = 3d-4   !Pessimistic Planck
!in MicroK^2
real, parameter &#58;&#58; fwhm_arcmin = 7. ! 13.  !WMAP ~ 13 &#40;0.22 deg min&#41;
real, parameter &#58;&#58; ENoiseFac = 2 !factor more noise on the polarization
integer, parameter &#58;&#58; lmax = 2250

!Other stuff
integer, parameter &#58;&#58;  C_T = 1, C_E = 2, C_B = 3, C_C = 4

real &#58;&#58; fwhm_deg = fwhm_arcmin/60
real &#58;&#58; Cl&#40;lmax,4&#41;, NoiseCl&#40;lmax&#41;
real amp, xlc, sigma2
integer l,ll
real T, E, TE,B, scal

print *,'lmax = ',lmax
print *,'fwhm_arcmin = ', fwhm_arcmin
print *,'Noise = ',NoiseVar

xlc= 180*sqrt&#40;8.*log&#40;2.&#41;&#41;/3.14159
sigma2 = &#40;fwhm_deg/xlc&#41;**2
do l=2, lmax
NoiseCl&#40;l&#41; = NoiseVar*exp&#40;l*&#40;l+1&#41;*sigma2&#41;
end do

Cl=0
B=0
open&#40;unit=1,file=Cl_infile,form='formatted',status='old'&#41;
do ll=2,lmax
read &#40;1,*&#41; l, T, E, TE
if &#40;l/=ll&#41; stop 'cl must start at l=2'
scal=twopi/&#40;l*&#40;l+1&#41;&#41;
Cl&#40;l,1&#41; = T*scal
Cl&#40;l,2&#41; = E*scal
Cl&#40;l,3&#41; = B*scal
Cl&#40;l,4&#41; = TE*scal
end do
close&#40;1&#41;

call CreateTxtFile&#40;out_name,34&#41;

do l=2, lmax

write &#40;34,'&#40;1I5,6E15.5&#41;'&#41; l,&#40;Cl&#40;l,1&#41;+NoiseCl&#40;l&#41;&#41; , &
&#40;Cl&#40;l,C_C&#41;&#41;, &
&#40;Cl&#40;l,C_E&#41;+ENoiseFac*NoiseCl&#40;l&#41;&#41;, &
!      &#40;Cl&#40;l,C_B&#41;+ENoiseFac*Noise%Cl&#40;l,1&#41;&#41;*1e6, &
NoiseCl&#40;l&#41;*1e6,ENoiseFac*NoiseCl&#40;l&#41;, 1.
end do
close&#40;34&#41;
end program CMB_cl_sim
If you want to use a proper simulation rather than taking the data to be the exact model, you should use 1/(2l+1) \sum_m |a_{lm}|^2 in the output, where a_{lm} is a Gaussian generated with variance C_l + N_l, or general a_{lm} from the theory C_l only and then add your own noise.
Last edited by Antony Lewis on April 19 2005, edited 1 time in total.

Tor Helge Huse
Posts: 6
Joined: December 15 2004
Affiliation: Astrofysisk Institutt, Oslo

### COSMOMC: all_l_exact data format

Thank you for the information.
I'm trying to include tensors and when I do I get a very high Cl_BB term (~300 for l=20) for the first 100 or so l values, then dropping. Is this as it should be? The N_T term is also very large (same order of magnitude as Cl_BB).
When running with the generated data the likelihood values get very large (xE+9) and it does not seem to get anywhere.

Just to clarify: should COBE_normalize be set to true in CAMB?

regards

Tor Helge

Antony Lewis
Posts: 1445
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

### Re: COSMOMC: all_l_exact data format

I have not tried it with tensors. Obviosuly the relative size of the noise depends on your experiment parameter, though for Planck it is correct that for sensible tensor amplitudes the signal will be noise dominated.

I wouldn't recommend using COBE_normalize, though you can as long as you make sure the final C_l is in \mu\rm{K}^2.

The noise free BB C_l should be about 0.001 the size of the temperature ones, so maybe you have a bug (not using the right column of the totCls output file or something: BB is column 4 of an output file with BB in).

Tor Helge Huse
Posts: 6
Joined: December 15 2004
Affiliation: Astrofysisk Institutt, Oslo

### COSMOMC: all_l_exact data format

Code: Select all

 do l=2, lmax

write &#40;34,'&#40;1I5,6E15.5&#41;'&#41; l,&#40;Cl&#40;l,1&#41;+NoiseCl&#40;l&#41;&#41; , &
&#40;Cl&#40;l,C_C&#41;&#41;, &
&#40;Cl&#40;l,C_E&#41;+ENoiseFac*NoiseCl&#40;l&#41;&#41;, &
!      &#40;Cl&#40;l,C_B&#41;+ENoiseFac*Noise%Cl&#40;l,1&#41;&#41;*1e6, &
NoiseCl&#40;l&#41;*1e6,ENoiseFac*NoiseCl&#40;l&#41;, 1.
end do
close&#40;34&#41;
end program CMB_cl_sim

I'm a bit confused when it comes to the above. Why is the C_l(B) term and NoiseCl(l) term multiplied by 1e6? This blows the numbers up a lot, and especially the noise term, and as far as I can that term is used unchanged in cosmomc.

And the line

Code: Select all

 !      &#40;Cl&#40;l,C_B&#41;+ENoiseFac*Noise%Cl&#40;l,1&#41;&#41;*1e6, &

is for including tensors right? Is the term

Code: Select all

Noise%Cl&#40;l,1&#41;
correct? I recieve a compilation error as it is not defined anywhere. Should it be

Code: Select all

NoiseCl&#40;l&#41;

Tor Helge

Edit:
I wouldn't recommend using COBE_normalize, though you can as long as you make sure the final Cl is in &#956;K2.
Now running with a fresh install of CAMB (april05), nothing changed except l_max, k_max and n_s (0.96), n_t(-0.04) and amp_ratio(0.248).
The noise free BB Cl should be about 0.001 the size of the temperature ones, so maybe you have a bug (not using the right column of the totCls output file or something: BB is column 4 of an output file with BB in).
The C_l(BB) is approx. 0.00001*C_l(TT) in the output from CAMB (column 4 vs column 2, l=48).
After running the data through your routine C_l(BB) is approx. 0.0001*C_l(TT)(l=48).

Antony Lewis
Posts: 1445
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

### Re: COSMOMC: all_l_exact data format

Yes, sorry, I missed deleting those 1e6 factors when converting from my code (which originally used Healpix-normalized output in m\rm{K}^2). Simiarly with the incompatible name. Obviously you need to replace CreateTxtFile as well unless you are using my utils library.

Should be

Code: Select all

!Simulate CMB C_l data
!Simple version assuming isotropic noise and full sky
!no lensing, no tensors &#40;check input Cl file has only 4 columns!&#41;
!all parameters hard wired in code
!Data points are max likelihood values
!AL&#58; Sept 2004

program CMB_cl_sim
use AMLutils
implicit none

!parameters
character&#40;LEN=*&#41;, parameter &#58;&#58; cl_infile = 'MAPcls.dat'
character&#40;LEN=*&#41;, parameter &#58;&#58; out_name = 'planck.dat'
logical &#58;&#58; DoPol = .true., DoTemp = .true.
real &#58;&#58; NoiseVar = 3d-4   !Pessimistic Planck
!in MicroK^2
real, parameter &#58;&#58; fwhm_arcmin = 7. ! 13.  !WMAP ~ 13 &#40;0.22 deg min&#41;
real, parameter &#58;&#58; ENoiseFac = 2 !factor more noise on the polarization
integer, parameter &#58;&#58; lmax = 2250

!Other stuff
integer, parameter &#58;&#58;  C_T = 1, C_E = 2, C_B = 3, C_C = 4

real &#58;&#58; fwhm_deg = fwhm_arcmin/60
real &#58;&#58; Cl&#40;lmax,4&#41;, NoiseCl&#40;lmax&#41;
real amp, xlc, sigma2
integer l,ll
real T, E, TE,B, scal

print *,'lmax = ',lmax
print *,'fwhm_arcmin = ', fwhm_arcmin
print *,'Noise = ',NoiseVar

xlc= 180*sqrt&#40;8.*log&#40;2.&#41;&#41;/3.14159
sigma2 = &#40;fwhm_deg/xlc&#41;**2
do l=2, lmax
NoiseCl&#40;l&#41; = NoiseVar*exp&#40;l*&#40;l+1&#41;*sigma2&#41;
end do

Cl=0
B=0
open&#40;unit=1,file=Cl_infile,form='formatted',status='old'&#41;
do ll=2,lmax
read &#40;1,*&#41; l, T, E, TE
if &#40;l/=ll&#41; stop 'cl must start at l=2'
scal=twopi/&#40;l*&#40;l+1&#41;&#41;
Cl&#40;l,1&#41; = T*scal
Cl&#40;l,2&#41; = E*scal
Cl&#40;l,3&#41; = B*scal
Cl&#40;l,4&#41; = TE*scal
end do
close&#40;1&#41;

call CreateTxtFile&#40;out_name,34&#41;

do l=2, lmax

write &#40;34,'&#40;1I5,6E15.5&#41;'&#41; l,&#40;Cl&#40;l,1&#41;+NoiseCl&#40;l&#41;&#41; , &
&#40;Cl&#40;l,C_C&#41;&#41;, &
&#40;Cl&#40;l,C_E&#41;+ENoiseFac*NoiseCl&#40;l&#41;&#41;, &
!      &#40;Cl&#40;l,C_B&#41;+ENoiseFac*NoiseCl&#40;l&#41;&#41;, &
NoiseCl&#40;l&#41;,ENoiseFac*NoiseCl&#40;l&#41;, 1.
end do
close&#40;34&#41;
end program CMB_cl_sim

Tor Helge Huse
Posts: 6
Joined: December 15 2004
Affiliation: Astrofysisk Institutt, Oslo

### COSMOMC: all_l_exact data format

Ok, thank you. That makes a whole lot more sense. Testing it now (fingers crossed).

Tor Helge

Samuel Leach
Posts: 16
Joined: October 15 2004
Affiliation: SISSA, Trieste
Contact:

### COSMOMC: all_l_exact data format

Dear Antony,

I've been following your discussion here and have been trying out your all_l_exact data format with CosmoMC which of course works rather superbly. Just a couple of related questions here that I'd like you to help me think through:

- I can see that using the exact C_l as the data is a Gaussian realisation, and a rather special one which can be useful for testing the mechanics of the data analysis pipeline for intrinsic bias in parameter reconstruction and in the determination of derived parameters, for instance. Do you know whether this will always lead to the right assessment for the posterior volume ? Of course I should just implement the Gaussian realisation version of the code to experiment a bit.

- What about your Planck noise model ? Can we set up a small database on CosmoCoffee which contains the current broad expectation for Planck and other future experiments, in terms of noise variance and beam width?

- What would be the standard way to cite all the useful information, codes etc from CosmoCofeee ? Did you discuss this together already? These aren't exactly Private Communications.

Thanks always for your time and energies Antony.

Antony Lewis
Posts: 1445
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

### Re: COSMOMC: all_l_exact data format

Samuel Leach wrote:- I can see that using the exact C_l as the data is a Gaussian realisation, and a rather special one which can be useful for testing the mechanics of the data analysis pipeline for intrinsic bias in parameter reconstruction and in the determination of derived parameters, for instance. Do you know whether this will always lead to the right assessment for the posterior volume ? Of course I should just implement the Gaussian realisation version of the code to experiment a bit.
This is an interesting question, and I don't really know the answer. It probably depends on what you think the "right" answer is for forecasting work when you don't know what the exact realisation will be.

My experience for the CMB is that the error bars come out very similar to those you get from a typical realisation (with the advantage that the peak should be exactly at the input parameter values). However, I've not been able to prove any relation to any exact Bayesian forcasting protocol -- I'd be interested to know any thoughts people have.

Note that that actual quadrupole appears to be low, and hence not very typical. Error bars can depend slightly on the value of the quadrupole realisation, which is an example where using best-fit theory value may not be realistic for future experiment error bars (given what we already know about the realisation from WMAP).
Samuel Leach wrote: - What about your Planck noise model ? Can we set up a small database on CosmoCoffee which contains the current broad expectation for Planck and other future experiments, in terms of noise variance and beam width?
Sarah started work on a Wiki giving details of future experiments etc. This would be useful, but of course someone has to put in the work to input all the data. (though the idea with a Wiki of course is that anyone can do it)
Samuel Leach wrote: - What would be the standard way to cite all the useful information, codes etc from CosmoCofeee ? Did you discuss this together already? These aren't exactly Private Communications.
I've referred to plots on CosmoCoffee - just cited the URL. Otherwise I guess mention CosmoCoffee in the Acknowledgements - but we haven't really discussed this.

Pascal Vaudrevange
Posts: 50
Joined: March 26 2006
Affiliation: DESY
Contact:

### COSMOMC: all_l_exact data format

Reviving this old thread.. I would like to create some mock datasets with WMAP3 accuracy. What would the values for noise_var be? Thanks

Pascal Vaudrevange
Posts: 50
Joined: March 26 2006
Affiliation: DESY
Contact:

### COSMOMC: all_l_exact data format

I guess I can answer the question myself. I found this paper by Antony

http://arxiv.org/abs/astro-ph/0502469

which uses N_l^{TT}=0.03\mu K^2 . (Of course, this is only a crude approximation as the beam is not Gaussian..)

Jochen Weller
Posts: 45
Joined: September 24 2004
Affiliation: Ludwig-Maximilians-University Munich
Contact:

### COSMOMC: all_l_exact data format

I have a question regarding the input format of the exact Cl mock data.
In cmbdata.F90 you write:

Code: Select all

  !File format&#58;
!l C_TT &#40;C_TE C_EE &#91;C_BB&#93;&#41; N_T &#40;N_P&#41; fsky_eff
!Must have num_cls set to correct value for file
do l = 2, aset%all_l_lmax
read &#40;file_unit, *, end=100, err=100&#41; idum,inobs&#40;1&#58;ncls&#41;, aset%all_l_noise&#40;l,&#58;&#41;,
aset%all_l_fsky&#40;l&#41;
if &#40;idum /= l&#41; stop 'Error reading all_l_file'
!set BB to pure noise if not in file
if &#40;aset%has_pol .and. ncls < num_cls&#41; inobs&#40;num_cls&#41; = aset%all_l_noise&#40;l,2&#41;
aset%all_l_obs&#40;l,&#58;&#41; = inobs&#40;1&#58;num_cls&#41;
end do

However in the example code to create the mock data you write:

Code: Select all

     do l=2, lmax

write &#40;34,'&#40;1I5,6E15.5&#41;'&#41; l,&#40;Cl&#40;l,1&#41;+NoiseCl&#40;l&#41;&#41; , &
&#40;Cl&#40;l,C_C&#41;&#41;, &
&#40;Cl&#40;l,C_E&#41;+ENoiseFac*NoiseCl&#40;l&#41;&#41;, &
!      &#40;Cl&#40;l,C_B&#41;+ENoiseFac*NoiseCl&#40;l&#41;&#41;, &
NoiseCl&#40;l&#41;,ENoiseFac*NoiseCl&#40;l&#41;, 1.
end do

[q]
Now I am a bit puzzled by why the second column has to be written Cl(l,1)+NoiseCl(l)
I would have expected to have Cl(l,C_Temp) properly normalized to be in there, from the above read statement?[/q]

Antony Lewis
Posts: 1445
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

### Re: COSMOMC: all_l_exact data format

I'm not sure I get the question, but all C_l here are the bare ones without factors of l(l+1)/2\pi.

[q]C_Temp=1.[/q]

Jochen Weller
Posts: 45
Joined: September 24 2004
Affiliation: Ludwig-Maximilians-University Munich
Contact:

### COSMOMC: all_l_exact data format

What I meant it looks like in the 2nd column you are writing Cl+noise, but you just read Cl

Antony Lewis
Posts: 1445
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

### Re: COSMOMC: all_l_exact data format

Yes, the C_l in the data file are the 'observed' C_l and include noise. The exact likelihood is a function of only C_l + N_l for full sky isotropic noise.