Skip to content
Snippets Groups Projects
Commit b9bb2f47 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Fixes summary

1) Improves the output
2) Fixes a bug in which the while loop got stcuk attempting to rename
the glitch parameters (when ng > 1)
parent 25e5f1ce
No related branches found
No related tags found
No related merge requests found
...@@ -995,31 +995,39 @@ class MCMCSearch(BaseSearchClass): ...@@ -995,31 +995,39 @@ class MCMCSearch(BaseSearchClass):
maxtwoF = self.lnlikes[jmax] maxtwoF = self.lnlikes[jmax]
d = OrderedDict() d = OrderedDict()
lnl_finite = copy.copy(self.lnlikes) repeats = []
lnl_finite[idxs] = 0
close_idxs = abs((maxtwoF - lnl_finite) / maxtwoF) < threshold
for i, k in enumerate(self.theta_keys): for i, k in enumerate(self.theta_keys):
ng = 1 if k in d and k not in repeats:
d[k+'_0'] = d[k] # relabel the old key
d.pop(k)
repeats.append(k)
if k in repeats:
k = k + '_0'
count = 1
while k in d: while k in d:
if k == 1: k = k.replace('_{}'.format(count-1), '_{}'.format(count))
k = k + '_1' count += 1
else:
k.replace('_{}'.format(ng-1), '_{}'.format(ng))
ng += 1
d[k] = self.samples[jmax][i] d[k] = self.samples[jmax][i]
s = self.samples[:, i][close_idxs]
d[k + '_std'] = np.std(s)
return d, maxtwoF return d, maxtwoF
def get_median_stds(self): def get_median_stds(self):
""" Returns a dict of the median and std of all production samples """ """ Returns a dict of the median and std of all production samples """
d = OrderedDict() d = OrderedDict()
repeats = []
for s, k in zip(self.samples.T, self.theta_keys): for s, k in zip(self.samples.T, self.theta_keys):
ng = 1 if k in d and k not in repeats:
d[k+'_0'] = d[k] # relabel the old key
d[k+'_0_std'] = d[k+'_std']
d.pop(k)
d.pop(k+'_std')
repeats.append(k)
if k in repeats:
k = k + '_0'
count = 1
while k in d: while k in d:
k = k.rstrip('_{}'.format(ng-1)) + '_{}'.format(ng) k = k.replace('_{}'.format(count-1), '_{}'.format(count))
ng += 1 count += 1
d[k] = np.median(s) d[k] = np.median(s)
d[k+'_std'] = np.std(s) d[k+'_std'] = np.std(s)
return d return d
...@@ -1044,10 +1052,14 @@ class MCMCSearch(BaseSearchClass): ...@@ -1044,10 +1052,14 @@ class MCMCSearch(BaseSearchClass):
f.write('{} = {:1.16e}\n'.format(key, val)) f.write('{} = {:1.16e}\n'.format(key, val))
def print_summary(self): def print_summary(self):
d, max_twoF = self.get_max_twoF() max_twoFd, max_twoF = self.get_max_twoF()
median_std_d = self.get_median_stds() median_std_d = self.get_median_stds()
print('Max twoF: {}'.format(max_twoF)) print('\nSummary:')
print('theta0 index: {}'.format(self.theta0_idx)) print('theta0 index: {}'.format(self.theta0_idx))
print('Max twoF: {} with parameters:'.format(max_twoF))
for k in np.sort(max_twoFd.keys()):
print(' {:10s} = {:1.9e}'.format(k, max_twoFd[k]))
print('\nMedian +/- std for production values')
for k in np.sort(median_std_d.keys()): for k in np.sort(median_std_d.keys()):
if 'std' not in k: if 'std' not in k:
print(' {:10s} = {:1.9e} +/- {:1.9e}'.format( print(' {:10s} = {:1.9e} +/- {:1.9e}'.format(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment