-
Notifications
You must be signed in to change notification settings - Fork 3
/
dscmb.m
205 lines (180 loc) · 5.59 KB
/
dscmb.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
function dscmb
% Makes a plot of the CMB spectrum, its WS error, and how it is improved
% using eigenvalue-weighted multitaper analysis
% PARAMETERS:
% $\Omega_{\mathrm b}=0.046,
%\Omega_{\mathrm c}=0.224, \Omega_{\Lambda}=0.730$ and $H_0=72$
% $\mathrm{km}\,\mathrm{s}^{-1}\,\mathrm{Mpc}^{-1}$
% This is the file name where the spectrum is kept
fname='cmb_68217229.fcl';
% These values are alreay prewhitened, and in microKelvin^2
cmb=load(fullfile(getenv('IFILES'),'CMB',fname));
% Trim this a bit
xmax=900;
cmb=cmb(cmb(:,1)<=xmax,:);
% The degrees at which this spectrum is defined
l=cmb(:,1);
% CMB temperature in microKelvin
Tcmb=2.725e6;
% Whitened spectrum which contains the l(l+1)/2/pi factor
S=cmb(:,2).*Tcmb^2;
% Noise parameters of the detector
dom=4e-6;
% In microkelvin per pixel
sig=100;
% fwhm in arcmin now in radians now
th=20*(pi/180/60);
% Noise spectrum
N=dom*sig^2.*exp(l.^2*th^2/8/log(2));
% Whitened spectrum using the same whitening as th spectrum
N=l.*(l+1)/2/pi.*N;
% Theoretical standard error for the whole-sphere no-taper result
tstd=sqrt(2./(2*l+1)).*(S+N);
% DOUBLE CAP
sord=2;
% SIZE OF THE CUT
TH=10;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clf
[ah,ha]=krijetem(subnum(3,2));
xlabs=sprintf('degree l');
xlobs=sprintf('angular scale');
ylabs=sprintf('l(l+1)S_l/2%s (%sK^2)','\pi','\mu');
axes(ah(1))
EL=[10 20 30 40 50 60];
% Make the small panel plots
for inx=1:length(ah)
[psl(inx),perr(inx),psb(inx),xl(inx),yl(inx)]=...
doitsmoothit(EL(inx),cmb,S,l,tstd,ah(inx),xlabs,ylabs,sord,TH,0);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Cosmetics
set(psl,'Color','k','LineW',1)
set(psb,'LineS','none','Marker','o','MarkerS',3,...
'MarkerF','w','MarkerE','k')
xtix=[2 100:200:xmax];
set(ah,'xlim',[0 xmax],'ylim',[0 6000],'xtick',[2 100:200:xmax])
longticks(ah)
set(ah(~~ah),'box','on')
% Do this before the serre operation
delete(yl([2 4 6]))
delete(xl(1:4))
nolabels(ah(1:4),1)
nolabels(ha(4:6),2)
serre(ha(1:3),2/5,'down')
serre(ha(4:6),2/5,'down')
serre(ah(1:2),1/2,'across')
serre(ah(3:4),1/2,'across')
serre(ah(5:6),1/2,'across')
for inx=1:length(ah)
% Put the identifying labels on
[bh,th]=boxtex('um',ah(inx),...
sprintf('L = %i',EL(inx)),12,1,0.75,1.15);
% Put a caplogo on here
cl(inx)=caplogo(ah(inx),sord+(sord==2),...
'ul',1/30,1/30);
end
movev(cl,-0.035)
moveh(cl,-0.002)
% Put the TH of the left-over cap on here
for inx=1:length(ah)
axes(ah(inx))
tx(inx)=text(10,4800,sprintf('%s = %i%s','\Theta',...
90*(sord==2)+(-1)^(sord+1)*TH,str2mat(176)));
end
set(tx,'FontS',8)
% Put an extra axis on top here using the Jeans relation
degs=[0.2 0.3 0.5 1 90];
for inx=1:length(degs)
xtox(inx)=max(roots([1 1 -(180/degs(inx))^2]));
end
[ax(1),xxl(1)]=xtraxis(ah(1),xtox,degs,xlobs);
[ax(2),xxl(2)]=xtraxis(ah(2),xtox,degs,xlobs);
longticks(ax)
deggies(ax,1)
% On the others put an "empty" xtraxis to properly close the plots
for inx=3:6
ax(inx)=xtraxis(ah(inx));
set(ax(inx),'box','on')
end
% Put the caplogo back on top where it belongs
for inx=1:length(ah)
axes(cl(inx))
end
set(gcf,'color','w','inverthardcopy','off')
fig2print(gcf,'portrait')
figdisp([],[],[],0)
!degs /home/fjsimons/EPS/dscmb.eps
disp('Rerun to get dimensions exactly right')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [SB,B]=smoothit(Lmax,L,S)
% Calculate coupling matrices
% The maximum of the WIGNER0JC database
dbmax=500;
M=mcouplings(L,Lmax,1,dbmax-L);
% Take out rows so the bins become non-overlapping
% These are the bins, add one to get the bins indices
B=L/2:2*L+1:Lmax;
% Take out the degree 0 and 1 part from the true spectrum
M=M(B+1,3:end);
% Perform the deliberate biasing
SB=M*S;
hold on
% Fix the last element up for cosmetic reasons
SB(end)=SB(end)/sum(M(end,:),2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [psl,perr,psb,xl,yl]=...
doitsmoothit(L,cmb,S,l,tstd,ah,xlabs,ylabs,sord,TH,xver)
axes(ah)
% Calculate the biased measurements
[SB,B]=smoothit(cmb(end,1),L,S);
% Plot the true values and the shading
% Make end bits a bit nicer by introducing fake data
% Note that this is NOT a condifence interval; we don't know the
% distribution really
[psl,e68,e95]=errorfill...
([l(1)-10 ; l(:) ; l(end)+10],[S(1) ; S(:) ; S(end)],...
[tstd(1) ; tstd(:) ; tstd(end)]);
delete(e95)
set(psl,'Color','k','LineW',1)
set(e68,'FaceC',grey(9))
% Plot the truth without the shaded bars
% psl=plot(l,S);
hold on
% No, hold on, calculate based on a cut
[mt2ws,ml,mt2wsinf]=mvarratios(L,TH,sord,B,xver);
if xver==1
% Calculate the error bars based on full coverage
mt2wsF1=mvarratios(L,180,1,B,xver);
mt2wsF2=mvarratios(L,0,2,B,xver);
difer(mt2wsF1-mt2wsF2,[],[],'All consistent')
% If you used a ratio, it would come out
% If you didn't, it shows you how it would have come out
% We only show the case where it has been used, i.e. where it comes out
% constant
rus=mt2ws./mt2wsF1;
if ~sum(diff(rus))
switch sord
case 1
Ato4pi=(1-cos(TH*pi/180))/2;
case 2
Ato4pi=(1-sin(TH*pi/180));
end
disp(sprintf('Exponent that appears to be used is %4.2f',...
log10(rus(1))/log10(Ato4pi)))
disp(sprintf('Actual ratio appearing to be used is %4.2f',rus(1)))
end
end
% Sure, at these bin widths, you may hit the maximum variance ratio first
% and then come down - you'd have to compute it at B=l to see the whole
% pattern
disp(sprintf('Error ratio at large l is %5.3f',sqrt(mt2wsinf)))
% Plot these as error bars
perr=errorbar(B,SB,sqrt(mt2ws(:)).*tstd(B+1));
set(getkids(perr,2),'Color','k')
delete(getkids(perr,1))
hold on
% Plot the biased measurements
psb(1)=plot(B,SB);
yl=ylabel(ylabs);
xl=xlabel(xlabs);