classy-szfast 0.0.8__tar.gz → 0.0.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {classy_szfast-0.0.8/classy_szfast.egg-info → classy_szfast-0.0.10}/PKG-INFO +1 -1
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/__init__.py +6 -2
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/classy_sz.py +79 -117
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/classy_szfast.py +343 -156
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/cosmopower.py +77 -9
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/custom_bias/custom_bias.py +1 -1
- {classy_szfast-0.0.8 → classy_szfast-0.0.10/classy_szfast.egg-info}/PKG-INFO +1 -1
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/pypi_upload.sh +2 -2
- classy_szfast-0.0.10/setup.py +30 -0
- classy_szfast-0.0.8/setup.py +0 -59
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/.gitignore +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/MANIFEST.in +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/README.md +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/config.py +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/cosmosis_classy_szfast_interface.py +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/custom_bias/__init__.py +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/custom_profiles/__init__.py +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/custom_profiles/custom_profiles.py +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/pks_and_sigmas.py +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/suppress_warnings.py +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast/utils.py +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast.egg-info/SOURCES.txt +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast.egg-info/dependency_links.txt +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast.egg-info/not-zip-safe +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast.egg-info/requires.txt +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/classy_szfast.egg-info/top_level.txt +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/pyproject.toml +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/requirements.txt +0 -0
- {classy_szfast-0.0.8 → classy_szfast-0.0.10}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: classy_szfast
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.10
|
4
4
|
Summary: The accelerator of the class_sz code from https://github.com/CLASS-SZ
|
5
5
|
Home-page: https://github.com/CLASS-SZ/classy_szfast
|
6
6
|
Download-URL: https://github.com/CLASS-SZ/classy_szfast
|
@@ -8,59 +8,69 @@ import numpy as np
|
|
8
8
|
import time
|
9
9
|
|
10
10
|
class classy_sz(classy):
|
11
|
-
|
11
|
+
|
12
|
+
use_class_sz_fast_mode = 1 # this is passed in the yaml file
|
12
13
|
use_class_sz_no_cosmo_mode = 0 # this is passed in the yaml file
|
13
|
-
lensing_lkl =
|
14
|
-
|
15
|
-
|
14
|
+
lensing_lkl = 'ACT'
|
15
|
+
|
16
|
+
baos = None
|
16
17
|
|
17
18
|
def initialize(self):
|
18
19
|
"""Importing CLASS from the correct path, if given, and if not, globally."""
|
20
|
+
|
19
21
|
self.classy_module = self.is_installed()
|
20
22
|
if not self.classy_module:
|
21
23
|
raise NotInstalledError(
|
22
24
|
self.log, "Could not find CLASS_SZ. Check error message above.")
|
25
|
+
|
23
26
|
from classy_sz import Class, CosmoSevereError, CosmoComputationError
|
27
|
+
|
24
28
|
global CosmoComputationError, CosmoSevereError
|
29
|
+
|
25
30
|
self.classy = Class()
|
26
31
|
super(classy,self).initialize()
|
32
|
+
|
33
|
+
|
27
34
|
# Add general CLASS stuff
|
28
35
|
self.extra_args["output"] = self.extra_args.get("output", "")
|
36
|
+
|
29
37
|
if "sBBN file" in self.extra_args:
|
30
38
|
self.extra_args["sBBN file"] = (
|
31
39
|
self.extra_args["sBBN file"].format(classy=self.path))
|
40
|
+
|
32
41
|
# Derived parameters that may not have been requested, but will be necessary later
|
33
42
|
self.derived_extra = []
|
34
43
|
self.log.info("Initialized!")
|
35
44
|
|
45
|
+
|
46
|
+
## rename some parameters to avoid conflices
|
47
|
+
classy_sz_renames = {
|
48
|
+
|
49
|
+
'omega_m':'Omega_m',
|
50
|
+
'Omegam':'Omega_m',
|
51
|
+
'Omega_m':'Omega_m'
|
52
|
+
}
|
53
|
+
self.renames.update(classy_sz_renames)
|
54
|
+
|
55
|
+
|
36
56
|
if self.use_class_sz_no_cosmo_mode == 1:
|
57
|
+
|
37
58
|
self.log.info("Initializing cosmology part!")
|
59
|
+
|
38
60
|
initial_parameters = self.extra_args.copy()
|
39
|
-
|
61
|
+
|
40
62
|
|
41
63
|
self.classy.set(initial_parameters)
|
42
|
-
self.classy.compute_class_szfast()
|
64
|
+
self.classy.compute_class_szfast(likelihood_mode=True)
|
43
65
|
self.log.info("cosmology part initialized!")
|
44
66
|
|
45
67
|
|
46
|
-
# print(self.lensing_lkl)
|
47
|
-
# exit(0)
|
48
|
-
|
49
|
-
# # class_sz default params for lkl
|
50
|
-
# self.extra_args["output"] = 'tSZ_1h'
|
51
|
-
# self.extra_args["multipoles_sz"] = 'P15'
|
52
|
-
# self.extra_args['nlSZ'] = 18
|
53
68
|
|
54
69
|
|
55
|
-
|
56
|
-
# def calculate(self, state, want_derived=True, **params_values_dict):
|
57
|
-
# print("Bypassing class_sz")
|
58
|
-
|
70
|
+
def must_provide(self, **requirements):
|
59
71
|
|
60
72
|
|
61
73
|
|
62
|
-
def must_provide(self, **requirements):
|
63
|
-
|
64
74
|
if "Cl_sz" in requirements:
|
65
75
|
# make sure cobaya still runs as it does for standard classy
|
66
76
|
requirements.pop("Cl_sz")
|
@@ -246,25 +256,25 @@ class classy_sz(classy):
|
|
246
256
|
args=[])
|
247
257
|
super().must_provide(**requirements)
|
248
258
|
|
259
|
+
|
249
260
|
# get the required new observable
|
250
261
|
def get_Cl(self, ell_factor=False, units="FIRASmuK2"):
|
262
|
+
|
251
263
|
if self.use_class_sz_fast_mode:
|
264
|
+
|
252
265
|
return self.get_Clfast(ell_factor=ell_factor)
|
266
|
+
|
253
267
|
else:
|
268
|
+
|
254
269
|
return self._get_Cl(ell_factor=ell_factor, units=units, lensed=True)
|
255
270
|
|
256
271
|
def get_Clfast(self,ell_factor = False):
|
257
|
-
|
258
|
-
# exit(0)
|
272
|
+
|
259
273
|
cls = {}
|
260
274
|
cls = deepcopy(self._current_state["Cl"])
|
261
|
-
|
262
|
-
# print(cls)
|
263
|
-
# exit(0)
|
264
|
-
# print('in get clfast:',ell_factor)
|
265
|
-
# print(cls)
|
275
|
+
|
266
276
|
lcp = np.asarray(cls['ell'])
|
267
|
-
|
277
|
+
|
268
278
|
if ell_factor==True:
|
269
279
|
cls['tt'] *= (2.7255e6)**2.*(lcp*(lcp+1.))/2./np.pi
|
270
280
|
cls['te'] *= (2.7255e6)**2.*(lcp*(lcp+1.))/2./np.pi
|
@@ -274,17 +284,18 @@ class classy_sz(classy):
|
|
274
284
|
cls['tt'] *= (2.7255e6)**2.
|
275
285
|
cls['te'] *= (2.7255e6)**2.
|
276
286
|
cls['ee'] *= (2.7255e6)**2.
|
277
|
-
|
278
|
-
# print(cls['te'][1230])
|
279
|
-
# print(cls['ee'][1230])
|
280
|
-
# exit(0)
|
287
|
+
|
281
288
|
if self.lensing_lkl == "SOLikeT":
|
282
289
|
cls['pp'] *= (lcp*(lcp+1.))**2./4.
|
290
|
+
|
283
291
|
elif self.lensing_lkl == "ACT":
|
284
|
-
cls['pp'] *= 1
|
292
|
+
cls['pp'] *= 1.
|
293
|
+
|
285
294
|
else: # here for the planck lensing lkl, using lfactor option gives:
|
286
295
|
cls['pp'] *= (lcp*(lcp+1.))**2.*1./2./np.pi
|
296
|
+
|
287
297
|
return cls
|
298
|
+
|
288
299
|
# get the required new observable
|
289
300
|
def get_Cl_sz(self):
|
290
301
|
cls = {}
|
@@ -362,8 +373,9 @@ class classy_sz(classy):
|
|
362
373
|
|
363
374
|
# get the required new observable
|
364
375
|
def get_sz_unbinned_cluster_counts(self):
|
376
|
+
|
365
377
|
cls = deepcopy(self._current_state["sz_unbinned_cluster_counts"])
|
366
|
-
|
378
|
+
|
367
379
|
return cls['loglike'],cls['ntot'],cls['rates']
|
368
380
|
|
369
381
|
|
@@ -380,37 +392,53 @@ class classy_sz(classy):
|
|
380
392
|
|
381
393
|
# IMPORTANT: this method is imported from cobaya and modified to accomodate the emulators
|
382
394
|
def calculate(self, state, want_derived=True, **params_values_dict):
|
383
|
-
|
395
|
+
|
396
|
+
|
384
397
|
params_values = params_values_dict.copy()
|
385
|
-
#
|
386
|
-
|
398
|
+
# if baos are requested we need to update the relevant flags
|
399
|
+
if self.baos:
|
400
|
+
params_values.update({'skip_chi':0,'skip_hubble':0})
|
401
|
+
|
387
402
|
if 'N_ncdm' in self.extra_args.keys():
|
403
|
+
|
388
404
|
if self.extra_args['N_ncdm'] == 3:
|
405
|
+
|
389
406
|
str_mncdm = str(params_values['m_ncdm'])
|
390
407
|
params_values['m_ncdm'] = str_mncdm+','+str_mncdm+','+str_mncdm
|
391
|
-
|
392
|
-
# exit(0)
|
408
|
+
|
393
409
|
try:
|
410
|
+
|
394
411
|
params_values['ln10^{10}A_s'] = params_values.pop("logA")
|
412
|
+
|
395
413
|
self.set(params_values)
|
414
|
+
|
396
415
|
except KeyError:
|
416
|
+
|
397
417
|
self.set(params_values)
|
418
|
+
|
398
419
|
# Compute!
|
399
420
|
try:
|
400
421
|
if self.use_class_sz_fast_mode == 1:
|
401
|
-
|
422
|
+
|
423
|
+
|
402
424
|
if self.use_class_sz_no_cosmo_mode == 1:
|
403
|
-
|
425
|
+
|
426
|
+
start_time = time.time()
|
404
427
|
self.classy.compute_class_sz(params_values)
|
428
|
+
end_time = time.time()
|
429
|
+
# self.log.info("Execution time of class_sz: {:.5f} seconds".format(end_time - start_time))
|
430
|
+
|
405
431
|
else:
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
432
|
+
|
433
|
+
start_time = time.time()
|
434
|
+
self.classy.compute_class_szfast(likelihood_mode=True)
|
435
|
+
end_time = time.time()
|
436
|
+
# self.log.info("Execution time of class_szfast: {:.5f} seconds".format(end_time - start_time))
|
437
|
+
# print('pars in classy',self.classy.pars)
|
412
438
|
else:
|
439
|
+
|
413
440
|
self.classy.compute()
|
441
|
+
|
414
442
|
# "Valid" failure of CLASS: parameters too extreme -> log and report
|
415
443
|
except self.classy_module.CosmoComputationError as e:
|
416
444
|
if self.stop_at_error:
|
@@ -492,81 +520,15 @@ class classy_sz(classy):
|
|
492
520
|
if collector.post:
|
493
521
|
state[product] = collector.post(*state[product])
|
494
522
|
# Prepare derived parameters
|
523
|
+
|
495
524
|
d, d_extra = self._get_derived_all(derived_requested=want_derived)
|
525
|
+
|
496
526
|
if want_derived:
|
527
|
+
|
497
528
|
state["derived"] = {p: d.get(p) for p in self.output_params}
|
498
|
-
|
529
|
+
|
530
|
+
|
499
531
|
state["derived_extra"] = deepcopy(d_extra)
|
500
|
-
# exit(0)
|
501
|
-
|
502
|
-
|
503
|
-
# # get the required new observable
|
504
|
-
# def get_Cl(self,ell_factor=True,units="FIRASmuK2"):
|
505
|
-
# ell_factor=self.ell_factor
|
506
|
-
# # if self.tsz.use_class_sz_fast_mode == 1:
|
507
|
-
# cls = {}
|
508
|
-
# cls['ell'] = np.arange(20000)
|
509
|
-
# # print(cls['ell'])
|
510
|
-
# cls['tt'] = np.zeros(20000)
|
511
|
-
# cls['te'] = np.zeros(20000)
|
512
|
-
# cls['ee'] = np.zeros(20000)
|
513
|
-
# cls['pp'] = np.zeros(20000)
|
514
|
-
# # if self.tt_spectra is not None:
|
515
|
-
# nl = len(self.classy.class_szfast.cp_predicted_tt_spectrum)
|
516
|
-
# # print('nl:',nl)
|
517
|
-
# cls['tt'][2:nl+2] = (2.7255e6)**2.*self.classy.class_szfast.cp_predicted_tt_spectrum
|
518
|
-
# if ell_factor==False:
|
519
|
-
# lcp = np.asarray(cls['ell'][2:nl+2])
|
520
|
-
# cls['tt'][2:nl+2] *= 1./(lcp*(lcp+1.)/2./np.pi)
|
521
|
-
#
|
522
|
-
# # if self.te_spectra is not None:
|
523
|
-
# cls['te'][2:nl+2] = (2.7255e6)**2.*self.classy.class_szfast.cp_predicted_te_spectrum
|
524
|
-
# if ell_factor==False:
|
525
|
-
# lcp = np.asarray(cls['ell'][2:nl+2])
|
526
|
-
# cls['te'][2:nl+2] *= 1./(lcp*(lcp+1.)/2./np.pi)
|
527
|
-
# # if self.ee_spectra is not None:
|
528
|
-
# cls['ee'][2:nl+2] = (2.7255e6)**2.*self.classy.class_szfast.cp_predicted_ee_spectrum
|
529
|
-
# if ell_factor==False:
|
530
|
-
# lcp = np.asarray(cls['ell'][2:nl+2])
|
531
|
-
# cls['ee'][2:nl+2] *= 1./(lcp*(lcp+1.)/2./np.pi)
|
532
|
-
# # if self.pp_spectra is not None:
|
533
|
-
# # nl = len(self.pp_spectra[0])
|
534
|
-
# if self.lensing_lkl == "SOLikeT":
|
535
|
-
# cls['pp'][2:nl+2] = self.classy.class_szfast.cp_predicted_pp_spectrum/4. ## this is clkk... works for so lensinglite lkl
|
536
|
-
# else:
|
537
|
-
# # here for the planck lensing lkl, using lfactor option gives:
|
538
|
-
# lcp = np.asarray(cls['ell'][2:nl+2])
|
539
|
-
# cls['pp'][2:nl+2] = self.classy.class_szfast.cp_predicted_pp_spectrum/(lcp*(lcp+1.))**2.
|
540
|
-
# cls['pp'][2:nl+2] *= (lcp*(lcp+1.))**2./2./np.pi
|
541
|
-
# return cls
|
542
|
-
|
543
|
-
# def check_ranges(self, z, k):
|
544
|
-
# return 1
|
545
|
-
|
546
|
-
# IMPORTANT: copied from cobaya and changed.
|
547
|
-
def get_param(self, p):
|
548
|
-
translated = self.translate_param(p)
|
549
|
-
for pool in ["params", "derived", "derived_extra"]:
|
550
|
-
value = (self.current_state[pool] or {}).get(translated, None)
|
551
|
-
if p == 'omegam':
|
552
|
-
print('getting omegam in get_param')
|
553
|
-
# print(translated)
|
554
|
-
# print(self.classy.Omega_m())
|
555
|
-
# exit(0)
|
556
|
-
return self.classy.Omega_m()
|
557
|
-
if value is not None:
|
558
|
-
return value
|
559
|
-
|
560
|
-
raise LoggedError(self.log, "Parameter not known: '%s'", p)
|
561
|
-
### ORIGINAL FUNCTION:
|
562
|
-
# def get_param(self, p):
|
563
|
-
# translated = self.translate_param(p)
|
564
|
-
# for pool in ["params", "derived", "derived_extra"]:
|
565
|
-
# value = (self.current_state[pool] or {}).get(translated, None)
|
566
|
-
# if value is not None:
|
567
|
-
# return value
|
568
|
-
#
|
569
|
-
# raise LoggedError(self.log, "Parameter not known: '%s'", p)
|
570
532
|
|
571
533
|
|
572
534
|
|