classy-szfast 0.0.8__py3-none-any.whl → 0.0.10__py3-none-any.whl

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/__init__.py CHANGED
@@ -6,5 +6,9 @@ from .pks_and_sigmas import *
6
6
 
7
7
  from pathlib import Path
8
8
  import sys
9
- from .custom_profiles import *
10
- from .custom_bias import *
9
+
10
+
11
+ from .custom_profiles.custom_profiles import *
12
+
13
+
14
+ from .custom_bias.custom_bias import *
@@ -8,59 +8,69 @@ import numpy as np
8
8
  import time
9
9
 
10
10
  class classy_sz(classy):
11
- use_class_sz_fast_mode = 0 # this is passed in the yaml file
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 = "SOLikeT"
14
- # skip_background_and_thermo = True
15
- # ell_factor = False # True for pyactlite and bplike, False for clik
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
- # print("initial_parameters:",initial_parameters)
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
- # # here modify if you want to bypass stuff in the class computation
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
- # print('ell_factor:',self.ell_factor)
258
- # exit(0)
272
+
259
273
  cls = {}
260
274
  cls = deepcopy(self._current_state["Cl"])
261
- # ell_factor = self.ell_factor
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
- # print(self.lensing_lkl)
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
- # print(cls['tt'][1230])
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.#(lcp*(lcp+1.))**2./4.
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
- # print(cls)
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
- # Set parameters
395
+
396
+
384
397
  params_values = params_values_dict.copy()
385
- # print('\n\n')
386
- # print('>>> class_sz.py: class/class_sz using params:',params_values)
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
- # print('>>> class_sz.py: class/class_sz using params:',params_values)
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
- # start = time.perf_counter()
422
+
423
+
402
424
  if self.use_class_sz_no_cosmo_mode == 1:
403
- # print(params_values)
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
- self.classy.compute_class_szfast()
407
- # end = time.perf_counter()
408
- # print('classy_szfast took:',end-start)
409
- # self.classy.compute_class_szfast()
410
- # elif self.use_class_sz_no_cosmo_mode == 1:
411
- # self.classy.compute_class_sz(params_values)
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
- # Prepare necessary extra derived parameters
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
 
@@ -12,14 +12,65 @@ import pickle
12
12
 
13
13
  H_units_conv_factor = {"1/Mpc": 1, "km/s/Mpc": Const.c_km_s}
14
14
 
15
+
16
+ import logging
17
+
18
+ def configure_logging(level=logging.INFO):
19
+ logging.basicConfig(
20
+ format='%(levelname)s - %(message)s',
21
+ level=level
22
+ )
23
+
24
+ def set_verbosity(verbosity):
25
+ levels = {
26
+ 'none': logging.CRITICAL,
27
+ 'minimal': logging.INFO,
28
+ 'extensive': logging.DEBUG
29
+ }
30
+ # print(f'Setting verbosity to {verbosity}')
31
+ level = levels.get(verbosity, logging.INFO)
32
+ configure_logging(level)
33
+
34
+
35
+
36
+ def update_params_with_defaults(params_values, default_values):
37
+ """
38
+ Update params_values with default values if they don't already exist.
39
+
40
+ Args:
41
+ params_values (dict): Dictionary containing parameter values.
42
+ default_values (dict): Dictionary containing default parameter values.
43
+ """
44
+
45
+
46
+ # Update params_values with default values if key does not exist
47
+ for key, value in default_values.items():
48
+ if key not in params_values:
49
+ params_values[key] = value
50
+
51
+
15
52
  class Class_szfast(object):
16
53
  def __init__(self,
54
+ params_settings = {},
17
55
  #lowring=False, some options if needed
18
56
  **kwargs):
19
57
  # some parameters
20
58
  # self.xy = xy
21
59
  # self.lowring = lowring
22
60
 
61
+
62
+ self.A_s_fast = 0
63
+ self.logA_fast = 0
64
+
65
+
66
+ set_verbosity(params_settings["classy_sz_verbose"])
67
+ self.logger = logging.getLogger(__name__)
68
+
69
+
70
+
71
+
72
+
73
+
23
74
  # cosmopower emulators
24
75
  self.cp_path_to_cosmopower_organization = path_to_cosmopower_organization + '/'
25
76
  self.cp_tt_nn = cp_tt_nn
@@ -33,22 +84,42 @@ class Class_szfast(object):
33
84
  self.cp_h_nn = cp_h_nn
34
85
  self.cp_s8_nn = cp_s8_nn
35
86
 
87
+ self.emulator_dict = emulator_dict
88
+
36
89
  if dofftlog_alphas == True:
37
90
  self.cp_pkl_fftlog_alphas_nus = cp_pkl_fftlog_alphas_nus
38
91
  self.cp_pkl_fftlog_alphas_real_nn = cp_pkl_fftlog_alphas_real_nn
39
92
  self.cp_pkl_fftlog_alphas_imag_nn = cp_pkl_fftlog_alphas_imag_nn
40
93
 
41
- self.cosmo_model = 'lcdm'
94
+ self.cosmo_model = 'ede-v2'
42
95
  self.use_Amod = 0
43
96
  self.Amod = 0
44
97
 
45
98
  self.cp_lmax = cp_l_max_scalars
46
99
  self.cp_ls = np.arange(2,self.cp_lmax+1)
47
100
 
48
- self.cp_kmax = 50.
49
- self.cp_kmin = 1e-4
50
- self.cp_nk = 5000
51
- self.cp_ndspl_k = 10
101
+
102
+
103
+
104
+ cosmo_model_dict = {0: 'lcdm',
105
+ 1: 'mnu',
106
+ 2: 'neff',
107
+ 3: 'wcdm',
108
+ 4: 'ede',
109
+ 5: 'mnu-3states',
110
+ 6: 'ede-v2'
111
+ }
112
+
113
+
114
+ if cosmo_model_dict[params_settings['cosmo_model']] == 'ede-v2':
115
+
116
+ self.cp_ndspl_k = 1
117
+ self.cp_nk = 1000
118
+
119
+ else:
120
+
121
+ self.cp_ndspl_k = 10
122
+ self.cp_nk = 5000
52
123
 
53
124
  self.cp_predicted_tt_spectrum =np.zeros(self.cp_lmax)
54
125
  self.cp_predicted_te_spectrum =np.zeros(self.cp_lmax)
@@ -59,55 +130,77 @@ class Class_szfast(object):
59
130
  self.cszfast_ldim = 20000 # used for the cls arrays
60
131
 
61
132
  self.cszfast_pk_grid_nz = 100 # has to be same as narraySZ, i.e., ndim_redshifts; it is setup hereafter if ndim_redshifts is passed
