-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdriver_tszksz_all_r2_old.py
1495 lines (1257 loc) · 59 KB
/
driver_tszksz_all_r2_old.py
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import universe
reload(universe)
from universe import *
import mass_conversion
reload(mass_conversion)
from mass_conversion import *
import catalog
reload(catalog)
from catalog import *
import thumbstack
reload(thumbstack)
from thumbstack import *
import cmb
reload(cmb)
from cmb import *
# running on cori
# 68 cores per knl node, 32 cores per haswell node
#salloc -N 1 --qos=interactive -C haswell -t 04:00:00 -L SCRATCH
# for cori
#plt.switch_backend('Agg')
##################################################################################
nProc = 32 # 1 haswell node on cori
pathFig = '/global/cscratch1/sd/eschaan/project_ksz_act_planck/code/thumbstack/figures/thumbstack/summary_plots_r2/'
##################################################################################
##################################################################################
# cosmological parameters
u = UnivMariana()
# M*-Mh relation
massConversion = MassConversionKravtsov14()
#massConversion.plot()
###################################################################################
# Galaxy catalogs
print("Read galaxy catalogs")
tStart = time()
# Mini CMASS Mariana, for debugging
nObj = 10000#50000
cmassMarianaShort = Catalog(u, massConversion, name="cmass_mariana", nameLong="CMASS M", save=False, nObj=nObj)
cmassMarianaShort.name = "cmass_mariana_short"
catalogs = {
#"cmass_mariana_short": cmassMarianaShort,
#
#"cmass_s_mariana": Catalog(u, massConversion, name="cmass_s_mariana", nameLong="CMASS S M", pathInCatalog="../../data/CMASS_DR12_mariana_20160200/output/cmass_dr12_S_mariana.txt", save=False),
#"cmass_n_mariana": Catalog(u, massConversion, name="cmass_n_mariana", nameLong="CMASS N M", pathInCatalog="../../data/CMASS_DR12_mariana_20160200/output/cmass_dr12_N_mariana.txt", save=False),
"cmass_mariana": Catalog(u, massConversion, name="cmass_mariana", nameLong="CMASS M", rV=0.5, save=False),
#
#"cmass_s_kendrick": Catalog(u, massConversion, name="cmass_s_kendrick", nameLong="CMASS S K", pathInCatalog="../../data/BOSS_DR10_kendrick_20150407/output/cmass_dr10_S_kendrick.txt", save=False),
#"cmass_n_kendrick": Catalog(u, massConversion, name="cmass_n_kendrick", nameLong="CMASS N K", pathInCatalog="../../data/BOSS_DR10_kendrick_20150407/output/cmass_dr10_N_kendrick.txt", save=False),
"cmass_kendrick": Catalog(u, massConversion, name="cmass_kendrick", nameLong="CMASS K", rV=0.7, save=False),
#"lowz_s_kendrick": Catalog(u, massConversion, name="lowz_s_kendrick", nameLong="LOWZ S K", pathInCatalog="../../data/BOSS_DR10_kendrick_20150407/output/lowz_dr10_S_kendrick.txt", save=False),
#"lowz_n_kendrick": Catalog(u, massConversion, name="lowz_n_kendrick", nameLong="LOWZ N K", pathInCatalog="../../data/BOSS_DR10_kendrick_20150407/output/lowz_dr10_N_kendrick.txt", save=False),
"lowz_kendrick": Catalog(u, massConversion, name="lowz_kendrick", nameLong="LOWZ K", rV=0.7, save=False),
#"boss_kendrick": Catalog(u, massConversion, name="boss_kendrick", nameLong="BOSS K", save=False),
#"cmass_mk_diff": Catalog(u, massConversion, name="cmass_mk_diff", nameLong="CMASS M-K", rV=1., save=False),
}
tStop = time()
print("took "+str(round((tStop-tStart)/60., 2))+" min")
###################################################################################
# Read CMB maps
class cmbMap(object):
def __init__(self, pathMap, pathMask, pathHit=None, name="test"):
self.name = name
self.pathMap = pathMap
self.pathMask = pathMask
self.pathHit = pathHit
def map(self):
result = enmap.read_map(self.pathMap)
# if the map contains polarization, keep only temperature
if len(result.shape)>2:
result = result[0]
return result
def mask(self):
result = enmap.read_map(self.pathMask)
# if the map contains polarization, keep only temperature
if len(result.shape)>2:
result = result[0]
return result
def hit(self):
if self.pathHit is None:
return None
else:
result = enmap.read_map(self.pathHit)
# if the map contains polarization, keep only temperature
if len(result.shape)>2:
result = result[0]
return result
print("Read CMB maps")
tStart = time()
cmbMaps = {
# PACT day+night, 20200228, Planck Galactic masks 60%
"pactf150daynight20200228maskgal60r2": cmbMap("/global/cscratch1/sd/eschaan/project_ksz_act_planck/data/planck_act_coadd_2020_02_28_r2/" + "act_planck_s08_s18_cmb_f150_daynight_map.fits",
"./output/cmb_map/pact20200228_r2/" + "mask_full_foot_gal60_ps.fits",
"/global/cscratch1/sd/eschaan/project_ksz_act_planck/data/planck_act_coadd_2020_02_28/" + "act_planck_s08_s18_cmb_f150_daynight_ivar.fits",
name="pactf150daynight20200228maskgal60r2"),
"pactf90daynight20200228maskgal60r2": cmbMap("/global/cscratch1/sd/eschaan/project_ksz_act_planck/data/planck_act_coadd_2020_02_28_r2/" + "act_planck_s08_s18_cmb_f090_daynight_map.fits",
"./output/cmb_map/pact20200228_r2/" + "mask_full_foot_gal60_ps.fits",
"/global/cscratch1/sd/eschaan/project_ksz_act_planck/data/planck_act_coadd_2020_02_28_r2/" + "act_planck_s08_s18_cmb_f090_daynight_ivar.fits",
name="pactf90daynight20200228maskgal60r2"),
"pactf150reconvto90minus90daynight20200228maskgal60r2": cmbMap("./output/cmb_map/planck_act_coadd_2020_02_28_r2/" + "act_planck_s08_s18_cmb_f150reconvto90_minus_f090_daynight_map.fits",
"./output/cmb_map/pact20200228_r2/" + "mask_full_foot_gal60_ps.fits",
"/global/cscratch1/sd/eschaan/project_ksz_act_planck/data/planck_act_coadd_2020_02_28_r2/" + "act_planck_s08_s18_cmb_f150_daynight_ivar.fits",
name="pactf150reconvto90minus90daynight20200228maskgal60r2"),
#
# TileC v1.2, reconvolved to 1.4' beam, combining BOSS N and D56
"tilecpactynocmb": cmbMap("./output/cmb_map/tilec_pact_ynocmb_v1.2.0/" + "tilec_map.fits",
"./output/cmb_map/tilec_pact_ynocmb_v1.2.0/" + "mask_full_foot_gal_ps.fits",
name="tilecpactynocmb"),
"tilecpactyminusynocib": cmbMap("./output/cmb_map/tilec_pact_yminusynocib_v1.2.0/" + "diff_map.fits",
"./output/cmb_map/tilec_pact_yminusynocib_v1.2.0/" + "mask_full_foot_gal_ps.fits",
name="tilecpactyminusynocib"),
#
"tilecpacty": cmbMap("./output/cmb_map/tilec_pact_y_v1.2.0/" + "tilec_map.fits",
"./output/cmb_map/tilec_pact_y_v1.2.0/" + "mask_full_foot_gal_ps.fits",
name="tilecpacty"),
"tilecpactynocib": cmbMap("./output/cmb_map/tilec_pact_ynocib_v1.2.0/" + "tilec_map.fits",
"./output/cmb_map/tilec_pact_ynocib_v1.2.0/" + "mask_full_foot_gal_ps.fits",
name="tilecpactynocib"),
#"tilecpactcmbksz": cmbMap("./output/cmb_map/tilec_pact_cmbksz_v1.2.0/" + "tilec_reconv1.4_map.fits",
#"./output/cmb_map/tilec_pact_cmbksz_v1.2.0/" + "mask_full_foot_gal_ps.fits",
#name="tilecpactcmbksz"),
#"tilecpactcmbksznoy": cmbMap("./output/cmb_map/tilec_pact_cmbksznoy_v1.2.0/" + "tilec_reconv2.4_map.fits",
#"./output/cmb_map/tilec_pact_cmbksznoy_v1.2.0/" + "mask_full_foot_gal_ps.fits",
#name="tilecpactcmbksznoy"),
#
# kSZ pipeline check
"pactf150daynight20200228maskgal60r2_minus_tilecpactcmbksz": cmbMap("./output/cmb_map/pactf150daynight20200228maskgal60r2_minus_tilec_pact_cmbksz/" + "diff_map.fits",
"./output/cmb_map/pactf150daynight20200228maskgal60r2_minus_tilec_pact_cmbksz/" + "mask_full_foot_gal_ps.fits",
name="pactf150daynight20200228maskgal60r2_minus_tilecpactcmbksz"),
#
# kSZ dust contamination test
"pactf150daynight20200228maskgal60r2_minus_tilecpactcmbksznocib": cmbMap("./output/cmb_map/pactf150daynight20200228maskgal60r2_minus_tilec_pact_cmbksznocib/" + "diff_map.fits",
"./output/cmb_map/pactf150daynight20200228maskgal60r2_minus_tilec_pact_cmbksznocib/" + "mask_full_foot_gal_ps.fits",
name="pactf150daynight20200228maskgal60r2_minus_tilecpactcmbksznocib"),
#
# tSZ pipeline (map) check
"pactf150daynight20200228maskgal60r2_minus_tilecpactymuk": cmbMap("./output/cmb_map/pactf150daynight20200228maskgal60r2_minus_tilec_pact_ymuk/" + "diff_map.fits",
"./output/cmb_map/pactf150daynight20200228maskgal60r2_minus_tilec_pact_ymuk/" + "mask_full_foot_gal_ps.fits",
name="pactf150daynight20200228maskgal60r2_minus_tilecpactymuk"),
#
# To have tau and y at the same TileC deproj beam
"pactf150daynight20200228maskgal60r2reconvtotilecdeproj": cmbMap("/global/cscratch1/sd/eschaan/project_ksz_act_planck/data/planck_act_coadd_2020_02_28_r2/" + "act_planck_s08_s18_cmb_f150_daynight_map_reconvtotilecdeproj.fits",
"./output/cmb_map/pact20200228_r2/" + "mask_full_foot_gal60_ps.fits",
name="pactf150daynight20200228maskgal60r2reconvtotilecdeproj"),
"pactf90daynight20200228maskgal60r2reconvtotilecdeproj": cmbMap("/global/cscratch1/sd/eschaan/project_ksz_act_planck/data/planck_act_coadd_2020_02_28_r2/" + "act_planck_s08_s18_cmb_f090_daynight_map_reconvtotilecdeproj.fits",
"./output/cmb_map/pact20200228_r2/" + "mask_full_foot_gal60_ps.fits",
name="pactf90daynight20200228maskgal60r2reconvtotilecdeproj"),
#
# daynight VS night null test
"pactf150daynight20200228maskgal60r2_minus_night": cmbMap("./output/cmb_map/planck_act_coadd_2020_02_28_r2/" + "act_planck_s08_s18_cmb_f150_daynight_minus_night_map.fits",
"./output/cmb_map/pact20200228_r2/" + "mask_full_foot_gal60_ps.fits",
name="pactf150daynight20200228maskgal60r2_minus_night"),
}
tStop = time()
print("took "+str(round((tStop-tStart)/60., 2))+" min")
###################################################################################
catalogCombi = {
"pactf150daynight20200228maskgal60r2reconvtotilecdeproj": ['lowz_kendrick', 'cmass_kendrick', 'cmass_mariana'],
"pactf90daynight20200228maskgal60r2reconvtotilecdeproj": ['lowz_kendrick', 'cmass_kendrick', 'cmass_mariana'],
#
"pactf150daynight20200228maskgal60r2": ['lowz_kendrick', 'cmass_kendrick', 'cmass_mariana'],
"pactf90daynight20200228maskgal60r2": ['cmass_kendrick', 'lowz_kendrick', 'cmass_mariana'],
"pactf150reconvto90minus90daynight20200228maskgal60r2": ['cmass_kendrick', 'lowz_kendrick'],
#
"tilecpactynocmb": ['cmass_kendrick', 'lowz_kendrick'],
"tilecpactyminusynocib": ['cmass_kendrick', 'lowz_kendrick'],
#
"tilecpacty": ['cmass_kendrick', 'lowz_kendrick'],
"tilecpactynocib": ['cmass_kendrick', 'lowz_kendrick'],
"tilecpactcmbksz": ['cmass_kendrick', 'lowz_kendrick'],
#
"pactf150daynight20200228maskgal60r2_minus_tilecpactcmbksz": ['cmass_kendrick', 'lowz_kendrick'],
"pactf150daynight20200228maskgal60r2_minus_tilecpactymuk": ['cmass_kendrick', 'lowz_kendrick'],
"pactf150daynight20200228maskgal60r2_minus_tilecpactcmbksznocib": ['cmass_kendrick', 'lowz_kendrick'],
#
"pactf150daynight20200228maskgal60r2_minus_night": ['cmass_kendrick'],
}
###################################################################################
###################################################################################
# Compute all the stacked profiles
'''
import thumbstack
reload(thumbstack)
from thumbstack import *
save = True
#for cmbMapKey in cmbMaps.keys():
#for cmbMapKey in cmbMaps.keys()[::-1]:
#for cmbMapKey in ['pactf150daynight20200228maskgal60r2reconvtotilecdeproj', 'pactf90daynight20200228maskgal60r2reconvtotilecdeproj']:
#for cmbMapKey in ['pactf90daynight20200228maskgal60r2reconvtotilecdeproj']:
#for cmbMapKey in cmbMaps.keys()[:len(cmbMaps.keys())//2]:
#for cmbMapKey in cmbMaps.keys()[len(cmbMaps.keys())//2:]:
for cmbMapKey in ["pactf150daynight20200228maskgal60r2_minus_night"]:
cmbMap = cmbMaps[cmbMapKey].map()
cmbMask = cmbMaps[cmbMapKey].mask()
cmbHit = cmbMaps[cmbMapKey].hit()
cmbName = cmbMaps[cmbMapKey].name
print("Analyzing map "+cmbName)
for catalogKey in catalogCombi[cmbMapKey]:
catalog = catalogs[catalogKey]
print("Analyzing catalog "+catalog.name)
name = catalog.name + "_" + cmbName
if name=='cmass_kendrick_pactf150daynight20200228maskgal60r2' or name=='lowz_kendrick_pactf150daynight20200228maskgal60r2' or name=='cmass_kendrick_pactf90daynight20200228maskgal60r2' or name=='lowz_kendrick_pactf90daynight20200228maskgal60r2':
ts = ThumbStack(u, catalog, cmbMap, cmbMask, cmbHit, name, nameLong=None, save=save, nProc=nProc, doMBins=True, doBootstrap=True, doVShuffle=True)
else:
ts = ThumbStack(u, catalog, cmbMap, cmbMask, cmbHit, name, nameLong=None, save=save, nProc=nProc, doMBins=False, doBootstrap=False, doVShuffle=False)
'''
###################################################################################
###################################################################################
# Stacked cutout maps for PR
'''
import thumbstack
reload(thumbstack)
from thumbstack import *
save = False
for cmbMapKey in ['pactf150daynight20200228maskgal60r2', 'pactf90daynight20200228maskgal60r2', 'tilecpactynocib', 'tilecpacty']:
cmbMap = cmbMaps[cmbMapKey].map()
cmbMask = cmbMaps[cmbMapKey].mask()
cmbHit = cmbMaps[cmbMapKey].hit()
cmbName = cmbMaps[cmbMapKey].name
print("Analyzing map "+cmbName)
for catalogKey in ['cmass_kendrick', 'lowz_kendrick']:#catalogCombi[cmbMapKey]:
catalog = catalogs[catalogKey]
print("Analyzing catalog "+catalog.name)
name = catalog.name + "_" + cmbName
print("C'est parti")
ts = ThumbStack(u, catalog, cmbMap, cmbMask, cmbHit, name, nameLong=None, save=save, nProc=nProc, doMBins=True, doBootstrap=True, doVShuffle=True, doStackedMap=True)
'''
###################################################################################
###################################################################################
# Joint cov 90-150 for PACT and PACT reconv to tilec deproj
'''
import thumbstack
reload(thumbstack)
from thumbstack import *
for catalogKey in ['cmass_kendrick', 'lowz_kendrick']:
#for catalogKey in ['cmass_kendrick']:
catalog = catalogs[catalogKey]
print("Analyzing catalog "+catalog.name)
# PACT 90 - 150 reconv to tilec deproj
ts = {}
for freq in ['90', '150']:
cmbMapKey = "pactf"+freq+"daynight20200228maskgal60r2reconvtotilecdeproj"
cmbMap = cmbMaps[cmbMapKey].map()
cmbMask = cmbMaps[cmbMapKey].mask()
cmbHit = cmbMaps[cmbMapKey].hit()
cmbName = cmbMaps[cmbMapKey].name
name = catalog.name + "_" + cmbName
#
ts[freq] = ThumbStack(u, catalog, cmbMap, cmbMask, cmbHit, name, nameLong=None, save=False, nProc=nProc, doMBins=False, doBootstrap=False, doVShuffle=False)
# compute the joint cov
if True:
ts['150'].saveAllCovBootstrapTwoStackedProfiles(ts['90'])
ts['150'].plotAllCovTwoStackedProfiles(ts['90'])
# PACT 90 - 150
ts = {}
for freq in ['90', '150']:
cmbMapKey = "pactf"+freq+"daynight20200228maskgal60r2"
cmbMap = cmbMaps[cmbMapKey].map()
cmbMask = cmbMaps[cmbMapKey].mask()
cmbHit = cmbMaps[cmbMapKey].hit()
cmbName = cmbMaps[cmbMapKey].name
name = catalog.name + "_" + cmbName
#
ts[freq] = ThumbStack(u, catalog, cmbMap, cmbMask, cmbHit, name, nameLong=None, save=False, nProc=nProc, doMBins=False, doBootstrap=False, doVShuffle=False)
# compute the joint cov
if True:
ts['150'].saveAllCovBootstrapTwoStackedProfiles(ts['90'])
ts['150'].plotAllCovTwoStackedProfiles(ts['90'])
'''
###################################################################################
###################################################################################
###################################################################################
###################################################################################
# Read all the stacked profiles
# convert from sr to arcmin^2
factor = (180.*60./np.pi)**2
# conversion from y to muK at 150 GHz
Tcmb = 2.726 # K
h = 6.63e-34 # SI
kB = 1.38e-23 # SI
def f(nu):
"""frequency dependence for tSZ temperature
"""
x = h*nu/(kB*Tcmb)
return x*(np.exp(x)+1.)/(np.exp(x)-1.) -4.
yTomuK150 = f(150.e9) * Tcmb * 1.e6 # [muK * sr]
pathThumb = './output/thumbstack/'
rKsz = {}
ksz = {}
sKsz = {}
covKsz = {}
#
rTsz = {}
tsz = {}
sTsz = {}
covTsz = {}
for cmbMapKey in cmbMaps.keys():
cmbName = cmbMaps[cmbMapKey].name
for catalogKey in catalogCombi[cmbMapKey]:
catalog = catalogs[catalogKey]
name = catalog.name + "_" + cmbName
# read the stacked kSZ profile
try:
data = np.genfromtxt(pathThumb + name + "/diskring_ksz_varweight_measured.txt")
except:
data = np.genfromtxt(pathThumb + name + "/diskring_ksz_uniformweight_measured.txt")
rKsz[name] = data[:,0]
ksz[name] = data[:,1] * factor
sKsz[name] = data[:,2] * factor
# read the kSZ cov
path = pathThumb + name + '/cov_diskring_ksz_varweight_bootstrap.txt'
if os.path.isfile(path):
covKsz[name] = np.genfromtxt(path) * factor**2
else:
path = pathThumb + name + '/cov_diskring_ksz_uniformweight_bootstrap.txt'
if os.path.isfile(path):
covKsz[name] = np.genfromtxt(path) * factor**2
# read the stacked tSZ profile
try:
data = np.genfromtxt(pathThumb + name + "/diskring_tsz_varweight_measured.txt")
except:
data = np.genfromtxt(pathThumb + name + "/diskring_tsz_uniformweight_measured.txt")
rTsz[name] = data[:,0]
tsz[name] = data[:,1] * factor
sTsz[name] = data[:,2] * factor
# read the tSZ cov
path = pathThumb + name + '/cov_diskring_tsz_varweight_bootstrap.txt'
if os.path.isfile(path):
covTsz[name] = np.genfromtxt(path) * factor**2
else:
path = pathThumb + name + '/cov_diskring_tsz_uniformweight_bootstrap.txt'
if os.path.isfile(path):
covTsz[name] = np.genfromtxt(path) * factor**2
# read the joint 150-90 cov for ksz and tsz
for catalogKey in ['cmass_kendrick', 'lowz_kendrick']:
catalog = catalogs[catalogKey]
# PACT 150 - 90
#
path = pathThumb + catalog.name + "_pactf150daynight20200228maskgal60r2" + "/cov_diskring_ksz_varweight_joint_"+catalog.name+"_pactf150daynight20200228maskgal60r2_"+catalog.name+"_pactf90daynight20200228maskgal60r2_bootstrap.txt"
covKsz[catalog.name+'_joint15090'] = np.genfromtxt(path) * factor**2
#
path = pathThumb + catalog.name + "_pactf150daynight20200228maskgal60r2" + "/cov_diskring_tsz_varweight_joint_"+catalog.name+"_pactf150daynight20200228maskgal60r2_"+catalog.name+"_pactf90daynight20200228maskgal60r2_bootstrap.txt"
covTsz[catalog.name+'_joint15090'] = np.genfromtxt(path) * factor**2
# PACT 150 - 90 reconv to tilec
#
# path = pathThumb + catalog.name + "_pactf150daynight20200228maskgal60r2reconvtotilecdeproj" + "/cov_diskring_ksz_varweight_joint_"+catalog.name+"_pactf150daynight20200228maskgal60r2reconvtotilecdeproj_"+catalog.name+"_pactf90daynight20200228maskgal60r2reconvtotilecdeproj_bootstrap.txt"
path = pathThumb + catalog.name + "_pactf150daynight20200228maskgal60r2reconvtotilecdeproj" + "/cov_diskring_ksz_uniformweight_joint_"+catalog.name+"_pactf150daynight20200228maskgal60r2reconvtotilecdeproj_"+catalog.name+"_pactf90daynight20200228maskgal60r2reconvtotilecdeproj_bootstrap.txt"
covKsz[catalog.name+'_joint15090reconvtotilecdeproj'] = np.genfromtxt(path) * factor**2
#
# path = pathThumb + catalog.name + "_pactf150daynight20200228maskgal60r2reconvtotilecdeproj" + "/cov_diskring_tsz_varweight_joint_"+catalog.name+"_pactf150daynight20200228maskgal60r2reconvtotilecdeproj_"+catalog.name+"_pactf90daynight20200228maskgal60r2reconvtotilecdeproj_bootstrap.txt"
path = pathThumb + catalog.name + "_pactf150daynight20200228maskgal60r2reconvtotilecdeproj" + "/cov_diskring_tsz_uniformweight_joint_"+catalog.name+"_pactf150daynight20200228maskgal60r2reconvtotilecdeproj_"+catalog.name+"_pactf90daynight20200228maskgal60r2reconvtotilecdeproj_bootstrap.txt"
covTsz[catalog.name+'_joint15090reconvtotilecdeproj'] = np.genfromtxt(path) * factor**2
# read the theory curves from Stefania
for catalogKey in ['cmass_kendrick', 'lowz_kendrick']:
catalog = catalogs[catalogKey]
path = './input/stefania/theory_curves/'
# NFW profiles at 90 and 150 GHz
data = np.genfromtxt(path+'nfw_'+catalogKey+'_mw_trunc1rvir.txt')
ksz[catalog.name+'_150_nfw'] = data[:,1] * factor
ksz[catalog.name+'_90_nfw'] = data[:,2] * factor
# Best fit theory curves
if catalog.name=='cmass_kendrick':
#
data = np.genfromtxt(path+'cmass_kendrick_ksz_best_150_90.txt')
ksz[catalog.name+'_150_theory'] = data[:,1] * factor
ksz[catalog.name+'_90_theory'] = data[:,2] * factor
#
data = np.genfromtxt(path+'cmass_kendrick_tsz+dust_best_150_90.txt')
tsz[catalog.name+'_150_theory'] = data[:,1] * factor
tsz[catalog.name+'_90_theory'] = data[:,2] * factor
#
data = np.genfromtxt(path+'cmass_kendrick_y_nocib_best.txt')
tsz[catalog.name+'_ynocib_theory'] = data[:,1] * factor
# Compare to Schaan+16 measurement
#
# CMASS K
path = "./input/ksz_schaan+16/diagonal_cov_paper/alpha_ksz_kendrick.txt"
data = np.genfromtxt(path)
rKsz['cmass_kendrick_150_schaan+16'] = data[:,0] # [arcmin]
alphaK = data[:,1] # [dimless]
sAlphaK = data[:,2] # [dimless]
# convert to the new measurement unit
cmassK = catalogs['cmass_kendrick']
ksz['cmass_kendrick_150_schaan+16'] = alphaK * np.std(cmassK.vR) / 3.e5 / cmassK.rV * 2.726e6 * np.mean(cmassK.integratedTau) * (180.*60./np.pi)**2
sKsz['cmass_kendrick_150_schaan+16'] = sAlphaK * np.std(cmassK.vR) / 3.e5 / cmassK.rV * 2.726e6 * np.mean(cmassK.integratedTau) * (180.*60./np.pi)**2
#
# CMASS M
path = "./input/ksz_schaan+16/diagonal_cov_paper/alpha_ksz_mariana.txt"
data = np.genfromtxt(path)
rKsz['cmass_mariana_150_schaan+16'] = data[:,0] # [arcmin]
alphaM = data[:,1] # [dimless]
sAlphaM = data[:,2] # [dimless]
# convert to the new measurement unit
cmassM = catalogs['cmass_mariana']
ksz['cmass_mariana_150_schaan+16'] = alphaM * np.std(cmassM.vR) / 3.e5 / cmassM.rV * 2.726e6 * np.mean(cmassM.integratedTau) * (180.*60./np.pi)**2
sKsz['cmass_mariana_150_schaan+16'] = sAlphaM * np.std(cmassM.vR) / 3.e5 / cmassM.rV * 2.726e6 * np.mean(cmassM.integratedTau) * (180.*60./np.pi)**2
# read the stacks on mock GRFs, to compare
pathMockGRF = "/global/cscratch1/sd/eschaan/project_ksz_act_planck/code/thumbstack/output/cmb_map/mocks_grf_planck_act_coadd_2019_03_11/"
iMock0 = 0
nMocks = 800
#
est = 'ksz_varweight'
meanStackedKszGRF = np.genfromtxt(pathMockGRF+"mean_diskring_"+est+"_mocks"+str(iMock0)+"-"+str(iMock0+nMocks)+".txt") * factor
covStackedKszGRF = np.genfromtxt(pathMockGRF+"cov_diskring_"+est+"_mocks"+str(iMock0)+"-"+str(iMock0+nMocks)+".txt") * factor**2
sStackedKszGRF = np.sqrt(np.diag(covStackedKszGRF)) / np.sqrt(nMocks)
#
est = 'tsz_varweight'
meanStackedTszGRF = np.genfromtxt(pathMockGRF+"mean_diskring_"+est+"_mocks"+str(iMock0)+"-"+str(iMock0+nMocks)+".txt") * factor
covStackedTszGRF = np.genfromtxt(pathMockGRF+"cov_diskring_"+est+"_mocks"+str(iMock0)+"-"+str(iMock0+nMocks)+".txt") * factor**2
sStackedTszGRF = np.sqrt(np.diag(covStackedTszGRF)) / np.sqrt(nMocks)
# kSZ: v-shuffle mean
data = np.genfromtxt(pathThumb + "cmass_kendrick_pactf150daynight20200228maskgal60r2/" + "diskring_ksz_varweight_vshufflemean.txt")
rKsz150VShuffleMean = data[:,0]
ksz150VShuffleMean = data[:,1] * factor
sKsz150VShuffleMean = data[:,2] * factor
###################################################################################
###################################################################################
###################################################################################
# Compute significances
for catalogKey in ['cmass_kendrick', 'lowz_kendrick']:
# kSZ
d = np.concatenate((ksz[catalogKey+'_pactf150daynight20200228maskgal60r2'],
ksz[catalogKey+'_pactf90daynight20200228maskgal60r2']))
cov = covKsz[catalogKey+'_joint15090']
tNFW = np.concatenate((ksz[catalogKey+'_150_nfw'],
ksz[catalogKey+'_90_nfw']))
if catalogKey=='cmass_kendrick':
t = np.concatenate((ksz[catalogKey+'_150_theory'],
ksz[catalogKey+'_90_theory']))
else:
t = np.zeros_like(d)
print(catalogKey+", joint ksz 150-90, best fit VS null")
computeSnr(d, t, cov)
print(catalogKey+", joint ksz 150-90, best fit VS NFW")
computeSnr(d - tNFW, t - tNFW, cov)
print(catalogKey+", joint ksz 150-90, null VS NFW")
computeSnr(d - tNFW, 0. - tNFW, cov)
# tSZ
d = tsz[catalogKey+'_tilecpactynocib']
cov = covTsz[catalogKey+'_tilecpactynocib']
if catalogKey=='cmass_kendrick':
t = tsz[catalogKey+'_ynocib_theory']
else:
t = np.zeros_like(d)
print(catalogKey+", tsz on tilec y no cib")
computeSnr(d, t, cov)
# tSZ + dust
print(catalogKey+", joint tsz+dust 150-90")
# joint tsz + dust,
# discard the first data point
d = np.concatenate((tsz[catalogKey+'_pactf150daynight20200228maskgal60r2'][1:],
tsz[catalogKey+'_pactf90daynight20200228maskgal60r2'][1:]))
I = np.concatenate((range(1,9), range(9+1, 9+9)))
J = np.ix_(I,I)
cov = covTsz[catalogKey+'_joint15090'][J]
if catalogKey=='cmass_kendrick':
t = np.concatenate((tsz[catalogKey+'_150_theory'][1:],
tsz[catalogKey+'_90_theory'][1:]))
else:
t = np.zeros_like(d)
computeSnr(d, t, cov)
###################################################################################
###################################################################################
###################################################################################
###################################################################################
# Generate all the plots
'''
for catalogKey in ['cmass_kendrick', 'lowz_kendrick']:
catalog = catalogs[catalogKey]
# true velocity RMS for CMASS K
zMean = catalog.Z.mean() # Msun
vRms = u.v1dRms(0., zMean, W3d_sth) # [km/s]
tauToKsz = 2.726e6 * (vRms/3.e5)
# virial radius, before convolving with the beams
mVirMean = catalog.Mvir.mean() # [Msun]. Will need to be converted to [Msun/h] below
rVir = u.frvir(mVirMean * u.bg.h, zMean) # [Mpc/h]
thetaVir = rVir / u.bg.comoving_distance(zMean) * (180.*60./np.pi) # [arcmin]
print catalogKey
print "mean z =", zMean
print "mean chi =", u.bg.comoving_distance(zMean), "Mpc/h"
print "mean mass =", mVirMean, "Msun"
print "virial radius =", rVir, "Mpc/h"
print "virial angle =", thetaVir, "arcmin"
print "RMS 1d velocity =", vRms, "km/s"
if catalogKey=='cmass_kendrick':
catalogTitle = 'CMASS'
fmt = 'o'
elif catalogKey=='lowz_kendrick':
catalogTitle = 'LOWZ'
fmt = 'o:'#'o--'
rAp = rKsz[catalogKey+'_pactf150daynight20200228maskgal60r2']
###################################################################################
# Summary ksz plots at 150 and 90
# PACT 150
ksz150 = ksz[catalogKey+'_pactf150daynight20200228maskgal60r2']
sKsz150 = sKsz[catalogKey+'_pactf150daynight20200228maskgal60r2']
#
# PACT 90
ksz90 = ksz[catalogKey+'_pactf90daynight20200228maskgal60r2']
sKsz90 = sKsz[catalogKey+'_pactf90daynight20200228maskgal60r2']
# best fit theory curves
if catalogKey=='cmass_kendrick':
ksz150Th = ksz[catalog.name+'_150_theory']
ksz150 = ksz[catalogKey+'_pactf150daynight20200228maskgal60r2']
sKsz150 = sKsz[catalogKey+'_pactf150daynight20200228maskgal60r2']
#
# PACT 90
ksz90 = ksz[catalogKey+'_pactf90daynight20200228maskgal60r2']
sKsz90 = sKsz[catalogKey+'_pactf90daynight20200228maskgal60r2']
# best fit theory curves
if catalogKey=='cmass_kendrick':
ksz150Th = ksz[catalog.name+'_150_theory']
ksz90Th = ksz[catalog.name+'_90_theory']
# NFW curves
ksz150NFW = ksz[catalog.name+'_150_nfw']
ksz90NFW = ksz[catalog.name+'_90_nfw']
# NFW curves
ksz150NFW = ksz[catalog.name+'_150_nfw']
ksz90NFW = ksz[catalog.name+'_90_nfw']
fig=plt.figure(0)
ax=fig.add_subplot(111)
ax.minorticks_on()
#
ax.axhline(0., c='k', lw=1)
#
# virial radius
ax.axvline(np.sqrt(thetaVir**2 + 1.3**2/(8.*np.log(2.))), color='blue', alpha=0.1)
ax.axvline(np.sqrt(thetaVir**2 + 2.1**2/(8.*np.log(2.))), color='purple', alpha=0.1)
#
# data
ax.errorbar(rAp, ksz150, sKsz150, fmt=fmt, c='blue', label='150 GHz DR5')
ax.errorbar(rAp + 0.05, ksz90, sKsz90, fmt=fmt, c='purple', label='98 GHz DR5')
#
# best fit theory curves
if catalogKey=='cmass_kendrick':
ax.plot(rAp, ksz150Th, 'blue', label=r'Joint best fit profile')
ax.plot(rAp, ksz90Th, 'purple')
#
# NFW profiles
ax.plot(rAp, ksz150NFW, ls='--', c='blue', label=r'NFW')
ax.plot(rAp, ksz90NFW, ls='--', c='purple')
#
# Gaussian profiles to guide the eye
fwhm = np.array([1.3, 2.1, 6.]) # arcmin
sigma = fwhm / np.sqrt(8. * np.log(2.))
for s in sigma:
#y = ftheoryGaussianProfile(s, filterType='diskring')
y = (1. - np.exp(-0.5*rAp**2/s**2))**2
# normalize to the last data point at 150 GHz
y *= ksz150[-1]
ax.plot(rAp, y, 'gray', alpha=0.3)
ax.plot([], [], 'gray', alpha=0.3, label=r'Gaussian profiles')
#
ax.legend(loc=4, fontsize='x-small', labelspacing=0.1)
ax.set_xlabel(r'$R$ [arcmin]')
ax.set_ylabel(r'$T_\text{kSZ}$ [$\mu K\cdot\text{arcmin}^2$]')
ax.set_title(catalogTitle + r' kSZ profile', x=0.5, y=1.25)
ax.set_yscale('log', nonposy='clip')
ax.set_ylim((0.03, 70.))
#
# make extra abscissa with disk comoving size in Mpc/h
ax2 = ax.twiny()
ax2.minorticks_on()
ticks = ax.get_xticks()
ax2.set_xticks(ticks)
newticks = np.array(ticks) * np.pi/(180.*60.)*u.bg.comoving_distance(zMean) # disk radius in Mpc/h
newticks = np.round(newticks, 2)
ax2.set_xticklabels(newticks)
ax2.set_xlim(ax.get_xlim())
ax2.set_xlabel(r'Comoving radius [Mpc/h] at $z=$'+str(round(zMean,2)), fontsize=20)
ax2.xaxis.set_label_coords(0.5, 1.15)
#
# extra ordinate to convert kSZ to tau
ax3 = ax.twinx()
ax3.minorticks_on()
ax3.set_yscale('log', nonposy='clip')
ylim = ax.get_ylim()
ylim = np.array(ylim) / tauToKsz
ax3.set_ylim(ylim)
ax3.set_ylabel(r'Integrated $\tau_\text{CAP}$ [arcmin$^2$]', fontsize=20)
#
path = pathFig+"summary_ksz_150_90_"+catalogKey+".pdf"
fig.savefig(path, bbox_inches='tight')
#plt.show()
fig.clf()
###################################################################################
# ksz: comparison plot with Schaan+16
if catalogKey=='cmass_kendrick':
# Schaan+16 ksz data, converted to the new unit
rK = rKsz['cmass_kendrick_150_schaan+16']
kszKS16 = ksz['cmass_kendrick_150_schaan+16']
sKszKS16 = sKsz['cmass_kendrick_150_schaan+16']
#
rM = rKsz['cmass_mariana_150_schaan+16']
kszMS16 = ksz['cmass_mariana_150_schaan+16']
sKszMS16 = sKsz['cmass_mariana_150_schaan+16']
fig=plt.figure(0)
ax=fig.add_subplot(111)
ax.minorticks_on()
#
ax.axhline(0., c='k', lw=1)
#
# virial radius
ax.axvline(np.sqrt(thetaVir**2 + 1.3**2/(8.*np.log(2.))), color='blue', alpha=0.1)
#
# data
ax.errorbar(rAp, ksz150, sKsz150, fmt=fmt, c='k', label='This work 150 GHz CMASS K')
#
# comparison with Schaan+16
ax.errorbar(rM, kszMS16, yerr=sKszMS16, c='blue', label=r'Schaan+16 150 GHz CMASS M')
ax.errorbar(rK + 0.05, kszKS16, yerr=sKszKS16, c='blue', alpha=0.3, label=r'Schaan+16 150 GHz CMASS K')
#
# # Theory curves if available
# if catalogKey=='cmass_kendrick':
# # best fit theory curves
# ax.plot(rAp, ksz150Th, 'blue', label=r'Joint best fit profile')
# ax.plot(rAp, ksz90Th, 'purple')
# # NFW profiles
# ax.plot(rAp, ksz150NFW, ls='--', c='blue', label=r'NFW')
# ax.plot(rAp, ksz90NFW, ls='--', c='purple')
#
ax.legend(loc=4, fontsize='x-small', labelspacing=0.1)
ax.set_xlabel(r'$R$ [arcmin]')
ax.set_ylabel(r'$T_\text{kSZ}$ [$\mu K\cdot\text{arcmin}^2$]')
ax.set_title(catalogTitle + r' kSZ profile', x=0.5, y=1.25)
ax.set_yscale('log', nonposy='clip')
ax.set_ylim((0.03, 40.))
#
# make extra abscissa with disk comoving size in Mpc/h
ax2 = ax.twiny()
ax2.minorticks_on()
ticks = ax.get_xticks()
ax2.set_xticks(ticks)
newticks = np.array(ticks) * np.pi/(180.*60.)*u.bg.comoving_distance(zMean) # disk radius in Mpc/h
newticks = np.round(newticks, 2)
ax2.set_xticklabels(newticks)
ax2.set_xlim(ax.get_xlim())
ax2.set_xlabel(r'Comoving radius [Mpc/h] at $z=$'+str(round(zMean,2)), fontsize=20)
ax2.xaxis.set_label_coords(0.5, 1.15)
#
# extra ordinate to convert kSZ to tau
ax3 = ax.twinx()
ax3.minorticks_on()
ax3.set_yscale('log', nonposy='clip')
ylim = ax.get_ylim()
ylim = np.array(ylim) / tauToKsz
ax3.set_ylim(ylim)
ax3.set_ylabel(r'Integrated $\tau_\text{CAP}$ [arcmin$^2$]', fontsize=20)
#
path = pathFig+"summary_ksz_150_90_"+catalogKey+"_vs_schaan+16.pdf"
fig.savefig(path, bbox_inches='tight')
#plt.show()
fig.clf()
###################################################################################
# summary tSZ + dust at 150 and 90
# PACT 150
tsz150 = tsz[catalogKey+'_pactf150daynight20200228maskgal60r2']
sTsz150 = sTsz[catalogKey+'_pactf150daynight20200228maskgal60r2']
#
# PACT 90
tsz90 = tsz[catalogKey+'_pactf90daynight20200228maskgal60r2']
sTsz90 = sTsz[catalogKey+'_pactf90daynight20200228maskgal60r2']
if catalogKey=='cmass_kendrick':
# best fit theory curves
tsz150Th = tsz[catalog.name+'_150_theory']
tsz90Th = tsz[catalog.name+'_90_theory']
# tSZ + dust plot at 150 and 90
fig=plt.figure(0)
ax=fig.add_subplot(111)
ax.minorticks_on()
#
ax.axhline(0., c='k', lw=1)
#
# virial radius
ax.axvline(np.sqrt(thetaVir**2 + 1.3**2/(8.*np.log(2.))), color='blue', alpha=0.1)
ax.axvline(np.sqrt(thetaVir**2 + 2.1**2/(8.*np.log(2.))), color='purple', alpha=0.1)
#
ax.errorbar(rAp, tsz150, sTsz150, fmt=fmt, c='blue', label='150 GHz DR5')
ax.errorbar(rAp + 0.05, tsz90, sTsz90, fmt=fmt, c='purple', label='98 GHz DR5')
#
# Theory curves if available
if catalogKey=='cmass_kendrick':
ax.plot(rAp, tsz150Th, 'blue', label=r'Joint best fit profile')
ax.plot(rAp, tsz90Th, 'purple')
#
ax.legend(loc=1, fontsize='x-small', labelspacing=0.1)
ax.set_xlabel(r'$R$ [arcmin]')
ax.set_ylabel(r'$T_{\text{tSZ} + \text{dust}}$ [$\mu K\cdot\text{arcmin}^2$]')
ax.set_title(catalogTitle + r' tSZ + dust profile', x=0.5, y=1.25)
ax.set_yscale('symlog')
#
# make extra abscissa with disk comoving size in Mpc/h
ax2 = ax.twiny()
ax2.minorticks_on()
ticks = ax.get_xticks()
ax2.set_xticks(ticks)
newticks = np.array(ticks) * np.pi/(180.*60.)*u.bg.comoving_distance(zMean) # disk radius in Mpc/h
newticks = np.round(newticks, 2)
ax2.set_xticklabels(newticks)
ax2.set_xlim(ax.get_xlim())
ax2.set_xlabel(r'Comoving radius [Mpc/h] at $z=$'+str(round(zMean,2)), fontsize=20)
ax2.xaxis.set_label_coords(0.5, 1.15)
#
path = pathFig+"summary_tsz_150_90_"+catalogKey+".pdf"
fig.savefig(path, bbox_inches='tight')
#plt.show()
fig.clf()
###################################################################################
# Summary tSZ on TileC y no CIB
# TileC y no Cib
tszYNoCib = tsz[catalogKey+'_tilecpactynocib'] * yTomuK150
sTszYNoCib = sTsz[catalogKey+'_tilecpactynocib'] * yTomuK150
# best fit theory curves
if catalogKey=='cmass_kendrick':
tszYNoCibTh = tsz[catalog.name+'_ynocib_theory'] * yTomuK150
# tSZ-only from the TileC y no CIB map
fig=plt.figure(0)
ax=fig.add_subplot(111)
ax.minorticks_on()
#
ax.axhline(0., c='k', lw=1)
#
# virial radius
ax.axvline(np.sqrt(thetaVir**2 + 2.4**2/(8.*np.log(2.))), color='r', alpha=0.1)
#
# Tilec y no CIB
ax.errorbar(rAp, tszYNoCib, yerr=sTszYNoCib, fmt=fmt, c='r', label='ILC y no CIB DR4')
#
# Theory curves if available
if catalogKey=='cmass_kendrick':
ax.plot(rAp, tszYNoCibTh, 'r')
#
ax.legend(loc=3, fontsize='x-small', labelspacing=0.1)
ax.set_xlabel(r'$R$ [arcmin]')
ax.set_ylabel(r'$T_{\text{tSZ}}$ [$\mu K\cdot\text{arcmin}^2$]')
ax.set_title(catalogTitle + r' tSZ profile', x=0.5, y=1.25)
ax.set_yscale('symlog', linthreshy=1e-1, linscaley=0.1)
#ax.set_ylim((0., 2.))
#
# make extra abscissa with disk comoving size in Mpc/h
ax2 = ax.twiny()
ax2.minorticks_on()
ticks = ax.get_xticks()
ax2.set_xticks(ticks)
newticks = np.array(ticks) * np.pi/(180.*60.)*u.bg.comoving_distance(zMean) # disk radius in Mpc/h
newticks = np.round(newticks, 2)
ax2.set_xticklabels(newticks)
ax2.set_xlim(ax.get_xlim())
ax2.set_xlabel(r'Comoving radius [Mpc/h] at $z=$'+str(round(zMean,2)), fontsize=20)
ax2.xaxis.set_label_coords(0.5, 1.15)
#
# extra ordinate to convert tSZ to y units
ax3 = ax.twinx()
ax3.minorticks_on()
ax3.set_yscale('symlog', linthreshy=1e-1 / np.abs(yTomuK150), linscaley=0.1)
ylim = ax.get_ylim()
ylim = np.array(ylim) / np.abs(yTomuK150)
ax3.set_ylim(ylim)
ax3.set_ylabel(r'Integrated $-y_\text{CAP}$ [arcmin$^2$]', fontsize=20)
#
path = pathFig+"summary_tsz_"+catalogKey+".pdf"
fig.savefig(path, bbox_inches='tight')
#plt.show()
fig.clf()
###################################################################################
# Comparison: tSZ + dust plot on 150, 90, TileC
fig=plt.figure(0)
ax=fig.add_subplot(111)
ax.minorticks_on()
#
ax.axhline(0., c='k', lw=1)
#
# virial radius
ax.axvline(np.sqrt(thetaVir**2 + 1.3**2/(8.*np.log(2.))), color='blue', alpha=0.1)
ax.axvline(np.sqrt(thetaVir**2 + 2.1**2/(8.*np.log(2.))), color='purple', alpha=0.1)
ax.axvline(np.sqrt(thetaVir**2 + 2.4**2/(8.*np.log(2.))), color='r', alpha=0.1)
#
# Tilec y no CIB
ax.errorbar(rAp, tszYNoCib, yerr=sTszYNoCib, fmt=fmt, c='r', label='ILC y no CIB DR4')
# PACT 150
ax.errorbar(rAp, tsz150, yerr=sTsz150, fmt='-', c='blue', label='150 GHz DR5')
# PACT 90
ax.errorbar(rAp, tsz90, yerr=sTsz90, fmt='-', c='purple', label='98 GHz DR5')
#
ax.legend(loc=3, fontsize='x-small', labelspacing=0.1)
ax.set_xlabel(r'$R$ [arcmin]')
ax.set_ylabel(r'$T_{\text{tSZ}}$ [$\mu K\cdot\text{arcmin}^2$]')
ax.set_title(catalogTitle + r' tSZ profile', x=0.5, y=1.25)
ax.set_yscale('symlog')
#ax.set_ylim((0., 2.))
#
# make extra abscissa with disk comoving size in Mpc/h
ax2 = ax.twiny()
ax2.minorticks_on()
ticks = ax.get_xticks()
ax2.set_xticks(ticks)
newticks = np.array(ticks) * np.pi/(180.*60.)*u.bg.comoving_distance(zMean) # disk radius in Mpc/h
newticks = np.round(newticks, 2)
ax2.set_xticklabels(newticks)
ax2.set_xlim(ax.get_xlim())
ax2.set_xlabel(r'Comoving radius [Mpc/h] at $z=$'+str(round(zMean,2)), fontsize=20)
ax2.xaxis.set_label_coords(0.5, 1.15)
#
#
path = pathFig+"comparison_tsz_150_90_tilec_"+catalogKey+".pdf"
fig.savefig(path, bbox_inches='tight')
#plt.show()
fig.clf()
###################################################################################
###################################################################################
# kSZ null tests
# fiducial uncertainty
ksz150 = ksz[catalogKey+'_pactf150daynight20200228maskgal60r2']
sKsz150 = sKsz[catalogKey+'_pactf150daynight20200228maskgal60r2']
# Mariana's velocities
if catalogKey=='cmass_kendrick':
catalogMariana = 'cmass_mariana'
ksz150Mariana = ksz[catalogMariana+'_pactf150daynight20200228maskgal60r2']
sKsz150Mariana = sKsz[catalogMariana+'_pactf150daynight20200228maskgal60r2']
#
# 150 - tilec cmb, as a consistency check
ksz150MinusTilecCmb = ksz[catalogKey+'_pactf150daynight20200228maskgal60r2_minus_tilecpactcmbksz']
sKsz150MinusTilecCmb = sKsz[catalogKey+'_pactf150daynight20200228maskgal60r2_minus_tilecpactcmbksz']
#
# 150 reconv to 90 minus 90, to check consistency
ksz150Reconv90Minus90 = ksz[catalogKey+'_pactf150reconvto90minus90daynight20200228maskgal60r2']
sKsz150Reconv90Minus90 = sKsz[catalogKey+'_pactf150reconvto90minus90daynight20200228maskgal60r2']
#
# tilec y no cmb, to check for tSZ contamination