Commit 99c8266f authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Minor changes to the core file

- Expose generate_loudest
- add check if par exists
- All read_par to read_loudest
- Make the default save_fig to be True in plot_corner
parent a8eba1d9
......@@ -18,16 +18,25 @@ args, tqdm = helper_functions.set_up_command_line_arguments()
earth_ephem, sun_ephem = helper_functions.set_up_ephemeris_configuration()
def read_par(label, outdir):
""" Read in a .par file, returns a dictionary of the values """
filename = '{}/{}.par'.format(outdir, label)
def read_par(label=None, outdir=None, filename=None, suffix='par'):
""" Read in a .par file, returns a dictionary of the values
Note, can also read in .loudest files
if filename is None:
filename = '{}/{}.{}'.format(outdir, label, suffix)
if os.path.isfile(filename) is False:
raise ValueError("No file ({}) found".format(filename))
d = {}
with open(filename, 'r') as f:
for line in f:
if len(line.split('=')) > 1:
key, val = line.rstrip('\n').split(' = ')
key = key.strip()
d[key] = np.float64(eval(val.rstrip('; ')))
if line[0] not in ['%', '#'] and len(line.split('=')) == 2:
key, val = line.rstrip('\n').split('=')
key = key.strip()
d[key] = np.float64(eval(val.rstrip('; ')))
except SyntaxError:
return d
......@@ -119,7 +128,7 @@ class BaseSearchClass(object):
self.thetas_at_tref = thetas
return thetas
def _generate_loudest(self):
def generate_loudest(self):
params = read_par(self.label, self.outdir)
for key in ['Alpha', 'Delta', 'F0', 'F1']:
if key not in params:
......@@ -507,7 +507,7 @@ class MCMCSearch(core.BaseSearchClass):
def plot_corner(self, figsize=(7, 7), add_prior=False, nstds=None,
label_offset=0.4, dpi=300, rc_context={},
tglitch_ratio=False, fig_and_axes=None, save_fig=False,
tglitch_ratio=False, fig_and_axes=None, save_fig=True,
""" Generate a corner plot of the posterior
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment