classy-szfast 0.0.7__py3-none-any.whl → 0.0.9__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 *
@@ -10,7 +10,7 @@ import time
10
10
  class classy_sz(classy):
11
11
  use_class_sz_fast_mode = 0 # this is passed in the yaml file
12
12
  use_class_sz_no_cosmo_mode = 0 # this is passed in the yaml file
13
- lensing_lkl = "SOLikeT"
13
+ lensing_lkl = None
14
14
  # skip_background_and_thermo = True
15
15
  # ell_factor = False # True for pyactlite and bplike, False for clik
16
16
 
@@ -12,6 +12,44 @@ 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, self):
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
+ self (object): The object containing emulator_dict and cosmo_model attributes.
43
+ """
44
+ # Retrieve default values
45
+ default_values = self.emulator_dict[self.cosmo_model]['default']
46
+
47
+ # Update params_values with default values if key does not exist
48
+ for key, value in default_values.items():
49
+ if key not in params_values:
50
+ params_values[key] = value
51
+
52
+
15
53
  class Class_szfast(object):
16
54
  def __init__(self,
17
55
  #lowring=False, some options if needed
@@ -20,6 +58,15 @@ class Class_szfast(object):
20
58
  # self.xy = xy
21
59
  # self.lowring = lowring
22
60
 
61
+
62
+ set_verbosity(kwargs["classy_sz_verbose"])
63
+ self.logger = logging.getLogger(__name__)
64
+
65
+
66
+
67
+
68
+
69
+
23
70
  # cosmopower emulators
24
71
  self.cp_path_to_cosmopower_organization = path_to_cosmopower_organization + '/'
25
72
  self.cp_tt_nn = cp_tt_nn
@@ -33,22 +80,41 @@ class Class_szfast(object):
33
80
  self.cp_h_nn = cp_h_nn
34
81
  self.cp_s8_nn = cp_s8_nn
35
82
 
83
+ self.emulator_dict = emulator_dict
84
+
36
85
  if dofftlog_alphas == True:
37
86
  self.cp_pkl_fftlog_alphas_nus = cp_pkl_fftlog_alphas_nus
38
87
  self.cp_pkl_fftlog_alphas_real_nn = cp_pkl_fftlog_alphas_real_nn
39
88
  self.cp_pkl_fftlog_alphas_imag_nn = cp_pkl_fftlog_alphas_imag_nn
40
89
 
41
- self.cosmo_model = 'lcdm'
90
+ self.cosmo_model = 'ede-v2'
42
91
  self.use_Amod = 0
43
92
  self.Amod = 0
44
93
 
45
94
  self.cp_lmax = cp_l_max_scalars
46
95
  self.cp_ls = np.arange(2,self.cp_lmax+1)
47
96
 
48
- self.cp_kmax = 50.
49
- self.cp_kmin = 1e-4
50
- self.cp_nk = 5000
51
- self.cp_ndspl_k = 10
97
+
98
+
99
+ cosmo_model_dict = {0: 'lcdm',
100
+ 1: 'mnu',
101
+ 2: 'neff',
102
+ 3: 'wcdm',
103
+ 4: 'ede',
104
+ 5: 'mnu-3states',
105
+ 6: 'ede-v2'
106
+ }
107
+
108
+
109
+ if cosmo_model_dict[kwargs['cosmo_model']] == 'ede-v2':
110
+
111
+ self.cp_ndspl_k = 1
112
+ self.cp_nk = 1000
113
+
114
+ else:
115
+
116
+ self.cp_ndspl_k = 10
117
+ self.cp_nk = 5000
52
118
 
53
119
  self.cp_predicted_tt_spectrum =np.zeros(self.cp_lmax)
54
120
  self.cp_predicted_te_spectrum =np.zeros(self.cp_lmax)
@@ -59,19 +125,43 @@ class Class_szfast(object):
59
125
  self.cszfast_ldim = 20000 # used for the cls arrays
60
126
 
61
127
  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)
128
+
129
+
130
+
131
+ if (cosmo_model_dict[kwargs['cosmo_model']] == 'ede-v2'):
132
+
133
+ self.cszfast_pk_grid_zmax = 20.
134
+ self.cszfast_pk_grid_kmin = 5e-4
135
+ self.cszfast_pk_grid_kmax = 10.
136
+ self.cp_kmax = self.cszfast_pk_grid_kmax
137
+ self.cp_kmin = self.cszfast_pk_grid_kmin
138
+ self.logger.info(f">>> using kmin = {self.cp_kmin}")
139
+ self.logger.info(f">>> using kmax = {self.cp_kmax}")
140
+ self.logger.info(f">>> using zmax = {self.cszfast_pk_grid_zmax}")
141
+
142
+ else:
143
+
144
+ self.cszfast_pk_grid_zmax = 5. # max z of our pk emulators (sept 23)
145
+ self.cszfast_pk_grid_kmin = 1e-4
146
+ self.cszfast_pk_grid_kmax = 50.
147
+ self.cp_kmax = self.cszfast_pk_grid_kmax
148
+ self.cp_kmin = self.cszfast_pk_grid_kmin
149
+ self.logger.info(f">>> using kmin = {self.cp_kmin}")
150
+ self.logger.info(f">>> using kmax = {self.cp_kmax}")
151
+ self.logger.info(f">>> using zmax = {self.cszfast_pk_grid_zmax}")
152
+
63
153
  self.cszfast_pk_grid_z = np.linspace(0.,self.cszfast_pk_grid_zmax,self.cszfast_pk_grid_nz)
64
154
  self.cszfast_pk_grid_ln1pz = np.log(1.+self.cszfast_pk_grid_z)
65
155
 
66
- self.cszfast_pk_grid_kmin = 1e-4
67
- self.cszfast_pk_grid_kmax = 50.
156
+
68
157
  self.cszfast_pk_grid_k = np.geomspace(self.cp_kmin,self.cp_kmax,self.cp_nk)[::self.cp_ndspl_k]
158
+
69
159
  self.cszfast_pk_grid_lnk = np.log(self.cszfast_pk_grid_k)
160
+
70
161
  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
162
+
71
163
  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)
164
+
75
165
  if k == 'ndim_redshifts':
76
166
  self.cszfast_pk_grid_nz = v
77
167
  self.cszfast_pk_grid_z = np.linspace(0.,self.cszfast_pk_grid_zmax,self.cszfast_pk_grid_nz)
@@ -80,23 +170,27 @@ class Class_szfast(object):
80
170
  self.cszfast_pk_grid_pkl_flat = np.zeros(self.cszfast_pk_grid_nz*self.cszfast_pk_grid_nk)
81
171
 
82
172
  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'}
173
+
90
174
  self.cosmo_model = cosmo_model_dict[v]
91
175
 
92
176
  if k == 'use_Amod':
177
+
93
178
  self.use_Amod = v
94
179
  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)
98
180
 
99
- # exit(0)
181
+
182
+
183
+ if cosmo_model_dict[kwargs['cosmo_model']] == 'ede-v2':
184
+
185
+ self.pk_power_fac = self.cszfast_pk_grid_k**-3
186
+
187
+ else:
188
+
189
+ ls = np.arange(2,self.cp_nk+2)[::self.cp_ndspl_k] # jan 10 ndspl
190
+ dls = ls*(ls+1.)/2./np.pi
191
+ self.pk_power_fac= (dls)**-1
192
+
193
+
100
194
  self.cp_z_interp = np.linspace(0.,20.,5000)
101
195
 
102
196
  self.csz_base = None
@@ -132,18 +226,21 @@ class Class_szfast(object):
132
226
  self.cszfast_gas_pressure_xgrid_xmax,
133
227
  self.cszfast_gas_pressure_xgrid_nx)
134
228
 
229
+ self.params_for_emulators = {}
135
230
 
136
231
  def find_As(self,params_cp):
137
232
  # params_cp = self.params_cp
138
233
  t0 = time.time()
139
234
 
140
235
  sigma_8_asked = params_cp["sigma8"]
236
+ update_params_with_defaults(params_cp, self)
141
237
  # print(params_cp)
142
238
  def to_root(ln10_10_As_goal):
143
239
  params_cp["ln10^{10}A_s"] = ln10_10_As_goal[0]
144
240
  params_dict = {}
145
241
  for k,v in params_cp.items():
146
242
  params_dict[k]=[v]
243
+
147
244
  return self.cp_der_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0][1]-sigma_8_asked
148
245
 
149
246
  lnA_s = optimize.root(to_root,
@@ -221,11 +318,13 @@ class Class_szfast(object):
221
318
  want_ee=True,
222
319
  want_pp=1,
223
320
  **params_values_dict):
321
+
224
322
  params_values = params_values_dict.copy()
225
- # params_values['ln10^{10}A_s'] = params_values.pop("logA")
226
- # print('in cmb:',params_values)
323
+ update_params_with_defaults(params_values, self)
324
+
325
+
227
326
  params_dict = {}
228
- # print('cosmo_model',self.cosmo_model)
327
+
229
328
  for k,v in params_values.items():
230
329
  params_dict[k]=[v]
231
330
 
@@ -233,16 +332,45 @@ class Class_szfast(object):
233
332
  if isinstance(params_dict['m_ncdm'][0],str):
234
333
  params_dict['m_ncdm'] = [float(params_dict['m_ncdm'][0].split(',')[0])]
235
334
 
236
- # print('params_dict',params_dict)
237
335
 
238
- if want_tt:
239
- self.cp_predicted_tt_spectrum = self.cp_tt_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0]
336
+
337
+ # if want_tt: for now always want_tt = True
338
+ self.cp_predicted_tt_spectrum = self.cp_tt_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0]
339
+
340
+ nl = len(self.cp_predicted_tt_spectrum)
341
+ cls = {}
342
+ cls['ell'] = np.arange(20000)
343
+ cls['tt'] = np.zeros(20000)
344
+ cls['te'] = np.zeros(20000)
345
+ cls['ee'] = np.zeros(20000)
346
+ cls['pp'] = np.zeros(20000)
347
+ cls['bb'] = np.zeros(20000)
348
+ lcp = np.asarray(cls['ell'][2:nl+2])
349
+
350
+ # print('cosmo_model:',self.cosmo_model,nl)
351
+ if self.cosmo_model == 'ede-v2':
352
+ factor_ttteee = 1./lcp**2
353
+ factor_pp = 1./lcp**3
354
+ else:
355
+ factor_ttteee = 1./(lcp*(lcp+1.)/2./np.pi)
356
+ factor_pp = 1./(lcp*(lcp+1.))**2.
357
+
358
+ self.cp_predicted_tt_spectrum *= factor_ttteee
359
+
360
+
240
361
  if want_te:
241
362
  self.cp_predicted_te_spectrum = self.cp_te_nn[self.cosmo_model].predictions_np(params_dict)[0]
363
+ self.cp_predicted_te_spectrum *= factor_ttteee
242
364
  if want_ee:
243
365
  self.cp_predicted_ee_spectrum = self.cp_ee_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0]
366
+ self.cp_predicted_ee_spectrum *= factor_ttteee
244
367
  if want_pp:
245
368
  self.cp_predicted_pp_spectrum = self.cp_pp_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0]
369
+ self.cp_predicted_pp_spectrum *= factor_pp
370
+
371
+
372
+
373
+
246
374
  # print('>>> clssy_szfast.py cmb computed')
247
375
 
248
376
  def load_cmb_cls_from_file(self,**params_values_dict):
@@ -268,17 +396,16 @@ class Class_szfast(object):
268
396
  def calculate_pkl(self,
269
397
  # cosmo_model = self.cosmo_model,
270
398
  **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
399
+
400
+ z_arr = self.cszfast_pk_grid_z
274
401
 
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
402
+
403
+ k_arr = self.cszfast_pk_grid_k
278
404
 
279
405
 
280
406
  params_values = params_values_dict.copy()
281
- # print('in pkl:',params_values)
407
+ update_params_with_defaults(params_values, self)
408
+
282
409
 
283
410
  params_dict = {}
284
411
  for k,v in zip(params_values.keys(),params_values.values()):
@@ -293,55 +420,37 @@ class Class_szfast(object):
293
420
  predicted_pk_spectrum_z = []
294
421
 
295
422
  if self.use_Amod:
296
- # print(">>> using Amod :",self.Amod)
423
+
297
424
  for zp in z_arr:
425
+
298
426
  params_dict_pp = params_dict.copy()
299
427
  params_dict_pp['z_pk_save_nonclass'] = [zp]
300
428
  pkl_p = self.cp_pkl_nn[self.cosmo_model].predictions_np(params_dict_pp)[0]
301
429
  pknl_p = self.cp_pknl_nn[self.cosmo_model].predictions_np(params_dict_pp)[0]
302
430
  pk_ae = pkl_p + self.Amod*(pknl_p-pkl_p)
303
431
  predicted_pk_spectrum_z.append(pk_ae)
432
+
304
433
  else:
434
+
305
435
  for zp in z_arr:
436
+
306
437
  params_dict_pp = params_dict.copy()
307
438
  params_dict_pp['z_pk_save_nonclass'] = [zp]
308
439
  predicted_pk_spectrum_z.append(self.cp_pkl_nn[self.cosmo_model].predictions_np(params_dict_pp)[0])
309
440
 
310
441
  predicted_pk_spectrum = np.asarray(predicted_pk_spectrum_z)
311
442
 
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
443
+
316
444
  pk = 10.**predicted_pk_spectrum
317
- pk_re = ((dls)**-1*pk)
445
+
446
+ pk_re = pk*self.pk_power_fac
318
447
  pk_re = np.transpose(pk_re)
319
448
 
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
449
  self.pkl_interp = PowerSpectrumInterpolator(z_arr,k_arr,np.log(pk_re).T,logP=True)
342
- # self.pkl_interp = None
450
+
343
451
  self.cszfast_pk_grid_pk = pk_re
344
452
  self.cszfast_pk_grid_pkl_flat = pk_re.flatten()
453
+
345
454
  return pk_re, k_arr, z_arr
346
455
 
347
456
 
@@ -396,6 +505,7 @@ class Class_szfast(object):
396
505
  # cosmo_model = self.cosmo_model,
397
506
  **params_values_dict):
398
507
  params_values = params_values_dict.copy()
508
+ update_params_with_defaults(params_values, self)
399
509
  # print('in pkl:',params_values)
400
510
 
401
511
  params_dict = {}
@@ -408,6 +518,7 @@ class Class_szfast(object):
408
518
 
409
519
  self.cp_predicted_der = self.cp_der_nn[self.cosmo_model].ten_to_predictions_np(params_dict)[0]
410
520
  self.sigma8 = self.cp_predicted_der[1]
521
+ self.Neff = self.cp_predicted_der[4]
411
522
  return 0
412
523
 
413
524
 
@@ -441,17 +552,16 @@ class Class_szfast(object):
441
552
  def calculate_pknl(self,
442
553
  # cosmo_model = self.cosmo_model,
443
554
  **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
555
+
556
+ z_arr = self.cszfast_pk_grid_z
557
+
447
558
 
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
559
+ k_arr = self.cszfast_pk_grid_k
451
560
 
452
561
 
453
562
  params_values = params_values_dict.copy()
454
- # print('in pknl:',params_values)
563
+ update_params_with_defaults(params_values, self)
564
+
455
565
 
456
566
  params_dict = {}
457
567
  for k,v in zip(params_values.keys(),params_values.values()):
@@ -471,26 +581,117 @@ class Class_szfast(object):
471
581
 
472
582
  predicted_pk_spectrum = np.asarray(predicted_pk_spectrum_z)
473
583
 
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
584
+
478
585
  pk = 10.**predicted_pk_spectrum
479
- pk_re = ((dls)**-1*pk)
586
+
587
+ pk_re = pk*self.pk_power_fac
480
588
  pk_re = np.transpose(pk_re)
481
589
 
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
590
 
487
- # is this line making things slower?
488
591
  self.pknl_interp = PowerSpectrumInterpolator(z_arr,k_arr,np.log(pk_re).T,logP=True)
489
- # self.pknl_interp = None
592
+
593
+
490
594
  self.cszfast_pk_grid_pknl = pk_re
491
595
  self.cszfast_pk_grid_pknl_flat = pk_re.flatten()
596
+
492
597
  return pk_re, k_arr, z_arr
598
+
599
+
600
+ def calculate_pkl_at_z(self,
601
+ z_asked,
602
+ params_values_dict=None):
603
+
604
+ z_arr = self.cszfast_pk_grid_z
605
+
606
+ k_arr = self.cszfast_pk_grid_k
607
+
608
+ if params_values_dict:
609
+
610
+ params_values = params_values_dict.copy()
611
+
612
+ else:
613
+
614
+ params_values = self.params_for_emulators
615
+
616
+ update_params_with_defaults(params_values, self)
617
+
618
+
619
+ params_dict = {}
620
+ for k,v in zip(params_values.keys(),params_values.values()):
621
+ params_dict[k]=[v]
622
+
623
+ if 'm_ncdm' in params_dict.keys():
624
+ if isinstance(params_dict['m_ncdm'][0],str):
625
+ params_dict['m_ncdm'] = [float(params_dict['m_ncdm'][0].split(',')[0])]
626
+
627
+
628
+ predicted_pk_spectrum_z = []
629
+
630
+ z_asked = z_asked
631
+ params_dict_pp = params_dict.copy()
632
+ update_params_with_defaults(params_dict_pp, self)
633
+
634
+ params_dict_pp['z_pk_save_nonclass'] = [z_asked]
635
+ predicted_pk_spectrum_z.append(self.cp_pkl_nn[self.cosmo_model].predictions_np(params_dict_pp)[0])
636
+
637
+ predicted_pk_spectrum = np.asarray(predicted_pk_spectrum_z)
638
+
639
+
640
+ pk = 10.**predicted_pk_spectrum
641
+ pk_re = pk*self.pk_power_fac
642
+ pk_re = np.transpose(pk_re)
643
+
644
+
645
+ return pk_re, k_arr
646
+
647
+
648
+ def calculate_pknl_at_z(self,
649
+ z_asked,
650
+ params_values_dict=None):
651
+
652
+ z_arr = self.cszfast_pk_grid_z
653
+
654
+ k_arr = self.cszfast_pk_grid_k
655
+
656
+ if params_values_dict:
657
+
658
+ params_values = params_values_dict.copy()
659
+
660
+ else:
661
+
662
+ params_values = self.params_for_emulators
663
+
664
+ update_params_with_defaults(params_values, self)
665
+
666
+
667
+ params_dict = {}
668
+ for k,v in zip(params_values.keys(),params_values.values()):
669
+ params_dict[k]=[v]
670
+
671
+ if 'm_ncdm' in params_dict.keys():
672
+ if isinstance(params_dict['m_ncdm'][0],str):
673
+ params_dict['m_ncdm'] = [float(params_dict['m_ncdm'][0].split(',')[0])]
674
+
675
+
676
+ predicted_pk_spectrum_z = []
677
+
678
+ z_asked = z_asked
679
+ params_dict_pp = params_dict.copy()
680
+ update_params_with_defaults(params_dict_pp, self)
681
+
682
+ params_dict_pp['z_pk_save_nonclass'] = [z_asked]
683
+ predicted_pk_spectrum_z.append(self.cp_pknl_nn[self.cosmo_model].predictions_np(params_dict_pp)[0])
684
+
685
+ predicted_pk_spectrum = np.asarray(predicted_pk_spectrum_z)
686
+
687
+
688
+ pk = 10.**predicted_pk_spectrum
689
+ pk_re = pk*self.pk_power_fac
690
+ pk_re = np.transpose(pk_re)
493
691
 
692
+
693
+ return pk_re, k_arr
694
+
494
695
 
495
696
  def calculate_hubble(self,
496
697
  # cosmo_model = self.cosmo_model,
classy_szfast/config.py CHANGED
@@ -1 +1,6 @@
1
- path_to_cosmopower_organization = '/Users/boris/Work/CLASS-SZ/SO-SZ/class_sz/cosmopower-organization'
1
+ import os
2
+
3
+ def get_cosmopower_path():
4
+ return os.getenv('PATH_TO_COSMOPOWER_ORGANIZATION')
5
+
6
+ path_to_cosmopower_organization = get_cosmopower_path()
@@ -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,9 @@ 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
+
59
64
 
60
65
  emulator_dict['mnu']['TT'] = 'TT_mnu_v1'
61
66
  emulator_dict['mnu']['TE'] = 'TE_mnu_v1'
@@ -67,6 +72,8 @@ emulator_dict['mnu']['DER'] = 'DER_mnu_v1'
67
72
  emulator_dict['mnu']['DAZ'] = 'DAZ_mnu_v1'
68
73
  emulator_dict['mnu']['HZ'] = 'HZ_mnu_v1'
69
74
  emulator_dict['mnu']['S8Z'] = 'S8Z_mnu_v1'
75
+ emulator_dict['mnu']['default'] = {}
76
+ emulator_dict['mnu']['default']['tau_reio'] = 0.054
70
77
 
71
78
 
72
79
  emulator_dict['neff']['TT'] = 'TT_neff_v1'
@@ -79,6 +86,8 @@ emulator_dict['neff']['DER'] = 'DER_neff_v1'
79
86
  emulator_dict['neff']['DAZ'] = 'DAZ_neff_v1'
80
87
  emulator_dict['neff']['HZ'] = 'HZ_neff_v1'
81
88
  emulator_dict['neff']['S8Z'] = 'S8Z_neff_v1'
89
+ emulator_dict['neff']['default'] = {}
90
+ emulator_dict['neff']['default']['tau_reio'] = 0.054
82
91
 
83
92
 
84
93
 
@@ -92,6 +101,8 @@ emulator_dict['wcdm']['DER'] = 'DER_w_v1'
92
101
  emulator_dict['wcdm']['DAZ'] = 'DAZ_w_v1'
93
102
  emulator_dict['wcdm']['HZ'] = 'HZ_w_v1'
94
103
  emulator_dict['wcdm']['S8Z'] = 'S8Z_w_v1'
104
+ emulator_dict['wcdm']['default'] = {}
105
+ emulator_dict['wcdm']['default']['tau_reio'] = 0.054
95
106
 
96
107
 
97
108
  emulator_dict['ede']['TT'] = 'TT_v1'
@@ -100,13 +111,21 @@ emulator_dict['ede']['EE'] = 'EE_v1'
100
111
  emulator_dict['ede']['PP'] = 'PP_v1'
101
112
  emulator_dict['ede']['PKNL'] = 'PKNL_v1'
102
113
  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
114
  emulator_dict['ede']['DER'] = 'DER_v1'
106
115
  emulator_dict['ede']['DAZ'] = 'DAZ_v1'
107
116
  emulator_dict['ede']['HZ'] = 'HZ_v1'
108
117
  emulator_dict['ede']['S8Z'] = 'S8Z_v1'
109
-
118
+ emulator_dict['ede']['default'] = {}
119
+ emulator_dict['ede']['default']['fEDE'] = 0.001
120
+ emulator_dict['ede']['default']['tau_reio'] = 0.054
121
+ 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
122
+ 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
123
+ emulator_dict['ede']['default']['r'] = 0.
124
+ emulator_dict['ede']['default']['N_ur'] = 0.00641
125
+ emulator_dict['ede']['default']['N_ncdm'] = 3
126
+ emulator_dict['ede']['default']['m_ncdm'] = 0.02
127
+ emulator_dict['ede']['default'] = {}
128
+ emulator_dict['ede']['default']['tau_reio'] = 0.054
110
129
 
111
130
 
112
131
  emulator_dict['mnu-3states']['TT'] = 'TT_v1'
@@ -119,6 +138,30 @@ emulator_dict['mnu-3states']['DER'] = 'DER_v1'
119
138
  emulator_dict['mnu-3states']['DAZ'] = 'DAZ_v1'
120
139
  emulator_dict['mnu-3states']['HZ'] = 'HZ_v1'
121
140
  emulator_dict['mnu-3states']['S8Z'] = 'S8Z_v1'
141
+ emulator_dict['mnu-3states']['default'] = {}
142
+ emulator_dict['mnu-3states']['default']['tau_reio'] = 0.054
143
+
144
+
145
+ emulator_dict['ede-v2']['TT'] = 'TT_v2'
146
+ emulator_dict['ede-v2']['TE'] = 'TE_v2'
147
+ emulator_dict['ede-v2']['EE'] = 'EE_v2'
148
+ emulator_dict['ede-v2']['PP'] = 'PP_v2'
149
+ emulator_dict['ede-v2']['PKNL'] = 'PKNL_v2'
150
+ emulator_dict['ede-v2']['PKL'] = 'PKL_v2'
151
+ emulator_dict['ede-v2']['DER'] = 'DER_v2'
152
+ emulator_dict['ede-v2']['DAZ'] = 'DAZ_v2'
153
+ emulator_dict['ede-v2']['HZ'] = 'HZ_v2'
154
+ emulator_dict['ede-v2']['S8Z'] = 'S8Z_v2'
155
+
156
+ emulator_dict['ede-v2']['default'] = {}
157
+ emulator_dict['ede-v2']['default']['fEDE'] = 0.001
158
+ emulator_dict['ede-v2']['default']['tau_reio'] = 0.054
159
+ 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
160
+ 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
161
+ emulator_dict['ede-v2']['default']['r'] = 0.
162
+ emulator_dict['ede-v2']['default']['N_ur'] = 0.00441
163
+ emulator_dict['ede-v2']['default']['N_ncdm'] = 3
164
+ emulator_dict['ede-v2']['default']['m_ncdm'] = 0.02
122
165
 
123
166
 
124
167
  cp_tt_nn = {}
@@ -150,13 +193,26 @@ with suppress_warnings():
150
193
  tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
151
194
 
152
195
 
196
+ import re
197
+
198
+ def split_emulator_string(input_string):
199
+ match = re.match(r"(.+)-v(\d+)", input_string)
200
+ if match:
201
+ folder = match.group(1)
202
+ version = match.group(2)
203
+ return folder, version
204
+ else:
205
+ folder = input_string
206
+ version = '1'
207
+ return folder, version
153
208
 
154
209
 
155
210
 
156
211
 
157
212
  for mp in cosmo_model_list:
158
-
159
- path_to_emulators = path_to_cosmopower_organization + '/' + mp +'/'
213
+ folder, version = split_emulator_string(mp)
214
+ # print(folder, version)
215
+ path_to_emulators = path_to_cosmopower_organization + '/' + folder +'/'
160
216
 
161
217
  cp_tt_nn[mp] = cosmopower_NN(restore=True,
162
218
  restore_filename=path_to_emulators + 'TTTEEE/' + emulator_dict[mp]['TT'])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: classy_szfast
3
- Version: 0.0.7
3
+ Version: 0.0.9
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
@@ -1,8 +1,8 @@
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=JwRAmdVL44ftwuJyrtuP6tZKmQC_yMJ-WdPustaFIWY,102
5
- classy_szfast/cosmopower.py,sha256=O9Jorm7st-z7CKLXgAIrIZmVZx5rS2xjiUtkEIDrkpo,7010
1
+ classy_szfast/__init__.py,sha256=E2thrL0Z9oXFfdzwcsu-xbOytudLFTlRlPqVFGlPPPg,279
2
+ classy_szfast/classy_sz.py,sha256=mp6tbYzeoi27ciShV2N8xGCR9vIrhm1ISgRHjDGEh-E,25829
3
+ classy_szfast/classy_szfast.py,sha256=WogzPos9dGlacklyAOjb58CS4Qbdip8BZyuj0RcGLtA,35452
4
+ classy_szfast/config.py,sha256=OJXwK9gTufJgmOxXUax3XJ6QJ1yF0pJARJBCG-odZQU,151
5
+ classy_szfast/cosmopower.py,sha256=poSQ6zRHJBPedZ-nO3BWjsxXLyd8FSh9aTCx6B-VoqQ,9553
6
6
  classy_szfast/cosmosis_classy_szfast_interface.py,sha256=zAnxvFtn73a5yS7jgs59zpWFEYKCIQyraYPs5hQ4Le8,11483
7
7
  classy_szfast/pks_and_sigmas.py,sha256=drtuujE1HhlrYY1hY92DyY5lXlYS1uE15MSuVI4uo6k,6625
8
8
  classy_szfast/suppress_warnings.py,sha256=6wIBml2Sj9DyRGZlZWhuA9hqvpxqrNyYjuz6BPK_a6E,202
@@ -11,7 +11,7 @@ classy_szfast/custom_bias/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
11
11
  classy_szfast/custom_bias/custom_bias.py,sha256=53RbMAawCurKuI44nqk6fTTkQbbuJDcZpK0YhNQS3j8,486
12
12
  classy_szfast/custom_profiles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  classy_szfast/custom_profiles/custom_profiles.py,sha256=4LZwb2XoqwCyWNmW2s24Z7AJdmgVdaRG7yYaBYe-d9Q,1188
14
- classy_szfast-0.0.7.dist-info/METADATA,sha256=-IehxlVfQsXMIBkODyolN9fmYV4bkk_ruY5N3CFAdSc,713
15
- classy_szfast-0.0.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
16
- classy_szfast-0.0.7.dist-info/top_level.txt,sha256=hRgqpilUck4lx2KkaWI2y9aCDKqF6pFfGHfNaoPFxv0,14
17
- classy_szfast-0.0.7.dist-info/RECORD,,
14
+ classy_szfast-0.0.9.dist-info/METADATA,sha256=-hPJoxQ6DfJok-Uz8W_RS-77DQ32doSDnDl5_z_-vV4,713
15
+ classy_szfast-0.0.9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
16
+ classy_szfast-0.0.9.dist-info/top_level.txt,sha256=hRgqpilUck4lx2KkaWI2y9aCDKqF6pFfGHfNaoPFxv0,14
17
+ classy_szfast-0.0.9.dist-info/RECORD,,