62
- self.cszfast_pk_grid_zmax = 5. # current max z of our pk emulators (sept 23)
133
+
134
+
135
+
136
+ if (cosmo_model_dict[params_settings['cosmo_model']] == 'ede-v2'):
137
+
138
+ self.cszfast_pk_grid_zmax = 20.
139
+ self.cszfast_pk_grid_kmin = 5e-4
140
+ self.cszfast_pk_grid_kmax = 10.
141
+ self.cp_kmax = self.cszfast_pk_grid_kmax
142
+ self.cp_kmin = self.cszfast_pk_grid_kmin
143
+ # self.logger.info(f">>> using kmin = {self.cp_kmin}")
144
+ # self.logger.info(f">>> using kmax = {self.cp_kmax}")
145
+ # self.logger.info(f">>> using zmax = {self.cszfast_pk_grid_zmax}")
146
+
147
+ else:
148
+
149
+ self.cszfast_pk_grid_zmax = 5. # max z of our pk emulators (sept 23)
150
+ self.cszfast_pk_grid_kmin = 1e-4
151
+ self.cszfast_pk_grid_kmax = 50.
152
+ self.cp_kmax = self.cszfast_pk_grid_kmax
153
+ self.cp_kmin = self.cszfast_pk_grid_kmin
154
+ # self.logger.info(f">>> using kmin = {self.cp_kmin}")
155
+ # self.logger.info(f">>> using kmax = {self.cp_kmax}")
156
+ # self.logger.info(f">>> using zmax = {self.cszfast_pk_grid_zmax}")
157
+
63
158
  self.cszfast_pk_grid_z = np.linspace(0.,self.cszfast_pk_grid_zmax,self.cszfast_pk_grid_nz)
64
159
  self.cszfast_pk_grid_ln1pz = np.log(1.+self.cszfast_pk_grid_z)
65
160
 
66
- self.cszfast_pk_grid_kmin = 1e-4
67
- self.cszfast_pk_grid_kmax = 50.
161
+
68
162
  self.cszfast_pk_grid_k = np.geomspace(self.cp_kmin,self.cp_kmax,self.cp_nk)[::self.cp_ndspl_k]
163
+
69
164
  self.cszfast_pk_grid_lnk = np.log(self.cszfast_pk_grid_k)
165
+
70
166
  self.cszfast_pk_grid_nk = len(np.geomspace(self.cp_kmin,self.cp_kmax,self.cp_nk)[::self.cp_ndspl_k]) # has to be same as ndimSZ, and the same as dimension of cosmopower pk emulators
71
- for k,v in kwargs.items():
72
- # if k == 'ndim_masses':
73
- # self.cszfast_pk_grid_nk = v
74
- # self.cszfast_pk_grid_k = np.geomspace(self.cszfast_pk_grid_kmin,self.cszfast_pk_grid_kmax,self.cszfast_pk_grid_nk)
167
+
168
+ for k,v in params_settings.items():
169
+
75
170
  if k == 'ndim_redshifts':
171
+
76
172
  self.cszfast_pk_grid_nz = v
77
173
  self.cszfast_pk_grid_z = np.linspace(0.,self.cszfast_pk_grid_zmax,self.cszfast_pk_grid_nz)
78
174
  self.cszfast_pk_grid_ln1pz = np.log(1.+self.cszfast_pk_grid_z)
175
+
79
176
  self.cszfast_pk_grid_pknl_flat = np.zeros(self.cszfast_pk_grid_nz*self.cszfast_pk_grid_nk)
80
177
  self.cszfast_pk_grid_pkl_flat = np.zeros(self.cszfast_pk_grid_nz*self.cszfast_pk_grid_nk)
81
178
 
82
179
  if k == 'cosmo_model':
83
- # print('updating cosmo model')
84
- cosmo_model_dict = {0: 'lcdm',
85
- 1: 'mnu',
86
- 2: 'neff',
87
- 3: 'wcdm',
88
- 4: 'ede',
89
- 5: 'mnu-3states'}
180
+
90
181
  self.cosmo_model = cosmo_model_dict[v]
91
182
 
92
183
  if k == 'use_Amod':
184
+
93
185
  self.use_Amod = v
94
- self.Amod = kwargs['Amod']
95
- # print('self.cosmo_model',self.cosmo_model)
96
- # print('self.cszfast_pk_grid_nk',self.cszfast_pk_grid_nk)
97
- # print('self.cszfast_pk_grid_nz',self.cszfast_pk_grid_nz)
186
+ self.Amod = params_settings['Amod']
98
187
 
99
- # exit(0)
100
- self.cp_z_interp = np.linspace(0.,20.,5000)
101
188
 
102
- self.csz_base = None
103
- # self.csz_base.compute()
104
189
 
190
+ if cosmo_model_dict[params_settings['cosmo_model']] == 'ede-v2':
191
+
192
+ self.pk_power_fac = self.cszfast_pk_grid_k**-3
193
+
194
+ else:
105
195
 
106
- # z_arr = np.linspace(0.,zmax,nz) # z-array of redshift data [21oct22] oct 26 22: nz = 1000, zmax = 20
107
- #
108
- # nk = self.cp_nk
109
- # ndspl = self.cp_ndspl_k
110
- # k_arr = np.geomspace(self.cp_kmin,self.cp_kmax,nk)[::ndspl] # oct 26 22 : (1e-4,50.,5000), jan 10: ndspl
196
+ ls = np.arange(2,self.cp_nk+2)[::self.cp_ndspl_k] # jan 10 ndspl
197
+ dls = ls*(ls+1.)/2./np.pi
198
+ self.pk_power_fac= (dls)**-1
199
+
200
+
201
+ self.cp_z_interp = np.linspace(0.,20.,5000)
202
+
203
+ self.csz_base = None
111
204
 
112
205
 
113
206
  self.cszfast_zgrid_zmin = 0.
@@ -131,33 +224,39 @@ class Class_szfast(object):
131
224
  self.cszfast_gas_pressure_xgrid = np.geomspace(self.cszfast_gas_pressure_xgrid_xmin,
132
225
  self.cszfast_gas_pressure_xgrid_xmax,
133
226
  self.cszfast_gas_pressure_xgrid_nx)
134
-
227
+
228
+ self.params_for_emulators = {}
135
229
 
136
230
  def find_As(self,params_cp):
137
- # params_cp = self.params_cp
138
- t0 = time.time()
139
231
 
140
232
  sigma_8_asked = params_cp["sigma8"]
141
- # print(params_cp)
233
+
234
+ update_params_with_defaults(params_cp, self.emulator_dict[self.cosmo_model]['default'])
235
+
142
236
  def to_root(ln10_10_As_goal):
143
237
  params_cp["ln10^{10}A_s"] = ln10_10_As_goal[0]
144
238
  params_dict = {}
145
239
  for k,v in params_cp.items():
146
240
  params_dict[k]=[v]
241
+
147
242
  return self.cp_der_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0][1]-sigma_8_asked
148
243
 
