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

Minor changes to the operation methods

1) Add rcparams to prevent all use of offsets
2) Fixes error when nglitch > 1 in which the summary did not show all
values
3) Fixes error in which the max_twoF used incorrect indexes
parent dc4b3b63
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,7 @@ import dill as pickle ...@@ -21,6 +21,7 @@ import dill as pickle
import lalpulsar import lalpulsar
plt.rcParams['text.usetex'] = True plt.rcParams['text.usetex'] = True
plt.rcParams['axes.formatter.useoffset'] = False
config_file = os.path.expanduser('~')+'/.pyfstat.conf' config_file = os.path.expanduser('~')+'/.pyfstat.conf'
if os.path.isfile(config_file): if os.path.isfile(config_file):
...@@ -951,12 +952,14 @@ class MCMCSearch(BaseSearchClass): ...@@ -951,12 +952,14 @@ class MCMCSearch(BaseSearchClass):
jmax = np.nanargmax(self.lnlikes[idxs]) jmax = np.nanargmax(self.lnlikes[idxs])
maxtwoF = self.lnlikes[jmax] maxtwoF = self.lnlikes[jmax]
d = OrderedDict() d = OrderedDict()
close_idxs = abs((maxtwoF - self.lnlikes[idxs]) / maxtwoF) < threshold
lnl_finite = copy.copy(self.lnlikes)
lnl_finite[idxs] = np.nan
close_idxs = abs((maxtwoF - lnl_finite) / maxtwoF) < threshold
for i, k in enumerate(self.theta_keys): for i, k in enumerate(self.theta_keys):
base_key = copy.copy(k)
ng = 1 ng = 1
while k in d: while k in d:
k = base_key + '_{}'.format(ng) k = k + '_{}'.format(ng)
d[k] = self.samples[jmax][i] d[k] = self.samples[jmax][i]
s = self.samples[:, i][close_idxs] s = self.samples[:, i][close_idxs]
...@@ -967,6 +970,9 @@ class MCMCSearch(BaseSearchClass): ...@@ -967,6 +970,9 @@ class MCMCSearch(BaseSearchClass):
""" 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()
for s, k in zip(self.samples.T, self.theta_keys): for s, k in zip(self.samples.T, self.theta_keys):
ng = 1
while k in d:
k = k + '_{}'.format(ng)
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
...@@ -992,12 +998,13 @@ class MCMCSearch(BaseSearchClass): ...@@ -992,12 +998,13 @@ class MCMCSearch(BaseSearchClass):
def print_summary(self): def print_summary(self):
d, max_twoF = self.get_max_twoF() d, max_twoF = self.get_max_twoF()
median_std_d = self.get_median_stds()
print('Max twoF: {}'.format(max_twoF)) print('Max twoF: {}'.format(max_twoF))
print('theta0 index: {}'.format(self.theta0_idx)) print('theta0 index: {}'.format(self.theta0_idx))
for k in np.sort(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(
k, d[k], d[k+'_std'])) k, median_std_d[k], median_std_d[k+'_std']))
class MCMCGlitchSearch(MCMCSearch): class MCMCGlitchSearch(MCMCSearch):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment