Skip to content

Commit b5ebb83

Browse files
committed
Better control of fixed parameters in metal correlations
1 parent c39a4e9 commit b5ebb83

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

vega/metals.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class Metals:
1919
cache_pk = LRUCache(128)
2020
cache_xi = LRUCache(128)
2121

22+
metal_growth_rate = None
23+
par_sigma_smooth = None
24+
per_sigma_smooth = None
25+
fast_metals = False
26+
2227
def __init__(self, corr_item, fiducial, scale_params, PktoXi_obj, data=None):
2328
"""Initialize metals
2429
@@ -41,18 +46,16 @@ def __init__(self, corr_item, fiducial, scale_params, PktoXi_obj, data=None):
4146
self.size = corr_item.model_coordinates.rp_grid.size
4247
ell_max = self._corr_item.config['model'].getint('ell_max', 6)
4348
self._coordinates = corr_item.model_coordinates
44-
self.metal_growth_rate = fiducial['metal-growth_rate']
49+
self.fast_metals = corr_item.config['model'].getboolean('fast_metals', False)
4550

51+
# Read the growth rate and sigma_smooth from the fiducial config
52+
if 'metal-growth_rate' in fiducial:
53+
self.metal_growth_rate = fiducial['metal-growth_rate']
4654
if 'par_sigma_smooth' in fiducial:
4755
self.par_sigma_smooth = fiducial['par_sigma_smooth']
4856
if 'per_sigma_smooth' in fiducial:
4957
self.per_sigma_smooth = fiducial['per_sigma_smooth']
5058

51-
self.fast_metals = corr_item.config['model'].getboolean('fast_metals', False)
52-
# self.fast_metals_unsafe = corr_item.config['model'].getboolean('fast_metals_unsafe', False)
53-
# if self.fast_metals_unsafe:
54-
# self.fast_metals = True
55-
5659
self.save_components = fiducial.get('save-components', False)
5760

5861
if self.save_components and self.fast_metals:
@@ -169,12 +172,15 @@ def compute(self, pars, pk_lin, component):
169172
"""
170173
assert self._corr_item.has_metals
171174
local_pars = copy.deepcopy(pars)
172-
if 'growth_rate' in local_pars:
173-
local_pars['growth_rate'] = self.metal_growth_rate
174-
if 'sigma_smooth_par' in local_pars:
175-
local_pars['sigma_smooth_par'] = self.par_sigma_smooth
176-
if 'sigma_smooth_per' in local_pars:
177-
local_pars['sigma_smooth_per'] = self.per_sigma_smooth
175+
176+
# TODO Check growth rate and sigma_smooth exist. They should be in the fiducial config.
177+
if self.fast_metals:
178+
if 'growth_rate' in local_pars and self.metal_growth_rate is not None:
179+
local_pars['growth_rate'] = self.metal_growth_rate
180+
if 'sigma_smooth_par' in local_pars and self.par_sigma_smooth is not None:
181+
local_pars['sigma_smooth_par'] = self.par_sigma_smooth
182+
if 'sigma_smooth_per' in local_pars and self.per_sigma_smooth is not None:
183+
local_pars['sigma_smooth_per'] = self.per_sigma_smooth
178184

179185
xi_metals = np.zeros(self.size)
180186
for name1, name2, in self._corr_item.metal_correlations:

0 commit comments

Comments
 (0)