149
244
  lnA_s = optimize.root(to_root,
150
245
  x0=3.046,
151
246
  #tol = 1e-10,
152
247
  method="hybr")
153
- params_cp['ln10^{10}A_s'] = lnA_s.x[0]# .x[0]
248
+
249
+ params_cp['ln10^{10}A_s'] = lnA_s.x[0]
250
+
154
251
  params_cp.pop('sigma8')
155
- # print("T total in find As",time.time()-t0)#self.t_total)
156
- # print(params_cp)
252
+
157
253
  return 1
158
254
 
159
255
 
160
256
  def get_H0_from_thetas(self,params_values):
257
+
258
+ update_params_with_defaults(params_values, self.emulator_dict[self.cosmo_model]['default'])
259
+
161
260
  # print(params_values)
162
261
  theta_s_asked = params_values['100*theta_s']
163
262
  def fzero(H0_goal):
@@ -165,7 +264,7 @@ class Class_szfast(object):
165
264
  params_dict = {}
166
265
  for k,v in params_values.items():
167
266
  params_dict[k]=[v]
168
- # print(params_dict)
267
+
169
268
  predicted_der_params = self.cp_der_nn[self.cosmo_model].ten_to_predictions_np(params_dict)
170
269
  return predicted_der_params[0][0]-theta_s_asked
171
270
  sol = optimize.root(fzero,
@@ -221,11 +320,14 @@ class Class_szfast(object):
221
320
  want_ee=True,
222
321
  want_pp=1,
223
322
  **params_values_dict):
323
+
324
+
224
325
  params_values = params_values_dict.copy()
225
- # params_values['ln10^{10}A_s'] = params_values.pop("logA")
226
- # print('in cmb:',params_values)
326
+
327
+ update_params_with_defaults(params_values, self.emulator_dict[self.cosmo_model]['default'])
328
+
227
329
  params_dict = {}
228
- # print('cosmo_model',self.cosmo_model)
330
+
229
331
  for k,v in params_values.items():
230
332
  params_dict[k]=[v]
231
333
 
@@ -233,16 +335,45 @@ class Class_szfast(object):
233
335
  if isinstance(params_dict['m_ncdm'][0],str):
234
336
  params_dict['m_ncdm'] = [float(params_dict['m_ncdm'][0].split(',')[0])]
235
337
 
236
- # print('params_dict',params_dict)
237
338
 
238
- if want_tt:
239
- self.cp_predicted_tt_spectrum = self.cp_tt_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0]
339
+
340
+ # if want_tt: for now always want_tt = True
341
+ self.cp_predicted_tt_spectrum = self.cp_tt_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0]
342
+
343
+ nl = len(self.cp_predicted_tt_spectrum)
344
+ cls = {}
345
+ cls['ell'] = np.arange(20000)
346
+ cls['tt'] = np.zeros(20000)
347
+ cls['te'] = np.zeros(20000)
348
+ cls['ee'] = np.zeros(20000)
349
+ cls['pp'] = np.zeros(20000)
350
+ cls['bb'] = np.zeros(20000)
351
+ lcp = np.asarray(cls['ell'][2:nl+2])
352
+
353
+ # print('cosmo_model:',self.cosmo_model,nl)
354
+ if self.cosmo_model == 'ede-v2':
355
+ factor_ttteee = 1./lcp**2
356
+ factor_pp = 1./lcp**3
357
+ else:
358
+ factor_ttteee = 1./(lcp*(lcp+1.)/2./np.pi)
359
+ factor_pp = 1./(lcp*(lcp+1.))**2.
360
+
361
+ self.cp_predicted_tt_spectrum *= factor_ttteee
362
+
363
+
240
364
  if want_te:
241
365
  self.cp_predicted_te_spectrum = self.cp_te_nn[self.cosmo_model].predictions_np(params_dict)[0]
366
+ self.cp_predicted_te_spectrum *= factor_ttteee
242
367
  if want_ee:
243
368
  self.cp_predicted_ee_spectrum = self.cp_ee_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0]
369
+ self.cp_predicted_ee_spectrum *= factor_ttteee
244
370
  if want_pp:
245
371
  self.cp_predicted_pp_spectrum = self.cp_pp_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0]
372
+ self.cp_predicted_pp_spectrum *= factor_pp
373
+
374
+
375
+
376
+
246
377
  # print('>>> clssy_szfast.py cmb computed')
247
378
 
248
379
  def load_cmb_cls_from_file(self,**params_values_dict):
@@ -268,17 +399,16 @@ class Class_szfast(object):
268
399
  def calculate_pkl(self,
269
400
  # cosmo_model = self.cosmo_model,
270
401
  **params_values_dict):
271
- nz = self.cszfast_pk_grid_nz # number of z-points in redshift data [21oct22] --> set to 80
272
- zmax = self.cszfast_pk_grid_zmax # max redshift of redshift data [21oct22] --> set to 4 because boltzmannbase.py wants to extrapolate
273
- z_arr = np.linspace(0.,zmax,nz) # z-array of redshift data [21oct22] oct 26 22: nz = 1000, zmax = 20
402
+
403
+ z_arr = self.cszfast_pk_grid_z
404
+
274
405
 
275
- nk = self.cp_nk
276
- ndspl = self.cp_ndspl_k
277
- k_arr = np.geomspace(self.cp_kmin,self.cp_kmax,nk)[::ndspl] # oct 26 22 : (1e-4,50.,5000), jan 10: ndspl
406
+ k_arr = self.cszfast_pk_grid_k
278
407
 
279
408
 
280
409
  params_values = params_values_dict.copy()
281
- # print('in pkl:',params_values)
410
+ update_params_with_defaults(params_values, self.emulator_dict[self.cosmo_model]['default'])
411
+
282
412
 
283
413
  params_dict = {}
284
414
  for k,v in zip(params_values.keys(),params_values.values()):
@@ -293,109 +423,85 @@ class Class_szfast(object):
293
423
  predicted_pk_spectrum_z = []
294
424
 
295
425
  if self.use_Amod:
296
- # print(">>> using Amod :",self.Amod)
426
+
297
427
  for zp in z_arr:
428
+
298
429
  params_dict_pp = params_dict.copy()
299
430
  params_dict_pp['z_pk_save_nonclass'] = [zp]
300
431
  pkl_p = self.cp_pkl_nn[self.cosmo_model].predictions_np(params_dict_pp)[0]
301
432
  pknl_p = self.cp_pknl_nn[self.cosmo_model].predictions_np(params_dict_pp)[0]
302
433
  pk_ae = pkl_p + self.Amod*(pknl_p-pkl_p)
303
434
  predicted_pk_spectrum_z.append(pk_ae)
435
+
304
436
  else:
437
+
305
438
  for zp in z_arr:
439
+
306
440
  params_dict_pp = params_dict.copy()
307
441
  params_dict_pp['z_pk_save_nonclass'] = [zp]
308
442
  predicted_pk_spectrum_z.append(self.cp_pkl_nn[self.cosmo_model].predictions_np(params_dict_pp)[0])
309
443
 
310
444
  predicted_pk_spectrum = np.asarray(predicted_pk_spectrum_z)
311
445
 
312
- # weird scaling to get rid off
313
- # scaling factor for the pk emulator:
314
- ls = np.arange(2,self.cp_nk+2)[::ndspl] # jan 10 ndspl
315
- dls = ls*(ls+1.)/2./np.pi
446
+
316
447
  pk = 10.**predicted_pk_spectrum
317
- pk_re = ((dls)**-1*pk)
448
+
449
+ pk_re = pk*self.pk_power_fac
318
450
  pk_re = np.transpose(pk_re)
319
451
 
320
- # print(z_arr,np.log(k_arr),np.log(pk_re))
321
- # print(np.log(pk_re).min())
322
- # print(np.log(pk_re).max())
323
- # print(np.shape(np.log(pk_re)))
324
- # print('coordinates')
325
- # # z_coords, k_coords = np.meshgrid(z_arr, np.log(k_arr), indexing='ij')
326
- # # z_coords, k_coords = z_coords.flatten(), k_coords.flatten()
327
- # z_coords, k_coords = z_arr,np.log(k_arr)
328
- # print(len(z_coords),len(k_coords))
329
- # #
330
- # # print(np.shape(list(zip(z_arr,np.log(k_arr)))))
331
- # pk_values = np.log(pk_re).T
332
- # # pk_values = pk_values.ravel()
333
- # print(np.shape(pk_values),pk_values)
334
- #
335
- # self.pkl_linearnd_interp = LinearNDInterpolator(np.asarray(z_coords),np.asarray(k_coords), pk_values)
336
- # exit(0)
337
- # # self.pkl_cloughtocher_interp = CloughTocher2DInterpolator(list(zip(z_arr,np.log(k_arr))), np.log(pk_re).T)
338
- # exit(0)
339
- # self.pkl_cloughtocher_interp = CloughTocher2DInterpolator(list(zip(z_arr,np.log(k_arr))), pk_value)
340
- # is this line making things slower?
341
452
  self.pkl_interp = PowerSpectrumInterpolator(z_arr,k_arr,np.log(pk_re).T,logP=True)
342
- # self.pkl_interp = None
453
+
343
454
  self.cszfast_pk_grid_pk = pk_re
344
455
  self.cszfast_pk_grid_pkl_flat = pk_re.flatten()
456
+
345
457
  return pk_re, k_arr, z_arr
346
458
 
347
459
 
348
460
  def calculate_sigma(self,
349
- # cosmo_model = self.cosmo_model,
350
- # z_asked = None,
351
- # r_asked = None,
461
+
352
462
  **params_values_dict):
463
+
353
464
  params_values = params_values_dict.copy()
465
+
354
466
  k = self.cszfast_pk_grid_k
355
- # self.cszfast_pk_grid_z
356
- # print(self.cszfast_pk_grid_pk,np.shape(self.cszfast_pk_grid_pk))
467
+
357
468
  P = self.cszfast_pk_grid_pk
469
+
358
470
  var = P.copy()
471
+
359
472
  dvar = P.copy()
473
+
360
474
  for iz,zp in enumerate(self.cszfast_pk_grid_z):
475
+
361
476
  R, var[:,iz] = TophatVar(k, lowring=True)(P[:,iz], extrap=True)
362
- # dvar[:,iz] = np.gradient(var[:,iz], np.log(R))
363
- # if params_values_dict['sigma_derivative'] == 1: ## need more points here !!
364
- # rds,dvar[:,iz] = TophatVar(k,lowring=True,deriv=1)(P[:,iz]*k,extrap=True)
365
- # else:
366
- # dvar[:,iz] = np.gradient(var[:,iz], R)
367
477
 
368
478
  dvar[:,iz] = np.gradient(var[:,iz], R)
369
- # from inigo: R_vec,self.dvar = TophatVar(k,lowring=True,deriv=1)(P[:,iz]*k,extrap=True)
370
- # from inigo: self.dsigma_vec = self.dvar/(2.*self.sigma_vec)
371
- # print('R:',R,np.shape(R))
372
- # varR = CubicSpline(R, var[:,iz])
373
- # print(zp,np.sqrt(varR(8)))
374
- # print(params_values)
375
- # print('in sigma:',params_values)
376
- # h = params_values['H0']/100.
377
- # var = var.T
378
- # dvar = dvar.T
479
+
480
+ # print(k)
481
+ # print(R)
482
+ # print(k*R)
483
+ # exit(0)
484
+
379
485
 
380
486
  self.cszfast_pk_grid_lnr = np.log(R)
381
487
  self.cszfast_pk_grid_sigma2 = var
488
+
382
489
  self.cszfast_pk_grid_sigma2_flat = var.flatten()
383
490
  self.cszfast_pk_grid_lnsigma2_flat = 0.5*np.log(var.flatten())
384
- # self.cszfast_pk_grid_lnsigma2_flat = self.cszfast_pk_grid_lnsigma2_flat.T
491
+
385
492
  self.cszfast_pk_grid_dsigma2 = dvar
386
493
  self.cszfast_pk_grid_dsigma2_flat = dvar.flatten()
387
- # if z_asked != None and r_asked != None:
388
- # print(z_asked[0],r_asked[0])
389
- # return z_asked, r_asked
390
- # else:
391
- # return 0
494
+
392
495
  return 0
393
496
 
394
497
 
395
498
  def calculate_sigma8_and_der(self,
396
499
  # cosmo_model = self.cosmo_model,
397
500
  **params_values_dict):
501
+
398
502
  params_values = params_values_dict.copy()
503
+ update_params_with_defaults(params_values, self.emulator_dict[self.cosmo_model]['default'])
504
+
399
505
  # print('in pkl:',params_values)
400
506
 
401
507
  params_dict = {}
@@ -408,6 +514,7 @@ class Class_szfast(object):
408
514
 
409
515
  self.cp_predicted_der = self.cp_der_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0]
410
516
  self.sigma8 = self.cp_predicted_der[1]
517
+ self.Neff = self.cp_predicted_der[4]
411
518
  return 0
412
519
 
413
520
 
@@ -441,17 +548,16 @@ class Class_szfast(object):
441
548
  def calculate_pknl(self,
442
549
  # cosmo_model = self.cosmo_model,
443
550
  **params_values_dict):
444
- nz = self.cszfast_pk_grid_nz # number of z-points in redshift data [21oct22] --> set to 80
445
- zmax = self.cszfast_pk_grid_zmax # max redshift of redshift data [21oct22] --> set to 4 because boltzmannbase.py wants to extrapolate
446
- z_arr = np.linspace(0.,zmax,nz) # z-array of redshift data [21oct22] oct 26 22: nz = 1000, zmax = 20
551
+
552
+ z_arr = self.cszfast_pk_grid_z
447
553
 
448
- nk = self.cp_nk
449
- ndspl = self.cp_ndspl_k
450
- k_arr = np.geomspace(self.cp_kmin,self.cp_kmax,nk)[::ndspl] # oct 26 22 : (1e-4,50.,5000), jan 10: ndspl
554
+
555
+ k_arr = self.cszfast_pk_grid_k
451
556
 
452
557
 
453
558
  params_values = params_values_dict.copy()
454
- # print('in pknl:',params_values)
559
+ update_params_with_defaults(params_values, self.emulator_dict[self.cosmo_model]['default'])
560
+
455
561
 
456
562
  params_dict = {}
457
563
  for k,v in zip(params_values.keys(),params_values.values()):
@@ -471,31 +577,40 @@ class Class_szfast(object):
471
577
 
472
578
  predicted_pk_spectrum = np.asarray(predicted_pk_spectrum_z)
473
579
 
474
- # weird scaling to get rid off
475
- # scaling factor for the pk emulator:
476
- ls = np.arange(2,self.cp_nk+2)[::ndspl] # jan 10 ndspl
477
- dls = ls*(ls+1.)/2./np.pi
580
+
478
581
  pk = 10.**predicted_pk_spectrum
479
- pk_re = ((dls)**-1*pk)
582
+
583
+ pk_re = pk*self.pk_power_fac
480
584
  pk_re = np.transpose(pk_re)
481
585
 
482
- # print(z_arr,np.log(k_arr),np.log(pk_re))
483
- # exit(0)
484
- # self.pknl_linearnd_interp = LinearNDInterpolator(list(zip(z_arr,np.log(k_arr))), pk_re.T)
485
- # self.pknl_cloughtocher_interp = CloughTocher2DInterpolator(list(zip(z_arr,np.log(k_arr))), pk_re.T)
486
586
 
487
- # is this line making things slower?
488
587
  self.pknl_interp = PowerSpectrumInterpolator(z_arr,k_arr,np.log(pk_re).T,logP=True)
489
- # self.pknl_interp = None
588
+
589
+
490
590
  self.cszfast_pk_grid_pknl = pk_re
491
591
  self.cszfast_pk_grid_pknl_flat = pk_re.flatten()
592
+
492
593
  return pk_re, k_arr, z_arr
594
+
493
595
 
596
+ def calculate_pkl_at_z(self,
597
+ z_asked,
598
+ params_values_dict=None):
599
+
600
+ z_arr = self.cszfast_pk_grid_z
601
+
602
+ k_arr = self.cszfast_pk_grid_k
603
+
604
+ if params_values_dict:
605
+
606
+ params_values = params_values_dict.copy()
607
+
608
+ else:
609
+
610
+ params_values = self.params_for_emulators
611
+
612
+ update_params_with_defaults(params_values, self.emulator_dict[self.cosmo_model]['default'])
494
613
 
495
- def calculate_hubble(self,
496
- # cosmo_model = self.cosmo_model,
497
- **params_values_dict):
498
- params_values = params_values_dict.copy()
499
614
 
500
615
  params_dict = {}
501
616
  for k,v in zip(params_values.keys(),params_values.values()):
@@ -506,10 +621,91 @@ class Class_szfast(object):
506
621
  params_dict['m_ncdm'] = [float(params_dict['m_ncdm'][0].split(',')[0])]
507
622
 
508
623
 
624
+ predicted_pk_spectrum_z = []
625
+
626
+ z_asked = z_asked
627
+ params_dict_pp = params_dict.copy()
628
+ update_params_with_defaults(params_dict_pp, self.emulator_dict[self.cosmo_model]['default'])
629
+
630
+ params_dict_pp['z_pk_save_nonclass'] = [z_asked]
631
+ predicted_pk_spectrum_z.append(self.cp_pkl_nn[self.cosmo_model].predictions_np(params_dict_pp)[0])
632
+
633
+ predicted_pk_spectrum = np.asarray(predicted_pk_spectrum_z)
634
+
635
+
636
+ pk = 10.**predicted_pk_spectrum
637
+ pk_re = pk*self.pk_power_fac
638
+ pk_re = np.transpose(pk_re)
639
+
640
+
641
+ return pk_re, k_arr
642
+
643
+
644
+ def calculate_pknl_at_z(self,
645
+ z_asked,
646
+ params_values_dict=None):
647
+
648
+ z_arr = self.cszfast_pk_grid_z
649
+
650
+ k_arr = self.cszfast_pk_grid_k
651
+
652
+ if params_values_dict:
653
+
654
+ params_values = params_values_dict.copy()
655
+
656
+ else:
657
+
658
+ params_values = self.params_for_emulators
659
+
660
+ update_params_with_defaults(params_values, self.emulator_dict[self.cosmo_model]['default'])
661
+
662
+
663
+ params_dict = {}
664
+ for k,v in zip(params_values.keys(),params_values.values()):
665
+ params_dict[k]=[v]
666
+
667
+ if 'm_ncdm' in params_dict.keys():
668
+ if isinstance(params_dict['m_ncdm'][0],str):
669
+ params_dict['m_ncdm'] = [float(params_dict['m_ncdm'][0].split(',')[0])]
670
+
671
+
672
+ predicted_pk_spectrum_z = []
673
+
674
+ z_asked = z_asked
675
+ params_dict_pp = params_dict.copy()
676
+ update_params_with_defaults(params_dict_pp, self.emulator_dict[self.cosmo_model]['default'])
677
+
678
+ params_dict_pp['z_pk_save_nonclass'] = [z_asked]
679
+ predicted_pk_spectrum_z.append(self.cp_pknl_nn[self.cosmo_model].predictions_np(params_dict_pp)[0])
680
+
681
+ predicted_pk_spectrum = np.asarray(predicted_pk_spectrum_z)
682
+
683
+
684
+ pk = 10.**predicted_pk_spectrum
685
+ pk_re = pk*self.pk_power_fac
686
+ pk_re = np.transpose(pk_re)
687
+
688
+
689
+ return pk_re, k_arr
690
+
691
+
692
+ def calculate_hubble(self,
693
+ **params_values_dict):
694
+
695
+ params_values = params_values_dict.copy()
696
+
697
+ update_params_with_defaults(params_values, self.emulator_dict[self.cosmo_model]['default'])
698
+
699
+ params_dict = {}
700
+ for k,v in zip(params_values.keys(),params_values.values()):
701
+ params_dict[k]=[v]
702
+
703
+ if 'm_ncdm' in params_dict.keys():
704
+ if isinstance(params_dict['m_ncdm'][0],str):
705
+ params_dict['m_ncdm'] = [float(params_dict['m_ncdm'][0].split(',')[0])]
509
706
 
