From fd36ea1b8b7b6eabf22988bd5e6b6063bc799cab Mon Sep 17 00:00:00 2001 From: Wang-weiYu <429682828@qq.com> Date: Wed, 20 Dec 2023 00:21:10 +0100 Subject: [PATCH 1/3] Fix to bug, add a parameter dictionary in JumpProposal Class --- enterprise_extensions/sampler.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/enterprise_extensions/sampler.py b/enterprise_extensions/sampler.py index 700caece..9fe840b4 100644 --- a/enterprise_extensions/sampler.py +++ b/enterprise_extensions/sampler.py @@ -166,6 +166,15 @@ def __init__(self, pta, snames=None, empirical_distr=None, f_stat_file=None, sav self.ndim = sum(p.size or 1 for p in pta.params) self.plist = [p.name for p in pta.params] + # wangwei add + self.params_dict = {} + for p in self.params: + if p.size: + for ii in range(0, p.size): + self.params_dict.update({p.name + "_{}".format(ii): p}) + else: + self.params_dict.update({p.name: p}) + # parameter map self.pmap = {} ct = 0 @@ -530,8 +539,9 @@ def draw_from_gwb_log_uniform_distribution(self, x, iter, beta): # draw parameter from signal model signal_name = [par for par in self.pnames if ('gw' in par and 'log10_A' in par)][0] - idx = list(self.pnames).index(signal_name) - param = self.params[idx] + + # wangwei add + param = self.params_dict[signal_name] q[self.pmap[str(param)]] = np.random.uniform(param.prior._defaults['pmin'], param.prior._defaults['pmax']) From 155aaf9d76a566dc8f77252bac6cfdedc109bc9a Mon Sep 17 00:00:00 2001 From: Wang-weiYu <429682828@qq.com> Date: Wed, 20 Dec 2023 01:55:30 +0100 Subject: [PATCH 2/3] Fix to bug, add a parameter dictionary in JumpProposal class --- enterprise_extensions/sampler.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/enterprise_extensions/sampler.py b/enterprise_extensions/sampler.py index 9fe840b4..f80b4a5a 100644 --- a/enterprise_extensions/sampler.py +++ b/enterprise_extensions/sampler.py @@ -166,7 +166,7 @@ def __init__(self, pta, snames=None, empirical_distr=None, f_stat_file=None, sav self.ndim = sum(p.size or 1 for p in pta.params) self.plist = [p.name for p in pta.params] - # wangwei add + # parameter dictionary self.params_dict = {} for p in self.params: if p.size: @@ -540,7 +540,6 @@ def draw_from_gwb_log_uniform_distribution(self, x, iter, beta): signal_name = [par for par in self.pnames if ('gw' in par and 'log10_A' in par)][0] - # wangwei add param = self.params_dict[signal_name] q[self.pmap[str(param)]] = np.random.uniform(param.prior._defaults['pmin'], param.prior._defaults['pmax']) From 2b935506420eeedd405455b4322e7fb53d733ff8 Mon Sep 17 00:00:00 2001 From: Wang-weiYu <429682828@qq.com> Date: Thu, 21 Dec 2023 10:34:29 +0100 Subject: [PATCH 3/3] delete the whitespace --- enterprise_extensions/sampler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enterprise_extensions/sampler.py b/enterprise_extensions/sampler.py index f80b4a5a..584ec86a 100644 --- a/enterprise_extensions/sampler.py +++ b/enterprise_extensions/sampler.py @@ -539,7 +539,7 @@ def draw_from_gwb_log_uniform_distribution(self, x, iter, beta): # draw parameter from signal model signal_name = [par for par in self.pnames if ('gw' in par and 'log10_A' in par)][0] - + param = self.params_dict[signal_name] q[self.pmap[str(param)]] = np.random.uniform(param.prior._defaults['pmin'], param.prior._defaults['pmax'])