510
707
  self.cp_predicted_hubble = self.cp_h_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0]
511
- # print(self.cp_predicted_hubble)
512
- # z_interp =
708
+
513
709
  self.hz_interp = scipy.interpolate.interp1d(
514
710
  self.cp_z_interp,
515
711
  self.cp_predicted_hubble,
@@ -521,36 +717,33 @@ class Class_szfast(object):
521
717
  assume_sorted=False)
522
718
 
523
719
  def calculate_chi(self,
524
- # cosmo_model = self.cosmo_model,
525
720
  **params_values_dict):
526
- # def test_integrand_func(x, alpha, beta, i, j, k, l):
527
- # return x * alpha * beta + i * j * k
528
- #
529
- #
530
- # grid = np.random.random((5000, 2))
531
- #
532
- # res, err = pyquad.quad_grid(test_integrand_func, 0, 1, grid, (1.0, 1.0, 1.0, 1.0))
533
- #
534
- # print(res,err)
535
- # def integrand_chi(z,alpha, beta, i, j, k, l):
536
- # z = z-1.
537
- # return 1./self.get_Hubble(z)
538
- # zmax = 1.
539
- # grid = np.random.random((10000000, 2))
540
- # chiz,err = pyquad.quad_grid(integrand_chi, 1., 1.+zmax, grid, (1.0, 1.0, 1.0, 1.0))
541
- # print(chiz)
721
+
542
722
  params_values = params_values_dict.copy()
543
723
 
724
+ update_params_with_defaults(params_values, self.emulator_dict[self.cosmo_model]['default'])
725
+
544
726
  params_dict = {}
727
+
545
728
  for k,v in zip(params_values.keys(),params_values.values()):
729
+
546
730
  params_dict[k]=[v]
547
731
 
548
732
  if 'm_ncdm' in params_dict.keys():
549
733
  if isinstance(params_dict['m_ncdm'][0],str):
550
734
  params_dict['m_ncdm'] = [float(params_dict['m_ncdm'][0].split(',')[0])]
551
735
 
736
+ # deal with different scaling of DA in different model from emulator training
737
+ if self.cosmo_model == 'ede-v2':
738
+
739
+ self.cp_predicted_da = self.cp_da_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0]
740
+ self.cp_predicted_da = np.insert(self.cp_predicted_da, 0, 0)
741
+
742
+ else:
743
+
744
+ self.cp_predicted_da = self.cp_da_nn[self.cosmo_model].predictions_np(params_dict)[0]
745
+
552
746
 
553
- self.cp_predicted_da = self.cp_da_nn[self.cosmo_model].predictions_np(params_dict)[0]
554
747
  self.chi_interp = scipy.interpolate.interp1d(
555
748
  self.cp_z_interp,
556
749
  self.cp_predicted_da*(1.+self.cp_z_interp),
@@ -562,6 +755,7 @@ class Class_szfast(object):
562
755
  assume_sorted=False)
563
756
 
564
757
  def get_cmb_cls(self,ell_factor=True,Tcmb_uk = Tcmb_uk):
758
+
565
759
  cls = {}
566
760
  cls['ell'] = np.arange(self.cszfast_ldim)
567
761
  cls['tt'] = np.zeros(self.cszfast_ldim)
@@ -573,13 +767,6 @@ class Class_szfast(object):
573
767
  cls['te'][2:self.cp_lmax+1] = (Tcmb_uk)**2.*self.cp_predicted_te_spectrum.copy()
574
768
  cls['ee'][2:self.cp_lmax+1] = (Tcmb_uk)**2.*self.cp_predicted_ee_spectrum.copy()
575
769
  cls['pp'][2:self.cp_lmax+1] = self.cp_predicted_pp_spectrum.copy()/4. ## this is clkk... works for so lensinglite lkl
576
- # cls['bb'][2:self.cp_lmax+1] = self.cp_predicted_pp_spectrum.copy()/4. ## this is clkk... works for so lensinglite lkl
577
- # print('doing gets')
578
- # For planck likelihood:
579
- # lcp = np.asarray(cls['ell'][2:nl+2])
580
- # cls['pp'][2:nl+2] = self.pp_spectra[0].copy()/(lcp*(lcp+1.))**2.
581
- # cls['pp'][2:nl+2] *= (lcp*(lcp+1.))**2./2./np.pi
582
-
583
770
 
584
771
 
585
772
  if ell_factor==False:
@@ -30,7 +30,8 @@ cosmo_model_list = [
30
30
  'neff',
31
31
  'wcdm',
32
32
  'ede',
33
- 'mnu-3states'
33
+ 'mnu-3states',
34
+ 'ede-v2'
34
35
  ]
35
36
 
36
37
  emulator_dict = {}
@@ -40,6 +41,7 @@ emulator_dict['neff'] = {}
40
41
  emulator_dict['wcdm'] = {}
41
42
  emulator_dict['ede'] = {}
42
43
  emulator_dict['mnu-3states'] = {}
44
+ emulator_dict['ede-v2'] = {}
43
45
 
44
46
 
45
47
 
@@ -56,6 +58,11 @@ emulator_dict['lcdm']['DER'] = 'DER_v1'
56
58
  emulator_dict['lcdm']['DAZ'] = 'DAZ_v1'
57
59
  emulator_dict['lcdm']['HZ'] = 'HZ_v1'
58
60
  emulator_dict['lcdm']['S8Z'] = 'S8Z_v1'
61
+ emulator_dict['lcdm']['default'] = {}
62
+ emulator_dict['lcdm']['default']['tau_reio'] = 0.054
63
+ emulator_dict['lcdm']['default']['N_ur'] = 2.0328
64
+ emulator_dict['lcdm']['default']['N_ncdm'] = 1
65
+ emulator_dict['lcdm']['default']['m_ncdm'] = 0.06
59
66
 
60
67
  emulator_dict['mnu']['TT'] = 'TT_mnu_v1'
61
68
  emulator_dict['mnu']['TE'] = 'TE_mnu_v1'
@@ -67,7 +74,11 @@ emulator_dict['mnu']['DER'] = 'DER_mnu_v1'
67
74
  emulator_dict['mnu']['DAZ'] = 'DAZ_mnu_v1'
68
75
  emulator_dict['mnu']['HZ'] = 'HZ_mnu_v1'
69
76
  emulator_dict['mnu']['S8Z'] = 'S8Z_mnu_v1'
70
-
77
+ emulator_dict['mnu']['default'] = {}
78
+ emulator_dict['mnu']['default']['tau_reio'] = 0.054
79
+ emulator_dict['mnu']['default']['N_ur'] = 2.0328
80
+ emulator_dict['mnu']['default']['N_ncdm'] = 1
81
+ emulator_dict['mnu']['default']['m_ncdm'] = 0.06
71
82
 
72
83
  emulator_dict['neff']['TT'] = 'TT_neff_v1'
73
84
  emulator_dict['neff']['TE'] = 'TE_neff_v1'
@@ -79,7 +90,11 @@ emulator_dict['neff']['DER'] = 'DER_neff_v1'
79
90
  emulator_dict['neff']['DAZ'] = 'DAZ_neff_v1'
80
91
  emulator_dict['neff']['HZ'] = 'HZ_neff_v1'
81
92
  emulator_dict['neff']['S8Z'] = 'S8Z_neff_v1'
82
-
93
+ emulator_dict['neff']['default'] = {}
94
+ emulator_dict['neff']['default']['tau_reio'] = 0.054
95
+ emulator_dict['neff']['default']['N_ur'] = 2.0328
96
+ emulator_dict['neff']['default']['N_ncdm'] = 1
97
+ emulator_dict['neff']['default']['m_ncdm'] = 0.06
83
98
 
84
99
 
85
100
  emulator_dict['wcdm']['TT'] = 'TT_w_v1'
@@ -92,7 +107,11 @@ emulator_dict['wcdm']['DER'] = 'DER_w_v1'
92
107
  emulator_dict['wcdm']['DAZ'] = 'DAZ_w_v1'
93
108
  emulator_dict['wcdm']['HZ'] = 'HZ_w_v1'
94
109
  emulator_dict['wcdm']['S8Z'] = 'S8Z_w_v1'
95
-
110
+ emulator_dict['wcdm']['default'] = {}
111
+ emulator_dict['wcdm']['default']['tau_reio'] = 0.054
112
+ emulator_dict['wcdm']['default']['N_ur'] = 2.0328
113
+ emulator_dict['wcdm']['default']['N_ncdm'] = 1
114
+ emulator_dict['wcdm']['default']['m_ncdm'] = 0.06
96
115
 
97
116
  emulator_dict['ede']['TT'] = 'TT_v1'
98
117
  emulator_dict['ede']['TE'] = 'TE_v1'
@@ -100,13 +119,19 @@ emulator_dict['ede']['EE'] = 'EE_v1'
100
119
  emulator_dict['ede']['PP'] = 'PP_v1'
101
120
  emulator_dict['ede']['PKNL'] = 'PKNL_v1'
102
121
  emulator_dict['ede']['PKL'] = 'PKL_v1'
103
- # emulator_dict['ede']['PKLFFTLOG_ALPHAS_REAL'] = 'PKLFFTLOGALPHAS_creal_v1'
104
- # emulator_dict['ede']['PKLFFTLOG_ALPHAS_IMAG'] = 'PKLFFTLOGALPHAS_cimag_v1'
105
122
  emulator_dict['ede']['DER'] = 'DER_v1'
106
123
  emulator_dict['ede']['DAZ'] = 'DAZ_v1'
107
124
  emulator_dict['ede']['HZ'] = 'HZ_v1'
108
125
  emulator_dict['ede']['S8Z'] = 'S8Z_v1'
109
-
126
+ emulator_dict['ede']['default'] = {}
127
+ emulator_dict['ede']['default']['fEDE'] = 0.001
128
+ emulator_dict['ede']['default']['tau_reio'] = 0.054
129
+ emulator_dict['ede']['default']['log10z_c'] = 3.562 # e.g. from https://github.com/mwt5345/class_ede/blob/master/class/notebooks-ede/2-CMB-Comparison.ipynb
130
+ emulator_dict['ede']['default']['thetai_scf'] = 2.83 # e.g. from https://github.com/mwt5345/class_ede/blob/master/class/notebooks-ede/2-CMB-Comparison.ipynb
131
+ emulator_dict['ede']['default']['r'] = 0.
132
+ emulator_dict['ede']['default']['N_ur'] = 0.00641
133
+ emulator_dict['ede']['default']['N_ncdm'] = 3
134
+ emulator_dict['ede']['default']['m_ncdm'] = 0.02
110
135
 
111
136
 
112
137
  emulator_dict['mnu-3states']['TT'] = 'TT_v1'
@@ -119,6 +144,36 @@ emulator_dict['mnu-3states']['DER'] = 'DER_v1'
119
144
  emulator_dict['mnu-3states']['DAZ'] = 'DAZ_v1'
120
145
  emulator_dict['mnu-3states']['HZ'] = 'HZ_v1'
121
146
  emulator_dict['mnu-3states']['S8Z'] = 'S8Z_v1'
147
+ emulator_dict['mnu-3states']['default'] = {}
148
+ emulator_dict['mnu-3states']['default']['tau_reio'] = 0.054
149
+ emulator_dict['mnu-3states']['default']['N_ur'] = 0.00641
150
+ emulator_dict['mnu-3states']['default']['N_ncdm'] = 3
151
+ emulator_dict['mnu-3states']['default']['m_ncdm'] = 0.02
152
+
153
+ emulator_dict['ede-v2']['TT'] = 'TT_v2'
154
+ emulator_dict['ede-v2']['TE'] = 'TE_v2'
155
+ emulator_dict['ede-v2']['EE'] = 'EE_v2'
156
+ emulator_dict['ede-v2']['PP'] = 'PP_v2'
157
+ emulator_dict['ede-v2']['PKNL'] = 'PKNL_v2'
158
+ emulator_dict['ede-v2']['PKL'] = 'PKL_v2'
159
+ emulator_dict['ede-v2']['DER'] = 'DER_v2'
160
+ emulator_dict['ede-v2']['DAZ'] = 'DAZ_v2'
161
+ emulator_dict['ede-v2']['HZ'] = 'HZ_v2'
162
+ emulator_dict['ede-v2']['S8Z'] = 'S8Z_v2'
163
+
164
+ emulator_dict['ede-v2']['default'] = {}
165
+ emulator_dict['ede-v2']['default']['fEDE'] = 0.001
166
+ emulator_dict['ede-v2']['default']['tau_reio'] = 0.054
167
+ emulator_dict['ede-v2']['default']['H0'] = 67.66
168
+ emulator_dict['ede-v2']['default']['ln10^{10}A_s'] = 3.047
169
+ emulator_dict['ede-v2']['default']['omega_b'] = 0.02242
170
+ emulator_dict['ede-v2']['default']['omega_cdm'] = 0.11933
171
+ emulator_dict['ede-v2']['default']['log10z_c'] = 3.562 # e.g. from https://github.com/mwt5345/class_ede/blob/master/class/notebooks-ede/2-CMB-Comparison.ipynb
172
+ emulator_dict['ede-v2']['default']['thetai_scf'] = 2.83 # e.g. from https://github.com/mwt5345/class_ede/blob/master/class/notebooks-ede/2-CMB-Comparison.ipynb
173
+ emulator_dict['ede-v2']['default']['r'] = 0.
174
+ emulator_dict['ede-v2']['default']['N_ur'] = 0.00441
175
+ emulator_dict['ede-v2']['default']['N_ncdm'] = 3
176
+ emulator_dict['ede-v2']['default']['m_ncdm'] = 0.02
122
177
 
123
178
 
124
179
  cp_tt_nn = {}
@@ -150,13 +205,26 @@ with suppress_warnings():
150
205
  tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
151
206
 
152
207
 
208
+ import re
209
+
210
+ def split_emulator_string(input_string):
211
+ match = re.match(r"(.+)-v(\d+)", input_string)
212
+ if match:
213
+ folder = match.group(1)
214
+ version = match.group(2)
215
+ return folder, version
216
+ else:
217
+ folder = input_string
218
+ version = '1'
219
+ return folder, version
153
220
 
154
221
 
155
222
 
156
223
 
157
224
  for mp in cosmo_model_list:
158
-
159
- path_to_emulators = path_to_cosmopower_organization + '/' + mp +'/'
225
+ folder, version = split_emulator_string(mp)
226
+ # print(folder, version)
227
+ path_to_emulators = path_to_cosmopower_organization + '/' + folder +'/'
160
228
 
161
229
  cp_tt_nn[mp] = cosmopower_NN(restore=True,
162
230
  restore_filename=path_to_emulators + 'TTTEEE/' + emulator_dict[mp]['TT'])
@@ -17,4 +17,4 @@ def custom1_b(z,classy_sz,*params):
17
17
  # else:
18
18
  # w = 3./2.*(H0/h)**2/Rho_crit_0*(chi/(1.+z))**-1.*(chi_star-chi)/chi_star #
19
19
 
20
- return 2.# + 2*z
20
+ return 4.# + 2*z
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: classy_szfast
3
- Version: 0.0.8
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
@@ -0,0 +1,17 @@
1
+ classy_szfast/__init__.py,sha256=E2thrL0Z9oXFfdzwcsu-xbOytudLFTlRlPqVFGlPPPg,279
2
+ classy_szfast/classy_sz.py,sha256=QmbwrSXInQLMvCDqsr7KPmtaU0KOiOt1Rb-cTKuulZw,22240
3
+ classy_szfast/classy_szfast.py,sha256=YiT4xHKmgYvEo5LphwLHooPc5H4kr2FuDSJG--H7cdo,33728
4
+ classy_szfast/config.py,sha256=OJXwK9gTufJgmOxXUax3XJ6QJ1yF0pJARJBCG-odZQU,151
5
+ classy_szfast/cosmopower.py,sha256=u9iLdt51Qss5KwOQ637lHDBWsUz0H2u-53VUMyP5foY,10435
6
+ classy_szfast/cosmosis_classy_szfast_interface.py,sha256=zAnxvFtn73a5yS7jgs59zpWFEYKCIQyraYPs5hQ4Le8,11483
7
+ classy_szfast/pks_and_sigmas.py,sha256=drtuujE1HhlrYY1hY92DyY5lXlYS1uE15MSuVI4uo6k,6625
8
+ classy_szfast/suppress_warnings.py,sha256=6wIBml2Sj9DyRGZlZWhuA9hqvpxqrNyYjuz6BPK_a6E,202
9
+ classy_szfast/utils.py,sha256=ZZxujm1yBM0KIeVVLOuoNqUVkXIZt817QDi7U_Fz_IM,1462
10
+ classy_szfast/custom_bias/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ classy_szfast/custom_bias/custom_bias.py,sha256=aR2t5RTIwv7P0m2bsEU0Eq6BTkj4pG10AebH6QpG4qM,486
12
+ classy_szfast/custom_profiles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ classy_szfast/custom_profiles/custom_profiles.py,sha256=4LZwb2XoqwCyWNmW2s24Z7AJdmgVdaRG7yYaBYe-d9Q,1188
14
+ classy_szfast-0.0.10.dist-info/METADATA,sha256=9xenjOGGj3pgWbw9Ygm8Wkq9IFUBkHcBNHUByCRherY,714
15
+ classy_szfast-0.0.10.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
16
+ classy_szfast-0.0.10.dist-info/top_level.txt,sha256=hRgqpilUck4lx2KkaWI2y9aCDKqF6pFfGHfNaoPFxv0,14
17
+ classy_szfast-0.0.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (71.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,17 +0,0 @@
1
- classy_szfast/__init__.py,sha256=Mp1HvqeZ9_XmjVkqljBe8qG8vxpDzQt-CzQDlZFmOIU,247
2
- classy_szfast/classy_sz.py,sha256=AUCJsWFOTUH1zadbfBcCS8coHLKNEvSlvAUV5DQ3xQ0,25834
3
- classy_szfast/classy_szfast.py,sha256=gpiGm3WLStyhiT-b-s8wUvlxCcdqjMZkVqpVhszkJ0M,32433
4
- classy_szfast/config.py,sha256=OJXwK9gTufJgmOxXUax3XJ6QJ1yF0pJARJBCG-odZQU,151
5
- classy_szfast/cosmopower.py,sha256=O9Jorm7st-z7CKLXgAIrIZmVZx5rS2xjiUtkEIDrkpo,7010
6
- classy_szfast/cosmosis_classy_szfast_interface.py,sha256=zAnxvFtn73a5yS7jgs59zpWFEYKCIQyraYPs5hQ4Le8,11483
7
- classy_szfast/pks_and_sigmas.py,sha256=drtuujE1HhlrYY1hY92DyY5lXlYS1uE15MSuVI4uo6k,6625
8
- classy_szfast/suppress_warnings.py,sha256=6wIBml2Sj9DyRGZlZWhuA9hqvpxqrNyYjuz6BPK_a6E,202
9
- classy_szfast/utils.py,sha256=ZZxujm1yBM0KIeVVLOuoNqUVkXIZt817QDi7U_Fz_IM,1462
10
- classy_szfast/custom_bias/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- classy_szfast/custom_bias/custom_bias.py,sha256=53RbMAawCurKuI44nqk6fTTkQbbuJDcZpK0YhNQS3j8,486
12
- classy_szfast/custom_profiles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- classy_szfast/custom_profiles/custom_profiles.py,sha256=4LZwb2XoqwCyWNmW2s24Z7AJdmgVdaRG7yYaBYe-d9Q,1188
14
- classy_szfast-0.0.8.dist-info/METADATA,sha256=aTR5RDlPBTAxaplz-G8x-Erlw8NVPFH6lNusCCxjNO4,713
15
- classy_szfast-0.0.8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
16
- classy_szfast-0.0.8.dist-info/top_level.txt,sha256=hRgqpilUck4lx2KkaWI2y9aCDKqF6pFfGHfNaoPFxv0,14
17
- classy_szfast-0.0.8.dist-info/RECORD,,